From 1477dbbb80523dde399a7cbaba25cbac54bf2816 Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Tue, 15 Nov 2022 00:46:51 +0000 Subject: [PATCH] DefiniteDescriptorKey: provide additional methods for converting to a DescriptorPublicKey --- src/descriptor/key.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/descriptor/key.rs b/src/descriptor/key.rs index 6af0146e0..9e8deb948 100644 --- a/src/descriptor/key.rs +++ b/src/descriptor/key.rs @@ -777,6 +777,16 @@ impl DefiniteDescriptorKey { pub fn full_derivation_path(&self) -> bip32::DerivationPath { self.0.full_derivation_path() } + + /// Reference to the underlying `DescriptorPublicKey` + pub fn as_descriptor_public_key(&self) -> &DescriptorPublicKey { + &self.0 + } + + /// Converts the definite key into a generic one + pub fn into_descriptor_public_key(self) -> DescriptorPublicKey { + self.0 + } } impl FromStr for DefiniteDescriptorKey { @@ -842,6 +852,12 @@ impl From for DescriptorPublicKey { } } +impl Borrow for DefiniteDescriptorKey { + fn borrow(&self) -> &DescriptorPublicKey { + &self.0 + } +} + #[cfg(test)] mod test { use core::str::FromStr;