Merge rust-bitcoin/rust-bitcoin#990: Derive Hash on a bunch of types
ef7fef001c
Derive Hash on a bunch of types (Tobin C. Harding) Pull request description: In preparation for being able to derive `Hash` on all types in `miniscript`, derive `Hash` on all of the required types. This PR includes all the changes in https://github.com/rust-bitcoin/rust-bitcoin/pull/933/files and hence supersedes it. ref: https://github.com/rust-bitcoin/rust-miniscript/issues/226 ACKs for top commit: Kixunil: ACKef7fef001c
apoelstra: ACKef7fef001c
Tree-SHA512: 1a1db8b4df2ea8f9e176434bb6fdee5b96f47dcdc6395ebc59e5f5ac5eb13a66fb61e1d90cdbbf12a027f7685fdff21060338c5f27b9d9bf5e9fee452c7c7e83
This commit is contained in:
commit
06a777d02d
|
@ -852,7 +852,7 @@ pub type SigHashType = EcdsaSighashType;
|
||||||
///
|
///
|
||||||
/// Fixed values so they can be cast as integer types for encoding (see also
|
/// Fixed values so they can be cast as integer types for encoding (see also
|
||||||
/// [`SchnorrSighashType`]).
|
/// [`SchnorrSighashType`]).
|
||||||
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
|
#[derive(PartialEq, Eq, Debug, Copy, Clone, Hash)]
|
||||||
pub enum EcdsaSighashType {
|
pub enum EcdsaSighashType {
|
||||||
/// 0x1: Sign all outputs.
|
/// 0x1: Sign all outputs.
|
||||||
All = 0x01,
|
All = 0x01,
|
||||||
|
|
|
@ -14,7 +14,7 @@ use secp256k1;
|
||||||
use crate::EcdsaSighashType;
|
use crate::EcdsaSighashType;
|
||||||
|
|
||||||
/// An ECDSA signature with the corresponding hash type.
|
/// 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", derive(Serialize, Deserialize))]
|
||||||
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
|
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
|
||||||
pub struct EcdsaSig {
|
pub struct EcdsaSig {
|
||||||
|
|
|
@ -68,7 +68,7 @@ const PSBT_IN_PROPRIETARY: u8 = 0xFC;
|
||||||
|
|
||||||
/// A key-value map for an input of the corresponding index in the unsigned
|
/// A key-value map for an input of the corresponding index in the unsigned
|
||||||
/// transaction.
|
/// 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", derive(Serialize, Deserialize))]
|
||||||
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
|
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
|
||||||
pub struct Input {
|
pub struct Input {
|
||||||
|
|
|
@ -36,7 +36,7 @@ const PSBT_OUT_PROPRIETARY: u8 = 0xFC;
|
||||||
|
|
||||||
/// A key-value map for an output of the corresponding index in the unsigned
|
/// A key-value map for an output of the corresponding index in the unsigned
|
||||||
/// transaction.
|
/// 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", derive(Serialize, Deserialize))]
|
||||||
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
|
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
|
||||||
pub struct Output {
|
pub struct Output {
|
||||||
|
@ -123,6 +123,12 @@ impl PartialEq for TapTree {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl core::hash::Hash for TapTree {
|
||||||
|
fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
|
||||||
|
self.node_info().hash(state)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Eq for TapTree {}
|
impl Eq for TapTree {}
|
||||||
|
|
||||||
impl From<TapTree> for TaprootBuilder {
|
impl From<TapTree> for TaprootBuilder {
|
||||||
|
|
|
@ -37,7 +37,7 @@ use crate::util::bip32::{ExtendedPubKey, KeySource};
|
||||||
pub type Psbt = PartiallySignedTransaction;
|
pub type Psbt = PartiallySignedTransaction;
|
||||||
|
|
||||||
/// A Partially Signed Transaction.
|
/// 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", derive(Serialize, Deserialize))]
|
||||||
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
|
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
|
||||||
pub struct PartiallySignedTransaction {
|
pub struct PartiallySignedTransaction {
|
||||||
|
|
|
@ -205,7 +205,7 @@ impl From<TweakedKeyPair> for crate::KeyPair {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A BIP340-341 serialized schnorr signature with the corresponding hash type.
|
/// 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", derive(Serialize, Deserialize))]
|
||||||
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
|
#[cfg_attr(feature = "serde", serde(crate = "actual_serde"))]
|
||||||
pub struct SchnorrSig {
|
pub struct SchnorrSig {
|
||||||
|
|
Loading…
Reference in New Issue