Enum sapio_miniscript::policy::concrete::Policy[][src]

pub enum Policy<Pk: MiniscriptKey> {
    Unsatisfiable,
    Trivial,
    Key(Pk),
    After(u32),
    Older(u32),
    Sha256(Hash),
    Hash256(Hash),
    Ripemd160(Hash),
    Hash160(Hash),
    And(Vec<Policy<Pk>>),
    Or(Vec<(usize, Policy<Pk>)>),
    Threshold(usizeVec<Policy<Pk>>),
    TxTemplate(Hash),
}

Concrete policy which corresponds directly to a Miniscript structure, and whose disjunctions are annotated with satisfaction probabilities to assist the compiler

Variants

Unsatisfiable

Unsatisfiable

Trivial

Trivially satisfiable

Key(Pk)

A public key which must sign to satisfy the descriptor

After(u32)

An absolute locktime restriction

Older(u32)

A relative locktime restriction

Sha256(Hash)

A SHA256 whose preimage must be provided to satisfy the descriptor

Hash256(Hash)

A SHA256d whose preimage must be provided to satisfy the descriptor

Ripemd160(Hash)

A RIPEMD160 whose preimage must be provided to satisfy the descriptor

Hash160(Hash)

A HASH160 whose preimage must be provided to satisfy the descriptor

And(Vec<Policy<Pk>>)

A list of sub-policies, all of which must be satisfied

Or(Vec<(usize, Policy<Pk>)>)

A list of sub-policies, one of which must be satisfied, along with relative probabilities for each one

Threshold(usizeVec<Policy<Pk>>)

A set of descriptors, satisfactions must be provided for k of them

TxTemplate(Hash)

A SHA256 whose must match the tx template

Implementations

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

pub fn translate_pk<Fpk, Q, E>(&self, translatefpk: Fpk) -> Result<Policy<Q>, E> where
    Fpk: FnMut(&Pk) -> Result<Q, E>,
    Q: MiniscriptKey
[src]

Convert a policy using one kind of public key to another type of public key

pub fn keys(&self) -> Vec<&Pk>[src]

Get all keys in the policy

pub fn check_duplicate_keys(&self) -> Result<(), PolicyError>[src]

Check whether the policy contains duplicate public keys

pub fn check_timelocks(&self) -> Result<(), PolicyError>[src]

Checks whether the given concrete policy contains a combination of timelocks and heightlocks. Returns an error if there is at least one satisfaction that contains a combination of hieghtlock and timelock.

pub fn is_valid(&self) -> Result<(), PolicyError>[src]

This returns whether the given policy is valid or not. It maybe possible that the policy contains Non-two argument and, or or a 0 arg thresh. Validity condition also checks whether there is a possible satisfaction combination of timelocks and heightlocks

pub fn is_safe_nonmalleable(&self) -> (bool, bool)[src]

This returns whether any possible compilation of the policy could be compiled as non-malleable and safe. Note that this returns a tuple (safe, non-malleable) to avoid because the non-malleability depends on safety and we would like to cache results.

Trait Implementations

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

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

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

impl<Pk: Eq + MiniscriptKey> Eq for Policy<Pk>[src]

impl<Pk: MiniscriptKey> ForEachKey<Pk> for Policy<Pk>[src]

impl<Pk> FromStr for Policy<Pk> where
    Pk: MiniscriptKey + FromStr,
    Pk::Hash: FromStr,
    <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.

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

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

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

impl<Pk: Ord + MiniscriptKey> Ord for Policy<Pk>[src]

impl<Pk: PartialEq + MiniscriptKey> PartialEq<Policy<Pk>> for Policy<Pk>[src]

impl<Pk: PartialOrd + MiniscriptKey> PartialOrd<Policy<Pk>> for Policy<Pk>[src]

impl<Pk: MiniscriptKey> StructuralEq for Policy<Pk>[src]

impl<Pk: MiniscriptKey> StructuralPartialEq for Policy<Pk>[src]

Auto Trait Implementations

impl<Pk> RefUnwindSafe for Policy<Pk> where
    Pk: RefUnwindSafe

impl<Pk> Send for Policy<Pk> where
    Pk: Send

impl<Pk> Sync for Policy<Pk> where
    Pk: Sync

impl<Pk> Unpin for Policy<Pk> where
    Pk: Unpin

impl<Pk> UnwindSafe for Policy<Pk> where
    Pk: 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<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.