Struct bdk::descriptor::DescriptorXKey
source · [−]pub struct DescriptorXKey<K>where
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
sourceimpl<K> DescriptorXKey<K>where
K: InnerXKey,
impl<K> DescriptorXKey<K>where
K: InnerXKey,
sourcepub fn matches<C>(
&self,
keysource: &(Fingerprint, DerivationPath),
secp: &Secp256k1<C>
) -> Option<DerivationPath>where
C: Signing,
pub fn matches<C>(
&self,
keysource: &(Fingerprint, DerivationPath),
secp: &Secp256k1<C>
) -> Option<DerivationPath>where
C: Signing,
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
sourceimpl<K> Clone for DescriptorXKey<K>where
K: Clone + InnerXKey,
impl<K> Clone for DescriptorXKey<K>where
K: Clone + InnerXKey,
sourcefn clone(&self) -> DescriptorXKey<K>
fn clone(&self) -> DescriptorXKey<K>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<K> Debug for DescriptorXKey<K>where
K: Debug + InnerXKey,
impl<K> Debug for DescriptorXKey<K>where
K: Debug + InnerXKey,
sourceimpl<K> Hash for DescriptorXKey<K>where
K: Hash + InnerXKey,
impl<K> Hash for DescriptorXKey<K>where
K: Hash + InnerXKey,
sourceimpl<K> Ord for DescriptorXKey<K>where
K: Ord + InnerXKey,
impl<K> Ord for DescriptorXKey<K>where
K: Ord + InnerXKey,
sourcefn cmp(&self, other: &DescriptorXKey<K>) -> Ordering
fn cmp(&self, other: &DescriptorXKey<K>) -> Ordering
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl<K> PartialEq<DescriptorXKey<K>> for DescriptorXKey<K>where
K: PartialEq<K> + InnerXKey,
impl<K> PartialEq<DescriptorXKey<K>> for DescriptorXKey<K>where
K: PartialEq<K> + InnerXKey,
sourcefn eq(&self, other: &DescriptorXKey<K>) -> bool
fn eq(&self, other: &DescriptorXKey<K>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourceimpl<K> PartialOrd<DescriptorXKey<K>> for DescriptorXKey<K>where
K: PartialOrd<K> + InnerXKey,
impl<K> PartialOrd<DescriptorXKey<K>> for DescriptorXKey<K>where
K: PartialOrd<K> + InnerXKey,
sourcefn partial_cmp(&self, other: &DescriptorXKey<K>) -> Option<Ordering>
fn partial_cmp(&self, other: &DescriptorXKey<K>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl<K> Eq for DescriptorXKey<K>where
K: Eq + InnerXKey,
impl<K> StructuralEq for DescriptorXKey<K>where
K: InnerXKey,
impl<K> StructuralPartialEq for DescriptorXKey<K>where
K: InnerXKey,
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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more