[][src]Enum miniscript::miniscript::decode::Terminal

pub enum Terminal<Pk: MiniscriptKey> {
    True,
    False,
    Pk(Pk),
    PkH(Pk::Hash),
    After(u32),
    Older(u32),
    Sha256(Hash),
    Hash256(Hash),
    Ripemd160(Hash),
    Hash160(Hash),
    Alt(Arc<Miniscript<Pk>>),
    Swap(Arc<Miniscript<Pk>>),
    Check(Arc<Miniscript<Pk>>),
    DupIf(Arc<Miniscript<Pk>>),
    Verify(Arc<Miniscript<Pk>>),
    NonZero(Arc<Miniscript<Pk>>),
    ZeroNotEqual(Arc<Miniscript<Pk>>),
    AndV(Arc<Miniscript<Pk>>, Arc<Miniscript<Pk>>),
    AndB(Arc<Miniscript<Pk>>, Arc<Miniscript<Pk>>),
    AndOr(Arc<Miniscript<Pk>>, Arc<Miniscript<Pk>>, Arc<Miniscript<Pk>>),
    OrB(Arc<Miniscript<Pk>>, Arc<Miniscript<Pk>>),
    OrD(Arc<Miniscript<Pk>>, Arc<Miniscript<Pk>>),
    OrC(Arc<Miniscript<Pk>>, Arc<Miniscript<Pk>>),
    OrI(Arc<Miniscript<Pk>>, Arc<Miniscript<Pk>>),
    Thresh(usizeVec<Arc<Miniscript<Pk>>>),
    ThreshM(usizeVec<Pk>),
}

All AST elements

Variants

True

1

False

0

Pk(Pk)

<key>

PkH(Pk::Hash)

DUP HASH160 <keyhash> EQUALVERIFY

After(u32)

n CHECKSEQUENCEVERIFY

Older(u32)

n CHECKLOCKTIMEVERIFY

Sha256(Hash)

SIZE 32 EQUALVERIFY SHA256 <hash> EQUAL

Hash256(Hash)

SIZE 32 EQUALVERIFY HASH256 <hash> EQUAL

Ripemd160(Hash)

SIZE 32 EQUALVERIFY RIPEMD160 <hash> EQUAL

Hash160(Hash)

SIZE 32 EQUALVERIFY HASH160 <hash> EQUAL

Alt(Arc<Miniscript<Pk>>)

TOALTSTACK [E] FROMALTSTACK

Swap(Arc<Miniscript<Pk>>)

SWAP [E1]

Check(Arc<Miniscript<Pk>>)

[Kt]/[Ke] CHECKSIG

DupIf(Arc<Miniscript<Pk>>)

DUP IF [V] ENDIF

Verify(Arc<Miniscript<Pk>>)

[T] VERIFY

NonZero(Arc<Miniscript<Pk>>)

SIZE 0NOTEQUAL IF Fn ENDIF

ZeroNotEqual(Arc<Miniscript<Pk>>)

[X] 0NOTEQUAL

AndV(Arc<Miniscript<Pk>>, Arc<Miniscript<Pk>>)

[V] [T]/[V]/[F]/[Kt]

AndB(Arc<Miniscript<Pk>>, Arc<Miniscript<Pk>>)

[E] [W] BOOLAND

AndOr(Arc<Miniscript<Pk>>, Arc<Miniscript<Pk>>, Arc<Miniscript<Pk>>)

[various] NOTIF [various] ELSE [various] ENDIF

OrB(Arc<Miniscript<Pk>>, Arc<Miniscript<Pk>>)

[E] [W] BOOLOR

OrD(Arc<Miniscript<Pk>>, Arc<Miniscript<Pk>>)

[E] IFDUP NOTIF [T]/[E] ENDIF

OrC(Arc<Miniscript<Pk>>, Arc<Miniscript<Pk>>)

[E] NOTIF [V] ENDIF

OrI(Arc<Miniscript<Pk>>, Arc<Miniscript<Pk>>)

IF [various] ELSE [various] ENDIF

Thresh(usizeVec<Arc<Miniscript<Pk>>>)

[E] ([W] ADD)* k EQUAL

ThreshM(usizeVec<Pk>)

k ()* n CHECKMULTISIG

Methods

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

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

Convert an AST element with one public key type to one of another public key type

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

pub fn encode(&self, builder: Builder) -> Builder[src]

Encode the element as a fragment of Bitcoin Script. The inverse function, from Script to an AST element, is implemented in the parse module.

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_dissatisfaction_witness_elements(&self) -> Option<usize>[src]

Maximum number of witness elements used to dissatisfy the Miniscript fragment. Used to estimate the weight of the VarInt that specifies this number in a serialized transaction.

Will panic if the fragment is not an E, W or Ke.

pub fn max_dissatisfaction_size(&self, one_cost: usize) -> Option<usize>[src]

Maximum dissatisfaction cost, in bytes, of a Miniscript fragment, if it is possible to compute this. This function should probably not ever be used directly. It is called from max_satisfaction_size.

Will panic if the fragment is not E, W or Ke

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

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

This number does not include the witness script itself, so 1 needs to be added to the final result.

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.)

Trait Implementations

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

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

impl<Pk: Eq + MiniscriptKey> Eq for Terminal<Pk> where
    Pk::Hash: Eq
[src]

impl<Pk: Clone + MiniscriptKey> Clone for Terminal<Pk> where
    Pk::Hash: Clone
[src]

impl<Pk: PartialOrd + MiniscriptKey> PartialOrd<Terminal<Pk>> for Terminal<Pk> where
    Pk::Hash: PartialOrd
[src]

impl<Pk: PartialEq + MiniscriptKey> PartialEq<Terminal<Pk>> for Terminal<Pk> where
    Pk::Hash: PartialEq
[src]

impl<Pk: Ord + MiniscriptKey> Ord for Terminal<Pk> where
    Pk::Hash: Ord
[src]

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

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

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

Auto Trait Implementations

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

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

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

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

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

Blanket Implementations

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