@@ -61,25 +61,25 @@ initialize() const NOEXCEPT
61
61
const auto bip141 = is_enabled (flags::bip141_rule);
62
62
const auto bip342 = is_enabled (flags::bip342_rule);
63
63
64
- // Apply stack element limit (520) to initial witness [bip141] [bip342].
65
- if (bip141 && witness_ && ! chain::witness::is_push_size (*witness_ ))
66
- return error::invalid_witness_stack ;
64
+ // Succeed if any success code, overrides all codes and errors [bip342].
65
+ if (bip342 && script_-> is_prevalid ( ))
66
+ return error::prevalid_script ;
67
67
68
- // Script size limit (10,000) [0.3.7+], removed [bip342] .
69
- if (!bip342 && nops && script_->is_oversized ())
70
- return error::invalid_script_size ;
68
+ // Fail if last op is underflow (same behavior as prefail, invalid code) .
69
+ if (script_->is_underflow ())
70
+ return error::invalid_script ;
71
71
72
- // Stacks element limit (1,000) applied to initial stack [bip342].
72
+ // Stack limit (1,000) applied to initial stack [bip342].
73
73
if (bip342 && is_stack_overflow ())
74
74
return error::invalid_stack_size;
75
75
76
- // Succeed if any success code, one overrides all codes [bip342].
77
- if (bip342 && script_-> is_prevalid ( ))
78
- return error::prevalid_script ;
76
+ // Apply stack element limit (520) to initial witness [bip342|bip141 ].
77
+ if (( bip342 || bip141) && witness_ && ! chain::witness::is_push_size (*witness_ ))
78
+ return error::invalid_witness_stack ;
79
79
80
- // Fail if last op underflow, lower priority than success codes [bip342].
81
- if (script_->is_underflow ())
82
- return error::invalid_script ;
80
+ // Script size limit (10,000) [0.3.7+], removed [bip342].
81
+ if (!bip342 && nops && script_->is_oversized ())
82
+ return error::invalid_script_size ;
83
83
84
84
// Fail if any op invalid (invalid codes reduced in tapscript).
85
85
// Should be after underflow check since underflow is also an invalid op.
0 commit comments