@@ -252,26 +252,29 @@ impl<'psbt> PsbtInputSatisfier<'psbt> {
252
252
/// create a new PsbtInputsatisfier from
253
253
/// psbt and index
254
254
pub fn new ( psbt : & ' psbt Psbt , index : usize ) -> Self { Self { psbt, index } }
255
+
256
+ /// Accessor for the input this satisfier is associated with.
257
+ pub fn psbt_input ( & self ) -> & psbt:: Input { & self . psbt . inputs [ self . index ] }
255
258
}
256
259
257
260
impl < Pk : MiniscriptKey + ToPublicKey > Satisfier < Pk > for PsbtInputSatisfier < ' _ > {
258
261
fn lookup_tap_key_spend_sig ( & self ) -> Option < bitcoin:: taproot:: Signature > {
259
- self . psbt . inputs [ self . index ] . tap_key_sig
262
+ self . psbt_input ( ) . tap_key_sig
260
263
}
261
264
262
265
fn lookup_tap_leaf_script_sig (
263
266
& self ,
264
267
pk : & Pk ,
265
268
lh : & TapLeafHash ,
266
269
) -> Option < bitcoin:: taproot:: Signature > {
267
- self . psbt . inputs [ self . index ]
270
+ self . psbt_input ( )
268
271
. tap_script_sigs
269
272
. get ( & ( pk. to_x_only_pubkey ( ) , * lh) )
270
273
. copied ( )
271
274
}
272
275
273
276
fn lookup_raw_pkh_pk ( & self , pkh : & hash160:: Hash ) -> Option < bitcoin:: PublicKey > {
274
- self . psbt . inputs [ self . index ]
277
+ self . psbt_input ( )
275
278
. bip32_derivation
276
279
. iter ( )
277
280
. find ( |& ( pubkey, _) | pubkey. to_pubkeyhash ( SigType :: Ecdsa ) == * pkh)
@@ -281,14 +284,14 @@ impl<Pk: MiniscriptKey + ToPublicKey> Satisfier<Pk> for PsbtInputSatisfier<'_> {
281
284
fn lookup_tap_control_block_map (
282
285
& self ,
283
286
) -> Option < & BTreeMap < ControlBlock , ( bitcoin:: ScriptBuf , LeafVersion ) > > {
284
- Some ( & self . psbt . inputs [ self . index ] . tap_scripts )
287
+ Some ( & self . psbt_input ( ) . tap_scripts )
285
288
}
286
289
287
290
fn lookup_raw_pkh_tap_leaf_script_sig (
288
291
& self ,
289
292
pkh : & ( hash160:: Hash , TapLeafHash ) ,
290
293
) -> Option < ( bitcoin:: secp256k1:: XOnlyPublicKey , bitcoin:: taproot:: Signature ) > {
291
- self . psbt . inputs [ self . index ]
294
+ self . psbt_input ( )
292
295
. tap_script_sigs
293
296
. iter ( )
294
297
. find ( |& ( ( pubkey, lh) , _sig) | {
@@ -298,7 +301,7 @@ impl<Pk: MiniscriptKey + ToPublicKey> Satisfier<Pk> for PsbtInputSatisfier<'_> {
298
301
}
299
302
300
303
fn lookup_ecdsa_sig ( & self , pk : & Pk ) -> Option < bitcoin:: ecdsa:: Signature > {
301
- self . psbt . inputs [ self . index ]
304
+ self . psbt_input ( )
302
305
. partial_sigs
303
306
. get ( & pk. to_public_key ( ) )
304
307
. copied ( )
@@ -308,7 +311,7 @@ impl<Pk: MiniscriptKey + ToPublicKey> Satisfier<Pk> for PsbtInputSatisfier<'_> {
308
311
& self ,
309
312
pkh : & hash160:: Hash ,
310
313
) -> Option < ( bitcoin:: PublicKey , bitcoin:: ecdsa:: Signature ) > {
311
- self . psbt . inputs [ self . index ]
314
+ self . psbt_input ( )
312
315
. partial_sigs
313
316
. iter ( )
314
317
. find ( |& ( pubkey, _sig) | pubkey. to_pubkeyhash ( SigType :: Ecdsa ) == * pkh)
@@ -337,28 +340,28 @@ impl<Pk: MiniscriptKey + ToPublicKey> Satisfier<Pk> for PsbtInputSatisfier<'_> {
337
340
}
338
341
339
342
fn lookup_hash160 ( & self , h : & Pk :: Hash160 ) -> Option < Preimage32 > {
340
- self . psbt . inputs [ self . index ]
343
+ self . psbt_input ( )
341
344
. hash160_preimages
342
345
. get ( & Pk :: to_hash160 ( h) )
343
346
. and_then ( |x : & Vec < u8 > | <[ u8 ; 32 ] >:: try_from ( & x[ ..] ) . ok ( ) )
344
347
}
345
348
346
349
fn lookup_sha256 ( & self , h : & Pk :: Sha256 ) -> Option < Preimage32 > {
347
- self . psbt . inputs [ self . index ]
350
+ self . psbt_input ( )
348
351
. sha256_preimages
349
352
. get ( & Pk :: to_sha256 ( h) )
350
353
. and_then ( |x : & Vec < u8 > | <[ u8 ; 32 ] >:: try_from ( & x[ ..] ) . ok ( ) )
351
354
}
352
355
353
356
fn lookup_hash256 ( & self , h : & Pk :: Hash256 ) -> Option < Preimage32 > {
354
- self . psbt . inputs [ self . index ]
357
+ self . psbt_input ( )
355
358
. hash256_preimages
356
359
. get ( & sha256d:: Hash :: from_byte_array ( Pk :: to_hash256 ( h) . to_byte_array ( ) ) ) // upstream psbt operates on hash256
357
360
. and_then ( |x : & Vec < u8 > | <[ u8 ; 32 ] >:: try_from ( & x[ ..] ) . ok ( ) )
358
361
}
359
362
360
363
fn lookup_ripemd160 ( & self , h : & Pk :: Ripemd160 ) -> Option < Preimage32 > {
361
- self . psbt . inputs [ self . index ]
364
+ self . psbt_input ( )
362
365
. ripemd160_preimages
363
366
. get ( & Pk :: to_ripemd160 ( h) )
364
367
. and_then ( |x : & Vec < u8 > | <[ u8 ; 32 ] >:: try_from ( & x[ ..] ) . ok ( ) )
0 commit comments