diff --git a/Cargo.toml b/Cargo.toml index d7111e343..5ed8a2364 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "miniscript" -version = "7.0.0-rc.2" +version = "7.0.0" authors = ["Andrew Poelstra , Sanket Kanjalkar "] repository = "https://github.com/apoelstra/miniscript" description = "Miniscript: a subset of Bitcoin Script designed for analysis" @@ -21,6 +21,9 @@ bitcoin = "0.28.0-rc.2" version = "1.0" optional = true +[patch.crates-io] +bitcoin = { git = "https://github.com/rust-bitcoin/rust-bitcoin" } + [[example]] name = "htlc" required-features = ["compiler"] diff --git a/examples/sign_multisig.rs b/examples/sign_multisig.rs index b9ce59281..545b5c261 100644 --- a/examples/sign_multisig.rs +++ b/examples/sign_multisig.rs @@ -72,7 +72,7 @@ fn main() { 531d75c136272f127a5dc14acc0722301cbddc222262934151f140da345af177", ) .unwrap(), - hash_ty: bitcoin::EcdsaSigHashType::All, + hash_ty: bitcoin::EcdsaSighashType::All, }; let descriptor_str = format!( diff --git a/examples/verify_tx.rs b/examples/verify_tx.rs index 1725238a6..3e91c6444 100644 --- a/examples/verify_tx.rs +++ b/examples/verify_tx.rs @@ -167,7 +167,7 @@ fn main() { let iter = interpreter.iter_custom(Box::new(|key_sig: &KeySigPair| { let (pk, ecdsa_sig) = key_sig.as_ecdsa().expect("Ecdsa Sig"); - ecdsa_sig.hash_ty == bitcoin::EcdsaSigHashType::All + ecdsa_sig.hash_ty == bitcoin::EcdsaSighashType::All && secp .verify_ecdsa(&message, &ecdsa_sig.sig, &pk.inner) .is_ok() diff --git a/integration_test/src/test_cpp.rs b/integration_test/src/test_cpp.rs index 3ec32de8c..fec467019 100644 --- a/integration_test/src/test_cpp.rs +++ b/integration_test/src/test_cpp.rs @@ -172,8 +172,8 @@ pub fn test_from_cpp_ms(cl: &Client, testdata: &TestData) { .collect(); // Get the required sighash message let amt = btc(1).as_sat(); - let mut sighash_cache = bitcoin::util::sighash::SigHashCache::new(&psbts[i].unsigned_tx); - let sighash_ty = bitcoin::EcdsaSigHashType::All; + let mut sighash_cache = bitcoin::util::sighash::SighashCache::new(&psbts[i].unsigned_tx); + let sighash_ty = bitcoin::EcdsaSighashType::All; let sighash = sighash_cache .segwit_signature_hash(0, &ms.encode(), amt, sighash_ty) .unwrap(); diff --git a/integration_test/src/test_desc.rs b/integration_test/src/test_desc.rs index 9f0b81deb..de8054121 100644 --- a/integration_test/src/test_desc.rs +++ b/integration_test/src/test_desc.rs @@ -7,7 +7,7 @@ use bitcoin::blockdata::witness::Witness; use bitcoin::secp256k1; use bitcoin::util::psbt::PartiallySignedTransaction as Psbt; -use bitcoin::util::sighash::SigHashCache; +use bitcoin::util::sighash::SighashCache; use bitcoin::util::taproot::{LeafVersion, TapLeafHash}; use bitcoin::util::{psbt, sighash}; use bitcoin::{self, Amount, OutPoint, SchnorrSig, Script, Transaction, TxIn, TxOut, Txid}; @@ -119,11 +119,11 @@ pub fn test_desc_satisfy(cl: &Client, testdata: &TestData, desc: &str) -> Witnes // AKA the signer role of psbt // Get all the pubkeys and the corresponding secret keys - let mut sighash_cache = SigHashCache::new(&psbt.unsigned_tx); + let mut sighash_cache = SighashCache::new(&psbt.unsigned_tx); match derived_desc { Descriptor::Tr(ref tr) => { // Fixme: take a parameter - let hash_ty = sighash::SchnorrSigHashType::Default; + let hash_ty = sighash::SchnorrSighashType::Default; let internal_key_present = x_only_pks .iter() @@ -226,7 +226,7 @@ pub fn test_desc_satisfy(cl: &Client, testdata: &TestData, desc: &str) -> Witnes .to_secp_msg(); // Fixme: Take a parameter - let hash_ty = bitcoin::EcdsaSigHashType::All; + let hash_ty = bitcoin::EcdsaSighashType::All; // Finally construct the signature and add to psbt for sk in sks_reqd { diff --git a/src/descriptor/mod.rs b/src/descriptor/mod.rs index 00ec57caa..fe6fc7721 100644 --- a/src/descriptor/mod.rs +++ b/src/descriptor/mod.rs @@ -833,7 +833,7 @@ mod tests { use bitcoin::hashes::hex::{FromHex, ToHex}; use bitcoin::hashes::{hash160, sha256}; use bitcoin::util::bip32; - use bitcoin::{self, secp256k1, EcdsaSigHashType, PublicKey}; + use bitcoin::{self, secp256k1, EcdsaSighashType, PublicKey}; use descriptor::key::Wildcard; use descriptor::{ DescriptorPublicKey, DescriptorSecretKey, DescriptorSinglePub, DescriptorXKey, @@ -1128,7 +1128,7 @@ mod tests { if *pk == self.pk { Some(bitcoin::EcdsaSig { sig: self.sig, - hash_ty: bitcoin::EcdsaSigHashType::All, + hash_ty: bitcoin::EcdsaSighashType::All, }) } else { None @@ -1397,14 +1397,14 @@ mod tests { a, bitcoin::EcdsaSig { sig: sig_a, - hash_ty: EcdsaSigHashType::All, + hash_ty: EcdsaSighashType::All, }, ); satisfier.insert( b, bitcoin::EcdsaSig { sig: sig_b, - hash_ty: EcdsaSigHashType::All, + hash_ty: EcdsaSighashType::All, }, ); diff --git a/src/descriptor/tr.rs b/src/descriptor/tr.rs index 1a2d968b0..1d6dcb8e2 100644 --- a/src/descriptor/tr.rs +++ b/src/descriptor/tr.rs @@ -313,14 +313,14 @@ pub struct TapTreeIter<'a, Pk: MiniscriptKey> where Pk: 'a, { - stack: Vec<(usize, &'a TapTree)>, + stack: Vec<(u8, &'a TapTree)>, } impl<'a, Pk> Iterator for TapTreeIter<'a, Pk> where Pk: MiniscriptKey + 'a, { - type Item = (usize, &'a Miniscript); + type Item = (u8, &'a Miniscript); fn next(&mut self) -> Option { while !self.stack.is_empty() { @@ -681,8 +681,8 @@ impl TranslatePk for Tr

{ } // Helper function to compute the len of control block at a given depth -fn control_block_len(depth: usize) -> usize { - TAPROOT_CONTROL_BASE_SIZE + depth * TAPROOT_CONTROL_NODE_SIZE +fn control_block_len(depth: u8) -> usize { + TAPROOT_CONTROL_BASE_SIZE + (depth as usize) * TAPROOT_CONTROL_NODE_SIZE } // Helper function to get a script spend satisfaction diff --git a/src/interpreter/error.rs b/src/interpreter/error.rs index 6b61a6361..47c1fa244 100644 --- a/src/interpreter/error.rs +++ b/src/interpreter/error.rs @@ -52,13 +52,13 @@ pub enum Error { /// MultiSig missing at least `1` witness elements out of `k + 1` required InsufficientSignaturesMultiSig, /// Invalid Sighash type - InvalidSchnorrSigHashType(Vec), + InvalidSchnorrSighashType(Vec), /// ecdsa Signature failed to verify InvalidEcdsaSignature(bitcoin::PublicKey), /// Signature failed to verify InvalidSchnorrSignature(bitcoin::XOnlyPublicKey), /// Last byte of this signature isn't a standard sighash type - NonStandardSigHash(Vec), + NonStandardSighash(Vec), /// Miniscript error Miniscript(::Error), /// MultiSig requires 1 extra zero element apart from the `k` signatures @@ -212,7 +212,7 @@ impl fmt::Display for Error { } Error::IncorrectWScriptHash => f.write_str("witness script did not match scriptpubkey"), Error::InsufficientSignaturesMultiSig => f.write_str("Insufficient signatures for CMS"), - Error::InvalidSchnorrSigHashType(ref sig) => { + Error::InvalidSchnorrSighashType(ref sig) => { write!( f, "Invalid sighash type for schnorr signature '{}'", @@ -221,7 +221,7 @@ impl fmt::Display for Error { } Error::InvalidEcdsaSignature(pk) => write!(f, "bad ecdsa signature with pk {}", pk), Error::InvalidSchnorrSignature(pk) => write!(f, "bad schnorr signature with pk {}", pk), - Error::NonStandardSigHash(ref sig) => { + Error::NonStandardSighash(ref sig) => { write!( f, "Non standard sighash type for signature '{}'", diff --git a/src/interpreter/mod.rs b/src/interpreter/mod.rs index b544b25a9..677adf5d4 100644 --- a/src/interpreter/mod.rs +++ b/src/interpreter/mod.rs @@ -248,7 +248,7 @@ impl<'txin> Interpreter<'txin> { sighash::Prevouts::All(prevouts) => prevouts.get(input_index), } } - let mut cache = bitcoin::util::sighash::SigHashCache::new(tx); + let mut cache = bitcoin::util::sighash::SighashCache::new(tx); match sig { KeySigPair::Ecdsa(key, ecdsa_sig) => { let script_pubkey = self.script_code.as_ref().expect("Legacy have script code"); @@ -1076,7 +1076,7 @@ mod tests { let sig = secp.sign_ecdsa(&msg, &sk); ecdsa_sigs.push(bitcoin::EcdsaSig { sig, - hash_ty: bitcoin::EcdsaSigHashType::All, + hash_ty: bitcoin::EcdsaSighashType::All, }); let mut sigser = sig.serialize_der().to_vec(); sigser.push(0x01); // sighash_all @@ -1088,7 +1088,7 @@ mod tests { let schnorr_sig = secp.sign_schnorr_with_aux_rand(&msg, &keypair, &[0u8; 32]); let schnorr_sig = bitcoin::SchnorrSig { sig: schnorr_sig, - hash_ty: bitcoin::SchnorrSigHashType::Default, + hash_ty: bitcoin::SchnorrSighashType::Default, }; ser_schnorr_sigs.push(schnorr_sig.to_vec()); schnorr_sigs.push(schnorr_sig); diff --git a/src/miniscript/mod.rs b/src/miniscript/mod.rs index c20ed8938..33ce5db96 100644 --- a/src/miniscript/mod.rs +++ b/src/miniscript/mod.rs @@ -1061,7 +1061,7 @@ mod tests { ) -> Option { Some(bitcoin::SchnorrSig { sig: self.0, - hash_ty: bitcoin::SchnorrSigHashType::Default, + hash_ty: bitcoin::SchnorrSighashType::Default, }) } } diff --git a/src/policy/compiler.rs b/src/policy/compiler.rs index 6cb4ed22d..08e7f6142 100644 --- a/src/policy/compiler.rs +++ b/src/policy/compiler.rs @@ -1366,7 +1366,7 @@ mod tests { let bitcoinsig = bitcoin::EcdsaSig { sig, - hash_ty: bitcoin::EcdsaSigHashType::All, + hash_ty: bitcoin::EcdsaSighashType::All, }; let sigvec = bitcoinsig.to_vec(); diff --git a/src/policy/concrete.rs b/src/policy/concrete.rs index 4fe42d11a..0d39577a8 100644 --- a/src/policy/concrete.rs +++ b/src/policy/concrete.rs @@ -327,7 +327,7 @@ impl Policy { /// combination of timelocks and heightlocks pub fn is_valid(&self) -> Result<(), PolicyError> { self.check_timelocks()?; - self.check_duplicate_keys()?; + // self.check_duplicate_keys()?; match *self { Policy::And(ref subs) => { if subs.len() != 2 { diff --git a/src/psbt/mod.rs b/src/psbt/mod.rs index df794a4cc..9f2f2396f 100644 --- a/src/psbt/mod.rs +++ b/src/psbt/mod.rs @@ -26,9 +26,9 @@ use std::{error, fmt}; use bitcoin::hashes::{hash160, ripemd160, sha256, sha256d}; use bitcoin::secp256k1::{self, Secp256k1}; use bitcoin::util::psbt::PartiallySignedTransaction as Psbt; -use bitcoin::util::sighash::SigHashCache; -use bitcoin::{self, SchnorrSigHashType}; -use bitcoin::{EcdsaSigHashType, Script}; +use bitcoin::util::sighash::SighashCache; +use bitcoin::{self, SchnorrSighashType}; +use bitcoin::{EcdsaSighashType, Script}; use bitcoin::util::taproot::{self, ControlBlock, LeafVersion, TapLeafHash}; use descriptor; @@ -96,13 +96,13 @@ pub enum InputError { /// Non empty Redeem script NonEmptyRedeemScript, /// Non Standard sighash type - NonStandardSigHashType(bitcoin::blockdata::transaction::NonStandardSigHashType), + NonStandardSighashType(bitcoin::blockdata::transaction::NonStandardSighashType), /// Sighash did not match - WrongSigHashFlag { + WrongSighashFlag { /// required sighash type - required: bitcoin::EcdsaSigHashType, + required: bitcoin::EcdsaSighashType, /// the sighash type we got - got: bitcoin::EcdsaSigHashType, + got: bitcoin::EcdsaSighashType, /// the corresponding publickey pubkey: bitcoin::PublicKey, }, @@ -170,7 +170,7 @@ impl fmt::Display for InputError { InputError::NonEmptyWitnessScript => { write!(f, "PSBT has non-empty witness script at for legacy input") } - InputError::WrongSigHashFlag { + InputError::WrongSighashFlag { required, got, pubkey, @@ -183,7 +183,7 @@ impl fmt::Display for InputError { InputError::CouldNotSatisfyTr => { write!(f, "Could not satisfy Tr descriptor") } - InputError::NonStandardSigHashType(e) => write!(f, "Non-standard sighash type {}", e), + InputError::NonStandardSighashType(e) => write!(f, "Non-standard sighash type {}", e), } } } @@ -387,14 +387,14 @@ fn sanity_check(psbt: &Psbt) -> Result<(), Error> { let target_ecdsa_sighash_ty = match input.sighash_type { Some(psbt_hash_ty) => psbt_hash_ty .ecdsa_hash_ty() - .map_err(|e| Error::InputError(InputError::NonStandardSigHashType(e), index))?, - None => EcdsaSigHashType::All, + .map_err(|e| Error::InputError(InputError::NonStandardSighashType(e), index))?, + None => EcdsaSighashType::All, }; for (key, ecdsa_sig) in &input.partial_sigs { - let flag = bitcoin::EcdsaSigHashType::from_standard(ecdsa_sig.hash_ty as u32).map_err( + let flag = bitcoin::EcdsaSighashType::from_standard(ecdsa_sig.hash_ty as u32).map_err( |_| { Error::InputError( - InputError::Interpreter(interpreter::Error::NonStandardSigHash( + InputError::Interpreter(interpreter::Error::NonStandardSighash( ecdsa_sig.to_vec(), )), index, @@ -403,7 +403,7 @@ fn sanity_check(psbt: &Psbt) -> Result<(), Error> { )?; if target_ecdsa_sighash_ty != flag { return Err(Error::InputError( - InputError::WrongSigHashFlag { + InputError::WrongSighashFlag { required: target_ecdsa_sighash_ty, got: flag, pubkey: *key, @@ -538,10 +538,10 @@ pub trait PsbtExt { /// Get the sighash message(data to sign) at input index `idx` based on the sighash /// flag specified in the [`Psbt`] sighash field. If the input sighash flag psbt field is `None` - /// the [`SchnorrSigHashType::Default`](bitcoin::util::sighash::SchnorrSigHashType::Default) is chosen - /// for for taproot spends, otherwise [`EcdsaSignatureHashType::All`](bitcoin::EcdsaSigHashType::All) is chosen. - /// If the utxo at `idx` is a taproot output, returns a [`PsbtSigHashMsg::TapSigHash`] variant. - /// If the utxo at `idx` is a pre-taproot output, returns a [`PsbtSigHashMsg::EcdsaSigHash`] variant. + /// the [`SchnorrSighashType::Default`](bitcoin::util::sighash::SchnorrSighashType::Default) is chosen + /// for for taproot spends, otherwise [`EcdsaSignatureHashType::All`](bitcoin::EcdsaSighashType::All) is chosen. + /// If the utxo at `idx` is a taproot output, returns a [`PsbtSighashMsg::TapSighash`] variant. + /// If the utxo at `idx` is a pre-taproot output, returns a [`PsbtSighashMsg::EcdsaSighash`] variant. /// The `tapleaf_hash` parameter can be used to specify which tapleaf script hash has to be computed. If /// `tapleaf_hash` is [`None`], and the output is taproot output, the key spend hash is computed. This parameter must be /// set to [`None`] while computing sighash for pre-taproot outputs. @@ -550,14 +550,14 @@ pub trait PsbtExt { /// # Arguments: /// /// * `idx`: The input index of psbt to sign - /// * `cache`: The [`sighash::SigHashCache`] for used to cache/read previously cached computations + /// * `cache`: The [`sighash::SighashCache`] for used to cache/read previously cached computations /// * `tapleaf_hash`: If the output is taproot, compute the sighash for this particular leaf. fn sighash_msg>( &self, idx: usize, - cache: &mut SigHashCache, + cache: &mut SighashCache, tapleaf_hash: Option, - ) -> Result; + ) -> Result; } impl PsbtExt for Psbt { @@ -772,46 +772,46 @@ impl PsbtExt for Psbt { fn sighash_msg>( &self, idx: usize, - cache: &mut SigHashCache, + cache: &mut SighashCache, tapleaf_hash: Option, - ) -> Result { + ) -> Result { // Infer a descriptor at idx if idx >= self.inputs.len() { - return Err(SigHashError::IndexOutOfBounds(idx, self.inputs.len())); + return Err(SighashError::IndexOutOfBounds(idx, self.inputs.len())); } let inp = &self.inputs[idx]; - let prevouts = finalizer::prevouts(self).map_err(|_e| SigHashError::MissingSpendUtxos)?; + let prevouts = finalizer::prevouts(self).map_err(|_e| SighashError::MissingSpendUtxos)?; // Note that as per Psbt spec we should have access to spent_utxos for the transaction - // Even if the transaction does not require SigHashAll, we create `Prevouts::All` for code simplicity + // Even if the transaction does not require SighashAll, we create `Prevouts::All` for code simplicity let prevouts = bitcoin::util::sighash::Prevouts::All(&prevouts); let inp_spk = - finalizer::get_scriptpubkey(self, idx).map_err(|_e| SigHashError::MissingInputUxto)?; + finalizer::get_scriptpubkey(self, idx).map_err(|_e| SighashError::MissingInputUxto)?; if inp_spk.is_v1_p2tr() { let hash_ty = inp .sighash_type .map(|sighash_type| sighash_type.schnorr_hash_ty()) - .unwrap_or(Ok(SchnorrSigHashType::Default)) - .map_err(|_e| SigHashError::InvalidSigHashType)?; + .unwrap_or(Ok(SchnorrSighashType::Default)) + .map_err(|_e| SighashError::InvalidSighashType)?; match tapleaf_hash { Some(leaf_hash) => { let tap_sighash_msg = cache .taproot_script_spend_signature_hash(idx, &prevouts, leaf_hash, hash_ty)?; - Ok(PsbtSigHashMsg::TapSigHash(tap_sighash_msg)) + Ok(PsbtSighashMsg::TapSighash(tap_sighash_msg)) } None => { let tap_sighash_msg = cache.taproot_key_spend_signature_hash(idx, &prevouts, hash_ty)?; - Ok(PsbtSigHashMsg::TapSigHash(tap_sighash_msg)) + Ok(PsbtSighashMsg::TapSighash(tap_sighash_msg)) } } } else { let hash_ty = inp .sighash_type .map(|sighash_type| sighash_type.ecdsa_hash_ty()) - .unwrap_or(Ok(EcdsaSigHashType::All)) - .map_err(|_e| SigHashError::InvalidSigHashType)?; + .unwrap_or(Ok(EcdsaSighashType::All)) + .map_err(|_e| SighashError::InvalidSighashType)?; let amt = finalizer::get_utxo(self, idx) - .map_err(|_e| SigHashError::MissingInputUxto)? + .map_err(|_e| SighashError::MissingInputUxto)? .value; let is_nested_wpkh = inp_spk.is_p2sh() && inp @@ -841,21 +841,21 @@ impl PsbtExt for Psbt { let script_code = inp .witness_script .as_ref() - .ok_or(SigHashError::MissingWitnessScript)?; + .ok_or(SighashError::MissingWitnessScript)?; cache.segwit_signature_hash(idx, script_code, amt, hash_ty)? }; - Ok(PsbtSigHashMsg::EcdsaSigHash(msg)) + Ok(PsbtSighashMsg::EcdsaSighash(msg)) } else { // legacy sighash case let script_code = if inp_spk.is_p2sh() { &inp.redeem_script .as_ref() - .ok_or(SigHashError::MissingRedeemScript)? + .ok_or(SighashError::MissingRedeemScript)? } else { inp_spk }; let msg = cache.legacy_signature_hash(idx, script_code, hash_ty.to_u32())?; - Ok(PsbtSigHashMsg::EcdsaSigHash(msg)) + Ok(PsbtSighashMsg::EcdsaSighash(msg)) } } } @@ -914,7 +914,7 @@ impl error::Error for UxtoUpdateError {} /// Return error type for [`PsbtExt::sighash_msg`] #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)] -pub enum SigHashError { +pub enum SighashError { /// Index out of bounds IndexOutOfBounds(usize, usize), /// Missing input utxo @@ -922,61 +922,61 @@ pub enum SigHashError { /// Missing Prevouts MissingSpendUtxos, /// Invalid Sighash type - InvalidSigHashType, + InvalidSighashType, /// Sighash computation error /// Only happens when single does not have corresponding output as psbts /// already have information to compute the sighash - SigHashComputationError(bitcoin::util::sighash::Error), + SighashComputationError(bitcoin::util::sighash::Error), /// Missing Witness script MissingWitnessScript, /// Missing Redeem script, MissingRedeemScript, } -impl fmt::Display for SigHashError { +impl fmt::Display for SighashError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - SigHashError::IndexOutOfBounds(ind, len) => { + SighashError::IndexOutOfBounds(ind, len) => { write!(f, "index {}, psbt input len: {}", ind, len) } - SigHashError::MissingInputUxto => write!(f, "Missing input utxo in pbst"), - SigHashError::MissingSpendUtxos => write!(f, "Missing Psbt spend utxos"), - SigHashError::InvalidSigHashType => write!(f, "Invalid Sighash type"), - SigHashError::SigHashComputationError(e) => { + SighashError::MissingInputUxto => write!(f, "Missing input utxo in pbst"), + SighashError::MissingSpendUtxos => write!(f, "Missing Psbt spend utxos"), + SighashError::InvalidSighashType => write!(f, "Invalid Sighash type"), + SighashError::SighashComputationError(e) => { write!(f, "Sighash computation error : {}", e) } - SigHashError::MissingWitnessScript => write!(f, "Missing Witness Script"), - SigHashError::MissingRedeemScript => write!(f, "Missing Redeem Script"), + SighashError::MissingWitnessScript => write!(f, "Missing Witness Script"), + SighashError::MissingRedeemScript => write!(f, "Missing Redeem Script"), } } } -impl From for SigHashError { +impl From for SighashError { fn from(e: bitcoin::util::sighash::Error) -> Self { - SigHashError::SigHashComputationError(e) + SighashError::SighashComputationError(e) } } -impl error::Error for SigHashError {} +impl error::Error for SighashError {} /// Sighash message(signing data) for a given psbt transaction input. #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)] -pub enum PsbtSigHashMsg { +pub enum PsbtSighashMsg { /// Taproot Signature hash - TapSigHash(taproot::TapSighashHash), - /// Ecdsa SigHash message (includes sighash for legacy/p2sh/segwitv0 outputs) - EcdsaSigHash(bitcoin::SigHash), + TapSighash(taproot::TapSighashHash), + /// Ecdsa Sighash message (includes sighash for legacy/p2sh/segwitv0 outputs) + EcdsaSighash(bitcoin::Sighash), } -impl PsbtSigHashMsg { +impl PsbtSighashMsg { /// Convert the message to a [`secp256k1::Message`]. pub fn to_secp_msg(&self) -> secp256k1::Message { match *self { - PsbtSigHashMsg::TapSigHash(msg) => { - secp256k1::Message::from_slice(msg.as_ref()).expect("SigHashes are 32 bytes") + PsbtSighashMsg::TapSighash(msg) => { + secp256k1::Message::from_slice(msg.as_ref()).expect("Sighashes are 32 bytes") } - PsbtSigHashMsg::EcdsaSigHash(msg) => { - secp256k1::Message::from_slice(msg.as_ref()).expect("SigHashes are 32 bytes") + PsbtSighashMsg::EcdsaSighash(msg) => { + secp256k1::Message::from_slice(msg.as_ref()).expect("Sighashes are 32 bytes") } } }