pub struct DescriptorXKey<K: InnerXKey> {
pub origin: Option<(Fingerprint, DerivationPath)>,
pub xkey: K,
pub derivation_path: DerivationPath,
pub wildcard: Wildcard,
}Expand description
An extended key with origin, derivation path, and wildcard.
Fields§
§origin: Option<(Fingerprint, DerivationPath)>Origin information
xkey: KThe extended key
derivation_path: DerivationPathThe derivation path
wildcard: WildcardWhether the descriptor is wildcard
Implementations§
Source§impl<K: InnerXKey> DescriptorXKey<K>
impl<K: InnerXKey> DescriptorXKey<K>
Sourcepub fn matches<C: Signing>(
&self,
keysource: &KeySource,
secp: &Secp256k1<C>,
) -> Option<DerivationPath>
pub fn matches<C: Signing>( &self, keysource: &KeySource, secp: &Secp256k1<C>, ) -> Option<DerivationPath>
Compares this key with a keysource and returns the matching derivation path, if any.
For keys that have an origin, the keysource’s fingerprint will be compared
with the origin’s fingerprint, and the keysource’s path will be compared with the concatenation of the
origin’s and key’s paths.
If the key wildcard, the last item of the keysource’s path will be ignored,
§Examples
use miniscript::bitcoin::bip32;
use miniscript::descriptor::DescriptorPublicKey;
let ctx = miniscript::elements::secp256k1_zkp::Secp256k1::signing_only();
let key = DescriptorPublicKey::from_str("[d34db33f/44'/0'/0']xpub6ERApfZwUNrhLCkDtcHTcxd75RbzS1ed54G1LkBUHQVHQKqhMkhgbmJbZRkrgZw4koxb5JaHWkY4ALHY2grBGRjaDMzQLcgJvLJuZZvRcEL/1/*")?;
let xpub = match key {
DescriptorPublicKey::XPub(xpub) => xpub,
_ => panic!("Parsing Error"),
};
assert_eq!(xpub.matches(&(bip32::Fingerprint::from_str("d34db33f")?, bip32::DerivationPath::from_str("m/44'/0'/0'/1/42")?), &ctx), Some(bip32::DerivationPath::from_str("m/44'/0'/0'/1")?));
assert_eq!(xpub.matches(&(bip32::Fingerprint::from_str("ffffffff")?, bip32::DerivationPath::from_str("m/44'/0'/0'/1/42")?), &ctx), None);
assert_eq!(xpub.matches(&(bip32::Fingerprint::from_str("d34db33f")?, bip32::DerivationPath::from_str("m/44'/0'/0'/100/0")?), &ctx), None);Trait Implementations§
Source§impl<K: InnerXKey> Display for DescriptorXKey<K>
impl<K: InnerXKey> Display for DescriptorXKey<K>
impl<K: Eq + InnerXKey> Eq for DescriptorXKey<K>
Source§impl<K> MiniscriptKey for DescriptorXKey<K>
impl<K> MiniscriptKey for DescriptorXKey<K>
Source§type Sha256 = Hash
type Sha256 = Hash
The associated
bitcoin::hashes::sha256::Hash for this MiniscriptKey, used in the
sha256 fragment.Source§type Hash256 = Hash
type Hash256 = Hash
The associated
miniscript::hash256::Hash for this MiniscriptKey, used in the
hash256 fragment.Source§type Ripemd160 = Hash
type Ripemd160 = Hash
The associated
bitcoin::hashes::ripemd160::Hash for this MiniscriptKey type, used
in the ripemd160 fragment.Source§type Hash160 = Hash
type Hash160 = Hash
The associated
bitcoin::hashes::hash160::Hash for this MiniscriptKey type, used in
the hash160 fragment.Source§fn is_x_only_key(&self) -> bool
fn is_x_only_key(&self) -> bool
Returns true if the pubkey is an x-only pubkey. Defaults to
false.Source§fn num_der_paths(&self) -> usize
fn num_der_paths(&self) -> usize
Returns the number of different derivation paths in this key. Only >1 for keys
in BIP389 multipath descriptors.
Source§fn is_uncompressed(&self) -> bool
fn is_uncompressed(&self) -> bool
Returns true if the pubkey is uncompressed. Defaults to
false.Source§impl<K: Ord + InnerXKey> Ord for DescriptorXKey<K>
impl<K: Ord + InnerXKey> Ord for DescriptorXKey<K>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl<K: PartialOrd + InnerXKey> PartialOrd for DescriptorXKey<K>
impl<K: PartialOrd + InnerXKey> PartialOrd for DescriptorXKey<K>
impl<K: PartialEq + InnerXKey> StructuralPartialEq for DescriptorXKey<K>
Auto Trait Implementations§
impl<K> Freeze for DescriptorXKey<K>where
K: Freeze,
impl<K> RefUnwindSafe for DescriptorXKey<K>where
K: RefUnwindSafe,
impl<K> Send for DescriptorXKey<K>where
K: Send,
impl<K> Sync for DescriptorXKey<K>where
K: Sync,
impl<K> Unpin for DescriptorXKey<K>where
K: Unpin,
impl<K> UnsafeUnpin for DescriptorXKey<K>where
K: UnsafeUnpin,
impl<K> UnwindSafe for DescriptorXKey<K>where
K: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more