pub enum Policy<Pk: MiniscriptKey> {
Show 13 variants 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),
}
Expand description

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

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

Example
use miniscript::{bitcoin::PublicKey, policy::concrete::Policy};
use std::str::FromStr;
let alice_key = "0270cf3c71f65a3d93d285d9149fddeeb638f87a2d4d8cf16c525f71c417439777";
let bob_key = "02f43b15c50a436f5335dbea8a64dd3b4e63e34c3b50c42598acb5f4f336b5d2fb";
let placeholder_policy = Policy::<String>::from_str("and(pk(alice_key),pk(bob_key))").unwrap();

let real_policy = placeholder_policy.translate_pk(|placeholder: &String| match placeholder.as_str() {
    "alice_key" => PublicKey::from_str(alice_key),
    "bob_key"   => PublicKey::from_str(bob_key),
    _ => panic!("unknown key!")
}).unwrap();

let expected_policy = Policy::from_str(&format!("and(pk({}),pk({}))", alice_key, bob_key)).unwrap();
assert_eq!(real_policy, expected_policy);

Get all keys in the policy

Check whether the policy contains duplicate public keys

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.

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

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

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

Run a predicate on every key in the descriptor, returning whether the predicate returned true for every key Read more

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

The associated error which can be returned from parsing.

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

Extract a structure from Tree representation

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. 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.