Enum elements_miniscript::descriptor::Descriptor [−][src]
pub enum Descriptor<Pk: MiniscriptKey> { Bare(Bare<Pk>), Pkh(Pkh<Pk>), Wpkh(Wpkh<Pk>), Sh(Sh<Pk>), Wsh(Wsh<Pk>), Cov(CovenantDescriptor<Pk>), }
Expand description
Script descriptor
Variants
Bare(Bare<Pk>)
A raw scriptpubkey (including pay-to-pubkey) under Legacy context
Pkh(Pkh<Pk>)
Pay-to-PubKey-Hash
Wpkh(Wpkh<Pk>)
Pay-to-Witness-PubKey-Hash
Sh(Sh<Pk>)
Pay-to-ScriptHash(includes nested wsh/wpkh/sorted multi)
Wsh(Wsh<Pk>)
Pay-to-Witness-ScriptHash with Segwitv0 context
Cov(CovenantDescriptor<Pk>)
Covenant descriptor
Implementations
Create a new Wpkh descriptor Will return Err if uncompressed key is used
Create a new sh wrapped wpkh from Pk
.
Errors when uncompressed keys are supplied
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
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
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
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
Create a new sh sortedmulti descriptor with threshold k
and Vec of pks
.
Errors when miniscript exceeds resource limits under p2sh context
Create a new sh wrapped wsh sortedmulti descriptor from threshold
k
and Vec of pks
Errors when miniscript exceeds resource limits under segwit context
Create a new wsh sorted multi descriptor Errors when miniscript exceeds resource limits under p2sh context
Create a new covenant descriptor
Get the DescriptorType of Descriptor
Tries to convert descriptor as a covenant descriptor
Return a string without the checksum
Whether or not the descriptor has any wildcards
Derives all wildcard keys in the descriptor using the supplied index
Panics if given an index ≥ 2^31
pub fn parse_descriptor<C: Signing>(
secp: &Secp256k1<C>,
s: &str
) -> Result<(Descriptor<DescriptorPublicKey>, KeyMap), Error>
pub fn parse_descriptor<C: Signing>(
secp: &Secp256k1<C>,
s: &str
) -> Result<(Descriptor<DescriptorPublicKey>, KeyMap), Error>
Parse a descriptor that may contain secret keys
Internally turns every secret key found into the corresponding public key and then returns a a descriptor that only contains public keys and a map to lookup the secret key given a public key.
Serialize a descriptor to string with its secret keys
Trait Implementations
impl<Pk: MiniscriptKey> DescriptorTrait<Pk> for Descriptor<Pk> where
Pk: FromStr,
Pk::Hash: FromStr,
<Pk as FromStr>::Err: ToString,
<<Pk as MiniscriptKey>::Hash as FromStr>::Err: ToString,
impl<Pk: MiniscriptKey> DescriptorTrait<Pk> for Descriptor<Pk> where
Pk: FromStr,
Pk::Hash: FromStr,
<Pk as FromStr>::Err: ToString,
<<Pk as MiniscriptKey>::Hash as FromStr>::Err: ToString,
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
fn address(&self, params: &'static AddressParams) -> Result<Address, Error> where
Pk: ToPublicKey,
fn address(&self, params: &'static AddressParams) -> Result<Address, Error> where
Pk: ToPublicKey,
Computes the Bitcoin address of the descriptor, if one exists
Computes the scriptpubkey of the descriptor
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).
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.
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.
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.
impl<Pk: MiniscriptKey> ElementsTrait<Pk> for Descriptor<Pk> where
Pk: FromStr,
Pk::Hash: FromStr,
<Pk as FromStr>::Err: ToString,
<<Pk as MiniscriptKey>::Hash as FromStr>::Err: ToString,
impl<Pk: MiniscriptKey> ElementsTrait<Pk> for Descriptor<Pk> where
Pk: FromStr,
Pk::Hash: FromStr,
<Pk as FromStr>::Err: ToString,
<<Pk as MiniscriptKey>::Hash as FromStr>::Err: ToString,
fn blind_addr(
&self,
blinder: Option<PublicKey>,
params: &'static AddressParams
) -> Result<Address, Error> where
Pk: ToPublicKey,
fn blind_addr(
&self,
blinder: Option<PublicKey>,
params: &'static AddressParams
) -> Result<Address, Error> where
Pk: ToPublicKey,
Compute a blinded address
Run a predicate on every key in the descriptor, returning whether the predicate returned true for every key Read more
fn for_any_key<'a, F>(&'a self, pred: F) -> bool where
Pk: 'a,
F: FnMut(ForEach<'a, Pk>) -> bool,
<Pk as MiniscriptKey>::Hash: 'a,
fn for_any_key<'a, F>(&'a self, pred: F) -> bool where
Pk: 'a,
F: FnMut(ForEach<'a, Pk>) -> bool,
<Pk as MiniscriptKey>::Hash: 'a,
Run a predicate on every key in the descriptor, returning whether the predicate returned true for any key Read more
impl<Pk> FromStr for Descriptor<Pk> where
Pk: MiniscriptKey + FromStr,
Pk::Hash: FromStr,
<Pk as FromStr>::Err: ToString,
<<Pk as MiniscriptKey>::Hash as FromStr>::Err: ToString,
impl<Pk> FromStr for Descriptor<Pk> where
Pk: MiniscriptKey + FromStr,
Pk::Hash: FromStr,
<Pk as FromStr>::Err: ToString,
<<Pk as MiniscriptKey>::Hash as FromStr>::Err: ToString,
impl<Pk> FromTree for Descriptor<Pk> where
Pk: MiniscriptKey + FromStr,
Pk::Hash: FromStr,
<Pk as FromStr>::Err: ToString,
<<Pk as MiniscriptKey>::Hash as FromStr>::Err: ToString,
impl<Pk> FromTree for Descriptor<Pk> where
Pk: MiniscriptKey + FromStr,
Pk::Hash: FromStr,
<Pk as FromStr>::Err: ToString,
<<Pk as MiniscriptKey>::Hash as FromStr>::Err: ToString,
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn translate_pk<Fpk, Fpkh, E>(
&self,
translatefpk: Fpk,
translatefpkh: Fpkh
) -> Result<Descriptor<Q>, E> where
Fpk: FnMut(&P) -> Result<Q, E>,
Fpkh: FnMut(&P::Hash) -> Result<Q::Hash, E>,
Q: MiniscriptKey,
fn translate_pk<Fpk, Fpkh, E>(
&self,
translatefpk: Fpk,
translatefpkh: Fpkh
) -> Result<Descriptor<Q>, E> where
Fpk: FnMut(&P) -> Result<Q, E>,
Fpkh: FnMut(&P::Hash) -> Result<Q::Hash, E>,
Q: MiniscriptKey,
Convert a descriptor using abstract keys to one using specific keys This will panic if translatefpk returns an uncompressed key when converting to a Segwit descriptor. To prevent this panic, ensure translatefpk returns an error in this case instead.
type Output = Descriptor<Q>
type Output = Descriptor<Q>
The associated output type. This must be Self
fn translate_pk_infallible<Fpk, Fpkh>(
&self,
translatefpk: Fpk,
translatefpkh: Fpkh
) -> Self::Output where
Fpk: FnMut(&P) -> Q,
Fpkh: FnMut(&<P as MiniscriptKey>::Hash) -> <Q as MiniscriptKey>::Hash,
fn translate_pk_infallible<Fpk, Fpkh>(
&self,
translatefpk: Fpk,
translatefpkh: Fpkh
) -> Self::Output where
Fpk: FnMut(&P) -> Q,
Fpkh: FnMut(&<P as MiniscriptKey>::Hash) -> <Q as MiniscriptKey>::Hash,
Calls translate_pk
with conversion functions that cannot fail
Auto Trait Implementations
impl<Pk> RefUnwindSafe for Descriptor<Pk> where
Pk: RefUnwindSafe,
<Pk as MiniscriptKey>::Hash: RefUnwindSafe,
impl<Pk> Send for Descriptor<Pk> where
Pk: Send + Sync,
<Pk as MiniscriptKey>::Hash: Send + Sync,
impl<Pk> Sync for Descriptor<Pk> where
Pk: Send + Sync,
<Pk as MiniscriptKey>::Hash: Send + Sync,
impl<Pk> Unpin for Descriptor<Pk> where
Pk: Unpin,
<Pk as MiniscriptKey>::Hash: Unpin,
impl<Pk> UnwindSafe for Descriptor<Pk> where
Pk: RefUnwindSafe + UnwindSafe,
<Pk as MiniscriptKey>::Hash: RefUnwindSafe + UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
impl<P, Q, T> TranslatePk1<P, Q> for T where
P: MiniscriptKey,
Q: MiniscriptKey<Hash = <P as MiniscriptKey>::Hash>,
T: TranslatePk<P, Q>,
impl<P, Q, T> TranslatePk1<P, Q> for T where
P: MiniscriptKey,
Q: MiniscriptKey<Hash = <P as MiniscriptKey>::Hash>,
T: TranslatePk<P, Q>,
Translate a struct from one generic to another where the translation for Pk is provided by translatefpk Read more
impl<P, Q, T> TranslatePk2<P, Q> for T where
P: MiniscriptKey<Hash = P>,
Q: MiniscriptKey,
T: TranslatePk<P, Q>,
impl<P, Q, T> TranslatePk2<P, Q> for T where
P: MiniscriptKey<Hash = P>,
Q: MiniscriptKey,
T: TranslatePk<P, Q>,
Translate a struct from one generic to another where the translation for Pk is provided by translatefpk Read more
impl<P, Q, T> TranslatePk3<P, Q> for T where
P: MiniscriptKey + ToPublicKey,
Q: MiniscriptKey<Hash = Hash>,
T: TranslatePk<P, Q>,
impl<P, Q, T> TranslatePk3<P, Q> for T where
P: MiniscriptKey + ToPublicKey,
Q: MiniscriptKey<Hash = Hash>,
T: TranslatePk<P, Q>,
Translate a struct from one generic to another where the translation for Pk is provided by translatefpk Read more