pub type PegInDescriptor = Descriptor<CompressedPublicKey>;
Aliased Type§
enum PegInDescriptor {
Bare(Bare<CompressedPublicKey>),
Pkh(Pkh<CompressedPublicKey>),
Wpkh(Wpkh<CompressedPublicKey>),
Sh(Sh<CompressedPublicKey>),
Wsh(Wsh<CompressedPublicKey>),
Tr(Tr<CompressedPublicKey>),
}
Variants§
Bare(Bare<CompressedPublicKey>)
A raw scriptpubkey (including pay-to-pubkey) under Legacy context
Pkh(Pkh<CompressedPublicKey>)
Pay-to-PubKey-Hash
Wpkh(Wpkh<CompressedPublicKey>)
Pay-to-Witness-PubKey-Hash
Sh(Sh<CompressedPublicKey>)
Pay-to-ScriptHash(includes nested wsh/wpkh/sorted multi)
Wsh(Wsh<CompressedPublicKey>)
Pay-to-Witness-ScriptHash with Segwitv0 context
Tr(Tr<CompressedPublicKey>)
Pay-to-Taproot
Implementations
§impl<Pk> Descriptor<Pk>where
Pk: MiniscriptKey + ToPublicKey,
impl<Pk> Descriptor<Pk>where
Pk: MiniscriptKey + ToPublicKey,
pub fn address(&self, network: Network) -> Result<Address, Error>
pub fn address(&self, network: Network) -> Result<Address, Error>
Computes the Bitcoin address of the descriptor, if one exists
Some descriptors like pk() don’t have an address.
§Errors
For raw/bare descriptors that don’t have an address.
pub fn script_pubkey(&self) -> ScriptBuf
pub fn script_pubkey(&self) -> ScriptBuf
Computes the scriptpubkey of the descriptor.
pub fn unsigned_script_sig(&self) -> ScriptBuf
pub fn unsigned_script_sig(&self) -> ScriptBuf
Computes the scriptSig that will be in place for an unsigned input spending an output with this descriptor. For pre-segwit descriptors, which use the scriptSig for signatures, this returns the empty script.
This is used in Segwit transactions to produce an unsigned transaction whose txid will not change during signing (since only the witness data will change).
pub fn explicit_script(&self) -> Result<ScriptBuf, Error>
pub fn explicit_script(&self) -> Result<ScriptBuf, Error>
Computes the the underlying script before any hashing is done. For
Bare
, Pkh
and Wpkh
this is the scriptPubkey; for ShWpkh
and Sh
this is the redeemScript; for the others it is the witness script.
§Errors
If the descriptor is a taproot descriptor.
pub fn script_code(&self) -> Result<ScriptBuf, Error>
pub fn script_code(&self) -> Result<ScriptBuf, Error>
Computes the scriptCode
of a transaction output.
The scriptCode
is the Script of the previous transaction output being
serialized in the sighash when evaluating a CHECKSIG
& co. OP code.
§Errors
If the descriptor is a taproot descriptor.
pub fn get_satisfaction<S>(
&self,
satisfier: S,
) -> Result<(Vec<Vec<u8>>, ScriptBuf), Error>where
S: Satisfier<Pk>,
pub fn get_satisfaction<S>(
&self,
satisfier: S,
) -> Result<(Vec<Vec<u8>>, ScriptBuf), Error>where
S: Satisfier<Pk>,
Returns satisfying non-malleable witness and scriptSig to spend an output controlled by the given descriptor if it possible to construct one using the satisfier S.
pub fn get_satisfaction_mall<S>(
&self,
satisfier: S,
) -> Result<(Vec<Vec<u8>>, ScriptBuf), Error>where
S: Satisfier<Pk>,
pub fn get_satisfaction_mall<S>(
&self,
satisfier: S,
) -> Result<(Vec<Vec<u8>>, ScriptBuf), Error>where
S: Satisfier<Pk>,
Returns a possilbly mallable satisfying non-malleable witness and scriptSig to spend an output controlled by the given descriptor if it possible to construct one using the satisfier S.
§impl<Pk> Descriptor<Pk>where
Pk: MiniscriptKey,
impl<Pk> Descriptor<Pk>where
Pk: MiniscriptKey,
pub fn new_pk(pk: Pk) -> Descriptor<Pk>
pub fn new_pk(pk: Pk) -> Descriptor<Pk>
Create a new pk descriptor
pub fn new_wpkh(pk: Pk) -> Result<Descriptor<Pk>, Error>
pub fn new_wpkh(pk: Pk) -> Result<Descriptor<Pk>, Error>
Create a new Wpkh descriptor Will return Err if uncompressed key is used
pub fn new_sh_wpkh(pk: Pk) -> Result<Descriptor<Pk>, Error>
pub fn new_sh_wpkh(pk: Pk) -> Result<Descriptor<Pk>, Error>
Create a new sh wrapped wpkh from Pk
.
Errors when uncompressed keys are supplied
pub fn new_sh(ms: Miniscript<Pk, Legacy>) -> Result<Descriptor<Pk>, Error>
pub fn new_sh(ms: Miniscript<Pk, Legacy>) -> Result<Descriptor<Pk>, Error>
Create a new sh for a given redeem script Errors when miniscript exceeds resource limits under p2sh context or does not type check at the top level
pub fn new_wsh(ms: Miniscript<Pk, Segwitv0>) -> Result<Descriptor<Pk>, Error>
pub fn new_wsh(ms: Miniscript<Pk, Segwitv0>) -> Result<Descriptor<Pk>, Error>
Create a new wsh descriptor from witness script Errors when miniscript exceeds resource limits under p2sh context or does not type check at the top level
pub fn new_sh_wsh(ms: Miniscript<Pk, Segwitv0>) -> Result<Descriptor<Pk>, Error>
pub fn new_sh_wsh(ms: Miniscript<Pk, Segwitv0>) -> Result<Descriptor<Pk>, Error>
Create a new sh wrapped wsh descriptor with witness script Errors when miniscript exceeds resource limits under wsh context or does not type check at the top level
pub fn new_bare(ms: Miniscript<Pk, BareCtx>) -> Result<Descriptor<Pk>, Error>
pub fn new_bare(ms: Miniscript<Pk, BareCtx>) -> Result<Descriptor<Pk>, Error>
Create a new bare descriptor from witness script Errors when miniscript exceeds resource limits under bare context or does not type check at the top level
pub fn new_sh_with_wpkh(wpkh: Wpkh<Pk>) -> Descriptor<Pk>
pub fn new_sh_with_wpkh(wpkh: Wpkh<Pk>) -> Descriptor<Pk>
Create a new sh wrapper for the given wpkh descriptor
pub fn new_sh_with_wsh(wsh: Wsh<Pk>) -> Descriptor<Pk>
pub fn new_sh_with_wsh(wsh: Wsh<Pk>) -> Descriptor<Pk>
Create a new sh wrapper for the given wsh descriptor
pub fn new_sh_sortedmulti(
k: usize,
pks: Vec<Pk>,
) -> Result<Descriptor<Pk>, Error>
pub fn new_sh_sortedmulti( k: usize, pks: Vec<Pk>, ) -> Result<Descriptor<Pk>, Error>
Create a new sh sortedmulti descriptor with threshold k
and Vec of pks
.
Errors when miniscript exceeds resource limits under p2sh context
pub fn new_sh_wsh_sortedmulti(
k: usize,
pks: Vec<Pk>,
) -> Result<Descriptor<Pk>, Error>
pub fn new_sh_wsh_sortedmulti( k: usize, pks: Vec<Pk>, ) -> Result<Descriptor<Pk>, Error>
Create a new sh wrapped wsh sortedmulti descriptor from threshold
k
and Vec of pks
Errors when miniscript exceeds resource limits under segwit context
pub fn new_wsh_sortedmulti(
k: usize,
pks: Vec<Pk>,
) -> Result<Descriptor<Pk>, Error>
pub fn new_wsh_sortedmulti( k: usize, pks: Vec<Pk>, ) -> Result<Descriptor<Pk>, Error>
Create a new wsh sorted multi descriptor Errors when miniscript exceeds resource limits under p2sh context
pub fn new_tr(
key: Pk,
script: Option<TapTree<Pk>>,
) -> Result<Descriptor<Pk>, Error>
pub fn new_tr( key: Pk, script: Option<TapTree<Pk>>, ) -> Result<Descriptor<Pk>, Error>
Create new tr descriptor Errors when miniscript exceeds resource limits under Tap context
pub fn desc_type(&self) -> DescriptorType
pub fn desc_type(&self) -> DescriptorType
Get the [DescriptorType] of [Descriptor]
pub fn sanity_check(&self) -> Result<(), Error>
pub fn sanity_check(&self) -> Result<(), Error>
Checks whether the descriptor is safe.
Checks whether all the spend paths in the descriptor are possible on the bitcoin network under the current standardness and consensus rules. Also checks whether the descriptor requires signatures on all spend paths and whether the script is malleable.
In general, all the guarantees of miniscript hold only for safe scripts. The signer may not be able to find satisfactions even if one exists.
pub fn max_weight_to_satisfy(&self) -> Result<Weight, Error>
pub fn max_weight_to_satisfy(&self) -> Result<Weight, Error>
Computes an upper bound on the difference between a non-satisfied
TxIn
’s segwit_weight
and a satisfied TxIn
’s segwit_weight
Since this method uses segwit_weight
instead of legacy_weight
,
if you want to include only legacy inputs in your transaction,
you should remove 1WU from each input’s max_weight_to_satisfy
for a more accurate estimate.
In other words, for segwit inputs or legacy inputs included in segwit transactions, the following will hold for each input if that input was satisfied with the largest possible witness:
for i in 0..transaction.input.len() {
assert_eq!(
descriptor_for_input[i].max_weight_to_satisfy(),
transaction.input[i].segwit_weight() - TxIn::default().segwit_weight()
);
}
Instead, for legacy transactions, the following will hold for each input if that input was satisfied with the largest possible witness:
for i in 0..transaction.input.len() {
assert_eq!(
descriptor_for_input[i].max_weight_to_satisfy(),
transaction.input[i].legacy_weight() - TxIn::default().legacy_weight()
);
}
Assumes all ECDSA signatures are 73 bytes, including push opcode and sighash suffix. Assumes all Schnorr signatures are 66 bytes, including push opcode and sighash suffix.
§Errors
When the descriptor is impossible to safisfy (ex: sh(OP_FALSE)).
pub fn max_satisfaction_weight(&self) -> Result<usize, Error>
👎Deprecated since 10.0.0: Use max_weight_to_satisfy instead. The method to count bytes was redesigned and the results will differ from max_weight_to_satisfy. For more details check rust-bitcoin/rust-miniscript#476.
pub fn max_satisfaction_weight(&self) -> Result<usize, Error>
Computes an upper bound on the weight of a satisfying witness to the transaction.
Assumes all ec-signatures are 73 bytes, including push opcode and sighash suffix. Includes the weight of the VarInts encoding the scriptSig and witness stack length.
§Errors
When the descriptor is impossible to safisfy (ex: sh(OP_FALSE)).
Trait Implementations
Source§impl<K> Decodable for Descriptor<K>
impl<K> Decodable for Descriptor<K>
Source§fn consensus_decode_partial_from_finite_reader<D>(
d: &mut D,
modules: &ModuleRegistry<Decoder, DecodingMode>,
) -> Result<Descriptor<K>, DecodeError>where
D: Read,
fn consensus_decode_partial_from_finite_reader<D>(
d: &mut D,
modules: &ModuleRegistry<Decoder, DecodingMode>,
) -> Result<Descriptor<K>, DecodeError>where
D: Read,
Self
from a size-limited reader. Read morefn consensus_decode_whole( slice: &[u8], modules: &ModuleRegistry<Decoder, DecodingMode>, ) -> Result<Self, DecodeError>
Source§fn consensus_decode_partial<R>(
r: &mut R,
modules: &ModuleRegistry<Decoder, DecodingMode>,
) -> Result<Self, DecodeError>where
R: Read,
fn consensus_decode_partial<R>(
r: &mut R,
modules: &ModuleRegistry<Decoder, DecodingMode>,
) -> Result<Self, DecodeError>where
R: Read,
Source§fn consensus_decode_hex(
hex: &str,
modules: &ModuleRegistry<Decoder, DecodingMode>,
) -> Result<Self, DecodeError>
fn consensus_decode_hex( hex: &str, modules: &ModuleRegistry<Decoder, DecodingMode>, ) -> Result<Self, DecodeError>
§impl<'de, Pk> Deserialize<'de> for Descriptor<Pk>where
Pk: FromStrKey,
impl<'de, Pk> Deserialize<'de> for Descriptor<Pk>where
Pk: FromStrKey,
§fn deserialize<D>(
deserializer: D,
) -> Result<Descriptor<Pk>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Descriptor<Pk>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl<K> Encodable for Descriptor<K>where
K: MiniscriptKey,
impl<K> Encodable for Descriptor<K>where
K: MiniscriptKey,
Source§fn consensus_encode<W>(&self, writer: &mut W) -> Result<(), Error>where
W: Write,
fn consensus_encode<W>(&self, writer: &mut W) -> Result<(), Error>where
W: Write,
Source§fn consensus_encode_to_vec(&self) -> Vec<u8> ⓘ
fn consensus_encode_to_vec(&self) -> Vec<u8> ⓘ
Self::consensus_encode
to newly allocated Vec<u8>
Source§fn consensus_encode_to_hex(&self) -> String
fn consensus_encode_to_hex(&self) -> String
Source§fn consensus_encode_to_len(&self) -> u64
fn consensus_encode_to_len(&self) -> u64
Source§fn consensus_hash<H>(&self) -> Hwhere
H: Hash,
<H as Hash>::Engine: Write,
fn consensus_hash<H>(&self) -> Hwhere
H: Hash,
<H as Hash>::Engine: Write,
H
. Read moreSource§fn consensus_hash_sha256(&self) -> Hash
fn consensus_hash_sha256(&self) -> Hash
Self::consensus_hash
for [bitcoin::hashes::sha256::Hash
]