Skip to content

Commit

Permalink
Update secp256k1 dependency to use PR rust-bitcoin/rust-secp256k1#721
Browse files Browse the repository at this point in the history
  • Loading branch information
jlest01 committed Aug 21, 2024
1 parent 044fb7b commit 5ae56d1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions bitcoin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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 }
Expand Down
12 changes: 9 additions & 3 deletions bitcoin/src/psbt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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"))]
Expand Down Expand Up @@ -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"))]
Expand Down Expand Up @@ -561,7 +567,7 @@ impl Psbt {
input_index: usize,
cache: &mut SighashCache<T>,
leaf_hash: Option<TapLeafHash>,
) -> Result<(Message, TapSighashType), SignError> {
) -> Result<(TapSighash, TapSighashType), SignError> {
use OutputType::*;

if self.signing_algorithm(input_index)? != SigningAlgorithm::Schnorr {
Expand Down Expand Up @@ -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),
}
Expand Down

0 comments on commit 5ae56d1

Please sign in to comment.