]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Check if msg.script.is_witness_program() before checking version
authorDuncan Dean <git@dunxen.dev>
Tue, 26 Mar 2024 09:17:05 +0000 (11:17 +0200)
committerDuncan Dean <git@dunxen.dev>
Tue, 23 Apr 2024 09:29:24 +0000 (11:29 +0200)
lightning/src/ln/interactivetxs.rs

index aea1e8ecbd7e8741d98a3e8c5e67d0152e84dcf4..7e3addc7788b6f0c402a09135cfa84ca098a2aa9 100644 (file)
@@ -259,9 +259,13 @@ 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 ¯\_(ツ)_/¯
-               if !msg.script.is_v0_p2wpkh()
-                       && !msg.script.is_v0_p2wsh()
-                       && msg.script.witness_version().map(|v| v.to_num() < 1).unwrap_or(true)
+               //
+               // 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_v0_p2wpkh()
+                       || msg.script.is_v0_p2wsh()
+                       || (msg.script.is_witness_program()
+                               && msg.script.witness_version().map(|v| v.to_num() >= 1).unwrap_or(false)))
                {
                        return Err(AbortReason::InvalidOutputScript);
                }