diff --git a/bitcoin/Cargo.toml b/bitcoin/Cargo.toml index 6aebc3f637..10e3a51941 100644 --- a/bitcoin/Cargo.toml +++ b/bitcoin/Cargo.toml @@ -16,7 +16,7 @@ exclude = ["tests", "contrib"] [features] default = [ "std", "secp-recovery" ] std = ["base58/std", "bech32/std", "hashes/std", "hex/std", "internals/std", "io/std", "secp256k1/std", "units/std"] -rand-std = ["secp256k1/rand-std", "std"] +rand-std = ["secp256k1/std", "secp256k1/rand", "std"] rand = ["secp256k1/rand"] serde = ["actual-serde", "hashes/serde", "secp256k1/serde", "internals/serde", "units/serde"] secp-lowmemory = ["secp256k1/lowmemory"] @@ -35,7 +35,7 @@ hex = { package = "hex-conservative", version = "0.2.0", default-features = fals hex_lit = "0.1.1" internals = { package = "bitcoin-internals", version = "0.3.0", features = ["alloc"] } io = { package = "bitcoin-io", version = "0.1.1", default-features = false, features = ["alloc"] } -secp256k1 = { version = "0.29.0", default-features = false, features = ["hashes", "alloc"] } +secp256k1 = { git = "https://github.com/rust-bitcoin/rust-secp256k1.git", rev = "refs/pull/721/head", default-features = false, features = ["alloc", "hashes", "rand", "std"] } units = { package = "bitcoin-units", version = "0.1.0", default-features = false, features = ["alloc"] } base64 = { version = "0.21.3", optional = true } diff --git a/bitcoin/src/psbt/mod.rs b/bitcoin/src/psbt/mod.rs index 3d428fdac9..46152bd2a0 100644 --- a/bitcoin/src/psbt/mod.rs +++ b/bitcoin/src/psbt/mod.rs @@ -28,7 +28,9 @@ use crate::crypto::{ecdsa, taproot}; use crate::key::{TapTweak, XOnlyPublicKey}; use crate::prelude::*; use crate::sighash::{self, EcdsaSighashType, Prevouts, SighashCache}; -use crate::{Amount, FeeRate, TapLeafHash, TapSighashType}; +use crate::{Amount, FeeRate, TapLeafHash, TapSighash, TapSighashType}; + +use crate::hashes::Hash; #[rustfmt::skip] // Keep public re-exports separate. #[doc(inline)] @@ -444,6 +446,8 @@ impl Psbt { .tap_tweak(secp, input.tap_merkle_root) .to_inner(); + let msg = msg.to_byte_array(); + #[cfg(feature = "rand-std")] let signature = secp.sign_schnorr(&msg, &key_pair); #[cfg(not(feature = "rand-std"))] @@ -471,6 +475,8 @@ impl Psbt { let (msg, sighash_type) = self.sighash_taproot(input_index, cache, Some(lh))?; + let msg = msg.to_byte_array(); + #[cfg(feature = "rand-std")] let signature = secp.sign_schnorr(&msg, &key_pair); #[cfg(not(feature = "rand-std"))] @@ -561,7 +567,7 @@ impl Psbt { input_index: usize, cache: &mut SighashCache, leaf_hash: Option, - ) -> Result<(Message, TapSighashType), SignError> { + ) -> Result<(TapSighash, TapSighashType), SignError> { use OutputType::*; if self.signing_algorithm(input_index)? != SigningAlgorithm::Schnorr { @@ -606,7 +612,7 @@ impl Psbt { } else { cache.taproot_key_spend_signature_hash(input_index, &prev_outs, hash_ty)? }; - Ok((Message::from(sighash), hash_ty)) + Ok((sighash, hash_ty)) } _ => Err(SignError::Unsupported), }