diff --git a/src/descriptor/key.rs b/src/descriptor/key.rs index 6af0146e0..eeced2f12 100644 --- a/src/descriptor/key.rs +++ b/src/descriptor/key.rs @@ -22,7 +22,7 @@ pub enum DescriptorPublicKey { } /// The descriptor secret key, either a single private key or an xprv. -#[derive(Debug)] +#[derive(Debug, Eq, PartialEq, Clone)] pub enum DescriptorSecretKey { /// Single private key. Single(SinglePriv), @@ -40,7 +40,7 @@ pub struct SinglePub { } /// A descriptor [`bitcoin::PrivateKey`] with optional origin information. -#[derive(Debug)] +#[derive(Debug, Eq, PartialEq, Clone)] pub struct SinglePriv { /// Origin information (fingerprint and derivation path). pub origin: Option<(bip32::Fingerprint, bip32::DerivationPath)>, diff --git a/src/descriptor/mod.rs b/src/descriptor/mod.rs index 31a30b2e3..bbe1457c8 100644 --- a/src/descriptor/mod.rs +++ b/src/descriptor/mod.rs @@ -835,7 +835,6 @@ serde_string_impl_pk!(Descriptor, "a script descriptor"); #[cfg(test)] mod tests { - use core::cmp; use core::str::FromStr; use bitcoin::blockdata::opcodes::all::{OP_CLTV, OP_CSV}; @@ -850,7 +849,7 @@ mod tests { use super::tr::Tr; use super::*; use crate::descriptor::key::Wildcard; - use crate::descriptor::{DescriptorPublicKey, DescriptorSecretKey, DescriptorXKey, SinglePub}; + use crate::descriptor::{DescriptorPublicKey, DescriptorXKey, SinglePub}; #[cfg(feature = "compiler")] use crate::policy; use crate::{hex_script, Descriptor, DummyKey, Error, Miniscript, Satisfier}; @@ -859,23 +858,6 @@ mod tests { const TEST_PK: &'static str = "pk(020000000000000000000000000000000000000000000000000000000000000002)"; - impl cmp::PartialEq for DescriptorSecretKey { - fn eq(&self, other: &Self) -> bool { - match (self, other) { - (&DescriptorSecretKey::Single(ref a), &DescriptorSecretKey::Single(ref b)) => { - a.origin == b.origin && a.key == b.key - } - (&DescriptorSecretKey::XPrv(ref a), &DescriptorSecretKey::XPrv(ref b)) => { - a.origin == b.origin - && a.xkey == b.xkey - && a.derivation_path == b.derivation_path - && a.wildcard == b.wildcard - } - _ => false, - } - } - } - fn roundtrip_descriptor(s: &str) { let desc = Descriptor::::from_str(&s).unwrap(); let output = desc.to_string();