pub struct Wsh<Pk: MiniscriptKey> { /* private fields */ }
Expand description
A Segwitv0 wsh descriptor
Implementations§
Source§impl<Pk: MiniscriptKey> Wsh<Pk>
impl<Pk: MiniscriptKey> Wsh<Pk>
Sourcepub fn into_inner(self) -> WshInner<Pk>
pub fn into_inner(self) -> WshInner<Pk>
Get the Inner
Sourcepub fn new_sortedmulti(k: usize, pks: Vec<Pk>) -> Result<Self, Error>
pub fn new_sortedmulti(k: usize, pks: Vec<Pk>) -> Result<Self, Error>
Create a new sortedmulti wsh descriptor
Sourcepub fn to_string_no_checksum(&self) -> String
pub fn to_string_no_checksum(&self) -> String
Get the descriptor without the checksum
Source§impl<Pk: MiniscriptKey + ToPublicKey> Wsh<Pk>
impl<Pk: MiniscriptKey + ToPublicKey> Wsh<Pk>
Sourcepub fn spk(&self) -> Script
pub fn spk(&self) -> Script
Obtain the corresponding script pubkey for this descriptor
Non failing verion of DescriptorTrait::script_pubkey
for this descriptor
Examples found in repository?
examples/parse.rs (line 50)
23fn main() {
24 let my_descriptor = miniscript::Descriptor::<bitcoin::PublicKey>::from_str(
25 "wsh(c:pk_k(020202020202020202020202020202020202020202020202020202020202020202))",
26 )
27 .unwrap();
28
29 // Check whether the descriptor is safe
30 // This checks whether all spend paths are accessible in bitcoin network.
31 // It maybe possible that some of the spend require more than 100 elements in Wsh scripts
32 // Or they contain a combination of timelock and heightlock.
33 assert!(my_descriptor.sanity_check().is_ok());
34
35 // Compute the script pubkey. As mentioned in the documentation, script_pubkey only fails
36 // for Tr descriptors that don't have some pre-computed data
37 assert_eq!(
38 format!("{:x}", my_descriptor.script_pubkey()),
39 "0020daef16dd7c946a3e735a6e43310cb2ce33dfd14a04f76bf8241a16654cb2f0f9"
40 );
41
42 // Another way to compute script pubkey
43 // We can also compute the type of descriptor
44 let desc_type = my_descriptor.desc_type();
45 assert_eq!(desc_type, DescriptorType::Wsh);
46 // Since we know the type of descriptor, we can get the Wsh struct from Descriptor
47 // This allows us to call infallible methods for getting script pubkey
48 if let Descriptor::Wsh(wsh) = &my_descriptor {
49 assert_eq!(
50 format!("{:x}", wsh.spk()),
51 "0020daef16dd7c946a3e735a6e43310cb2ce33dfd14a04f76bf8241a16654cb2f0f9"
52 );
53 } else {
54 // We checked for the descriptor type earlier
55 }
56
57 // Get the inner script inside the descriptor
58 assert_eq!(
59 format!(
60 "{:x}",
61 my_descriptor
62 .explicit_script()
63 .expect("Wsh descriptors have inner scripts")
64 ),
65 "21020202020202020202020202020202020202020202020202020202020202020202ac"
66 );
67
68 let desc = miniscript::Descriptor::<bitcoin::PublicKey>::from_str(
69 "sh(wsh(c:pk_k(020202020202020202020202020202020202020202020202020202020202020202)))",
70 )
71 .unwrap();
72
73 assert!(desc.desc_type() == DescriptorType::ShWsh);
74}
Sourcepub fn addr(&self, network: Network) -> Address
pub fn addr(&self, network: Network) -> Address
Obtain the corresponding script pubkey for this descriptor
Non failing verion of DescriptorTrait::address
for this descriptor
Sourcepub fn inner_script(&self) -> Script
pub fn inner_script(&self) -> Script
Obtain the underlying miniscript for this descriptor
Non failing verion of DescriptorTrait::explicit_script
for this descriptor
Sourcepub fn ecdsa_sighash_script_code(&self) -> Script
pub fn ecdsa_sighash_script_code(&self) -> Script
Obtain the pre bip-340 signature script code for this descriptor
Non failing verion of DescriptorTrait::script_code
for this descriptor
Trait Implementations§
Source§impl<Pk: MiniscriptKey> Debug for Wsh<Pk>
impl<Pk: MiniscriptKey> Debug for Wsh<Pk>
Source§impl<Pk: MiniscriptKey> DescriptorTrait<Pk> for Wsh<Pk>
impl<Pk: MiniscriptKey> DescriptorTrait<Pk> for Wsh<Pk>
Source§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
Source§fn 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
Some descriptors like pk() don’t have any address.
Errors: Read more
Source§fn script_pubkey(&self) -> Scriptwhere
Pk: ToPublicKey,
fn script_pubkey(&self) -> Scriptwhere
Pk: ToPublicKey,
Computes the scriptpubkey of the descriptor
Source§fn unsigned_script_sig(&self) -> Scriptwhere
Pk: ToPublicKey,
fn unsigned_script_sig(&self) -> Scriptwhere
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. Read more
Source§fn explicit_script(&self) -> Result<Script, Error>where
Pk: ToPublicKey,
fn explicit_script(&self) -> Result<Script, Error>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.
For Tr
descriptors, this will error as there is no underlying scriptSource§fn get_satisfaction<S>(
&self,
satisfier: S,
) -> Result<(Vec<Vec<u8>>, Script), Error>where
Pk: ToPublicKey,
S: Satisfier<Pk>,
fn get_satisfaction<S>(
&self,
satisfier: S,
) -> Result<(Vec<Vec<u8>>, Script), Error>where
Pk: ToPublicKey,
S: Satisfier<Pk>,
Returns satisfying non-malleable witness and scriptSig with minimum weight to spend an
output controlled by the given descriptor if it possible to
construct one using the satisfier S.
Source§fn get_satisfaction_mall<S>(
&self,
satisfier: S,
) -> Result<(Vec<Vec<u8>>, Script), Error>where
Pk: ToPublicKey,
S: Satisfier<Pk>,
fn get_satisfaction_mall<S>(
&self,
satisfier: S,
) -> Result<(Vec<Vec<u8>>, Script), Error>where
Pk: ToPublicKey,
S: Satisfier<Pk>,
Returns satisfying, possibly malleable witness and scriptSig to spend an
output controlled by the given descriptor if it possible to
construct one using the satisfier S.
Source§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 ec-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))
Source§fn script_code(&self) -> Result<Script, Error>where
Pk: ToPublicKey,
fn script_code(&self) -> Result<Script, Error>where
Pk: ToPublicKey,
Get the
scriptCode
of a transaction output. Read moreSource§impl<Pk: MiniscriptKey> Display for Wsh<Pk>
impl<Pk: MiniscriptKey> Display for Wsh<Pk>
Source§impl<Pk: MiniscriptKey> ForEachKey<Pk> for Wsh<Pk>
impl<Pk: MiniscriptKey> ForEachKey<Pk> for Wsh<Pk>
Source§impl<Pk: MiniscriptKey> From<Wsh<Pk>> for Descriptor<Pk>
impl<Pk: MiniscriptKey> From<Wsh<Pk>> for Descriptor<Pk>
Source§impl<Pk: MiniscriptKey> Liftable<Pk> for Wsh<Pk>
impl<Pk: MiniscriptKey> Liftable<Pk> for Wsh<Pk>
Source§impl<Pk: Ord + MiniscriptKey> Ord for Wsh<Pk>
impl<Pk: Ord + MiniscriptKey> Ord for Wsh<Pk>
Source§impl<Pk: PartialOrd + MiniscriptKey> PartialOrd for Wsh<Pk>
impl<Pk: PartialOrd + MiniscriptKey> PartialOrd for Wsh<Pk>
Source§impl<Pk: MiniscriptKey> PreTaprootDescriptorTrait<Pk> for Wsh<Pk>
impl<Pk: MiniscriptKey> PreTaprootDescriptorTrait<Pk> for Wsh<Pk>
Source§fn explicit_script(&self) -> Scriptwhere
Pk: ToPublicKey,
fn explicit_script(&self) -> Scriptwhere
Pk: ToPublicKey,
Same as
DescriptorTrait::explicit_script
, but a non failing version.
All PreTaproot descriptors have a unique explicit scriptSource§fn script_code(&self) -> Scriptwhere
Pk: ToPublicKey,
fn script_code(&self) -> Scriptwhere
Pk: ToPublicKey,
Same as
DescriptorTrait::script_code
, but a non failing version.
All PreTaproot descriptors have a script codeSource§impl<P: MiniscriptKey, Q: MiniscriptKey> TranslatePk<P, Q> for Wsh<P>
impl<P: MiniscriptKey, Q: MiniscriptKey> TranslatePk<P, Q> for Wsh<P>
Source§fn translate_pk<Fpk, Fpkh, E>(
&self,
translatefpk: Fpk,
translatefpkh: Fpkh,
) -> Result<Self::Output, E>
fn translate_pk<Fpk, Fpkh, E>( &self, translatefpk: Fpk, translatefpkh: Fpkh, ) -> Result<Self::Output, E>
Translate a struct from one Generic to another where the
translation for Pk is provided by translatefpk, and translation for
PkH is provided by translatefpkh
impl<Pk: Eq + MiniscriptKey> Eq for Wsh<Pk>
impl<Pk: MiniscriptKey> StructuralPartialEq for Wsh<Pk>
Auto Trait Implementations§
impl<Pk> Freeze for Wsh<Pk>
impl<Pk> RefUnwindSafe for Wsh<Pk>
impl<Pk> Send for Wsh<Pk>
impl<Pk> Sync for Wsh<Pk>
impl<Pk> Unpin for Wsh<Pk>
impl<Pk> UnwindSafe for Wsh<Pk>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<P, Q, T> TranslatePk1<P, Q> for T
impl<P, Q, T> TranslatePk1<P, Q> for T
Source§fn translate_pk1<Fpk, E>(
&self,
translatefpk: Fpk,
) -> Result<<Self as TranslatePk<P, Q>>::Output, E>
fn translate_pk1<Fpk, E>( &self, translatefpk: Fpk, ) -> Result<<Self as TranslatePk<P, Q>>::Output, E>
Translate a struct from one generic to another where the
translation for Pk is provided by translatefpk
Source§fn translate_pk1_infallible<Fpk: FnMut(&P) -> Q>(
&self,
translatefpk: Fpk,
) -> <Self as TranslatePk<P, Q>>::Output
fn translate_pk1_infallible<Fpk: FnMut(&P) -> Q>( &self, translatefpk: Fpk, ) -> <Self as TranslatePk<P, Q>>::Output
Translate a struct from one generic to another where the
translation for Pk is provided by translatefpk
Source§impl<P, Q, T> TranslatePk2<P, Q> for T
impl<P, Q, T> TranslatePk2<P, Q> for T
Source§fn translate_pk2<Fpk: Fn(&P) -> Result<Q, E>, E>(
&self,
translatefpk: Fpk,
) -> Result<<Self as TranslatePk<P, Q>>::Output, E>
fn translate_pk2<Fpk: Fn(&P) -> Result<Q, E>, E>( &self, translatefpk: Fpk, ) -> Result<<Self as TranslatePk<P, Q>>::Output, E>
Translate a struct from one generic to another where the
translation for Pk is provided by translatefpk
Source§fn translate_pk2_infallible<Fpk: Fn(&P) -> Q>(
&self,
translatefpk: Fpk,
) -> <Self as TranslatePk<P, Q>>::Output
fn translate_pk2_infallible<Fpk: Fn(&P) -> Q>( &self, translatefpk: Fpk, ) -> <Self as TranslatePk<P, Q>>::Output
Translate a struct from one generic to another where the
translation for Pk is provided by translatefpk
Source§impl<P, Q, T> TranslatePk3<P, Q> for T
impl<P, Q, T> TranslatePk3<P, Q> for T
Source§fn translate_pk3<Fpk, E>(
&self,
translatefpk: Fpk,
) -> Result<<Self as TranslatePk<P, Q>>::Output, E>
fn translate_pk3<Fpk, E>( &self, translatefpk: Fpk, ) -> Result<<Self as TranslatePk<P, Q>>::Output, E>
Translate a struct from one generic to another where the
translation for Pk is provided by translatefpk
Source§fn translate_pk3_infallible<Fpk: FnMut(&P) -> Q>(
&self,
translatefpk: Fpk,
) -> <Self as TranslatePk<P, Q>>::Output
fn translate_pk3_infallible<Fpk: FnMut(&P) -> Q>( &self, translatefpk: Fpk, ) -> <Self as TranslatePk<P, Q>>::Output
Translate a struct from one generic to another where the
translation for Pk is provided by translatefpk