[][src]Struct miniscript::miniscript::Miniscript

pub struct Miniscript<P>(pub AstElem<P>);

Top-level script AST type

Methods

impl<P: Clone> Miniscript<P>[src]

pub fn abstract_policy(&self) -> AbstractPolicy<P>[src]

Abstract the script into an "abstract policy" which can be filtered and analyzed

impl Miniscript<PublicKey>[src]

pub fn parse(script: &Script) -> Result<Miniscript<PublicKey>, Error>[src]

Attempt to parse a script into a Miniscript representation

impl<P: ToPublicKey> Miniscript<P>[src]

pub fn encode(&self) -> Script[src]

Encode as a Bitcoin script

pub fn script_size(&self) -> usize[src]

Size, in bytes of the script-pubkey. If this Miniscript is used outside of segwit (e.g. in a bare or P2SH descriptor), this quantity should be multiplied by 4 to compute the weight.

In general, it is not recommended to use this function directly, but to instead call the corresponding function on a Descriptor, which will handle the segwit/non-segwit technicalities for you.

pub fn max_satisfaction_witness_elements(&self) -> usize[src]

Maximum number of witness elements used to satisfy the Miniscript fragment, including the witness script itself. Used to estimate the weight of the VarInt that specifies this number in a serialized transaction.

This function may panic on misformed Miniscript objects which do not correspond to semantically sane Scripts. (Such scripts should be rejected at parse time. Any exceptions are bugs.)

pub fn max_satisfaction_size(&self, one_cost: usize) -> usize[src]

Maximum size, in bytes, of a satisfying witness. For Segwit outputs one_cost should be set to 2, since the number 1 requires two bytes to encode. For non-segwit outputs one_cost should be set to 1, since OP_1 is available in scriptSigs.

In general, it is not recommended to use this function directly, but to instead call the corresponding function on a Descriptor, which will handle the segwit/non-segwit technicalities for you.

All signatures are assumed to be 73 bytes in size, including the length prefix (segwit) or push opcode (pre-segwit) and sighash postfix.

This function may panic on misformed Miniscript objects which do not correspond to semantically sane Scripts. (Such scripts should be rejected at parse time. Any exceptions are bugs.)

impl<P> Miniscript<P>[src]

pub fn translate<F, Q, E>(&self, translatefn: F) -> Result<Miniscript<Q>, E> where
    F: FnMut(&P) -> Result<Q, E>, 
[src]

impl<P: ToPublicKey> Miniscript<P>[src]

pub fn satisfy<F, H>(
    &self,
    keyfn: Option<F>,
    hashfn: Option<H>,
    age: u32
) -> Result<Vec<Vec<u8>>, Error> where
    F: FnMut(&P) -> Option<(Signature, SigHashType)>,
    H: FnMut(Hash) -> Option<[u8; 32]>, 
[src]

Attempt to produce a satisfying witness for the scriptpubkey represented by the parse tree

impl<P: Clone> Miniscript<P>[src]

pub fn public_keys(&self) -> Vec<P>[src]

Return a list of all public keys which might contribute to satisfaction of the scriptpubkey

Trait Implementations

impl<P: Debug + FromStr> FromTree for Miniscript<P> where
    <P as FromStr>::Err: ToString
[src]

fn from_tree(top: &Tree) -> Result<Miniscript<P>, Error>[src]

Parse an expression tree into a Miniscript. As a general rule this should not be called directly; rather go through the output descriptor API.

impl<P: Eq> Eq for Miniscript<P>[src]

impl<P: Ord> Ord for Miniscript<P>[src]

fn max(self, other: Self) -> Self1.21.0[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self1.21.0[src]

Compares and returns the minimum of two values. Read more

fn clamp(self, min: Self, max: Self) -> Self[src]

🔬 This is a nightly-only experimental API. (clamp)

Restrict a value to a certain interval. Read more

impl<P: PartialEq> PartialEq<Miniscript<P>> for Miniscript<P>[src]

impl<P: Clone> Clone for Miniscript<P>[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<P: PartialOrd> PartialOrd<Miniscript<P>> for Miniscript<P>[src]

impl<P> From<AstElem<P>> for Miniscript<P>[src]

impl<P: Debug> Debug for Miniscript<P>[src]

impl<P: Display> Display for Miniscript<P>[src]

impl<P: Debug + FromStr> FromStr for Miniscript<P> where
    <P as FromStr>::Err: ToString
[src]

type Err = Error

The associated error which can be returned from parsing.

Auto Trait Implementations

impl<P> Send for Miniscript<P> where
    P: Send

impl<P> Sync for Miniscript<P> where
    P: Sync

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> From<T> for T[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.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]