Skip to content

Commit c1291e0

Browse files
committed
Add shorthand API derive_public_key_at_index
The name is deliberately long and not `derive_public_key` because we already have `DefiniteDescriptorKey::derive_public_key` Bikeshedding of names welcome
1 parent f611162 commit c1291e0

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/descriptor/key.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,18 @@ impl DescriptorPublicKey {
448448
self.at_derivation_index(index)
449449
}
450450

451+
/// Derive the key at the given index.
452+
/// Shorthand for `at_derivation_index(idx).derive_public_key(secp)`.
453+
///
454+
/// If the key does not have a wildcard, the user can supply a dummy derivation index.
455+
pub fn derive_public_key_at_index<C: Verification>(
456+
self,
457+
secp: &Secp256k1<C>,
458+
index: u32,
459+
) -> Result<bitcoin::PublicKey, ConversionError> {
460+
self.at_derivation_index(index).derive_public_key(secp)
461+
}
462+
451463
/// Replaces any wildcard (i.e. `/*`) in the key with a particular derivation index, turning it into a
452464
/// *definite* key (i.e. one where all the derivation paths are set).
453465
///

0 commit comments

Comments
 (0)