Skip to content

Commit aa2041c

Browse files
committed
Derive Hash on a bunch of types
In preparation for being able to derive `Hash` on all types in `miniscript`, derive `Hash` on all of the required types.
1 parent a8eca3c commit aa2041c

File tree

6 files changed

+12
-6
lines changed

6 files changed

+12
-6
lines changed

src/blockdata/transaction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,7 @@ pub type SigHashType = EcdsaSighashType;
852852
///
853853
/// Fixed values so they can be cast as integer types for encoding (see also
854854
/// [`SchnorrSighashType`]).
855-
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
855+
#[derive(PartialEq, Eq, Debug, Copy, Clone, Hash)]
856856
pub enum EcdsaSighashType {
857857
/// 0x1: Sign all outputs.
858858
All = 0x01,

src/util/ecdsa.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use secp256k1;
1414
use crate::EcdsaSighashType;
1515

1616
/// An ECDSA signature with the corresponding hash type.
17-
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
17+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
1818
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
1919
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
2020
pub struct EcdsaSig {

src/util/psbt/map/input.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const PSBT_IN_PROPRIETARY: u8 = 0xFC;
6868

6969
/// A key-value map for an input of the corresponding index in the unsigned
7070
/// transaction.
71-
#[derive(Clone, Default, Debug, PartialEq, Eq)]
71+
#[derive(Clone, Default, Debug, PartialEq, Eq, Hash)]
7272
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
7373
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
7474
pub struct Input {

src/util/psbt/map/output.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const PSBT_OUT_PROPRIETARY: u8 = 0xFC;
3636

3737
/// A key-value map for an output of the corresponding index in the unsigned
3838
/// transaction.
39-
#[derive(Clone, Default, Debug, PartialEq, Eq)]
39+
#[derive(Clone, Default, Debug, PartialEq, Eq, Hash)]
4040
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
4141
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
4242
pub struct Output {
@@ -123,6 +123,12 @@ impl PartialEq for TapTree {
123123
}
124124
}
125125

126+
impl core::hash::Hash for TapTree {
127+
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
128+
self.node_info().hash(state)
129+
}
130+
}
131+
126132
impl Eq for TapTree {}
127133

128134
impl From<TapTree> for TaprootBuilder {

src/util/psbt/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use crate::util::bip32::{ExtendedPubKey, KeySource};
3737
pub type Psbt = PartiallySignedTransaction;
3838

3939
/// A Partially Signed Transaction.
40-
#[derive(Debug, Clone, PartialEq, Eq)]
40+
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
4141
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
4242
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
4343
pub struct PartiallySignedTransaction {

src/util/schnorr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ impl From<TweakedKeyPair> for crate::KeyPair {
205205
}
206206

207207
/// A BIP340-341 serialized schnorr signature with the corresponding hash type.
208-
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
208+
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
209209
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
210210
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
211211
pub struct SchnorrSig {

0 commit comments

Comments
 (0)