@@ -5,10 +5,10 @@ use base64;
55use clap;
66use hex;
77
8+ use bitcoin:: { EcdsaSighashType , PublicKey , Transaction } ;
89use bitcoin:: consensus:: { deserialize, serialize} ;
910use bitcoin:: util:: bip32;
1011use bitcoin:: util:: psbt;
11- use bitcoin:: { PublicKey , Transaction } ;
1212use miniscript:: psbt:: PsbtExt ;
1313use secp256k1;
1414
@@ -504,15 +504,18 @@ fn exec_rawsign<'a>(args: &clap::ArgMatches<'a>) {
504504 } ;
505505
506506 let sighashtype = psbt. inputs [ i] . sighash_type
507- . need ( "error locating sighash type on the selected input" )
508- . ecdsa_hash_ty ( )
509- . need ( "schnorr signatures are not yet supported" ) ;
510- let mut btc_sig = secp_sig. serialize_der ( ) . as_ref ( ) . to_vec ( ) ;
511- btc_sig. push ( sighashtype. to_u32 ( ) as u8 ) ;
507+ . map ( |t| t. ecdsa_hash_ty ( ) . need ( "schnorr signatures are not yet supported" ) )
508+ . unwrap_or_else ( || {
509+ eprintln ! ( "No sighash type set for input {}, so signing with SIGHASH_ALL" , i+1 ) ;
510+ EcdsaSighashType :: All
511+ } ) ;
512+ let sig = bitcoin:: EcdsaSig {
513+ sig : secp_sig,
514+ hash_ty : sighashtype,
515+ } ;
512516
513517 // mutate the psbt
514- psbt. inputs [ i] . partial_sigs . insert ( pk, bitcoin:: EcdsaSig :: from_slice ( & btc_sig)
515- . need ( "failed to sign psbt" ) ) ;
518+ psbt. inputs [ i] . partial_sigs . insert ( pk, sig) ;
516519 let raw = serialize ( & psbt) ;
517520 if let Some ( path) = args. value_of ( "output" ) {
518521 let mut file = File :: create ( & path) . need ( "failed to open output file" ) ;
0 commit comments