What changed, and why it matters
This commit adds support in btcd's transaction-signing code for a new Bitcoin output type called P2A (Pay-to-Anchor). P2A outputs are intentionally designed to be 'anyone-can-spend,' meaning no signature is needed to spend them. The change simply tells btcd to return an empty script when asked to sign such an output, rather than failing because it doesn't recognize the type. This is a feature addition to keep btcd compatible with Bitcoin's evolving protocol, not a fix for a vulnerability in the cryptographic sense. However, because P2A outputs are anyone-can-spend by design, any wallet or node that mishandles them could in theory lose funds placed in such outputs, so the change has security-adjacent relevance.
Treat as a routine protocol-compatibility feature commit. Reviewers should verify that PayToAnchorTy is correctly classified elsewhere in btcd's script engine and that spending such outputs does not bypass any intended policy checks. Users relying on btcd for wallet signing should ensure they understand that P2A outputs carry no spend-authorization guarantees by design.
Security signals we found
New script class PayToAnchorTy handled in signing path
P2A outputs are anyone-can-spend by design
Empty script returned for signing, consistent with no-signature-required semantics
No bounds-checking, cryptographic, or memory-safety changes present
Change is additive and does not modify existing script validation logic
Evidence from the diff
The patch modifies txscript/sign.go to handle the PayToAnchorTy (P2A) script class in the sign() function. For P2A outputs, it returns an empty script signature ([]byte{}), the script class, addresses, and nrequired. This aligns with BIP-related P2A semantics where the output is an anyone-can-spend anchor output and no signature is required. The change is minimal (+7 lines) and sits alongside existing handling for NullDataTy. There is no cryptographic bug being fixed; the change enables signing support for a new standard output type.
Changed components
btcd/txscript/sign.goP2A (Pay-to-Anchor) transaction signingInspect captured patch +7 / −0
diff --git a/txscript/sign.go b/txscript/sign.go
index 0a11e1b..d47ec6d 100644
--- a/txscript/sign.go
+++ b/txscript/sign.go
@@ -303,9 +303,16 @@ func sign(chainParams *chaincfg.Params, tx *wire.MsgTx, idx int,
script, _ := signMultiSig(tx, idx, subScript, hashType,
addresses, nrequired, kdb)
return script, class, addresses, nrequired, nil
+
case NullDataTy:
return nil, class, nil, 0,
errors.New("can't sign NULLDATA transactions")
+
+ case PayToAnchorTy:
+ // P2A outputs require no signing - they're anyone-can-spend.
+ // Return an empty script.
+ return []byte{}, class, addresses, nrequired, nil
+
default:
return nil, class, nil, 0,
errors.New("can't sign unknown transactions")
Why this scored 34/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.