@@ -28,6 +28,7 @@ use std::marker::PhantomData;
28
28
use std:: { fmt, str} ;
29
29
30
30
use bitcoin:: blockdata:: script;
31
+ use bitcoin:: util:: taproot:: { LeafVersion , TapLeafHash } ;
31
32
32
33
pub use self :: context:: { BareCtx , Legacy , Segwitv0 , Tap } ;
33
34
@@ -358,7 +359,11 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Miniscript<Pk, Ctx> {
358
359
where
359
360
Pk : ToPublicKey ,
360
361
{
361
- match satisfy:: Satisfaction :: satisfy ( & self . node , & satisfier, self . ty . mall . safe ) . stack {
362
+ // Only satisfactions for default versions (0xc0) are allowed.
363
+ let leaf_hash = TapLeafHash :: from_script ( & self . encode ( ) , LeafVersion :: TapScript ) ;
364
+ match satisfy:: Satisfaction :: satisfy ( & self . node , & satisfier, self . ty . mall . safe , & leaf_hash)
365
+ . stack
366
+ {
362
367
satisfy:: Witness :: Stack ( stack) => {
363
368
Ctx :: check_witness :: < Pk > ( & stack) ?;
364
369
Ok ( stack)
@@ -378,7 +383,15 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Miniscript<Pk, Ctx> {
378
383
where
379
384
Pk : ToPublicKey ,
380
385
{
381
- match satisfy:: Satisfaction :: satisfy_mall ( & self . node , & satisfier, self . ty . mall . safe ) . stack {
386
+ let leaf_hash = TapLeafHash :: from_script ( & self . encode ( ) , LeafVersion :: TapScript ) ;
387
+ match satisfy:: Satisfaction :: satisfy_mall (
388
+ & self . node ,
389
+ & satisfier,
390
+ self . ty . mall . safe ,
391
+ & leaf_hash,
392
+ )
393
+ . stack
394
+ {
382
395
satisfy:: Witness :: Stack ( stack) => {
383
396
Ctx :: check_witness :: < Pk > ( & stack) ?;
384
397
Ok ( stack)
@@ -449,6 +462,7 @@ serde_string_impl_pk!(Miniscript, "a miniscript", Ctx; ScriptContext);
449
462
#[ cfg( test) ]
450
463
mod tests {
451
464
465
+ use bitcoin:: util:: taproot:: TapLeafHash ;
452
466
use { Satisfier , ToPublicKey } ;
453
467
454
468
use super :: { Miniscript , ScriptContext } ;
@@ -1039,7 +1053,11 @@ mod tests {
1039
1053
1040
1054
// a simple satisfier that always outputs the same signature
1041
1055
impl < Pk : ToPublicKey > Satisfier < Pk > for SimpleSatisfier {
1042
- fn lookup_schnorr_sig ( & self , _pk : & Pk ) -> Option < bitcoin:: SchnorrSig > {
1056
+ fn lookup_tap_leaf_script_sig (
1057
+ & self ,
1058
+ _pk : & Pk ,
1059
+ _h : & TapLeafHash ,
1060
+ ) -> Option < bitcoin:: SchnorrSig > {
1043
1061
Some ( bitcoin:: SchnorrSig {
1044
1062
sig : self . 0 ,
1045
1063
hash_ty : bitcoin:: SchnorrSigHashType :: Default ,
0 commit comments