Remove redundant witness program check
What changed, and why it matters
This is a small code cleanup that removes an unnecessary duplicate check when validating Bitcoin output scripts during Lightning channel funding. The old code first asked 'is this a witness program?' and then separately asked 'what is its witness version?' The newer version of the underlying rust-bitcoin library makes the first question redundant, so the patch drops it. There is no functional behavior change intended.
No security action required. Treat as routine refactoring. If reviewing, confirm that rust-bitcoin 0.32.4 is indeed the dependency version and that Script::witness_version returns Some only for valid witness programs, preserving the prior acceptance set.
Security signals we found
No security-relevant behavior change in the diff
Change is a defensive-input validation cleanup, not a fix
No new attack surface introduced
No memory safety, cryptographic, or authorization changes
Evidence from the diff
The commit updates interactivetxs.rs to rely solely on Script::witness_version() for accepting witness programs with version >= 1, removing the previously required Script::is_witness_program() guard. The change is predicated on rust-bitcoin 0.32.4 making Script::is_witness_program delegate to Script::witness_version internally, so the two checks are now equivalent. The diff is a pure simplification (+1/-5) with no change to accepted script types or error handling.
Changed components
lightning/src/ln/interactivetxs.rsInteractive transaction negotiation output-script validationInspect captured patch +1 / −5
diff --git a/lightning/src/ln/interactivetxs.rs b/lightning/src/ln/interactivetxs.rs
index 6769e2d..3a93306 100644
--- a/lightning/src/ln/interactivetxs.rs
+++ b/lightning/src/ln/interactivetxs.rs
@@ -1252,13 +1252,9 @@ impl NegotiationContext {
// with witness versions V1 and up are always considered standard. Yes, the scripts can be
// anyone-can-spend-able, but if our counterparty wants to add an output like that then it's none
// of our concern really ¯\_(ツ)_/¯
- //
- // TODO: The last check would be simplified when https://github.com/rust-bitcoin/rust-bitcoin/commit/1656e1a09a1959230e20af90d20789a4a8f0a31b
- // hits the next release of rust-bitcoin.
if !(msg.script.is_p2wpkh()
|| msg.script.is_p2wsh()
- || (msg.script.is_witness_program()
- && msg.script.witness_version().map(|v| v.to_num() >= 1).unwrap_or(false)))
+ || msg.script.witness_version().map(|v| v.to_num() >= 1).unwrap_or(false))
{
return Err(AbortReason::InvalidOutputScript);
}
Why this scored 19/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.