pub struct Interpreter<'txin> { /* private fields */ }
Expand description

An iterable Miniscript-structured representation of the spending of a coin

Implementations

Constructs an interpreter from the data of a spending transaction

Accepts a signature-validating function. If you are willing to trust that ECSDA signatures are valid, this can be set to the constant true function; otherwise, it should be a closure containing a sighash and secp context, which can actually verify a given signature.

Same as Interpreter::iter, but allows for a custom verification function. See Self::iter_assume_sigs for a simpler API without information about Prevouts but skips the signature verification

Verify a signature for a given transaction and prevout information This is a low level API, Interpreter::iter or [Interpreter::iter_assume_sig] should satisfy most use-cases. Returns false if

  • the signature verification fails
  • the input index is out of range
  • Insufficient sighash information is present
  • sighash single without corresponding output

Creates an iterator over the satisfied spending conditions

Returns all satisfied constraints, even if they were redundant (i.e. did not contribute to the script being satisfied). For example, if a signature were provided for an and_b(Pk,false) fragment, that signature will be returned, even though the entire and_b must have failed and must not have been used.

In case the script is actually dissatisfied, this may return several values before ultimately returning an error.

Not all fields are used by legacy/segwitv0 descriptors; if you are sure this is a legacy spend (you can check with the is_legacy\is_segwitv0 method) you can provide dummy data for the amount/prevouts.

  • For legacy outputs, no information about prevouts is required
  • For segwitv0 outputs, prevout at corresponding index with correct amount must be provided
  • For taproot outputs, information about all prevouts must be supplied

Creates an iterator over the satisfied spending conditions without checking signatures

Outputs a “descriptor” string which reproduces the spent coins

This may not represent the original descriptor used to produce the transaction, since it cannot distinguish between sorted and unsorted multisigs (and anyway it can only see the final keys, keyorigin info is lost in serializing to Bitcoin).

If you are using the interpreter as a sanity check on a transaction, it is worthwhile to try to parse this as a descriptor using from_str which will check standardness and consensus limits, which the interpreter does not do on its own. Or use the inferred_descriptor method which does this for you.

Whether this is a pre-segwit spend

Whether this is a segwit spend

Whether this is a taproot key spend

Whether this is a taproot script spend

Outputs a “descriptor” which reproduces the spent coins

This may not represent the original descriptor used to produce the transaction, since it cannot distinguish between sorted and unsorted multisigs (and anyway it can only see the final keys, keyorigin info is lost in serializing to Bitcoin). x-only keys are translated to bitcoin::PublicKey with 0x02 prefix.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.