Enum Terminal

Source
pub enum Terminal<Pk: MiniscriptKey, Ctx: ScriptContext, Ext: Extension = NoExt> {
Show 29 variants True, False, PkK(Pk), PkH(Pk), RawPkH(Hash), After(AbsLockTime), Older(Sequence), Sha256(Pk::Sha256), Hash256(Pk::Hash256), Ripemd160(Pk::Ripemd160), Hash160(Pk::Hash160), Alt(Arc<Miniscript<Pk, Ctx, Ext>>), Swap(Arc<Miniscript<Pk, Ctx, Ext>>), Check(Arc<Miniscript<Pk, Ctx, Ext>>), DupIf(Arc<Miniscript<Pk, Ctx, Ext>>), Verify(Arc<Miniscript<Pk, Ctx, Ext>>), NonZero(Arc<Miniscript<Pk, Ctx, Ext>>), ZeroNotEqual(Arc<Miniscript<Pk, Ctx, Ext>>), AndV(Arc<Miniscript<Pk, Ctx, Ext>>, Arc<Miniscript<Pk, Ctx, Ext>>), AndB(Arc<Miniscript<Pk, Ctx, Ext>>, Arc<Miniscript<Pk, Ctx, Ext>>), AndOr(Arc<Miniscript<Pk, Ctx, Ext>>, Arc<Miniscript<Pk, Ctx, Ext>>, Arc<Miniscript<Pk, Ctx, Ext>>), OrB(Arc<Miniscript<Pk, Ctx, Ext>>, Arc<Miniscript<Pk, Ctx, Ext>>), OrD(Arc<Miniscript<Pk, Ctx, Ext>>, Arc<Miniscript<Pk, Ctx, Ext>>), OrC(Arc<Miniscript<Pk, Ctx, Ext>>, Arc<Miniscript<Pk, Ctx, Ext>>), OrI(Arc<Miniscript<Pk, Ctx, Ext>>, Arc<Miniscript<Pk, Ctx, Ext>>), Thresh(usize, Vec<Arc<Miniscript<Pk, Ctx, Ext>>>), Multi(usize, Vec<Pk>), MultiA(usize, Vec<Pk>), Ext(Ext),
}
Expand description

All AST elements.

This variant is the inner Miniscript variant that allows the user to bypass some of the miniscript rules. You should never construct Terminal directly. This is only exposed to external users to allow matching on the Miniscript.

The average user should always use the Descriptor APIs. Advanced users who want deal with Miniscript ASTs should use the Miniscript APIs.

Variants§

§

True

1

§

False

0

§

PkK(Pk)

<key>

§

PkH(Pk)

DUP HASH160 <keyhash> EQUALVERIFY

§

RawPkH(Hash)

Only for parsing PkH for Script. These raw descriptors are not yet specified in miniscript. We only this variant internally for inferring miniscripts from raw Scripts. It is not possible to construct this variant from any of the Miniscript APIs. We don’t have a generic over here because we don’t want to user to have any abstract reasoning over raw descriptors.

§

After(AbsLockTime)

n CHECKLOCKTIMEVERIFY

§

Older(Sequence)

n CHECKSEQUENCEVERIFY

§

Sha256(Pk::Sha256)

SIZE 32 EQUALVERIFY SHA256 <hash> EQUAL

§

Hash256(Pk::Hash256)

SIZE 32 EQUALVERIFY HASH256 <hash> EQUAL

§

Ripemd160(Pk::Ripemd160)

SIZE 32 EQUALVERIFY RIPEMD160 <hash> EQUAL

§

Hash160(Pk::Hash160)

SIZE 32 EQUALVERIFY HASH160 <hash> EQUAL

§

Alt(Arc<Miniscript<Pk, Ctx, Ext>>)

TOALTSTACK [E] FROMALTSTACK

§

Swap(Arc<Miniscript<Pk, Ctx, Ext>>)

SWAP [E1]

§

Check(Arc<Miniscript<Pk, Ctx, Ext>>)

[Kt]/[Ke] CHECKSIG

§

DupIf(Arc<Miniscript<Pk, Ctx, Ext>>)

DUP IF [V] ENDIF

§

Verify(Arc<Miniscript<Pk, Ctx, Ext>>)

[T] VERIFY

§

NonZero(Arc<Miniscript<Pk, Ctx, Ext>>)

SIZE 0NOTEQUAL IF [Fn] ENDIF

§

ZeroNotEqual(Arc<Miniscript<Pk, Ctx, Ext>>)

[X] 0NOTEQUAL

§

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

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

§

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

[E] [W] BOOLAND

§

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

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

§

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

[E] [W] BOOLOR

§

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

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

§

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

[E] NOTIF [V] ENDIF

§

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

IF [various] ELSE [various] ENDIF

§

Thresh(usize, Vec<Arc<Miniscript<Pk, Ctx, Ext>>>)

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

§

Multi(usize, Vec<Pk>)

k (<key>)* n CHECKMULTISIG

§

MultiA(usize, Vec<Pk>)

<key> CHECKSIG (<key> CHECKSIGADD)*(n-1) k NUMEQUAL

§

Ext(Ext)

Extensions

Implementations§

Source§

impl<Pk: MiniscriptKey, Ctx: ScriptContext, Ext: Extension> Terminal<Pk, Ctx, Ext>

Source

pub fn encode(&self, builder: Builder) -> Builder
where Pk: ToPublicKey, Ext: ParseableExt,

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

Source

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.

Trait Implementations§

Source§

impl<Pk: Clone + MiniscriptKey, Ctx: Clone + ScriptContext, Ext: Clone + Extension> Clone for Terminal<Pk, Ctx, Ext>
where Pk::Sha256: Clone, Pk::Hash256: Clone, Pk::Ripemd160: Clone, Pk::Hash160: Clone,

Source§

fn clone(&self) -> Terminal<Pk, Ctx, Ext>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Pk, Ctx, Ext> Debug for Terminal<Pk, Ctx, Ext>
where Pk: MiniscriptKey, Ctx: ScriptContext, Ext: Extension,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Pk, Ctx, Ext> Display for Terminal<Pk, Ctx, Ext>
where Pk: MiniscriptKey, Ctx: ScriptContext, Ext: Extension,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Pk, Ctx, Ext> ForEachKey<Pk> for Terminal<Pk, Ctx, Ext>
where Pk: MiniscriptKey, Ctx: ScriptContext, Ext: Extension,

Source§

