File tree Expand file tree Collapse file tree 2 files changed +17
-14
lines changed Expand file tree Collapse file tree 2 files changed +17
-14
lines changed Original file line number Diff line number Diff line change @@ -301,6 +301,15 @@ pub fn parse<Ctx: ScriptContext>(
301301 // Note this does not collide with hash32 because they always followed by equal
302302 // and would be parsed in different branch. If we get a naked Bytes32, it must be
303303 // a x-only key
304+ // In miniscript spec, bytes32 only occurs at three places.
305+ // - during parsing XOnly keys in Pk fragment
306+ // - during parsing XOnly keys in MultiA fragment
307+ // - checking for 32 bytes hashlocks (sha256/hash256)
308+ // The second case(MultiA) is disambiguated using NumEqual which is not used anywhere in miniscript
309+ // The third case can only occur hashlocks is disambiguated because hashlocks start from equal, and
310+ // it is impossible for any K type fragment to be followed by EQUAL in miniscript spec. Thus, EQUAL
311+ // after bytes32 means bytes32 is in a hashlock
312+ // Finally for the first case, K being parsed as a solo expression is a Pk type
304313 Tk :: Bytes32 ( pk) => {
305314 let ret = Ctx :: Key :: from_slice( pk) . map_err( |e| Error :: PubKeyCtxError ( e, Ctx :: name_str( ) ) ) ?;
306315 term. reduce0( Terminal :: PkK ( ret) ) ?
Original file line number Diff line number Diff line change @@ -133,20 +133,14 @@ pub struct ExtData {
133133
134134impl Property for ExtData {
135135 fn sanity_checks ( & self ) {
136- fn xor < T > ( a : Option < T > , b : Option < T > ) -> bool {
137- match ( a, b) {
138- ( Some ( _) , Some ( _) ) | ( None , None ) => false ,
139- _ => true ,
140- }
141- }
142- debug_assert ! ( !xor(
143- self . stack_elem_count_sat,
144- self . exec_stack_elem_count_sat
145- ) ) ;
146- debug_assert ! ( !xor(
147- self . stack_elem_count_dissat,
148- self . exec_stack_elem_count_dissat
149- ) ) ;
136+ debug_assert_eq ! (
137+ self . stack_elem_count_sat. is_some( ) ,
138+ self . exec_stack_elem_count_sat. is_some( )
139+ ) ;
140+ debug_assert_eq ! (
141+ self . stack_elem_count_dissat. is_some( ) ,
142+ self . exec_stack_elem_count_dissat. is_some( )
143+ ) ;
150144 }
151145
152146 fn from_true ( ) -> Self {
You can’t perform that action at this time.
0 commit comments