19
19
//! `https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki`
20
20
//!
21
21
22
+ use std:: collections:: BTreeMap ;
22
23
use std:: { error, fmt} ;
23
24
24
25
use bitcoin;
@@ -28,6 +29,7 @@ use bitcoin::secp256k1::{self, Secp256k1};
28
29
use bitcoin:: util:: psbt:: PartiallySignedTransaction as Psbt ;
29
30
use bitcoin:: Script ;
30
31
32
+ use bitcoin:: util:: taproot:: { ControlBlock , LeafVersion , TapLeafHash } ;
31
33
use interpreter;
32
34
use miniscript:: limits:: SEQUENCE_LOCKTIME_DISABLE_FLAG ;
33
35
use miniscript:: satisfy:: { After , Older } ;
@@ -232,6 +234,37 @@ impl<'psbt> PsbtInputSatisfier<'psbt> {
232
234
}
233
235
234
236
impl < ' 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
+
235
268
fn lookup_ecdsa_sig ( & self , pk : & Pk ) -> Option < bitcoin:: EcdsaSig > {
236
269
self . psbt . inputs [ self . index ]
237
270
. partial_sigs
0 commit comments