Enum miniscript::policy::concrete::Policy
source · 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.
Trait Implementations§
source§impl<Pk: Clone + MiniscriptKey> Clone for Policy<Pk>where
Pk::Sha256: Clone,
Pk::Hash256: Clone,
Pk::Ripemd160: Clone,
Pk::Hash160: Clone,
impl<Pk: Clone + MiniscriptKey> Clone for Policy<Pk>where Pk::Sha256: Clone, Pk::Hash256: Clone, Pk::Ripemd160: Clone, Pk::Hash160: Clone,
source§impl<Pk: MiniscriptKey> Debug for Policy<Pk>
impl<Pk: MiniscriptKey> Debug for Policy<Pk>
source§impl<Pk: MiniscriptKey> Display for Policy<Pk>
impl<Pk: MiniscriptKey> Display for Policy<Pk>
source§impl<Pk: MiniscriptKey> ForEachKey<Pk> for Policy<Pk>
impl<Pk: MiniscriptKey> ForEachKey<Pk> for Policy<Pk>
source§impl<Pk: FromStrKey> FromStr for Policy<Pk>
impl<Pk: FromStrKey> FromStr for Policy<Pk>
source§impl<Pk: FromStrKey> FromTree for Policy<Pk>
impl<Pk: FromStrKey> FromTree for Policy<Pk>
source§impl<Pk: Hash + MiniscriptKey> Hash for Policy<Pk>where
Pk::Sha256: Hash,
Pk::Hash256: Hash,
Pk::Ripemd160: Hash,
Pk::Hash160: Hash,
impl<Pk: Hash + MiniscriptKey> Hash for Policy<Pk>where Pk::Sha256: Hash, Pk::Hash256: Hash, Pk::Ripemd160: Hash, Pk::Hash160: Hash,
source§impl<Pk: MiniscriptKey> Liftable<Pk> for Concrete<Pk>
impl<Pk: MiniscriptKey> Liftable<Pk> for Concrete<Pk>
source§impl<Pk: Ord + MiniscriptKey> Ord for Policy<Pk>where
Pk::Sha256: Ord,
Pk::Hash256: Ord,
Pk::Ripemd160: Ord,
Pk::Hash160: Ord,
impl<Pk: Ord + MiniscriptKey> Ord for Policy<Pk>where Pk::Sha256: Ord, Pk::Hash256: Ord, Pk::Ripemd160: Ord, Pk::Hash160: Ord,
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
source§impl<Pk: PartialEq + MiniscriptKey> PartialEq<Policy<Pk>> for Policy<Pk>where
Pk::Sha256: PartialEq,
Pk::Hash256: PartialEq,
Pk::Ripemd160: PartialEq,
Pk::Hash160: PartialEq,
impl<Pk: PartialEq + MiniscriptKey> PartialEq<Policy<Pk>> for Policy<Pk>where Pk::Sha256: PartialEq, Pk::Hash256: PartialEq, Pk::Ripemd160: PartialEq, Pk::Hash160: PartialEq,
source§impl<Pk: PartialOrd + MiniscriptKey> PartialOrd<Policy<Pk>> for Policy<Pk>where
Pk::Sha256: PartialOrd,
Pk::Hash256: PartialOrd,
Pk::Ripemd160: PartialOrd,
Pk::Hash160: PartialOrd,
impl<Pk: PartialOrd + MiniscriptKey> PartialOrd<Policy<Pk>> for Policy<Pk>where Pk::Sha256: PartialOrd, Pk::Hash256: PartialOrd, Pk::Ripemd160: PartialOrd, Pk::Hash160: PartialOrd,
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more