[][src]Trait miniscript::descriptor::DescriptorTrait

pub trait DescriptorTrait<Pk: MiniscriptKey> {
    pub fn sanity_check(&self) -> Result<(), Error>;
pub fn address(&self, network: Network) -> Result<Address, Error>
    where
        Pk: ToPublicKey
;
pub fn script_pubkey(&self) -> Script
    where
        Pk: ToPublicKey
;
pub fn unsigned_script_sig(&self) -> Script
    where
        Pk: ToPublicKey
;
pub fn explicit_script(&self) -> Script
    where
        Pk: ToPublicKey
;
pub fn get_satisfaction<S>(
        &self,
        satisfier: S
    ) -> Result<(Vec<Vec<u8>>, Script), Error>
    where
        Pk: ToPublicKey,
        S: Satisfier<Pk>
;
pub fn max_satisfaction_weight(&self) -> Result<usize, Error>;
pub fn script_code(&self) -> Script
    where
        Pk: ToPublicKey
; pub fn satisfy<S>(&self, txin: &mut TxIn, satisfier: S) -> Result<(), Error>
    where
        Pk: ToPublicKey,
        S: Satisfier<Pk>
, { ... } }

A general trait for Bitcoin descriptor. Offers function for witness cost estimation, script pubkey creation satisfaction using the Satisfier trait.

Required methods

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 Some descriptors like pk() don't have any address.

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>>, 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. Returns Error when the descriptor is impossible to safisfy (ex: sh(OP_FALSE))

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.

Loading content...

Provided methods

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

Loading content...

Implementors

impl<Pk: MiniscriptKey> DescriptorTrait<Pk> for Descriptor<Pk>[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>>, 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.

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

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

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

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

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

Loading content...