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

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

Required Methods

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

Computes the Bitcoin address of the descriptor, if one exists Some descriptors like pk() don’t have any address. Errors:

  • On raw/bare descriptors that don’t have any address

Computes the scriptpubkey of the descriptor

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

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. For Tr descriptors, this will error as there is no underlying script

Returns satisfying non-malleable witness and scriptSig with minimum weight to spend an output controlled by the given descriptor if it possible to construct one using the satisfier S.

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

Computes an upper bound on the weight of a satisfying witness to the transaction. Assumes all ec-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))

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. Errors:

  • When the descriptor is Tr

Provided Methods

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

Implementors