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
An extended key with origin, derivation path, and wildcard.
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/*").or(Err(()))?;
let xpub = match key {
DescriptorPublicKey::XPub(xpub) => xpub,
_ => panic!("Parsing Error"),
};
assert_eq!(
xpub.matches(&(
bip32::Fingerprint::from_str("d34db33f").or(Err(()))?,
bip32::DerivationPath::from_str("m/44'/0'/0'/1/42").or(Err(()))?
), &ctx),
Some(bip32::DerivationPath::from_str("m/44'/0'/0'/1").or(Err(()))?)
);
assert_eq!(
xpub.matches(&(
bip32::Fingerprint::from_str("ffffffff").or(Err(()))?,
bip32::DerivationPath::from_str("m/44'/0'/0'/1/42").or(Err(()))?
), &ctx),
None
);
assert_eq!(
xpub.matches(&(
bip32::Fingerprint::from_str("d34db33f").or(Err(()))?,
bip32::DerivationPath::from_str("m/44'/0'/0'/100/0").or(Err(()))?
), &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 moresourceimpl<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) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn 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
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + 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
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>
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 moreimpl<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