Struct miniscript::descriptor::DescriptorXKey [−][src]
pub struct DescriptorXKey<K: InnerXKey> { pub origin: Option<(Fingerprint, DerivationPath)>, pub xkey: K, pub derivation_path: DerivationPath, pub wildcard: Wildcard, }
Expand description
Instance of an extended key with origin and derivation path
Fields
origin: Option<(Fingerprint, DerivationPath)>
Origin information
xkey: K
The extended key
derivation_path: DerivationPath
The derivation path
wildcard: Wildcard
Whether the descriptor is wildcard
Implementations
pub 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::util::bip32; use miniscript::descriptor::DescriptorPublicKey; let ctx = miniscript::bitcoin::secp256k1::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
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Auto Trait Implementations
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> UnwindSafe for DescriptorXKey<K> where
K: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more