1919//! `https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki`
2020//!
2121
22+ use std:: collections:: BTreeMap ;
2223use std:: { error, fmt} ;
2324
2425use bitcoin;
@@ -28,6 +29,7 @@ use bitcoin::secp256k1::{self, Secp256k1};
2829use bitcoin:: util:: psbt:: PartiallySignedTransaction as Psbt ;
2930use bitcoin:: Script ;
3031
32+ use bitcoin:: util:: taproot:: { ControlBlock , LeafVersion , TapLeafHash } ;
3133use interpreter;
3234use miniscript:: limits:: SEQUENCE_LOCKTIME_DISABLE_FLAG ;
3335use miniscript:: satisfy:: { After , Older } ;
@@ -232,6 +234,37 @@ impl<'psbt> PsbtInputSatisfier<'psbt> {
232234}
233235
234236impl < ' psbt , Pk : MiniscriptKey + ToPublicKey > Satisfier < Pk > for PsbtInputSatisfier < ' psbt > {
237+ fn lookup_tap_key_spend_sig ( & self ) -> Option < bitcoin:: SchnorrSig > {
238+ self . psbt . inputs [ self . index ] . tap_key_sig
239+ }
240+
241+ fn lookup_tap_leaf_script_sig ( & self , pk : & Pk , lh : & TapLeafHash ) -> Option < bitcoin:: SchnorrSig > {
242+ self . psbt . inputs [ self . index ]
243+ . tap_script_sigs
244+ . get ( & ( pk. to_x_only_pubkey ( ) , * lh) )
245+ . map ( |x| * x) // replace by copied in 1.36
246+ }
247+
248+ fn lookup_tap_control_block_map (
249+ & self ,
250+ ) -> Option < & BTreeMap < ControlBlock , ( bitcoin:: Script , LeafVersion ) > > {
251+ Some ( & self . psbt . inputs [ self . index ] . tap_scripts )
252+ }
253+
254+ fn lookup_pkh_tap_leaf_script_sig (
255+ & self ,
256+ pkh : & ( Pk :: Hash , TapLeafHash ) ,
257+ ) -> Option < ( bitcoin:: secp256k1:: XOnlyPublicKey , bitcoin:: SchnorrSig ) > {
258+ self . psbt . inputs [ self . index ]
259+ . tap_script_sigs
260+ . iter ( )
261+ . filter ( |& ( ( pubkey, lh) , _sig) | {
262+ pubkey. to_pubkeyhash ( ) == Pk :: hash_to_hash160 ( & pkh. 0 ) && * lh == pkh. 1
263+ } )
264+ . next ( )
265+ . map ( |( ( x_only_pk, _leaf_hash) , sig) | ( * x_only_pk, * sig) )
266+ }
267+
235268 fn lookup_ecdsa_sig ( & self , pk : & Pk ) -> Option < bitcoin:: EcdsaSig > {
236269 self . psbt . inputs [ self . index ]
237270 . partial_sigs
0 commit comments