Skip to content

Commit 1477dbb

Browse files
committed
DefiniteDescriptorKey: provide additional methods for converting to a DescriptorPublicKey
1 parent a7bfff4 commit 1477dbb

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/descriptor/key.rs

+16
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,16 @@ impl DefiniteDescriptorKey {
777777
pub fn full_derivation_path(&self) -> bip32::DerivationPath {
778778
self.0.full_derivation_path()
779779
}
780+
781+
/// Reference to the underlying `DescriptorPublicKey`
782+
pub fn as_descriptor_public_key(&self) -> &DescriptorPublicKey {
783+
&self.0
784+
}
785+
786+
/// Converts the definite key into a generic one
787+
pub fn into_descriptor_public_key(self) -> DescriptorPublicKey {
788+
self.0
789+
}
780790
}
781791

782792
impl FromStr for DefiniteDescriptorKey {
@@ -842,6 +852,12 @@ impl From<DefiniteDescriptorKey> for DescriptorPublicKey {
842852
}
843853
}
844854

855+
impl Borrow<DescriptorPublicKey> for DefiniteDescriptorKey {
856+
fn borrow(&self) -> &DescriptorPublicKey {
857+
&self.0
858+
}
859+
}
860+
845861
#[cfg(test)]
846862
mod test {
847863
use core::str::FromStr;

0 commit comments

Comments
 (0)