[]Struct bdk::descriptor::Miniscript

pub struct Miniscript<Pk, Ctx> where
    Ctx: ScriptContext,
    Pk: MiniscriptKey
{ pub node: Terminal<Pk, Ctx>, pub ty: Type, pub ext: ExtData, // some fields omitted }

Top-level script AST type

Fields

node: Terminal<Pk, Ctx>

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.

Implementations

impl<Pk, Ctx> Miniscript<Pk, Ctx> where
    Ctx: ScriptContext,
    Pk: MiniscriptKey

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

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, Ctx> Miniscript<Pk, Ctx> where
    Ctx: ScriptContext,
    Pk: MiniscriptKey

pub fn into_inner(self) -> Terminal<Pk, Ctx>

Extracts the AstElem representing the root of the miniscript

pub fn as_inner(&self) -> &Terminal<Pk, Ctx>

impl<Ctx> Miniscript<PublicKey, Ctx> where
    Ctx: ScriptContext

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

Attempt to parse a script into a Miniscript representation

impl<Pk, Ctx> Miniscript<Pk, Ctx> where
    Ctx: ScriptContext,
    Pk: MiniscriptKey + ToPublicKey

pub fn encode(&self) -> Script

Encode as a Bitcoin script

pub fn script_size(&self) -> usize

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

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

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, Ctx> Miniscript<Pk, Ctx> where
    Ctx: ScriptContext,
    Pk: MiniscriptKey

pub fn translate_pk<FPk, FPkh, Q, FuncError>(
    &self,
    translatefpk: &mut FPk,
    translatefpkh: &mut FPkh
) -> Result<Miniscript<Q, Ctx>, FuncError> where
    FPk: FnMut(&Pk) -> Result<Q, FuncError>,
    FPkh: FnMut(&<Pk as MiniscriptKey>::Hash) -> Result<<Q as MiniscriptKey>::Hash, FuncError>,
    Q: MiniscriptKey

This will panic if translatefpk returns an uncompressed key when converting to a Segwit descriptor. To prevent this panic, ensure translatefpk returns an error in this case instead.

impl<Pk, Ctx> Miniscript<Pk, Ctx> where
    Ctx: ScriptContext,
    Pk: MiniscriptKey + ToPublicKey

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

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

Trait Implementations

impl<Pk, Ctx> Clone for Miniscript<Pk, Ctx> where
    Ctx: ScriptContext + Clone,
    Pk: MiniscriptKey + Clone

impl<Pk, Ctx> Debug for Miniscript<Pk, Ctx> where
    Ctx: ScriptContext,
    Pk: MiniscriptKey

impl<Pk, Ctx> Display for Miniscript<Pk, Ctx> where
    Ctx: ScriptContext,
    Pk: MiniscriptKey

impl<Pk, Ctx> Eq for Miniscript<Pk, Ctx> where
    Ctx: ScriptContext,
    Pk: MiniscriptKey

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.

impl<Ctx: ScriptContext> ExtractPolicy for Miniscript<DescriptorPublicKey, Ctx>[src]

impl<Pk, Ctx> FromStr for Miniscript<Pk, Ctx> where
    Ctx: ScriptContext,
    Pk: MiniscriptKey,
    <Pk as FromStr>::Err: ToString,
    <<Pk as MiniscriptKey>::Hash as FromStr>::Err: ToString

type Err = Error

The associated error which can be returned from parsing.

impl<Pk, Ctx> FromTree for Miniscript<Pk, Ctx> where
    Ctx: ScriptContext,
    Pk: MiniscriptKey,
    <Pk as FromStr>::Err: ToString,
    <<Pk as MiniscriptKey>::Hash as FromStr>::Err: ToString

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

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, Ctx> Hash for Miniscript<Pk, Ctx> where
    Ctx: ScriptContext + Hash,
    Pk: MiniscriptKey + Hash

impl<Pk, Ctx> Liftable<Pk> for Miniscript<Pk, Ctx> where
    Ctx: ScriptContext,
    Pk: MiniscriptKey

impl<Pk, Ctx> Ord for Miniscript<Pk, Ctx> where
    Ctx: ScriptContext,
    Pk: MiniscriptKey

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.

impl<Pk, Ctx> PartialEq<Miniscript<Pk, Ctx>> for Miniscript<Pk, Ctx> where
    Ctx: ScriptContext,
    Pk: MiniscriptKey

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.

impl<Pk, Ctx> PartialOrd<Miniscript<Pk, Ctx>> for Miniscript<Pk, Ctx> where
    Ctx: ScriptContext,
    Pk: MiniscriptKey

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.

Auto Trait Implementations

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

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

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

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

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

Blanket Implementations

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

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

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

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> From<T> for T[src]

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

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

type Owned = T

The resulting type after obtaining ownership.

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<V, T> VZip<V> for T where
    V: MultiLane<T>,