Struct sapio_miniscript::descriptor::DescriptorXKey[][src]

pub struct DescriptorXKey<K: InnerXKey> {
    pub origin: Option<(Fingerprint, DerivationPath)>,
    pub xkey: K,
    pub derivation_path: DerivationPath,
    pub wildcard: Wildcard,
}

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

impl<K: InnerXKey> DescriptorXKey<K>[src]

pub fn matches<C: Signing>(
    &self,
    keysource: &KeySource,
    secp: &Secp256k1<C>
) -> Option<DerivationPath>
[src]

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

impl<K: Clone + InnerXKey> Clone for DescriptorXKey<K>[src]

impl<K: Debug + InnerXKey> Debug for DescriptorXKey<K>[src]

impl<K: Eq + InnerXKey> Eq for DescriptorXKey<K>[src]

impl<K: Hash + InnerXKey> Hash for DescriptorXKey<K>[src]

impl<K: Ord + InnerXKey> Ord for DescriptorXKey<K>[src]

impl<K: PartialEq + InnerXKey> PartialEq<DescriptorXKey<K>> for DescriptorXKey<K>[src]

impl<K: PartialOrd + InnerXKey> PartialOrd<DescriptorXKey<K>> for DescriptorXKey<K>[src]

impl<K: InnerXKey> StructuralEq for DescriptorXKey<K>[src]

impl<K: InnerXKey> StructuralPartialEq for DescriptorXKey<K>[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.