diff --git a/src/blockdata/transaction.rs b/src/blockdata/transaction.rs index c92b73c3..c8241f5e 100644 --- a/src/blockdata/transaction.rs +++ b/src/blockdata/transaction.rs @@ -852,7 +852,7 @@ pub type SigHashType = EcdsaSighashType; /// /// Fixed values so they can be cast as integer types for encoding (see also /// [`SchnorrSighashType`]). -#[derive(PartialEq, Eq, Debug, Copy, Clone)] +#[derive(PartialEq, Eq, Debug, Copy, Clone, Hash)] pub enum EcdsaSighashType { /// 0x1: Sign all outputs. All = 0x01, diff --git a/src/util/ecdsa.rs b/src/util/ecdsa.rs index 8c4282d1..4d85c37c 100644 --- a/src/util/ecdsa.rs +++ b/src/util/ecdsa.rs @@ -14,7 +14,7 @@ use secp256k1; use crate::EcdsaSighashType; /// An ECDSA signature with the corresponding hash type. -#[derive(Debug, Copy, Clone, PartialEq, Eq)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", serde(crate = "actual_serde"))] pub struct EcdsaSig { diff --git a/src/util/psbt/map/input.rs b/src/util/psbt/map/input.rs index a6277066..754df14b 100644 --- a/src/util/psbt/map/input.rs +++ b/src/util/psbt/map/input.rs @@ -68,7 +68,7 @@ const PSBT_IN_PROPRIETARY: u8 = 0xFC; /// A key-value map for an input of the corresponding index in the unsigned /// transaction. -#[derive(Clone, Default, Debug, PartialEq, Eq)] +#[derive(Clone, Default, Debug, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", serde(crate = "actual_serde"))] pub struct Input { diff --git a/src/util/psbt/map/output.rs b/src/util/psbt/map/output.rs index 71dcf939..74d27d5a 100644 --- a/src/util/psbt/map/output.rs +++ b/src/util/psbt/map/output.rs @@ -36,7 +36,7 @@ const PSBT_OUT_PROPRIETARY: u8 = 0xFC; /// A key-value map for an output of the corresponding index in the unsigned /// transaction. -#[derive(Clone, Default, Debug, PartialEq, Eq)] +#[derive(Clone, Default, Debug, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", serde(crate = "actual_serde"))] pub struct Output { @@ -123,6 +123,12 @@ impl PartialEq for TapTree { } } +impl core::hash::Hash for TapTree { + fn hash(&self, state: &mut H) { + self.node_info().hash(state) + } +} + impl Eq for TapTree {} impl From for TaprootBuilder { diff --git a/src/util/psbt/mod.rs b/src/util/psbt/mod.rs index 6b6469bd..d978e884 100644 --- a/src/util/psbt/mod.rs +++ b/src/util/psbt/mod.rs @@ -37,7 +37,7 @@ use crate::util::bip32::{ExtendedPubKey, KeySource}; pub type Psbt = PartiallySignedTransaction; /// A Partially Signed Transaction. -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", serde(crate = "actual_serde"))] pub struct PartiallySignedTransaction { diff --git a/src/util/schnorr.rs b/src/util/schnorr.rs index 7c13cc26..01859387 100644 --- a/src/util/schnorr.rs +++ b/src/util/schnorr.rs @@ -205,7 +205,7 @@ impl From for crate::KeyPair { } /// A BIP340-341 serialized schnorr signature with the corresponding hash type. -#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", serde(crate = "actual_serde"))] pub struct SchnorrSig {