Miniscript¶
Create a Policy requiring that all of the given sub-policies are satisfied.
Can be called with variadic arguments as and($p1, $p2, ..), or with an array as and([ $p1, $p2, .. ]).
For example: and(pk($alice), older(3 days))
Also possible using the && operator: pk($alice) && older(3 days)
Unlike Miniscript's native
and()policy which only accepts exactly 2 sub-policies, Minsc'sand()and&&also supports>2by translating them into anN-of-Nthresh()policy.
Aliased as: all()
Rust source code: src/stdlib/miniscript.rs:N/A
Create a Policy requiring that one of the given sub-policies is satisfied.
Can be called with variadic arguments as or($p1, $p2, ..), or with an array as or([ $p1, $p2, .. ]).
Execution probability weights may be provided using the @ operator. Miniscript uses this information to optimize for lower spending costs.
When unspecified, the default weight is 1.
This is only supported with 2 sub-policies, but they may be nested.
For example: or(pk($alice), pk($bob))
With weights: or(5@pk($alice), 1@or(2@pk($bob), 3@pk($charlie)))
Also possible using the || operator: pk($alice) || pk($bob)
With weights: 5@pk($alice) || (2@pk($bob) || 3@pk($charlie))
Unlike Miniscript's native
or()policy which only accepts exactly 2 sub-policies, Minsc'sor()and||also supports>2by translating them into an1-of-Nthresh()policy.
Aliased as: any()
Rust source code: src/stdlib/miniscript.rs:N/A
Create a Policy requiring that k of the given sub-policies are satisfied.
Can be called with variadic arguments as thresh(2, $p1, $p2, ..), or with an array as thresh(2, [ $p1, $p2, .. ]).
Also possible using the of operator: 2 of [ pk($alice), pk($bob), pk($charlie) ]
Execution probability weights are not supported in threshold policies.
Aliased as: multi()
Rust source code: src/stdlib/miniscript.rs:N/A
Create a Policy requiring a signature by the PubKey.
PubKeys are automatically coerced into a Policy when used as such,
making explicit pk() calls typically unnecessary.
For example, wsh($alice && $bob) is equivalent to wsh(pk($alice) && pk($bob)).
(Not to be confused with pubkey())
Rust source code: src/stdlib/miniscript.rs:N/A
Create a Policy requiring an absolute locktime (by-height or by-timestamp) to pass.
Supports human-readable dates formatted as yyyy-mm-ddT or yyyy-mm-ddThh:mm(Z).
For example: after(900000), after(2030-04-05T), after(2030-04-05T16:20)
Rust source code: src/stdlib/miniscript.rs:N/A
Create a Policy requiring a relative locktime (by-block-count or by-seconds) to pass.
Supports human-readable durations formatted as N year(s)|month(s)|day(s)|week(s)|day(s)|hour(s)|second(s).
Note that time durations are encoded in granularity of 512 seconds and rounded up (e.g. 513 seconds becomes 1024 seconds).
For example: older(5), older(10 days), older(1 month 3 weeks)
The heightwise keyword can be used as a prefix for block-count-estimated durations. For example, older(heightwise 1 day) is equivalent to older(144).
The blocks keyword may optionally be used as a suffix. This typically simply evaluates to the number,
but also verifies that it does not cross the BIP68 limit of 65535 blocks –
older(65536 blocks) will fail with an error, while older(65536) would work but possibly not as intended (interpreted as seconds).
Rust source code: src/stdlib/miniscript.rs:N/A
Create a Policy requiring the pre-image for the sha256 Hash to be revealed.
(Not to be confused with hash::sha256())
Rust source code: src/stdlib/miniscript.rs:N/A
Create a Policy requiring the pre-image for the hash256 Hash (double sha256) to be revealed.
(Not to be confused with hash::sha256d())
Rust source code: src/stdlib/miniscript.rs:N/A
Create a Policy requiring the pre-image for the ripemd160 Hash to be revealed.
(Not to be confused with hash::ripemd160())
Rust source code: src/stdlib/miniscript.rs:N/A
Create a Policy requiring the pre-image for the hash160 Hash (ripemd160 over sha256) to be revealed.
(Not to be confused with hash::hash160())
Rust source code: src/stdlib/miniscript.rs:N/A
Policy
¶
Construction Examples:
→ See the Miniscript guide for more options.
Variations:
Policy<SinglePath>|Policy<MultiPath>Policy<Definite>|Policy<Indefinite>
Coerces from:
Underlying type: miniscript::Policy
Rust source code: src/stdlib/miniscript.rs:N/A
Rust source code: src/stdlib/miniscript.rs:N/A