@@ -893,14 +893,17 @@ impl PsbtExt for Psbt {
893893 . unwrap_or ( false ) ;
894894 if inp_spk. is_v0_p2wpkh ( ) || inp_spk. is_v0_p2wsh ( ) || is_nested_wpkh || is_nested_wsh {
895895 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" ) ;
897899 cache. segwit_signature_hash ( idx, & script_code, amt, hash_ty) ?
898900 } 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" ) ;
904907 cache. segwit_signature_hash ( idx, & script_code, amt, hash_ty) ?
905908 } else {
906909 // wsh and nested wsh, script code is witness script
@@ -1254,17 +1257,6 @@ fn update_item_with_descriptor_helper<F: PsbtFields>(
12541257 Ok ( ( derived, true ) )
12551258}
12561259
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-
12681260/// Return error type for [`PsbtExt::update_input_with_descriptor`]
12691261#[ derive( Debug , PartialEq , Eq , PartialOrd , Ord , Hash , Clone , Copy ) ]
12701262pub enum UtxoUpdateError {
0 commit comments