Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DefiniteDescriptorKey: provide additional methods for converting to a DescriptorPublicKey #492

Merged
merged 1 commit into from
Dec 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/descriptor/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -842,6 +852,12 @@ impl From<DefiniteDescriptorKey> for DescriptorPublicKey {
}
}

impl Borrow<DescriptorPublicKey> for DefiniteDescriptorKey {
fn borrow(&self) -> &DescriptorPublicKey {
&self.0
}
}

#[cfg(test)]
mod test {
use core::str::FromStr;
Expand Down