Skip to content

Commit 0ee470d

Browse files
committed
Merge #492: DefiniteDescriptorKey: provide additional methods for converting to a DescriptorPublicKey
1477dbb DefiniteDescriptorKey: provide additional methods for converting to a DescriptorPublicKey (Andrew Poelstra) Pull request description: Fixes #491 I didn't provide a mutable version of this. I'm not sure if we want to support this or not; generally public keys should be immutable after creation. ACKs for top commit: sanket1729: ACK 1477dbb Tree-SHA512: 8c06ac3b6c395c3805b8cbd958ce4f354025ee88b2915562662cb084216048c6543591c468112981e8afa72d89373a544965096227475f0c198af9194d826a7e
2 parents 928e283 + 1477dbb commit 0ee470d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/descriptor/key.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,6 +1067,16 @@ impl DefiniteDescriptorKey {
10671067
pub fn full_derivation_path(&self) -> Option<bip32::DerivationPath> {
10681068
self.0.full_derivation_path()
10691069
}
1070+
1071+
/// Reference to the underlying `DescriptorPublicKey`
1072+
pub fn as_descriptor_public_key(&self) -> &DescriptorPublicKey {
1073+
&self.0
1074+
}
1075+
1076+
/// Converts the definite key into a generic one
1077+
pub fn into_descriptor_public_key(self) -> DescriptorPublicKey {
1078+
self.0
1079+
}
10701080
}
10711081

10721082
impl FromStr for DefiniteDescriptorKey {
@@ -1134,6 +1144,12 @@ impl From<DefiniteDescriptorKey> for DescriptorPublicKey {
11341144
}
11351145
}
11361146

1147+
impl Borrow<DescriptorPublicKey> for DefiniteDescriptorKey {
1148+
fn borrow(&self) -> &DescriptorPublicKey {
1149+
&self.0
1150+
}
1151+
}
1152+
11371153
#[cfg(test)]
11381154
mod test {
11391155
use core::str::FromStr;

0 commit comments

Comments
 (0)