Enum bdk::descriptor::Descriptor[][src]

pub enum Descriptor<Pk> where
    Pk: MiniscriptKey
{ Bare(Bare<Pk>), Pkh(Pkh<Pk>), Wpkh(Wpkh<Pk>), Sh(Sh<Pk>), Wsh(Wsh<Pk>), }
Expand description

Script descriptor

Variants

Bare(Bare<Pk>)
Expand description

A raw scriptpubkey (including pay-to-pubkey) under Legacy context

Pkh(Pkh<Pk>)
Expand description

Pay-to-PubKey-Hash

Wpkh(Wpkh<Pk>)
Expand description

Pay-to-Witness-PubKey-Hash

Sh(Sh<Pk>)
Expand description

Pay-to-ScriptHash(includes nested wsh/wpkh/sorted multi)

Wsh(Wsh<Pk>)
Expand description

Pay-to-Witness-ScriptHash with Segwitv0 context

Implementations

impl<Pk> Descriptor<Pk> where
    Pk: MiniscriptKey
[src]

pub fn new_pk(pk: Pk) -> Descriptor<Pk>[src]

Create a new pk descriptor

pub fn new_pkh(pk: Pk) -> Descriptor<Pk>[src]

Create a new PkH descriptor

pub fn new_wpkh(pk: Pk) -> Result<Descriptor<Pk>, Error>[src]

Create a new Wpkh descriptor Will return Err if uncompressed key is used

pub fn new_sh_wpkh(pk: Pk) -> Result<Descriptor<Pk>, Error>[src]

Create a new sh wrapped wpkh from Pk. Errors when uncompressed keys are supplied

pub fn new_sh(ms: Miniscript<Pk, Legacy>) -> Result<Descriptor<Pk>, Error>[src]

Create a new sh for a given redeem script Errors when miniscript exceeds resource limits under p2sh context or does not type check at the top level

pub fn new_wsh(ms: Miniscript<Pk, Segwitv0>) -> Result<Descriptor<Pk>, Error>[src]

Create a new wsh descriptor from witness script Errors when miniscript exceeds resource limits under p2sh context or does not type check at the top level

pub fn new_sh_wsh(ms: Miniscript<Pk, Segwitv0>) -> Result<Descriptor<Pk>, Error>[src]

Create a new sh wrapped wsh descriptor with witness script Errors when miniscript exceeds resource limits under wsh context or does not type check at the top level

pub fn new_bare(ms: Miniscript<Pk, BareCtx>) -> Result<Descriptor<Pk>, Error>[src]

Create a new bare descriptor from witness script Errors when miniscript exceeds resource limits under bare context or does not type check at the top level

pub fn new_sh_sortedmulti(
    k: usize,
    pks: Vec<Pk, Global>
) -> Result<Descriptor<Pk>, Error>
[src]

Create a new sh sortedmulti descriptor with threshold k and Vec of pks. Errors when miniscript exceeds resource limits under p2sh context

pub fn new_sh_wsh_sortedmulti(
    k: usize,
    pks: Vec<Pk, Global>
) -> Result<Descriptor<Pk>, Error>
[src]

Create a new sh wrapped wsh sortedmulti descriptor from threshold k and Vec of pks Errors when miniscript exceeds resource limits under segwit context

pub fn new_wsh_sortedmulti(
    k: usize,
    pks: Vec<Pk, Global>
) -> Result<Descriptor<Pk>, Error>
[src]

Create a new wsh sorted multi descriptor Errors when miniscript exceeds resource limits under p2sh context

pub fn desc_type(&self) -> DescriptorType[src]

impl Descriptor<DescriptorPublicKey>[src]

pub fn is_deriveable(&self) -> bool[src]

Whether or not the descriptor has any wildcards

pub fn derive(&self, index: u32) -> Descriptor<DescriptorPublicKey>[src]

Derives all wildcard keys in the descriptor using the supplied index

Panics if given an index ≥ 2^31

pub fn parse_descriptor<C>(
    secp: &Secp256k1<C>,
    s: &str
) -> Result<(Descriptor<DescriptorPublicKey>, HashMap<DescriptorPublicKey, DescriptorSecretKey, RandomState>), Error> where
    C: Signing, 
[src]

Parse a descriptor that may contain secret keys

