Merge PR 'Return an empty witness for P2A anchor inputs' (#5510)
What changed, and why it matters
This commit fixes how a specific type of Bitcoin transaction input (used in fee-bumping anchors) builds its witness data. Previously it created a witness containing a single empty element; now it creates a truly empty witness. The change is subtle but important because Bitcoin consensus rules treat these two forms differently for a new output type (P2A). The included test confirms the witness is now empty.
Review whether the old non-empty witness serialization could cause invalid or non-standard transactions for P2A anchor inputs, and ensure this fix is included in any release supporting P2A anchors. No immediate emergency action is indicated by the diff alone.
Security signals we found
Consensus-critical witness serialization change for anchor inputs
P2A (Pay-to-Anchor) output type involved
Regression test added to enforce empty witness behavior
Change is minimal and targeted at a specific transaction path
Evidence from the diff
In lightning/src/events/bump_transaction/mod.rs, AnchorDescriptor::tx_input_witness for P2A (anchor) inputs changed from Witness::from_slice(&[&[]]) to Witness::new(). The old form produced a witness with one empty stack element (length byte 0x00), while the new form produces a witness with zero elements. A regression test was added asserting anchor_descriptor.tx_input_witness(…).is_empty().
Changed components
lightning/src/events/bump_transaction/mod.rsAnchorDescriptor::tx_input_witnessP2A anchor fee-bumping transaction constructionInspect captured patch +21 / −1
### lightning/src/events/bump_transaction/mod.rs
@@ -96,7 +96,7 @@ impl AnchorDescriptor {
)
} else {
debug_assert!(tx_params.channel_type_features.supports_anchor_zero_fee_commitments());
- Witness::from_slice(&[&[]])
+ Witness::new()
}
}
}
@@ -1100,4 +1100,24 @@ mod tests {
assert_eq!(anchor_descriptor.previous_utxo().script_pubkey, expected_script_pubkey);
}
+
+ #[test]
+ fn test_anchor_descriptor_p2a_witness_is_empty() {
+ let mut transaction_parameters = ChannelTransactionParameters::test_dummy(42_000_000);
+ transaction_parameters.channel_type_features =
+ ChannelTypeFeatures::anchors_zero_fee_commitments();
+
+ let anchor_descriptor = AnchorDescriptor {
+ channel_derivation_parameters: ChannelDerivationParameters {
+ value_satoshis: 42_000_000,
+ keys_id: [42; 32],
+ transaction_parameters,
+ },
+ outpoint: OutPoint::null(),
+ value: Amount::from_sat(ANCHOR_OUTPUT_VALUE_SATOSHI),
+ };
+
+ let dummy_sig = secp256k1::ecdsa::Signature::from_compact(&[1; 64]).unwrap();
+ assert!(anchor_descriptor.tx_input_witness(&dummy_sig).is_empty());
+ }
}Why this scored 33/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.