@@ -11,6 +11,7 @@ use descriptor::satisfied_constraints::{Stack, StackElement};
1111use descriptor:: Descriptor ;
1212use miniscript:: { Legacy , Miniscript , Segwitv0 } ;
1313use Error ;
14+ use NullCtx ;
1415use ToPublicKey ;
1516
1617/// Helper function for creating StackElement from Push instructions. Special case required for
@@ -89,8 +90,9 @@ fn verify_p2wpkh<'txin>(
8990 }
9091 if let Some ( ( pk_bytes, witness) ) = witness. split_last ( ) {
9192 if let Ok ( pk) = bitcoin:: PublicKey :: from_slice ( pk_bytes) {
92- let addr = bitcoin:: Address :: p2wpkh ( & pk. to_public_key ( ) , bitcoin:: Network :: Bitcoin )
93- . map_err ( |_| Error :: InterpreterError ( IntError :: UncompressedPubkey ) ) ?;
93+ let addr =
94+ bitcoin:: Address :: p2wpkh ( & pk. to_public_key ( NullCtx ) , bitcoin:: Network :: Bitcoin )
95+ . map_err ( |_| Error :: InterpreterError ( IntError :: UncompressedPubkey ) ) ?;
9496 if addr. script_pubkey ( ) != * script_pubkey {
9597 return Err ( Error :: InterpreterError ( IntError :: PkEvaluationError ( pk) ) ) ;
9698 }
@@ -145,7 +147,7 @@ fn verify_p2pkh<'txin>(
145147) -> Result < ( Descriptor < bitcoin:: PublicKey > , Stack < ' txin > ) , Error > {
146148 let ( pk_bytes, stack) = parse_scriptsig_top ( script_sig) ?;
147149 if let Ok ( pk) = bitcoin:: PublicKey :: from_slice ( & pk_bytes) {
148- let addr = bitcoin:: Address :: p2pkh ( & pk. to_public_key ( ) , bitcoin:: Network :: Bitcoin ) ;
150+ let addr = bitcoin:: Address :: p2pkh ( & pk. to_public_key ( NullCtx ) , bitcoin:: Network :: Bitcoin ) ;
149151 if !witness. is_empty ( ) {
150152 return Err ( Error :: NonEmptyWitness ) ;
151153 }
@@ -247,7 +249,7 @@ mod tests {
247249 use descriptor:: satisfied_constraints:: { Stack , StackElement } ;
248250 use std:: str:: FromStr ;
249251 use ToPublicKey ;
250- use { Descriptor , Miniscript } ;
252+ use { Descriptor , Miniscript , NullCtx } ;
251253
252254 macro_rules! stack {
253255 ( $( $data: ident$( ( $pushdata: expr) ) * ) ,* ) => (
@@ -309,7 +311,7 @@ mod tests {
309311
310312 //test pk
311313 let script_pubkey = script:: Builder :: new ( )
312- . push_key ( & pks[ 0 ] . to_public_key ( ) )
314+ . push_key ( & pks[ 0 ] . to_public_key ( NullCtx ) )
313315 . push_opcode ( opcodes:: all:: OP_CHECKSIG )
314316 . into_script ( ) ;
315317 let script_sig = script:: Builder :: new ( ) . push_slice ( & sigs[ 0 ] ) . into_script ( ) ;
@@ -334,17 +336,21 @@ mod tests {
334336 //test Wsh: and(pkv, pk). Note this does not check miniscript.
335337 let ms = ms_str ! ( "and_v(vc:pk_k({}),c:pk_k({}))" , pks[ 0 ] , pks[ 1 ] ) ;
336338 let script_pubkey =
337- bitcoin:: Address :: p2wsh ( & ms. encode ( ) , bitcoin:: Network :: Bitcoin ) . script_pubkey ( ) ;
339+ bitcoin:: Address :: p2wsh ( & ms. encode ( NullCtx ) , bitcoin:: Network :: Bitcoin ) . script_pubkey ( ) ;
338340 let script_sig = script:: Builder :: new ( ) . into_script ( ) ;
339- let witness = vec ! [ sigs[ 1 ] . clone( ) , sigs[ 0 ] . clone( ) , ms. encode( ) . to_bytes( ) ] ;
341+ let witness = vec ! [
342+ sigs[ 1 ] . clone( ) ,
343+ sigs[ 0 ] . clone( ) ,
344+ ms. encode( NullCtx ) . to_bytes( ) ,
345+ ] ;
340346 let ( des, stack) = from_txin_with_witness_stack ( & script_pubkey, & script_sig, & witness)
341347 . expect ( "Descriptor/Witness stack creation to succeed" ) ;
342348 assert_eq ! ( Descriptor :: Wsh ( ms. clone( ) ) , des) ;
343349 assert_eq ! ( stack, stack![ Push ( & sigs[ 1 ] ) , Push ( & sigs[ 0 ] ) ] ) ;
344350
345351 //test Bare: and(pkv, pk). Note this does not check miniscript.
346352 let ms = ms_str ! ( "or_b(c:pk_k({}),sc:pk_k({}))" , pks[ 0 ] , pks[ 1 ] ) ;
347- let script_pubkey = ms. encode ( ) ;
353+ let script_pubkey = ms. encode ( NullCtx ) ;
348354 let script_sig = script:: Builder :: new ( )
349355 . push_int ( 0 )
350356 . push_slice ( & sigs[ 0 ] )
@@ -358,11 +364,11 @@ mod tests {
358364 //test Sh: and(pkv, pk). Note this does not check miniscript.
359365 let ms = ms_str ! ( "c:or_i(pk_k({}),pk_k({}))" , pks[ 0 ] , pks[ 1 ] ) ;
360366 let script_pubkey =
361- bitcoin:: Address :: p2sh ( & ms. encode ( ) , bitcoin:: Network :: Bitcoin ) . script_pubkey ( ) ;
367+ bitcoin:: Address :: p2sh ( & ms. encode ( NullCtx ) , bitcoin:: Network :: Bitcoin ) . script_pubkey ( ) ;
362368 let script_sig = script:: Builder :: new ( )
363369 . push_slice ( & sigs[ 0 ] )
364370 . push_int ( 1 )
365- . push_slice ( & ms. encode ( ) . to_bytes ( ) )
371+ . push_slice ( & ms. encode ( NullCtx ) . to_bytes ( ) )
366372 . into_script ( ) ;
367373 let witness = vec ! [ ] as Vec < Vec < u8 > > ;
368374 let ( des, stack) = from_txin_with_witness_stack ( & script_pubkey, & script_sig, & witness)
@@ -374,11 +380,16 @@ mod tests {
374380 //This test passes incorrect witness argument.
375381 let ms = ms_str ! ( "and_v(vc:pk_k({}),c:pk_k({}))" , pks[ 0 ] , pks[ 1 ] ) ;
376382 let script_pubkey =
377- bitcoin:: Address :: p2shwsh ( & ms. encode ( ) , bitcoin:: Network :: Bitcoin ) . script_pubkey ( ) ;
383+ bitcoin:: Address :: p2shwsh ( & ms. encode ( NullCtx ) , bitcoin:: Network :: Bitcoin )
384+ . script_pubkey ( ) ;
378385 let script_sig = script:: Builder :: new ( )
379- . push_slice ( & ms. encode ( ) . to_v0_p2wsh ( ) . to_bytes ( ) )
386+ . push_slice ( & ms. encode ( NullCtx ) . to_v0_p2wsh ( ) . to_bytes ( ) )
380387 . into_script ( ) ;
381- let witness = vec ! [ sigs[ 1 ] . clone( ) , sigs[ 3 ] . clone( ) , ms. encode( ) . to_bytes( ) ] ;
388+ let witness = vec ! [
389+ sigs[ 1 ] . clone( ) ,
390+ sigs[ 3 ] . clone( ) ,
391+ ms. encode( NullCtx ) . to_bytes( ) ,
392+ ] ;
382393 let ( des, stack) = from_txin_with_witness_stack ( & script_pubkey, & script_sig, & witness)
383394 . expect ( "Descriptor/Witness stack creation to succeed" ) ;
384395 assert_eq ! ( Descriptor :: ShWsh ( ms. clone( ) ) , des) ;
0 commit comments