Skip to content

Commit

Permalink
Merge pull request #1527 from evoskuil/master
Browse files Browse the repository at this point in the history
Consensus: witness program push must be minimal.
  • Loading branch information
evoskuil authored Aug 22, 2024
2 parents 590919d + d51d8b3 commit 1456394
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/bitcoin/system/impl/chain/script.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ VCONSTEXPR bool script::is_witness_program_pattern(
{
return ops.size() == 2
&& ops[0].is_version()
&& ops[1].is_minimal_push()
&& ops[1].data().size() >= min_witness_program
&& ops[1].data().size() <= max_witness_program;
}
Expand Down
3 changes: 2 additions & 1 deletion test/chain/script.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,8 @@ const script_test_list valid_context_free_scripts
{ "[42424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242]", "[2.42424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242] equal", "basic push signedness check" },
{ "[1.42424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242]", "[2.42424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242] equal", "basic pushdata1 signedness check" },
{ "0x00", "size 0 equal", "basic op_0 execution" },
{ "", "0 1 equal size 0 equal", "boolean encoding" }
{ "", "0 1 equal size 0 equal", "boolean encoding" },
{ "[4242]", "zero [1.4242424242424242424242]", "non-minimal push should not match as witness program" }
}};

// These are always invalid.
Expand Down

0 comments on commit 1456394

Please sign in to comment.