@@ -28,7 +28,9 @@ use crate::crypto::{ecdsa, taproot};
2828use crate :: key:: { TapTweak , XOnlyPublicKey } ;
2929use crate :: prelude:: * ;
3030use crate :: sighash:: { self , EcdsaSighashType , Prevouts , SighashCache } ;
31- use crate :: { Amount , FeeRate , TapLeafHash , TapSighashType } ;
31+ use crate :: { Amount , FeeRate , TapLeafHash , TapSighash , TapSighashType } ;
32+
33+ use crate :: hashes:: Hash ;
3234
3335#[ rustfmt:: skip] // Keep public re-exports separate.
3436#[ doc( inline) ]
@@ -444,6 +446,8 @@ impl Psbt {
444446 . tap_tweak ( secp, input. tap_merkle_root )
445447 . to_inner ( ) ;
446448
449+ let msg = msg. to_byte_array ( ) ;
450+
447451 #[ cfg( feature = "rand-std" ) ]
448452 let signature = secp. sign_schnorr ( & msg, & key_pair) ;
449453 #[ cfg( not( feature = "rand-std" ) ) ]
@@ -471,6 +475,8 @@ impl Psbt {
471475 let ( msg, sighash_type) =
472476 self . sighash_taproot ( input_index, cache, Some ( lh) ) ?;
473477
478+ let msg = msg. to_byte_array ( ) ;
479+
474480 #[ cfg( feature = "rand-std" ) ]
475481 let signature = secp. sign_schnorr ( & msg, & key_pair) ;
476482 #[ cfg( not( feature = "rand-std" ) ) ]
@@ -561,7 +567,7 @@ impl Psbt {
561567 input_index : usize ,
562568 cache : & mut SighashCache < T > ,
563569 leaf_hash : Option < TapLeafHash > ,
564- ) -> Result < ( Message , TapSighashType ) , SignError > {
570+ ) -> Result < ( TapSighash , TapSighashType ) , SignError > {
565571 use OutputType :: * ;
566572
567573 if self . signing_algorithm ( input_index) ? != SigningAlgorithm :: Schnorr {
@@ -606,7 +612,7 @@ impl Psbt {
606612 } else {
607613 cache. taproot_key_spend_signature_hash ( input_index, & prev_outs, hash_ty) ?
608614 } ;
609- Ok ( ( Message :: from ( sighash) , hash_ty) )
615+ Ok ( ( sighash, hash_ty) )
610616 }
611617 _ => Err ( SignError :: Unsupported ) ,
612618 }
0 commit comments