pub enum Policy<Pk: SimplicityKey> {
Unsatisfiable(FailEntropy),
Trivial,
Key(Pk),
After(u32),
Older(u16),
Sha256(Pk::Sha256),
And {
left: Arc<Policy<Pk>>,
right: Arc<Policy<Pk>>,
},
Or {
left: Arc<Policy<Pk>>,
right: Arc<Policy<Pk>>,
},
Threshold(usize, Vec<Policy<Pk>>),
Assembly(Cmr),
}
Expand description
Policy that expresses spending conditions for Simplicity.
The policy can be compiled into a Simplicity program and executed on the Bit Machine, given a witness.
Furthermore, the policy can be normalized and is amenable to semantic analysis.
Variants§
Unsatisfiable(FailEntropy)
Unsatisfiable
Trivial
Trivially satisfiable
Key(Pk)
Provide a signature that matches the given public key and some given message hash
After(u32)
Absolute timelock
Older(u16)
Relative timelock
Sha256(Pk::Sha256)
Provide the preimage of the given SHA256 hash image
And
Satisfy both of the given sub-policies
Or
Satisfy exactly one of the given sub-policies
Threshold(usize, Vec<Policy<Pk>>)
Satisfy exactly k
of the given sub-policies
Assembly(Cmr)
Satisfy the program with the given CMR
Implementations§
Source§impl<Pk: ToXOnlyPubkey> Policy<Pk>
impl<Pk: ToXOnlyPubkey> Policy<Pk>
Source§impl<Pk: SimplicityKey> Policy<Pk>
impl<Pk: SimplicityKey> Policy<Pk>
Sourcepub fn translate<T, Q, E>(&self, translator: &mut T) -> Result<Policy<Q>, E>where
T: Translator<Pk, Q, E>,
Q: SimplicityKey,
pub fn translate<T, Q, E>(&self, translator: &mut T) -> Result<Policy<Q>, E>where
T: Translator<Pk, Q, E>,
Q: SimplicityKey,
Convert a policy using one kind of public key to another type of public key
Sourcepub fn normalized(self) -> Policy<Pk>
pub fn normalized(self) -> Policy<Pk>
Flatten out trees of And
s and Or
s; eliminate Trivial
and
Unsatisfiable
s. Does not reorder any branches; use .sort
.
Source§impl<Pk: ToXOnlyPubkey> Policy<Pk>
impl<Pk: ToXOnlyPubkey> Policy<Pk>
Sourcepub fn satisfy<S: Satisfier<Pk>>(
&self,
satisfier: &S,
env: &ElementsEnv<Arc<Transaction>>,
) -> Result<Arc<RedeemNode<Elements>>, SatisfierError>
pub fn satisfy<S: Satisfier<Pk>>( &self, satisfier: &S, env: &ElementsEnv<Arc<Transaction>>, ) -> Result<Arc<RedeemNode<Elements>>, SatisfierError>
Return the policy program with satisfying witness data.
The program is run on the Bit Machine for pruning, so the transaction environment needs to be provided.