@@ -525,6 +525,53 @@ impl error::Error for ConversionError {
525
525
}
526
526
}
527
527
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
+
561
+ /// Computes the public key corresponding to this descriptor key.
562
+ /// When deriving from an XOnlyPublicKey, it adds the default 0x02 y-coordinate
563
+ /// and returns the obtained full [`bitcoin::PublicKey`]. All BIP32 derivations
564
+ /// always return a compressed key
565
+ ///
566
+ /// Will return an error if the descriptor key has any hardened derivation steps in its path. To
567
+ /// avoid this error you should replace any such public keys first with [`translate_pk`].
568
+ ///
569
+ /// [`translate_pk`]: crate::TranslatePk::translate_pk
570
+ fn derive_public_key < C : Verification > (
571
+ & self ,
572
+ secp : & Secp256k1 < C > ,
573
+ ) -> Result < bitcoin:: PublicKey , ConversionError > ;
574
+ }
528
575
impl DescriptorPublicKey {
529
576
/// The fingerprint of the master key associated with this key, `0x00000000` if none.
530
577
pub fn master_fingerprint ( & self ) -> bip32:: Fingerprint {
0 commit comments