@@ -893,14 +893,17 @@ impl PsbtExt for Psbt {
893
893
. unwrap_or ( false ) ;
894
894
if inp_spk. is_v0_p2wpkh ( ) || inp_spk. is_v0_p2wsh ( ) || is_nested_wpkh || is_nested_wsh {
895
895
let msg = if inp_spk. is_v0_p2wpkh ( ) {
896
- let script_code = script_code_wpkh ( inp_spk) ;
896
+ let script_code = inp_spk
897
+ . p2wpkh_script_code ( )
898
+ . expect ( "checked is p2wpkh above" ) ;
897
899
cache. segwit_signature_hash ( idx, & script_code, amt, hash_ty) ?
898
900
} else if is_nested_wpkh {
899
- let script_code = script_code_wpkh (
900
- inp. redeem_script
901
- . as_ref ( )
902
- . expect ( "Redeem script non-empty checked earlier" ) ,
903
- ) ;
901
+ let script_code = inp
902
+ . redeem_script
903
+ . as_ref ( )
904
+ . expect ( "redeem script non-empty checked earlier" )
905
+ . p2wpkh_script_code ( )
906
+ . expect ( "checked is p2wpkh above" ) ;
904
907
cache. segwit_signature_hash ( idx, & script_code, amt, hash_ty) ?
905
908
} else {
906
909
// wsh and nested wsh, script code is witness script
@@ -1254,17 +1257,6 @@ fn update_item_with_descriptor_helper<F: PsbtFields>(
1254
1257
Ok ( ( derived, true ) )
1255
1258
}
1256
1259
1257
- // Get a script from witness script pubkey hash
1258
- fn script_code_wpkh ( script : & Script ) -> Script {
1259
- assert ! ( script. is_v0_p2wpkh( ) ) ;
1260
- // ugly segwit stuff
1261
- let mut script_code = vec ! [ 0x76u8 , 0xa9 , 0x14 ] ;
1262
- script_code. extend ( & script. as_bytes ( ) [ 2 ..] ) ;
1263
- script_code. push ( 0x88 ) ;
1264
- script_code. push ( 0xac ) ;
1265
- Script :: from ( script_code)
1266
- }
1267
-
1268
1260
/// Return error type for [`PsbtExt::update_input_with_descriptor`]
1269
1261
#[ derive( Debug , PartialEq , Eq , PartialOrd , Ord , Hash , Clone , Copy ) ]
1270
1262
pub enum UtxoUpdateError {
0 commit comments