Skip to content

Commit f52a8cb

Browse files
committed
Check if msg.script.is_witness_program() before checking version
1 parent 9406bea commit f52a8cb

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lightning/src/ln/interactivetxs.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,13 @@ impl NegotiationContext {
260260
// with witness versions V1 and up are always considered standard. Yes, the scripts can be
261261
// anyone-can-spend-able, but if our counterparty wants to add an output like that then it's none
262262
// of our concern really ¯\_(ツ)_/¯
263-
if !msg.script.is_v0_p2wpkh()
264-
&& !msg.script.is_v0_p2wsh()
265-
&& msg.script.witness_version().map(|v| v.to_num() < 1).unwrap_or(true)
263+
//
264+
// TODO: The last check would be simplified when https://github.com/rust-bitcoin/rust-bitcoin/commit/1656e1a09a1959230e20af90d20789a4a8f0a31b
265+
// hits the next release of rust-bitcoin.
266+
if !(msg.script.is_v0_p2wpkh()
267+
|| msg.script.is_v0_p2wsh()
268+
|| (msg.script.is_witness_program()
269+
&& msg.script.witness_version().map(|v| v.to_num() >= 1).unwrap_or(false)))
266270
{
267271
return Err(AbortReason::InvalidOutputScript);
268272
}

0 commit comments

Comments
 (0)