Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consensus: witness program push must be minimal. #1527

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading