pub enum Policy {
Key([u8; 33]),
After(u32),
Older(u32),
Sha256([u8; 32]),
Ripemd160([u8; 20]),
Hash160([u8; 20]),
And(Vec<Policy>),
Or(Vec<Policy>),
Threshold(usize, Vec<Policy>),
Unsatisfiable,
Trivial,
}Expand description
A high-level spending policy.
Policies describe what conditions must be satisfied, without specifying how they are encoded in Bitcoin Script.
Variants§
Key([u8; 33])
Require a signature for this public key (33-byte compressed).
After(u32)
Absolute timelock (BIP-65 CLTV).
Older(u32)
Relative timelock (BIP-112 CSV).
Sha256([u8; 32])
SHA-256 hash preimage lock.
Ripemd160([u8; 20])
RIPEMD-160 hash preimage lock.
Hash160([u8; 20])
HASH-160 (SHA-256 → RIPEMD-160) preimage lock.
And(Vec<Policy>)
All sub-policies must be satisfied (AND).
Or(Vec<Policy>)
Any one sub-policy must be satisfied (OR with equal weights).
Threshold(usize, Vec<Policy>)
k-of-n threshold: at least k sub-policies must be satisfied.
Unsatisfiable
Always fails (un-spendable).
Trivial
Always succeeds (trivially satisfiable).
Implementations§
Source§impl Policy
impl Policy
Sourcepub fn compile(&self) -> Result<Miniscript, SignerError>
pub fn compile(&self) -> Result<Miniscript, SignerError>
Compile this policy to a Miniscript fragment.
Returns Err if the policy is malformed (e.g., empty threshold,
threshold k > n, or empty AND/OR).
Trait Implementations§
impl Eq for Policy
impl StructuralPartialEq for Policy
Auto Trait Implementations§
impl Freeze for Policy
impl RefUnwindSafe for Policy
impl Send for Policy
impl Sync for Policy
impl Unpin for Policy
impl UnsafeUnpin for Policy
impl UnwindSafe for Policy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more