Skip to content

Commit 00d4832

Browse files
committed
Fix the length of the taproot output to 34 bytes in script_is_v1_tr
1 parent 6a89bd0 commit 00d4832

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/util.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,14 @@ impl MsKeyBuilder for script::Builder {
5252
// This belongs in rust-bitcoin, make this upstream later
5353
pub(crate) fn script_is_v1_tr(s: &Script) -> bool {
5454
let mut iter = s.instructions_minimal();
55-
if s.len() != 32
56-
|| iter.next() != Some(Ok(Instruction::Op(opcodes::all::OP_PUSHNUM_1)))
57-
|| iter.next() != Some(Ok(Instruction::Op(opcodes::all::OP_PUSHBYTES_32)))
58-
{
55+
if s.len() != 34 {
56+
return false;
57+
}
58+
if iter.next() != Some(Ok(Instruction::Op(opcodes::all::OP_PUSHNUM_1))) {
5959
return false;
6060
}
61-
return true;
61+
if let Some(Ok(Instruction::PushBytes(p))) = iter.next() {
62+
return p.len() == 32;
63+
}
64+
return false;
6265
}

0 commit comments

Comments
 (0)