Enum bdk::descriptor::Descriptor
source · [−]pub enum Descriptor<Pk> where
Pk: MiniscriptKey, {
Bare(Bare<Pk>),
Pkh(Pkh<Pk>),
Wpkh(Wpkh<Pk>),
Sh(Sh<Pk>),
Wsh(Wsh<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
Implementations
sourceimpl<Pk> Descriptor<Pk> where
Pk: MiniscriptKey,
impl<Pk> Descriptor<Pk> where
Pk: MiniscriptKey,
sourcepub fn new_pk(pk: Pk) -> Descriptor<Pk>
pub fn new_pk(pk: Pk) -> Descriptor<Pk>
Create a new pk descriptor
sourcepub fn new_pkh(pk: Pk) -> Descriptor<Pk>
pub fn new_pkh(pk: Pk) -> Descriptor<Pk>
Create a new PkH descriptor
sourcepub 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
sourcepub 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
sourcepub 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
sourcepub 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
sourcepub 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
sourcepub 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
sourcepub fn new_sh_sortedmulti(
k: usize,
pks: Vec<Pk, Global>
) -> Result<Descriptor<Pk>, Error>
pub fn new_sh_sortedmulti(
k: usize,
pks: Vec<Pk, Global>
) -> 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
sourcepub fn new_sh_wsh_sortedmulti(
k: usize,
pks: Vec<Pk, Global>
) -> Result<Descriptor<Pk>, Error>
pub fn new_sh_wsh_sortedmulti(
k: usize,
pks: Vec<Pk, Global>
) -> 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
sourcepub fn new_wsh_sortedmulti(
k: usize,
pks: Vec<Pk, Global>
) -> Result<Descriptor<Pk>, Error>
pub fn new_wsh_sortedmulti(
k: usize,
pks: Vec<Pk, Global>
) -> Result<Descriptor<Pk>, Error>
Create a new wsh sorted multi descriptor Errors when miniscript exceeds resource limits under p2sh context
sourcepub fn desc_type(&self) -> DescriptorType
pub fn desc_type(&self) -> DescriptorType
Get the DescriptorType of Descriptor
sourceimpl Descriptor<DescriptorPublicKey>
impl Descriptor<DescriptorPublicKey>
sourcepub fn is_deriveable(&self) -> bool
pub fn is_deriveable(&self) -> bool
Whether or not the descriptor has any wildcards
sourcepub fn derive(&self, index: u32) -> Descriptor<DescriptorPublicKey>
pub fn derive(&self, index: u32) -> Descriptor<DescriptorPublicKey>
Derives all wildcard keys in the descriptor using the supplied index
Panics if given an index ≥ 2^31
sourcepub fn parse_descriptor<C>(
secp: &Secp256k1<C>,
s: &str
) -> Result<(Descriptor<DescriptorPublicKey>, HashMap<DescriptorPublicKey, DescriptorSecretKey, RandomState>), Error> where
C: Signing,
pub fn parse_descriptor<C>(
secp: &Secp256k1<C>,
s: &str
) -> Result<(Descriptor<DescriptorPublicKey>, HashMap<DescriptorPublicKey, DescriptorSecretKey, RandomState>), Error> where
C: Signing,
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.
sourcepub fn to_string_with_secret(
&self,
key_map: &HashMap<DescriptorPublicKey, DescriptorSecretKey, RandomState>
) -> String
pub fn to_string_with_secret(
&self,
key_map: &HashMap<DescriptorPublicKey, DescriptorSecretKey, RandomState>
) -> String
Serialize a descriptor to string with its secret keys
Trait Implementations
sourceimpl AsDerived for Descriptor<DescriptorPublicKey>
impl AsDerived for Descriptor<DescriptorPublicKey>
sourcefn as_derived<'s>(
&self,
index: u32,
secp: &'s Secp256k1<All>
) -> Descriptor<DerivedDescriptorKey<'s>>
fn as_derived<'s>(
&self,
index: u32,
secp: &'s Secp256k1<All>
) -> Descriptor<DerivedDescriptorKey<'s>>
Derive a descriptor and transform all of its keys to DerivedDescriptorKey
sourcefn as_derived_fixed<'s>(
&self,
secp: &'s Secp256k1<All>
) -> Descriptor<DerivedDescriptorKey<'s>>
fn as_derived_fixed<'s>(
&self,
secp: &'s Secp256k1<All>
) -> Descriptor<DerivedDescriptorKey<'s>>
Transform the keys into DerivedDescriptorKey
. Read more
sourceimpl<Pk> Clone for Descriptor<Pk> where
Pk: Clone + MiniscriptKey,
impl<Pk> Clone for Descriptor<Pk> where
Pk: Clone + MiniscriptKey,
sourcefn clone(&self) -> Descriptor<Pk>
fn clone(&self) -> Descriptor<Pk>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<Pk> Debug for Descriptor<Pk> where
Pk: MiniscriptKey,
impl<Pk> Debug for Descriptor<Pk> where
Pk: MiniscriptKey,
sourceimpl<Pk> DescriptorTrait<Pk> for Descriptor<Pk> where
Pk: MiniscriptKey,
impl<Pk> DescriptorTrait<Pk> for Descriptor<Pk> where
Pk: MiniscriptKey,
sourcefn 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
sourcefn address(&self, network: Network) -> Result<Address, Error> where
Pk: ToPublicKey,
fn address(&self, network: Network) -> Result<Address, Error> where
Pk: ToPublicKey,
Computes the Bitcoin address of the descriptor, if one exists
sourcefn script_pubkey(&self) -> Script where
Pk: ToPublicKey,
fn script_pubkey(&self) -> Script where
Pk: ToPublicKey,
Computes the scriptpubkey of the descriptor
sourcefn 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).
sourcefn 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.
sourcefn get_satisfaction<S>(
&self,
satisfier: S
) -> Result<(Vec<Vec<u8, Global>, Global>, Script), Error> where
Pk: ToPublicKey,
S: Satisfier<Pk>,
fn get_satisfaction<S>(
&self,
satisfier: S
) -> Result<(Vec<Vec<u8, Global>, Global>, Script), Error> where
Pk: ToPublicKey,
S: Satisfier<Pk>,
Returns satisfying witness and scriptSig to spend an output controlled by the given descriptor if it possible to construct one using the satisfier S.
sourcefn 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.
sourcefn 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.
sourceimpl<'de, Pk> Deserialize<'de> for Descriptor<Pk> where
Pk: MiniscriptKey + FromStr,
<Pk as MiniscriptKey>::Hash: FromStr,
<Pk as FromStr>::Err: Display,
<<Pk as MiniscriptKey>::Hash as FromStr>::Err: Display,
impl<'de, Pk> Deserialize<'de> for Descriptor<Pk> where
Pk: MiniscriptKey + FromStr,
<Pk as MiniscriptKey>::Hash: FromStr,
<Pk as FromStr>::Err: Display,
<<Pk as MiniscriptKey>::Hash as FromStr>::Err: Display,
sourcefn 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>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<Pk> Display for Descriptor<Pk> where
Pk: MiniscriptKey,
impl<Pk> Display for Descriptor<Pk> where
Pk: MiniscriptKey,
sourceimpl ExtractPolicy for Descriptor<DescriptorPublicKey>
impl ExtractPolicy for Descriptor<DescriptorPublicKey>
sourcefn extract_policy(
&self,
signers: &SignersContainer,
build_sat: BuildSatisfaction<'_>,
secp: &Secp256k1<All>
) -> Result<Option<Policy>, Error>
fn extract_policy(
&self,
signers: &SignersContainer,
build_sat: BuildSatisfaction<'_>,
secp: &Secp256k1<All>
) -> Result<Option<Policy>, Error>
Extract the spending policy
sourceimpl<Pk> ForEachKey<Pk> for Descriptor<Pk> where
Pk: MiniscriptKey,
impl<Pk> ForEachKey<Pk> for Descriptor<Pk> where
Pk: MiniscriptKey,
sourcefn for_each_key<'a, F>(&'a self, pred: F) -> bool where
F: FnMut(ForEach<'a, Pk>) -> bool,
Pk: 'a,
<Pk as MiniscriptKey>::Hash: 'a,
fn for_each_key<'a, F>(&'a self, pred: F) -> bool where
F: FnMut(ForEach<'a, Pk>) -> bool,
Pk: 'a,
<Pk as MiniscriptKey>::Hash: 'a,
Run a predicate on every key in the descriptor, returning whether the predicate returned true for every key Read more
sourcefn for_any_key<'a, F>(&'a self, pred: F) -> bool where
F: FnMut(ForEach<'a, Pk>) -> bool,
Pk: 'a,
<Pk as MiniscriptKey>::Hash: 'a,
fn for_any_key<'a, F>(&'a self, pred: F) -> bool where
F: FnMut(ForEach<'a, Pk>) -> bool,
Pk: 'a,
<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
sourceimpl<Pk> FromStr for Descriptor<Pk> where
Pk: MiniscriptKey + FromStr,
<Pk as MiniscriptKey>::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 as MiniscriptKey>::Hash: FromStr,
<Pk as FromStr>::Err: ToString,
<<Pk as MiniscriptKey>::Hash as FromStr>::Err: ToString,
sourceimpl<Pk> FromTree for Descriptor<Pk> where
Pk: MiniscriptKey + FromStr,
<Pk as MiniscriptKey>::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 as MiniscriptKey>::Hash: FromStr,
<Pk as FromStr>::Err: ToString,
<<Pk as MiniscriptKey>::Hash as FromStr>::Err: ToString,
sourceimpl<Pk> Hash for Descriptor<Pk> where
Pk: Hash + MiniscriptKey,
impl<Pk> Hash for Descriptor<Pk> where
Pk: Hash + MiniscriptKey,
sourceimpl<Pk> Liftable<Pk> for Descriptor<Pk> where
Pk: MiniscriptKey,
impl<Pk> Liftable<Pk> for Descriptor<Pk> where
Pk: MiniscriptKey,
sourceimpl<Pk> Ord for Descriptor<Pk> where
Pk: Ord + MiniscriptKey,
impl<Pk> Ord for Descriptor<Pk> where
Pk: Ord + MiniscriptKey,
sourceimpl<Pk> PartialEq<Descriptor<Pk>> for Descriptor<Pk> where
Pk: PartialEq<Pk> + MiniscriptKey,
impl<Pk> PartialEq<Descriptor<Pk>> for Descriptor<Pk> where
Pk: PartialEq<Pk> + MiniscriptKey,
sourcefn eq(&self, other: &Descriptor<Pk>) -> bool
fn eq(&self, other: &Descriptor<Pk>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &Descriptor<Pk>) -> bool
fn ne(&self, other: &Descriptor<Pk>) -> bool
This method tests for !=
.
sourceimpl<Pk> PartialOrd<Descriptor<Pk>> for Descriptor<Pk> where
Pk: PartialOrd<Pk> + MiniscriptKey,
impl<Pk> PartialOrd<Descriptor<Pk>> for Descriptor<Pk> where
Pk: PartialOrd<Pk> + MiniscriptKey,
sourcefn partial_cmp(&self, other: &Descriptor<Pk>) -> Option<Ordering>
fn partial_cmp(&self, other: &Descriptor<Pk>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl<'de, Pk> Serialize for Descriptor<Pk> where
Pk: MiniscriptKey,
impl<'de, Pk> Serialize for Descriptor<Pk> where
Pk: MiniscriptKey,
sourcefn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
sourceimpl<P, Q> TranslatePk<P, Q> for Descriptor<P> where
P: MiniscriptKey,
Q: MiniscriptKey,
impl<P, Q> TranslatePk<P, Q> for Descriptor<P> where
P: MiniscriptKey,
Q: MiniscriptKey,
sourcefn translate_pk<Fpk, Fpkh, E>(
&self,
translatefpk: Fpk,
translatefpkh: Fpkh
) -> Result<Descriptor<Q>, E> where
Fpk: FnMut(&P) -> Result<Q, E>,
Fpkh: FnMut(&<P as MiniscriptKey>::Hash) -> Result<<Q as MiniscriptKey>::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 as MiniscriptKey>::Hash) -> Result<<Q as MiniscriptKey>::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
sourcefn 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
impl<Pk> Eq for Descriptor<Pk> where
Pk: Eq + MiniscriptKey,
impl<Pk> StructuralEq for Descriptor<Pk> where
Pk: MiniscriptKey,
impl<Pk> StructuralPartialEq for Descriptor<Pk> where
Pk: MiniscriptKey,
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: UnwindSafe + RefUnwindSafe,
<Pk as MiniscriptKey>::Hash: UnwindSafe + RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> CallHasher for T where
T: Hash + ?Sized,
impl<T> CallHasher for T where
T: Hash + ?Sized,
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more