@@ -531,15 +531,9 @@ impl error::Error for ConversionError {
531
531
}
532
532
}
533
533
534
- impl DescriptorExtendedPublicKey {
534
+ pub trait DescriptorInnerKey {
535
535
/// The fingerprint of the master key associated with this key, `0x00000000` if none.
536
- pub fn master_fingerprint ( & self ) -> bip32:: Fingerprint {
537
- if let Some ( ( fingerprint, _) ) = self . origin {
538
- fingerprint
539
- } else {
540
- self . xkey . fingerprint ( )
541
- }
542
- }
536
+ fn master_fingerprint ( & self ) -> bip32:: Fingerprint ;
543
537
544
538
/// Full path, from the master key
545
539
///
@@ -548,19 +542,10 @@ impl DescriptorExtendedPublicKey {
548
542
/// to the wildcard type (hardened or normal).
549
543
///
550
544
/// For multipath extended keys, this returns `None`.
551
- pub fn full_derivation_path ( & self ) -> Option < bip32:: DerivationPath > {
552
- let origin_path = if let Some ( ( _, ref path) ) = self . origin {
553
- path. clone ( )
554
- } else {
555
- bip32:: DerivationPath :: from ( vec ! [ ] )
556
- } ;
557
- Some ( origin_path. extend ( & self . derivation_path ) )
558
- }
545
+ fn full_derivation_path ( & self ) -> Option < bip32:: DerivationPath > ;
559
546
560
547
/// Whether or not the key has a wildcard
561
- pub fn has_wildcard ( & self ) -> bool {
562
- self . wildcard != Wildcard :: None
563
- }
548
+ fn has_wildcard ( & self ) -> bool ;
564
549
565
550
/// Replaces any wildcard (i.e. `/*`) in the key with a particular derivation index, turning it into a
566
551
/// *definite* key (i.e. one where all the derivation paths are set).
@@ -574,7 +559,35 @@ impl DescriptorExtendedPublicKey {
574
559
/// # Errors
575
560
///
576
561
/// - If `index` is hardened.
577
- pub fn at_derivation_index ( self , index : u32 ) -> Result < DefiniteDescriptorKey , ConversionError > {
562
+ fn at_derivation_index ( self , index : u32 ) -> Result < DefiniteDescriptorKey , ConversionError > ;
563
+
564
+ /// Whether or not this key has multiple derivation paths.
565
+ fn is_multipath ( & self ) -> bool ;
566
+ }
567
+
568
+ impl DescriptorInnerKey for DescriptorExtendedPublicKey {
569
+ fn master_fingerprint ( & self ) -> bip32:: Fingerprint {
570
+ if let Some ( ( fingerprint, _) ) = self . origin {
571
+ fingerprint
572
+ } else {
573
+ self . xkey . fingerprint ( )
574
+ }
575
+ }
576
+
577
+ fn full_derivation_path ( & self ) -> Option < bip32:: DerivationPath > {
578
+ let origin_path = if let Some ( ( _, ref path) ) = self . origin {
579
+ path. clone ( )
580
+ } else {
581
+ bip32:: DerivationPath :: from ( vec ! [ ] )
582
+ } ;
583
+ Some ( origin_path. extend ( & self . derivation_path ) )
584
+ }
585
+
586
+ fn has_wildcard ( & self ) -> bool {
587
+ self . wildcard != Wildcard :: None
588
+ }
589
+
590
+ fn at_derivation_index ( self , index : u32 ) -> Result < DefiniteDescriptorKey , ConversionError > {
578
591
let derivation_path = match self . wildcard {
579
592
Wildcard :: None => self . derivation_path ,
580
593
Wildcard :: Unhardened => self . derivation_path . into_child (
@@ -599,8 +612,7 @@ impl DescriptorExtendedPublicKey {
599
612
. expect ( "The key should not contain any wildcards at this point" ) )
600
613
}
601
614
602
- /// Whether or not this key has multiple derivation paths.
603
- pub fn is_multipath ( & self ) -> bool {
615
+ fn is_multipath ( & self ) -> bool {
604
616
false
605
617
}
606
618
}
0 commit comments