Assert in tests that the witness spending a P2A anchor is empty
What changed, and why it matters
This commit adds a test-only assertion to make sure that when a transaction input spends a special 'P2A anchor' output, the witness data (cryptographic proof attached to the input) is empty. It does not change any production code behavior; it only strengthens test coverage for a known protocol detail.
No security action required. Treat as normal test-hardening commit. Reviewers may optionally verify that the assertion correctly reflects the expected P2A anchor spending rules in the relevant protocol specification.
Security signals we found
Test-only assertion added for P2A anchor witness being empty
No production code path modified
No cryptographic or consensus logic changed
No input validation or resource handling changed
Evidence from the diff
The change is a single new branch in a debug/test assertion block inside ChannelMonitorImpl. When the spent script pubkey matches the shared anchor script pubkey (chan_utils::shared_anchor_script_pubkey()), it now asserts that input.witness.is_empty(). This is consistent with BIP-118-style P2A (Pay-to-Anchor) semantics where the output is spent with an empty witness. The surrounding code already asserted conditions for P2WSH and P2WPKH; this fills the gap for the shared anchor case and otherwise panics. No runtime logic, fee policy, or signature validation is modified.
Changed components
lightning/src/chain/channelmonitor.rsTest assertions in ChannelMonitorImplInspect captured patch +2 / −0
diff --git a/lightning/src/chain/channelmonitor.rs b/lightning/src/chain/channelmonitor.rs
index 9ef44cf..6d77da5 100644
--- a/lightning/src/chain/channelmonitor.rs
+++ b/lightning/src/chain/channelmonitor.rs
@@ -5831,6 +5831,8 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
assert_eq!(&bitcoin::Address::p2wsh(&ScriptBuf::from(input.witness.last().unwrap().to_vec()), bitcoin::Network::Bitcoin).script_pubkey(), _script_pubkey);
} else if _script_pubkey.is_p2wpkh() {
assert_eq!(&bitcoin::Address::p2wpkh(&bitcoin::CompressedPublicKey(bitcoin::PublicKey::from_slice(&input.witness.last().unwrap()).unwrap().inner), bitcoin::Network::Bitcoin).script_pubkey(), _script_pubkey);
+ } else if _script_pubkey == &chan_utils::shared_anchor_script_pubkey() {
+ assert!(input.witness.is_empty());
} else { panic!(); }
}
return true;
Why this scored 15/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.