Struct sapio_miniscript::interpreter::Interpreter [−][src]
An iterable Miniscript-structured representation of the spending of a coin
Implementations
impl<'txin> Interpreter<'txin>
[src]
pub fn from_txdata(
spk: &Script,
script_sig: &'txin Script,
witness: &'txin [Vec<u8>],
age: u32,
height: u32
) -> Result<Self, Error>
[src]
spk: &Script,
script_sig: &'txin Script,
witness: &'txin [Vec<u8>],
age: u32,
height: u32
) -> Result<Self, Error>
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.
pub fn iter<'iter, F: FnMut(&PublicKey, BitcoinSig) -> bool>(
&'iter mut self,
verify_sig: F
) -> Iter<'txin, 'iter, F>ⓘNotable traits for Iter<'intp, 'txin, F>
impl<'intp, 'txin: 'intp, F> Iterator for Iter<'intp, 'txin, F> where
NoChecks: ScriptContext,
F: FnMut(&PublicKey, BitcoinSig) -> bool, type Item = Result<SatisfiedConstraint<'intp, 'txin>, Error>;
[src]
&'iter mut self,
verify_sig: F
) -> Iter<'txin, 'iter, F>ⓘ
Notable traits for Iter<'intp, 'txin, F>
impl<'intp, 'txin: 'intp, F> Iterator for Iter<'intp, 'txin, F> where
NoChecks: ScriptContext,
F: FnMut(&PublicKey, BitcoinSig) -> bool, type Item = Result<SatisfiedConstraint<'intp, 'txin>, Error>;
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.
Running the iterator through will consume the internal stack of the
Iterpreter
, and it should not be used again after this.
pub fn inferred_descriptor_string(&self) -> String
[src]
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.
pub fn is_legacy(&self) -> bool
[src]
Whether this is a pre-segwit spend
pub fn inferred_descriptor(&self) -> Result<Descriptor<PublicKey>, Error>
[src]
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).
pub fn sighash_message(
&self,
unsigned_tx: &Transaction,
input_idx: usize,
amount: u64,
sighash_type: SigHashType
) -> Message
[src]
&self,
unsigned_tx: &Transaction,
input_idx: usize,
amount: u64,
sighash_type: SigHashType
) -> Message
Returns a sighash over the entire transaction which can be used to verify signatures in the descriptor
Not all fields are used by legacy descriptors; if you are sure this is a legacy
spend (you can check with the is_legacy
method) you can provide dummy data for
the amount.
pub fn sighash_verify<'a, C: Verification>(
&self,
secp: &'a Secp256k1<C>,
unsigned_tx: &'a Transaction,
input_idx: usize,
amount: u64
) -> impl Fn(&PublicKey, BitcoinSig) -> bool + 'a
[src]
&self,
secp: &'a Secp256k1<C>,
unsigned_tx: &'a Transaction,
input_idx: usize,
amount: u64
) -> impl Fn(&PublicKey, BitcoinSig) -> bool + 'a
Returns a closure which can be given to the iter
method to check all signatures
Auto Trait Implementations
impl<'txin> RefUnwindSafe for Interpreter<'txin>
impl<'txin> Send for Interpreter<'txin>
impl<'txin> Sync for Interpreter<'txin>
impl<'txin> Unpin for Interpreter<'txin>
impl<'txin> UnwindSafe for Interpreter<'txin>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
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]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,