Skip to content

Commit 4b63ba4

Browse files
author
Scott Robinson
committed
DescriptorInnerKey trait
1 parent d3af6d9 commit 4b63ba4

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/descriptor/key.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,39 @@ impl error::Error for ConversionError {
525525
}
526526
}
527527

528+
pub trait DescriptorInnerKey {
529+
/// The fingerprint of the master key associated with this key, `0x00000000` if none.
530+
fn master_fingerprint(&self) -> bip32::Fingerprint;
531+
532+
/// Full path, from the master key
533+
///
534+
/// For wildcard keys this will return the path up to the wildcard, so you
535+
/// can get full paths by appending one additional derivation step, according
536+
/// to the wildcard type (hardened or normal).
537+
///
538+
/// For multipath extended keys, this returns `None`.
539+
fn full_derivation_path(&self) -> Option<bip32::DerivationPath>;
540+
541+
/// Whether or not the key has a wildcard
542+
fn has_wildcard(&self) -> bool;
543+
544+
/// Replaces any wildcard (i.e. `/*`) in the key with a particular derivation index, turning it into a
545+
/// *definite* key (i.e. one where all the derivation paths are set).
546+
///
547+
/// # Returns
548+
///
549+
/// - If this key is not an xpub, returns `self`.
550+
/// - If this key is an xpub but does not have a wildcard, returns `self`.
551+
/// - Otherwise, returns the xpub at derivation `index` (removing the wildcard).
552+
///
553+
/// # Errors
554+
///
555+
/// - If `index` is hardened.
556+
fn at_derivation_index(self, index: u32) -> Result<DefiniteDescriptorKey, ConversionError>;
557+
558+
/// Whether or not this key has multiple derivation paths.
559+
fn is_multipath(&self) -> bool;
560+
}
528561
impl DescriptorPublicKey {
529562
/// The fingerprint of the master key associated with this key, `0x00000000` if none.
530563
pub fn master_fingerprint(&self) -> bip32::Fingerprint {

0 commit comments

Comments
 (0)