Enum Terminal

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

All AST elements

Variants§

§

True

1

§

False

0

§

PkK(Pk)

<key>

§

PkH(Pk::Hash)

DUP HASH160 <keyhash> EQUALVERIFY

§

After(u32)

n CHECKLOCKTIMEVERIFY

§

Older(u32)

n CHECKSEQUENCEVERIFY

§

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, Ctx>>)

TOALTSTACK [E] FROMALTSTACK

§

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

SWAP [E1]

§

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

[Kt]/[Ke] CHECKSIG

§

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

DUP IF [V] ENDIF

§

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

[T] VERIFY

§

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

SIZE 0NOTEQUAL IF Fn ENDIF

§

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

[X] 0NOTEQUAL

§

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

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

§

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

[E] [W] BOOLAND

§

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

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

§

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

[E] [W] BOOLOR

§

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

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

§

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

[E] NOTIF [V] ENDIF

§

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

IF [various] ELSE [various] ENDIF

§

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

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

§

Multi(usize, Vec<Pk>)

k ()* n CHECKMULTISIG

§

MultiA(usize, Vec<Pk>)

CHECKSIG ( CHECKSIGADD)*(n-1) k NUMEQUAL

§

TxTemplate(Hash)

<hash> OP_CHECKTEMPLATEVERIFY OP_DROP

Implementations§

Source§

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

Source

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

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> Clone for Terminal<Pk, Ctx>
where Pk::Hash: Clone,

Source§

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

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: MiniscriptKey, Ctx: ScriptContext> Debug for Terminal<Pk, Ctx>

Source§

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

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

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

Source§

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

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

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

Source§

fn for_each_key<'a, F: FnMut(ForEach<'a, Pk>) -> bool>( &'a self, pred: F, ) -> bool
where Pk: 'a, Pk::Hash: '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: FnMut(ForEach<'a, Pk>) -> bool>(&'a self, pred: F) -> bool
where Pk: 'a, Pk::Hash: 'a,

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

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

Source§

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

Extract a structure from Tree representation
Source§

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

Source§

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

Convert the object into an abstract policy
Source§

impl<Pk: Ord + MiniscriptKey, Ctx: Ord + ScriptContext> Ord for Terminal<Pk, Ctx>
where Pk::Hash: Ord,

Source§

fn cmp(&self, other: &Terminal<Pk, Ctx>) -> 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> PartialEq for Terminal<Pk, Ctx>
where Pk::Hash: PartialEq,

Source§

fn eq(&self, other: &Terminal<Pk, Ctx>) -> 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> PartialOrd for Terminal<Pk, Ctx>
where Pk::Hash: PartialOrd,

Source§

fn partial_cmp(&self, other: &Terminal<Pk, Ctx>) -> 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: MiniscriptKey, Q: MiniscriptKey, Ctx: ScriptContext> TranslatePk<Pk, Q> for Terminal<Pk, Ctx>

Source§

fn translate_pk<FPk, FPkh, FuncError>( &self, translatefpk: FPk, translatefpkh: FPkh, ) -> Result<Self::Output, FuncError>
where FPk: FnMut(&Pk) -> Result<Q, FuncError>, FPkh: FnMut(&Pk::Hash) -> Result<Q::Hash, FuncError>,

Convert an AST element with one public key type to one of another public key type .This will panic while converting to Segwit Miniscript using uncompressed public keys

Source§

type Output = Terminal<Q, Ctx>

The associated output type. This must be Self
Source§

fn translate_pk_infallible<Fpk, Fpkh>( &self, translatefpk: Fpk, translatefpkh: Fpkh, ) -> Self::Output
where Fpk: FnMut(&P) -> Q, Fpkh: FnMut(&P::Hash) -> Q::Hash,

Calls translate_pk with conversion functions that cannot fail
Source§

impl<Pk: Eq + MiniscriptKey, Ctx: Eq + ScriptContext> Eq for Terminal<Pk, Ctx>
where Pk::Hash: Eq,

Source§

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

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

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

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<P, Q, T> TranslatePk1<P, Q> for T
where P: MiniscriptKey, Q: MiniscriptKey<Hash = <P as MiniscriptKey>::Hash>, T: TranslatePk<P, Q>,

Source§

fn translate_pk1<Fpk, E>( &self, translatefpk: Fpk, ) -> Result<<Self as TranslatePk<P, Q>>::Output, E>
where Fpk: FnMut(&P) -> Result<Q, E>,

Translate a struct from one generic to another where the translation for Pk is provided by translatefpk
Source§

fn translate_pk1_infallible<Fpk: FnMut(&P) -> Q>( &self, translatefpk: Fpk, ) -> <Self as TranslatePk<P, Q>>::Output

Translate a struct from one generic to another where the translation for Pk is provided by translatefpk
Source§

impl<P, Q, T> TranslatePk2<P, Q> for T
where P: MiniscriptKey<Hash = P>, Q: MiniscriptKey, T: TranslatePk<P, Q>,

Source§

fn translate_pk2<Fpk: Fn(&P) -> Result<Q, E>, E>( &self, translatefpk: Fpk, ) -> Result<<Self as TranslatePk<P, Q>>::Output, E>

Translate a struct from one generic to another where the translation for Pk is provided by translatefpk
Source§

fn translate_pk2_infallible<Fpk: Fn(&P) -> Q>( &self, translatefpk: Fpk, ) -> <Self as TranslatePk<P, Q>>::Output

Translate a struct from one generic to another where the translation for Pk is provided by translatefpk
Source§

impl<P, Q, T> TranslatePk3<P, Q> for T
where P: MiniscriptKey + ToPublicKey, Q: MiniscriptKey<Hash = Hash>, T: TranslatePk<P, Q>,

Source§

fn translate_pk3<Fpk, E>( &self, translatefpk: Fpk, ) -> Result<<Self as TranslatePk<P, Q>>::Output, E>
where Fpk: FnMut(&P) -> Result<Q, E>,

Translate a struct from one generic to another where the translation for Pk is provided by translatefpk
Source§

fn translate_pk3_infallible<Fpk: FnMut(&P) -> Q>( &self, translatefpk: Fpk, ) -> <Self as TranslatePk<P, Q>>::Output

Translate a struct from one generic to another where the translation for Pk is provided by translatefpk
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.