Trait miniscript::descriptor::DescriptorTrait
source · [−]pub trait DescriptorTrait<Pk: MiniscriptKey> {
fn sanity_check(&self) -> Result<(), Error>;
fn address(&self, network: Network) -> Result<Address, Error>
where
Pk: ToPublicKey;
fn script_pubkey(&self) -> Script
where
Pk: ToPublicKey;
fn unsigned_script_sig(&self) -> Script
where
Pk: ToPublicKey;
fn explicit_script(&self) -> Script
where
Pk: ToPublicKey;
fn get_satisfaction<S>(
&self,
satisfier: S
) -> Result<(Vec<Vec<u8>>, Script), Error>
where
Pk: ToPublicKey,
S: Satisfier<Pk>;
fn max_satisfaction_weight(&self) -> Result<usize, Error>;
fn script_code(&self) -> Script
where
Pk: ToPublicKey;
fn satisfy<S>(&self, txin: &mut TxIn, satisfier: S) -> Result<(), Error>
where
Pk: ToPublicKey,
S: Satisfier<Pk>,
{ ... }
}
Expand description
A general trait for Bitcoin descriptor. Offers function for witness cost estimation, script pubkey creation satisfaction using the Satisfier trait.
Required Methods
fn sanity_check(&self) -> Result<(), Error>
fn sanity_check(&self) -> Result<(), Error>
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 signauture on all spend paths And whether the script is malleable. In general, all the guarantees of miniscript hold only for safe scripts. All the analysis guarantees of miniscript only hold safe scripts. The signer may not be able to find satisfactions even if one exists
Computes the Bitcoin address of the descriptor, if one exists Some descriptors like pk() don’t have any address.
fn script_pubkey(&self) -> Script where
Pk: ToPublicKey,
fn script_pubkey(&self) -> Script where
Pk: ToPublicKey,
Computes the scriptpubkey of the descriptor
fn unsigned_script_sig(&self) -> Script where
Pk: ToPublicKey,
fn unsigned_script_sig(&self) -> Script where
Pk: ToPublicKey,
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).
fn explicit_script(&self) -> Script where
Pk: ToPublicKey,
fn explicit_script(&self) -> Script where
Pk: ToPublicKey,
Computes the “witness script” of the descriptor, i.e. 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.
Returns satisfying witness and scriptSig to spend an output controlled by the given descriptor if it possible to construct one using the satisfier S.
fn max_satisfaction_weight(&self) -> Result<usize, Error>
fn max_satisfaction_weight(&self) -> Result<usize, Error>
Computes an upper bound on the weight of a satisfying witness to the transaction. Assumes all signatures are 73 bytes, including push opcode and sighash suffix. Includes the weight of the VarInts encoding the scriptSig and witness stack length. Returns Error when the descriptor is impossible to safisfy (ex: sh(OP_FALSE))
fn script_code(&self) -> Script where
Pk: ToPublicKey,
fn script_code(&self) -> Script where
Pk: ToPublicKey,
Get 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.