Struct revault_tx::scripts::DepositDescriptor [−][src]
pub struct DepositDescriptor(_);
Expand description
A generalistic (with wildcard xpubs) deposit Miniscript descriptor.
Implementations
pub fn derive<C: Verification>(
&self,
child_number: ChildNumber,
secp: &Secp256k1<C>
) -> DerivedDepositDescriptor
pub fn derive<C: Verification>(
&self,
child_number: ChildNumber,
secp: &Secp256k1<C>
) -> DerivedDepositDescriptor
Derives all wildcard keys in the descriptor using the supplied child_number
Get all the xpubs used in this descriptor.
pub fn new(
stakeholders: Vec<DescriptorPublicKey>
) -> Result<DepositDescriptor, ScriptCreationError>
pub fn new(
stakeholders: Vec<DescriptorPublicKey>
) -> Result<DepositDescriptor, ScriptCreationError>
Get the xpub miniscript descriptor for deposit outputs.
The deposit policy is an N-of-N, so thresh(len(all_pubkeys), all_pubkeys)
.
Examples
use revault_tx::{scripts, miniscript::{bitcoin::{self, secp256k1, util::bip32}, DescriptorPublicKey, DescriptorTrait}};
use std::str::FromStr;
let first_stakeholder = DescriptorPublicKey::from_str("xpub6EHLFGpTTiZgHAHfBJ1LoepGFX5iyLeZ6CVtF9HhzeB1dkxLsEfkiJda78EKhSXuo2m8gQwAs4ZAbqaJixFYHMFWTL9DJX1KsAXS2VY5JJx/*").unwrap();
let second_stakeholder = DescriptorPublicKey::from_str("xpub6F2U61Uh9FNX94mZE6EgdZ3p5Wg8af6MHzFhskEskkAZ9ns2uvsnHBskU47wYY63yiYv8WufvTuHCePwUjK9zhKT1Cce8JGLBptncpvALw6/*").unwrap();
let deposit_descriptor =
scripts::DepositDescriptor::new(vec![first_stakeholder, second_stakeholder]).expect("Compiling descriptor");
println!("Deposit descriptor: {}", deposit_descriptor);
let desc_str = deposit_descriptor.to_string();
assert_eq!(deposit_descriptor, scripts::DepositDescriptor::from_str(&desc_str).unwrap());
let secp = secp256k1::Secp256k1::verification_only();
println!("Tenth child witness script: {}", deposit_descriptor.derive(bip32::ChildNumber::from(10), &secp).inner().explicit_script());
Errors
- If the given
DescriptorPublickKey
s are not wildcards (can be derived from). - If the given vector contains less than 2 public keys.
- If the policy compilation to miniscript failed, which should not happen (tm) and would be a bug.
Trait Implementations
type Err = ScriptCreationError
type Err = ScriptCreationError
The associated error which can be returned from parsing.
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
Auto Trait Implementations
impl RefUnwindSafe for DepositDescriptor
impl Send for DepositDescriptor
impl Sync for DepositDescriptor
impl Unpin for DepositDescriptor
impl UnwindSafe for DepositDescriptor
Blanket Implementations
Mutably borrows from an owned value. Read more