pub enum Policy<Pk: MiniscriptKey> {
Unsatisfiable,
Trivial,
Key(Pk),
After(AbsLockTime),
Older(RelLockTime),
Sha256(Pk::Sha256),
Hash256(Pk::Hash256),
Ripemd160(Pk::Ripemd160),
Hash160(Pk::Hash160),
And(Vec<Arc<Policy<Pk>>>),
Or(Vec<(usize, Arc<Policy<Pk>>)>),
Thresh(Threshold<Arc<Policy<Pk>>, 0>),
}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(AbsLockTime)
An absolute locktime restriction.
Older(RelLockTime)
A relative locktime restriction.
Sha256(Pk::Sha256)
A SHA256 whose preimage must be provided to satisfy the descriptor.
Hash256(Pk::Hash256)
A SHA256d whose preimage must be provided to satisfy the descriptor.
Ripemd160(Pk::Ripemd160)
A RIPEMD160 whose preimage must be provided to satisfy the descriptor.
Hash160(Pk::Hash160)
A HASH160 whose preimage must be provided to satisfy the descriptor.
And(Vec<Arc<Policy<Pk>>>)
A list of sub-policies, all of which must be satisfied.
Or(Vec<(usize, Arc<Policy<Pk>>)>)
A list of sub-policies, one of which must be satisfied, along with relative probabilities for each one.
Thresh(Threshold<Arc<Policy<Pk>>, 0>)
A set of descriptors, satisfactions must be provided for k of them.
Implementations§
Source§impl<Pk: MiniscriptKey> Policy<Pk>
impl<Pk: MiniscriptKey> Policy<Pk>
Sourcepub fn translate_pk<Q, E, T>(&self, t: &mut T) -> Result<Policy<Q>, E>where
T: Translator<Pk, Q, E>,
Q: MiniscriptKey,
pub fn translate_pk<Q, E, T>(&self, t: &mut T) -> Result<Policy<Q>, E>where
T: Translator<Pk, Q, E>,
Q: MiniscriptKey,
Converts a policy using one kind of public key to another type of public key.
For example usage please see crate::policy::semantic::Policy::translate_pk.
Sourcepub fn translate_unsatisfiable_pk(self, key: &Pk) -> Policy<Pk>
pub fn translate_unsatisfiable_pk(self, key: &Pk) -> Policy<Pk>
Translates Concrete::Key(key) to Concrete::Unsatisfiable when extracting TapKey.
Sourcepub fn check_duplicate_keys(&self) -> Result<(), PolicyError>
pub fn check_duplicate_keys(&self) -> Result<(), PolicyError>
Checks whether the policy contains duplicate public keys.
Sourcepub fn check_timelocks(&self) -> Result<(), PolicyError>
pub fn check_timelocks(&self) -> Result<(), PolicyError>
Checks whether the given concrete policy contains a combination of timelocks and heightlocks.
§Returns
Returns an error if there is at least one satisfaction that contains a combination of heightlock and timelock.
Sourcepub fn is_valid(&self) -> Result<(), PolicyError>
pub fn is_valid(&self) -> Result<(), PolicyError>
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
Sourcepub fn is_safe_nonmalleable(&self) -> (bool, bool)
pub fn is_safe_nonmalleable(&self) -> (bool, bool)
Checks if any possible compilation of the policy could be compiled as non-malleable and safe.
§Returns
Returns a tuple (safe, non-malleable) to avoid the fact that
non-malleability depends on safety and we would like to cache results.