Internally turns every secret key found into the corresponding public key and then returns a a descriptor that only contains public keys and a map to lookup the secret key given a public key.

pub fn to_string_with_secret(
    &self,
    key_map: &HashMap<DescriptorPublicKey, DescriptorSecretKey, RandomState>
) -> String
[src]

Serialize a descriptor to string with its secret keys

Trait Implementations

impl<Pk> Clone for Descriptor<Pk> where
    Pk: Clone + MiniscriptKey
[src]

pub fn clone(&self) -> Descriptor<Pk>[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<Pk> Debug for Descriptor<Pk> where
    Pk: MiniscriptKey
[src]

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

Formats the value using the given formatter. Read more

impl<Pk> DescriptorTrait<Pk> for Descriptor<Pk> where
    Pk: MiniscriptKey
[src]

pub fn sanity_check(&self) -> Result<(), Error>[src]

Whether the descriptor is safe Checks whether all the spend paths in the descriptor are possible on the bitcoin network under the current standardness and consensus rules Also checks whether the descriptor requires signauture on all spend paths And whether the script is malleable. In general, all the guarantees of miniscript hold only for safe scripts. All the analysis guarantees of miniscript only hold safe scripts. The signer may not be able to find satisfactions even if one exists

pub fn address(&self, network: Network) -> Result<Address, Error> where
    Pk: ToPublicKey
[src]

Computes the Bitcoin address of the descriptor, if one exists

pub fn script_pubkey(&self) -> Script where
    Pk: ToPublicKey
[src]

Computes the scriptpubkey of the descriptor

pub fn unsigned_script_sig(&self) -> Script where
    Pk: ToPublicKey
[src]

Computes the scriptSig that will be in place for an unsigned input spending an output with this descriptor. For pre-segwit descriptors, which use the scriptSig for signatures, this returns the empty script.

This is used in Segwit transactions to produce an unsigned transaction whose txid will not change during signing (since only the witness data will change).

pub fn explicit_script(&self) -> Script where
    Pk: ToPublicKey
[src]

Computes the “witness script” of the descriptor, i.e. the underlying script before any hashing is done. For Bare, Pkh and Wpkh this is the scriptPubkey; for ShWpkh and Sh this is the redeemScript; for the others it is the witness script.

pub fn get_satisfaction<S>(
    &self,
    satisfier: S
) -> Result<(Vec<Vec<u8, Global>, Global>, Script), Error> where
    Pk: ToPublicKey,
    S: Satisfier<Pk>, 
[src]

Returns satisfying witness and scriptSig to spend an output controlled by the given descriptor if it possible to construct one using the satisfier S.

pub fn max_satisfaction_weight(&self) -> Result<usize, Error>[src]

Computes an upper bound on the weight of a satisfying witness to the transaction. Assumes all signatures are 73 bytes, including push opcode and sighash suffix. Includes the weight of the VarInts encoding the scriptSig and witness stack length.

pub fn script_code(&self) -> Script where
    Pk: ToPublicKey
[src]

Get the scriptCode of a transaction output.

The scriptCode is the Script of the previous transaction output being serialized in the sighash when evaluating a CHECKSIG & co. OP code.

fn satisfy<S>(&self, txin: &mut TxIn, satisfier: S) -> Result<(), Error> where
    Pk: ToPublicKey,
    S: Satisfier<Pk>, 
[src]

Attempts to produce a satisfying witness and scriptSig to spend an output controlled by the given descriptor; add the data to a given TxIn output. Read more

impl<Pk> Display for Descriptor<Pk> where
    Pk: MiniscriptKey
[src]

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

Formats the value using the given formatter. Read more

impl ExtractPolicy for Descriptor<DescriptorPublicKey>[src]

fn extract_policy(
    &self,
    signers: &SignersContainer,
    build_sat: BuildSatisfaction<'_>,
    secp: &Secp256k1<All>
) -> Result<Option<Policy>, Error>
[src]

Extract the spending policy

impl<Pk> ForEachKey<Pk> for Descriptor<Pk> where
    Pk: MiniscriptKey
[src]

pub fn for_each_key<'a, F>(&'a self, pred: F) -> bool where
    F: FnMut(ForEach<'a, Pk>) -> bool,
    Pk: 'a,
    <Pk as MiniscriptKey>::Hash: 'a, 
[src]

Run a predicate on every key in the descriptor, returning whether the predicate returned true for every key Read more

fn for_any_key<'a, F>(&'a self, pred: F) -> bool where
    F: FnMut(ForEach<'a, Pk>) -> bool,
    Pk: 'a,
    <Pk as MiniscriptKey>::Hash: 'a, 
[src]

Run a predicate on every key in the descriptor, returning whether the predicate returned true for any key Read more

impl<Pk> FromStr for Descriptor<Pk> where
    Pk: MiniscriptKey + FromStr,
    <Pk as MiniscriptKey>::Hash: FromStr,
    <Pk as FromStr>::Err: ToString,
    <<Pk as MiniscriptKey>::Hash as FromStr>::Err: ToString
[src]

type Err = Error

The associated error which can be returned from parsing.

pub fn from_str(s: &str) -> Result<Descriptor<Pk>, Error>[src]

Parses a string s to return a value of this type. Read more

impl<Pk> FromTree for Descriptor<Pk> where
    Pk: MiniscriptKey + FromStr,
    <Pk as MiniscriptKey>::Hash: FromStr,
    <Pk as FromStr>::Err: ToString,
    <<Pk as MiniscriptKey>::Hash as FromStr>::Err: ToString
[src]

pub fn from_tree(top: &Tree<'_>) -> Result<Descriptor<Pk>, Error>[src]

Parse an expression tree into a descriptor

impl<Pk> Liftable<Pk> for Descriptor<Pk> where
    Pk: MiniscriptKey
[src]

pub fn lift(&self) -> Result<Policy<Pk>, Error>[src]

Convert the object into an abstract policy

impl<Pk> Ord for Descriptor<Pk> where
    Pk: Ord + MiniscriptKey
[src]

pub fn cmp(&self, other: &Descriptor<Pk>) -> Ordering[src]

This method returns an Ordering between self and other. Read more

#[must_use]
fn max(self, other: Self) -> Self
1.21.0[src]

Compares and returns the maximum of two values. Read more

#[must_use]
fn min(self, other: Self) -> Self
1.21.0[src]

Compares and returns the minimum of two values. Read more

#[must_use]
fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]

Restrict a value to a certain interval. Read more

impl<Pk> PartialEq<Descriptor<Pk>> for Descriptor<Pk> where
    Pk: PartialEq<Pk> + MiniscriptKey
[src]

pub fn eq(&self, other: &Descriptor<Pk>) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

pub fn ne(&self, other: &Descriptor<Pk>) -> bool[src]

This method tests for !=.

impl<Pk> PartialOrd<Descriptor<Pk>> for Descriptor<Pk> where
    Pk: PartialOrd<Pk> + MiniscriptKey
[src]

pub fn partial_cmp(&self, other: &Descriptor<Pk>) -> Option<Ordering>[src]

This method returns an ordering between self and other values if one exists. Read more

#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl<P, Q> TranslatePk<P, Q> for Descriptor<P> where
    P: MiniscriptKey,
    Q: MiniscriptKey
[src]

pub fn translate_pk<Fpk, Fpkh, E>(
    &self,
    translatefpk: Fpk,
    translatefpkh: Fpkh
) -> Result<Descriptor<Q>, E> where
    Q: MiniscriptKey,
    Fpk: FnMut(&P) -> Result<Q, E>,
    Fpkh: FnMut(&<P as MiniscriptKey>::Hash) -> Result<<Q as MiniscriptKey>::Hash, E>, 
[src]

Convert a descriptor using abstract keys to one using specific keys This will panic if translatefpk returns an uncompressed key when converting to a Segwit descriptor. To prevent this panic, ensure translatefpk returns an error in this case instead.

type Output = Descriptor<Q>

The associated output type. This must be Self

fn translate_pk_infallible<Fpk, Fpkh>(
    &self,
    translatefpk: Fpk,
    translatefpkh: Fpkh
) -> Self::Output where
    Fpk: FnMut(&P) -> Q,
    Fpkh: FnMut(&<P as MiniscriptKey>::Hash) -> <Q as MiniscriptKey>::Hash
[src]

Calls translate_pk with conversion functions that cannot fail

impl<Pk> Eq for Descriptor<Pk> where
    Pk: Eq + MiniscriptKey
[src]

impl<Pk> StructuralEq for Descriptor<Pk> where
    Pk: MiniscriptKey
[src]

impl<Pk> StructuralPartialEq for Descriptor<Pk> where
    Pk: MiniscriptKey
[src]

Auto Trait Implementations

impl<Pk> RefUnwindSafe for Descriptor<Pk> where
    Pk: RefUnwindSafe,
    <Pk as MiniscriptKey>::Hash: RefUnwindSafe

impl<Pk> Send for Descriptor<Pk> where
    Pk: Send + Sync,
    <Pk as MiniscriptKey>::Hash: Send + Sync

impl<Pk> Sync for Descriptor<Pk> where
    Pk: Send + Sync,
    <Pk as MiniscriptKey>::Hash: Send + Sync

impl<Pk> Unpin for Descriptor<Pk> where
    Pk: Unpin,
    <Pk as MiniscriptKey>::Hash: Unpin

impl<Pk> UnwindSafe for Descriptor<Pk> where
    Pk: RefUnwindSafe + UnwindSafe,
    <Pk as MiniscriptKey>::Hash: RefUnwindSafe + UnwindSafe

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<Q, K> Equivalent<K> for Q where
    Q: Eq + ?Sized,
    K: Borrow<Q> + ?Sized
[src]

pub fn equivalent(&self, key: &K) -> bool[src]

Compare self to key and return true if they are equal.

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

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> Instrument for T[src]

fn instrument(self, span: Span) -> Instrumented<Self>[src]

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

fn in_current_span(self) -> Instrumented<Self>[src]

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

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

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Pointable for T

pub const ALIGN: usize

The alignment of pointer.

type Init = T

The type for initializers.

pub unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more

pub unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more

pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more

pub unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more

impl<T> Same<T> for T

type Output = T

Should always be Self

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

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T> ToString for T where
    T: Display + ?Sized
[src]

pub default fn to_string(&self) -> String[src]

Converts the given value to a String. Read more

impl<P, Q, T> TranslatePk1<P, Q> for T where
    P: MiniscriptKey,
    T: TranslatePk<P, Q>,
    Q: MiniscriptKey<Hash = <P as MiniscriptKey>::Hash>, 
[src]

fn translate_pk1<Fpk, E>(&self, translatefpk: Fpk) -> Result<Self::Output, E> where
    Fpk: FnMut(&P) -> Result<Q, E>, 
[src]

Translate a struct from one generic to another where the translation for Pk is provided by translatefpk Read more

fn translate_pk1_infallible<Fpk>(&self, translatefpk: Fpk) -> Self::Output where
    Fpk: FnMut(&P) -> Q, 
[src]

Translate a struct from one generic to another where the translation for Pk is provided by translatefpk Read more

impl<P, Q, T> TranslatePk2<P, Q> for T where
    P: MiniscriptKey<Hash = P>,
    T: TranslatePk<P, Q>,
    Q: MiniscriptKey
[src]

fn translate_pk2<Fpk, E>(&self, translatefpk: Fpk) -> Result<Self::Output, E> where
    Fpk: Fn(&P) -> Result<Q, E>, 
[src]

Translate a struct from one generic to another where the translation for Pk is provided by translatefpk Read more

fn translate_pk2_infallible<Fpk>(&self, translatefpk: Fpk) -> Self::Output where
    Fpk: Fn(&P) -> Q, 
[src]

Translate a struct from one generic to another where the translation for Pk is provided by translatefpk Read more

impl<P, Q, T> TranslatePk3<P, Q> for T where
    P: MiniscriptKey + ToPublicKey,
    T: TranslatePk<P, Q>,
    Q: MiniscriptKey<Hash = Hash>, 
[src]

fn translate_pk3<Fpk, E>(&self, translatefpk: Fpk) -> Result<Self::Output, E> where
    Fpk: FnMut(&P) -> Result<Q, E>, 
[src]

Translate a struct from one generic to another where the translation for Pk is provided by translatefpk Read more

fn translate_pk3_infallible<Fpk>(&self, translatefpk: Fpk) -> Self::Output where
    Fpk: FnMut(&P) -> Q, 
[src]

Translate a struct from one generic to another where the translation for Pk is provided by translatefpk Read more

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V