diff --git a/api/bitcoin/all-features.txt b/api/bitcoin/all-features.txt index 70bcacfe6..20a318d28 100644 --- a/api/bitcoin/all-features.txt +++ b/api/bitcoin/all-features.txt @@ -6350,6 +6350,7 @@ pub const bitcoin::pow::Target::MAX_ATTAINABLE_SIGNET: Self pub const bitcoin::pow::Target::MAX_ATTAINABLE_TESTNET: Self pub const bitcoin::pow::Target::ZERO: bitcoin::pow::Target pub const bitcoin::psbt::Psbt::DEFAULT_MAX_FEE_RATE: bitcoin_units::fee_rate::FeeRate +pub const bitcoin::psbt::PsbtSighashType::ALL: bitcoin::psbt::PsbtSighashType pub const bitcoin::script::witness_program::MAX_SIZE: usize = 40usize pub const bitcoin::script::witness_program::MIN_SIZE: usize = 2usize pub const bitcoin::sign_message::BITCOIN_SIGNED_MSG_PREFIX: &[u8] diff --git a/api/bitcoin/default-features.txt b/api/bitcoin/default-features.txt index 53f0eae48..0643c7c0f 100644 --- a/api/bitcoin/default-features.txt +++ b/api/bitcoin/default-features.txt @@ -6052,6 +6052,7 @@ pub const bitcoin::pow::Target::MAX_ATTAINABLE_SIGNET: Self pub const bitcoin::pow::Target::MAX_ATTAINABLE_TESTNET: Self pub const bitcoin::pow::Target::ZERO: bitcoin::pow::Target pub const bitcoin::psbt::Psbt::DEFAULT_MAX_FEE_RATE: bitcoin_units::fee_rate::FeeRate +pub const bitcoin::psbt::PsbtSighashType::ALL: bitcoin::psbt::PsbtSighashType pub const bitcoin::script::witness_program::MAX_SIZE: usize = 40usize pub const bitcoin::script::witness_program::MIN_SIZE: usize = 2usize pub const bitcoin::sign_message::BITCOIN_SIGNED_MSG_PREFIX: &[u8] diff --git a/api/bitcoin/no-features.txt b/api/bitcoin/no-features.txt index 36ffc2e83..5dc7e5b1f 100644 --- a/api/bitcoin/no-features.txt +++ b/api/bitcoin/no-features.txt @@ -5433,6 +5433,7 @@ pub const bitcoin::pow::Target::MAX_ATTAINABLE_SIGNET: Self pub const bitcoin::pow::Target::MAX_ATTAINABLE_TESTNET: Self pub const bitcoin::pow::Target::ZERO: bitcoin::pow::Target pub const bitcoin::psbt::Psbt::DEFAULT_MAX_FEE_RATE: bitcoin_units::fee_rate::FeeRate +pub const bitcoin::psbt::PsbtSighashType::ALL: bitcoin::psbt::PsbtSighashType pub const bitcoin::script::witness_program::MAX_SIZE: usize = 40usize pub const bitcoin::script::witness_program::MIN_SIZE: usize = 2usize pub const bitcoin::sign_message::BITCOIN_SIGNED_MSG_PREFIX: &[u8] diff --git a/bitcoin/src/psbt/map/input.rs b/bitcoin/src/psbt/map/input.rs index f59a6de76..79445d797 100644 --- a/bitcoin/src/psbt/map/input.rs +++ b/bitcoin/src/psbt/map/input.rs @@ -197,6 +197,22 @@ impl From for PsbtSighashType { } impl PsbtSighashType { + /// Ambiguous `ALL` sighash type, may refer to either [`EcdsaSighashType::All`] + /// or [`TapSighashType::All`]. + /// + /// This is equivalent to either `EcdsaSighashType::All.into()` or `TapSighashType::All.into()`. + /// For sighash types other than `ALL` use the ECDSA or Taproot sighash type directly. + /// + /// # Examples + /// + /// ``` + /// use bitcoin::{EcdsaSighashType, TapSighashType}; + /// use bitcoin::psbt::PsbtSighashType; + /// let ecdsa_sighash_anyone_can_pay: PsbtSighashType = EcdsaSighashType::AllPlusAnyoneCanPay.into(); + /// let tap_sighash_anyone_can_pay: PsbtSighashType = TapSighashType::AllPlusAnyoneCanPay.into(); + /// ``` + pub const ALL: PsbtSighashType = PsbtSighashType { inner: 0x01 }; + /// Returns the [`EcdsaSighashType`] if the [`PsbtSighashType`] can be /// converted to one. pub fn ecdsa_hash_ty(self) -> Result { @@ -545,4 +561,11 @@ mod test { assert_eq!(back.ecdsa_hash_ty(), Err(NonStandardSighashTypeError(nonstd))); assert_eq!(back.taproot_hash_ty(), Err(InvalidSighashTypeError(nonstd))); } + + #[test] + fn psbt_sighash_const_all() { + assert_eq!(PsbtSighashType::ALL.to_u32(), 0x01); + assert_eq!(PsbtSighashType::ALL.ecdsa_hash_ty().unwrap(), EcdsaSighashType::All); + assert_eq!(PsbtSighashType::ALL.taproot_hash_ty().unwrap(), TapSighashType::All); + } }