fn for_each_key<'a, F: FnMut(&'a Pk) -> bool>(&'a self, pred: F) -> bool
where Pk: 'a,

Run a predicate on every key in the descriptor, returning whether the predicate returned true for every key
Source§

fn for_any_key<'a, F>(&'a self, pred: F) -> bool
where F: FnMut(&'a Pk) -> bool, Pk: 'a,

Run a predicate on every key in the descriptor, returning whether the predicate returned true for any key
Source§

impl<Pk, Ctx, Ext> FromTree for Terminal<Pk, Ctx, Ext>
where Pk: FromStrKey, Ctx: ScriptContext, Ext: Extension,

Source§

fn from_tree(top: &Tree<'_>) -> Result<Terminal<Pk, Ctx, Ext>, Error>

Extract a structure from Tree representation
Source§

impl<Pk: Hash + MiniscriptKey, Ctx: Hash + ScriptContext, Ext: Hash + Extension> Hash for Terminal<Pk, Ctx, Ext>
where Pk::Sha256: Hash, Pk::Hash256: Hash, Pk::Ripemd160: Hash, Pk::Hash160: Hash,

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<Pk, Ctx, Ext> Liftable<Pk> for Terminal<Pk, Ctx, Ext>
where Pk: MiniscriptKey, Ctx: ScriptContext, Ext: Extension,

Source§

fn lift(&self) -> Result<Semantic<Pk>, Error>

Convert the object into an abstract policy
Source§

impl<Pk: Ord + MiniscriptKey, Ctx: Ord + ScriptContext, Ext: Ord + Extension> Ord for Terminal<Pk, Ctx, Ext>
where Pk::Sha256: Ord, Pk::Hash256: Ord, Pk::Ripemd160: Ord, Pk::Hash160: Ord,

Source§

fn cmp(&self, other: &Terminal<Pk, Ctx, Ext>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<Pk: PartialEq + MiniscriptKey, Ctx: PartialEq + ScriptContext, Ext: PartialEq + Extension> PartialEq for Terminal<Pk, Ctx, Ext>

Source§

fn eq(&self, other: &Terminal<Pk, Ctx, Ext>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<Pk: PartialOrd + MiniscriptKey, Ctx: PartialOrd + ScriptContext, Ext: PartialOrd + Extension> PartialOrd for Terminal<Pk, Ctx, Ext>

Source§

fn partial_cmp(&self, other: &Terminal<Pk, Ctx, Ext>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<Pk, Ctx, Ext, QExt> TranslateExt<Ext, QExt> for Terminal<Pk, Ctx, Ext>
where Pk: MiniscriptKey, Ctx: ScriptContext, Ext: Extension + TranslateExt<Ext, QExt, Output = QExt>, QExt: Extension,

Source§

type Output = Terminal<Pk, Ctx, <Ext as TranslateExt<Ext, QExt>>::Output>

The associated output type.
Source§

fn translate_ext<T, E>(&self, translator: &mut T) -> Result<Self::Output, E>
where T: ExtTranslator<Ext, QExt, E>,

Translates a struct from one generic to another where the translations for Pk are provided by the given Translator.
Source§

impl<Pk, Q, Ctx, Ext> TranslatePk<Pk, Q> for Terminal<Pk, Ctx, Ext>

Source§

fn translate_pk<T, E>(&self, translate: &mut T) -> Result<Self::Output, E>
where T: Translator<Pk, Q, E>,

Converts an AST element with one public key type to one of another public key type.

Source§

type Output = Terminal<Q, Ctx, Ext>

The associated output type. This must be Self<Q>.
Source§

impl<Pk: Eq + MiniscriptKey, Ctx: Eq + ScriptContext, Ext: Eq + Extension> Eq for Terminal<Pk, Ctx, Ext>
where Pk::Sha256: Eq, Pk::Hash256: Eq, Pk::Ripemd160: Eq, Pk::Hash160: Eq,

Source§

impl<Pk: MiniscriptKey, Ctx: ScriptContext, Ext: Extension> StructuralPartialEq for Terminal<Pk, Ctx, Ext>

Auto Trait Implementations§

§

impl<Pk, Ctx, Ext> Freeze for Terminal<Pk, Ctx, Ext>

§

impl<Pk, Ctx, Ext> RefUnwindSafe for Terminal<Pk, Ctx, Ext>

§

impl<Pk, Ctx, Ext> Send for Terminal<Pk, Ctx, Ext>
where Pk: Send + Sync, <Pk as MiniscriptKey>::Sha256: Send + Sync, <Pk as MiniscriptKey>::Hash256: Send + Sync, <Pk as MiniscriptKey>::Ripemd160: Send + Sync, <Pk as MiniscriptKey>::Hash160: Send + Sync, Ext: Send + Sync, Ctx: Sync + Send,

§

impl<Pk, Ctx, Ext> Sync for Terminal<Pk, Ctx, Ext>
where Pk: Sync + Send, <Pk as MiniscriptKey>::Sha256: Sync + Send, <Pk as MiniscriptKey>::Hash256: Sync + Send, <Pk as MiniscriptKey>::Ripemd160: Sync + Send, <Pk as MiniscriptKey>::Hash160: Sync + Send, Ext: Sync + Send, Ctx: Sync + Send,

§

impl<Pk, Ctx, Ext> Unpin for Terminal<Pk, Ctx, Ext>
where Pk: Unpin, <Pk as MiniscriptKey>::Sha256: Unpin, <Pk as MiniscriptKey>::Hash256: Unpin, <Pk as MiniscriptKey>::Ripemd160: Unpin, <Pk as MiniscriptKey>::Hash160: Unpin, Ext: Unpin,

§

impl<Pk, Ctx, Ext> UnwindSafe for Terminal<Pk, Ctx, Ext>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V