Descriptors API Reference¶
Resources:
wpkh()
¶
wpkh(PubKey) -> Descriptor<Wpkh>
Constructs a P2WPKH Descriptor with the given public key.
For example:
Rust source code: src/stdlib/miniscript.rs:N/A
wsh()
¶
wsh(Policy|SortedMulti) -> Descriptor<Wsh>
When called with a Policy or SortedMulti, constructs a P2WSH Descriptor.
When called with a raw Script, constructs a WshInfo representation.
For example: wsh(`$alice OP_CHECKSIGVERIFY 5 OP_CSV`)
Descriptors can only represent scripts expressed as Miniscript. For raw Script, the
WshInfostructure is used instead. See the raw Scripting guide for more details.
Rust source code: src/stdlib/miniscript.rs:N/A
tr()
¶
tr(internal_key: PubKey) -> Descriptor<Tr>
tr(internal_key: PubKey, tree: Policy|Array<Policy>) -> Descriptor<Tr>
tr(tree: Policy|Array<Policy>) -> Descriptor<Tr>
tr(internal_key: PubKey, tree: Script|Array<Script>) -> TapInfo
tr(internal_key: PubKey, merkle_root: Hash) -> TapInfo
tr(tree: Script|Array<Script>) -> TapInfo
When called with a Miniscript Policy script tree or no tree (keypath-only),
constructs a P2TR Descriptor.
When called with a raw Script tree or merkle_root hash, constructs a TapInfo.
Descriptors can only represent Taproot trees expressed as Miniscript. To represent trees with raw Script or trees known only by their merkle root hash, the
TapInfostructure is used instead.
→ See the full tr() documentation under the Taproot reference.
Rust source code: src/stdlib/taproot.rs:N/A
sh()
¶
sh(Policy|SortedMulti) -> Descriptor<Sh>
Constructs a legacy P2SH Descriptor with the given Policy|SortedMulti as the redeemScript.
sh(Descriptor<Wpkh|Wsh>) -> Descriptor<ShWpkh|ShWsh>
Wrap a Segwitv0 P2WPKH/P2WSH descriptor with a legacy P2SH descriptor,
producing a P2SH-P2WPKH/P2SH-P2WSH descriptor.
For example: sh(wpkh($alice)), sh(wsh(pk($alice) && older(5)))
Rust source code: src/stdlib/miniscript.rs:N/A
pkh()
¶
pkh(PubKey) -> Descriptor<Pkh>
Constructs a legacy P2PKH Descriptor with the given public key.
Rust source code: src/stdlib/miniscript.rs:N/A
bare()
¶
bare(Policy) -> Descriptor<Bare>
Constructs a bare descriptor, with the Policy used directly as the output's scriptPubKey.
Typically used for legacy P2PK: bare(pk($alice)), or just bare($alice)
Or for bare multi-sig: bare(multi(1, $alice, $bob)), bare(1 of [ $alice, $bob ])
Rust source code: src/stdlib/miniscript.rs:N/A
Require a signature by threshold_k of the public keys specified in pks.
The pks in the compiled Script will retain their original ordering.
Can be called with variadic arguments as multi(2, $alice, $bob, $charlie), or with an array as multi(2, [ $alice, $bob, $charlie ]).
Alias for: thresh()
While this is an alias to Miniscript's
thresh()which technically returns aPolicyand not a descriptor, it behaves and compiles identically as a descriptormulti()would. (see this comment)
Also see: BIP 383
Rust source code: src/stdlib/miniscript.rs:N/A
Like multi(), expect that the pks in the compiled Script are sorted lexicographically.
Returns: The virtual SortedMulti type, represented as a tagged Array
Also see: BIP 383
Note that
sortedmulti()must be used withwsh()orsh(). Using it underbare()ortr()descriptors is currently unsupported (by the underlyingrust-miniscriptlibrary).
Rust source code: src/stdlib/miniscript.rs:N/A
Descriptor
¶
Construction Examples:
wpkh(xpub661MyMwAqRbcFvXwqbgwi…cBX2nPX9KYVTz3cotpLmSkMxrp99L)wsh(pk($alice) && older(2 days))tr($alice, pk($bob) && older(3))pkh(xpub661MyMwAqRbcFvXwqbgwi…cBX2nPX9KYVTz3cotpLmSkMxrp99L/<0;1>/*)descriptor("wsh(and_v(v:pk(xpub661MyMwAqRbcFvXwqbgwi…cBX2nPX9KYVTz3cotpLmSkMxrp99L),older(1)))")
→ See the Descriptors guide for more.
Variations:
Descriptor<Tr>|Descriptor<Wpkh>|Descriptor<Wsh>|Descriptor<Pkh>|Descriptor<Sh>|Descriptor<ShWpkh>|Descriptor<ShWsh>|Descriptor<Bare>Descriptor<SinglePath>|Descriptor<MultiPath>Descriptor<Definite>|Descriptor<Indefinite>
Coerces from: (None)
Underlying type: miniscript::Descriptor
descriptor()
¶
descriptor(String|Descriptor) -> Descriptor
Rust source code: src/stdlib/miniscript.rs:N/A
Descriptor->singles
Array<Descriptor<SinglePath>>
¶
Definite-only¶
The script_pubkey, explicit_script and witness_program fields are only available for definite descriptors
- non-multi-path and with no underived /* wildcards.
Also see:* scriptPubKey()
Only available for definite non-taproot descriptors
Only available for definite segwit descriptors
Taproot-only¶
The rest of the fields are only only available for Taproot tr() descriptors.
Similar fields are mirrored on TapInfo.
Also available for non-definite descriptors, returning the wildcard/multi-path PubKey used by the descriptor.
Taproot+Definite-only¶
The fields below are only only available for Taproot descriptors that are also definite.
The parity of the output key (0 for even, 1 for odd).
Only available for definite taproot descriptors.
Only available for definite taproot descriptors with script paths.
Only available for definite taproot descriptors with script paths.
Only available for definite taproot descriptors. Returns an empty array when there are no script paths.
WshInfo
¶
Underlying type: minsc::WshInfo
Always true
Always "p2wsh"