Enum sapio_miniscript::descriptor::Descriptor[][src]

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

Script descriptor

Variants

Bare(Bare<Pk>)

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

Pkh(Pkh<Pk>)

Pay-to-PubKey-Hash

Wpkh(Wpkh<Pk>)

Pay-to-Witness-PubKey-Hash

Sh(Sh<Pk>)

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

Wsh(Wsh<Pk>)

Pay-to-Witness-ScriptHash with Segwitv0 context

Implementations

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

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

Create a new pk descriptor

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

Create a new PkH descriptor

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

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

pub fn new_sh_wpkh(pk: Pk) -> Result<Self, 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<Self, 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<Self, 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<Self, 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<Self, 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>) -> Result<Self, 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>) -> Result<Self, 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>) -> Result<Self, 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: Signing>(
    secp: &Secp256k1<C>,
    s: &str
) -> Result<(Descriptor<DescriptorPublicKey>, KeyMap), Error>
[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: &KeyMap) -> String[src]

Serialize a descriptor to string with its secret keys

Trait Implementations

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

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

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

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

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

Computes the Bitcoin address of the descriptor, if one exists

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

Computes the scriptpubkey of the descriptor

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).

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.

fn get_satisfaction<S>(
    &self,
    satisfier: S
) -> Result<(Vec<Vec<u8>>, 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.

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.

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.

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

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

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

impl<Pk> FromStr for Descriptor<Pk> where
    Pk: MiniscriptKey + FromStr,
    Pk::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.

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

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

Parse an expression tree into a descriptor

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

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

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

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

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

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

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

type Output = Descriptor<Q>

The associated output type. This must be Self

fn translate_pk<Fpk, Fpkh, E>(
    &self,
    translatefpk: Fpk,
    translatefpkh: Fpkh
) -> Result<Descriptor<Q>, E> where
    Fpk: FnMut(&P) -> Result<Q, E>,
    Fpkh: FnMut(&P::Hash) -> Result<Q::Hash, E>,
    Q: MiniscriptKey
[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.

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]

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> ToString for T where
    T: Display + ?Sized
[src]

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

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

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

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.