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

Abstract policy which corresponds to the semantics of a Miniscript and which allows complex forms of analysis, e.g. filtering and normalization. Semantic policies store only hashes of keys to ensure that objects representing the same policy are lifted to the same Semantic, regardless of their choice of pk or pk_h nodes.

Variants

Unsatisfiable

Unsatisfiable

Trivial

Trivially satisfiable

KeyHash(Pk::Hash)

Signature and public key matching a given hash is required

After(u32)

A relative locktime restriction

Older(u32)

An absolute 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<Policy<Pk>>)

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

Threshold(usizeVec<Policy<Pk>>)

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

Implementations

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

Flatten out trees of Ands and Ors; eliminate Trivial and Unsatisfiables. Does not reorder any branches; use .sort.

Helper function to detect a true/trivial policy

Helper function to detect a false/unsatisfiable policy

Returns a list of all relative timelocks, not including 0, which appear in the policy

Filter a policy by eliminating relative timelock constraints that are not satisfied at the given age.

Count the number of public keys and keyhashes referenced in a policy. Duplicate keys will be double-counted.

Count the minimum number of public keys for which signatures could be used to satisfy the policy.

“Sort” a policy to bring it into a canonical form to allow comparisons. Does not allow policies to be compared for functional equivalence; in general this appears to require Gröbner basis techniques that are not implemented.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

Convert the object into an abstract policy

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.