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

pub struct Miniscript<Pk: MiniscriptKey> {
    pub node: Terminal<Pk>,
    pub ty: Type,
    pub ext: ExtData,
}

Top-level script AST type

Fields

node: Terminal<Pk>

A node in the Abstract Syntax Tree(

ty: Type

The correctness and malleability type information for the AST node

ext: ExtData

Additional information helpful for extra analysis.

Methods

impl<Pk: MiniscriptKey> Miniscript<Pk>[src]

pub fn from_ast(t: Terminal<Pk>) -> Result<Miniscript<Pk>, Error>[src]

Add type information(Type and Extdata) to Miniscript based on AstElem fragment. Dependent on display and clone because of Error Display code of type_check.

impl<Pk: MiniscriptKey> Miniscript<Pk>[src]

pub fn into_inner(self) -> Terminal<Pk>[src]

Extracts the AstElem representing the root of the miniscript

pub fn as_inner(&self) -> &Terminal<Pk>[src]

impl Miniscript<PublicKey>[src]

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

Attempt to parse a script into a Miniscript representation

impl<Pk: MiniscriptKey + ToPublicKey> Miniscript<Pk>[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<Pk: MiniscriptKey> Miniscript<Pk>[src]

pub fn translate_pk<FPk, FPkh, Q, Error>(
    &self,
    translatefpk: &mut FPk,
    translatefpkh: &mut FPkh
) -> Result<Miniscript<Q>, Error> where
    FPk: FnMut(&Pk) -> Result<Q, Error>,
    FPkh: FnMut(&Pk::Hash) -> Result<Q::Hash, Error>,
    Q: MiniscriptKey
[src]

impl<Pk: MiniscriptKey + ToPublicKey> Miniscript<Pk>[src]

pub fn satisfy<S: Satisfier<Pk>>(&self, satisfier: S) -> Option<Vec<Vec<u8>>>[src]

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

Trait Implementations

impl<Pk> FromTree for Miniscript<Pk> where
    Pk: MiniscriptKey,
    <Pk as FromStr>::Err: ToString,
    <<Pk as MiniscriptKey>::Hash as FromStr>::Err: ToString
[src]

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

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

impl<Pk: MiniscriptKey> Liftable<Pk> for Miniscript<Pk>[src]

impl<Pk: MiniscriptKey> Eq for Miniscript<Pk>[src]

Eq of Miniscript must depend only on node and not the type information. The type information and extra_properties can be deterministically determined by the ast tree.

impl<Pk: Clone + MiniscriptKey> Clone for Miniscript<Pk>[src]

impl<Pk: MiniscriptKey> PartialOrd<Miniscript<Pk>> for Miniscript<Pk>[src]

PartialOrd of Miniscript must depend only on node and not the type information. The type information and extra_properties can be deterministically determined by the ast tree.

impl<Pk: MiniscriptKey> PartialEq<Miniscript<Pk>> for Miniscript<Pk>[src]

PartialEq of Miniscript must depend only on node and not the type information. The type information and extra_properties can be deterministically determined by the ast tree.

impl<Pk: MiniscriptKey> Ord for Miniscript<Pk>[src]

Ord of Miniscript must depend only on node and not the type information. The type information and extra_properties can be deterministically determined by the ast tree.

impl<Pk: Hash + MiniscriptKey> Hash for Miniscript<Pk>[src]

impl<Pk: MiniscriptKey> Debug for Miniscript<Pk>[src]

impl<Pk: MiniscriptKey> Display for Miniscript<Pk>[src]

impl<Pk> FromStr for Miniscript<Pk> where
    Pk: MiniscriptKey,
    <Pk as FromStr>::Err: ToString,
    <<Pk as MiniscriptKey>::Hash as FromStr>::Err: ToString
[src]

type Err = Error

The associated error which can be returned from parsing.

Auto Trait Implementations

impl<Pk> Send for Miniscript<Pk> where
    Pk: Send + Sync,
    <Pk as MiniscriptKey>::Hash: Send + Sync

impl<Pk> Unpin for Miniscript<Pk> where
    Pk: Unpin,
    <Pk as MiniscriptKey>::Hash: Unpin

impl<Pk> Sync for Miniscript<Pk> where
    Pk: Send + Sync,
    <Pk as MiniscriptKey>::Hash: Send + Sync

impl<Pk> UnwindSafe for Miniscript<Pk> where
    Pk: RefUnwindSafe + UnwindSafe,
    <Pk as MiniscriptKey>::Hash: RefUnwindSafe + UnwindSafe

impl<Pk> RefUnwindSafe for Miniscript<Pk> where
    Pk: RefUnwindSafe,
    <Pk as MiniscriptKey>::Hash: RefUnwindSafe

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> From<T> for T[src]

impl<T> ToString for T where
    T: Display + ?Sized
[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]