Struct revault_tx::scripts::UnvaultDescriptor [−][src]
pub struct UnvaultDescriptor(_);
Expand description
A generalistic (with wildcard xpubs) Unvault miniscript descriptor.
Implementations
pub fn derive<C: Verification>(
&self,
child_number: ChildNumber,
secp: &Secp256k1<C>
) -> DerivedUnvaultDescriptor
pub fn derive<C: Verification>(
&self,
child_number: ChildNumber,
secp: &Secp256k1<C>
) -> DerivedUnvaultDescriptor
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>,
managers: Vec<DescriptorPublicKey>,
managers_threshold: usize,
cosigners: Vec<DescriptorPublicKey>,
csv_value: u32
) -> Result<UnvaultDescriptor, ScriptCreationError>
pub fn new(
stakeholders: Vec<DescriptorPublicKey>,
managers: Vec<DescriptorPublicKey>,
managers_threshold: usize,
cosigners: Vec<DescriptorPublicKey>,
csv_value: u32
) -> Result<UnvaultDescriptor, ScriptCreationError>
Get the miniscript descriptors for Unvault outputs.
The Unvault policy allows either all the stakeholders to spend, or the fund managers after a timelock. Depending on the kind of spending policies required, Cosigning Servers may be deployed to be used as anti-replay oracles and their signature required along with the managers’.
Examples
Without Cosigning Servers
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 third_stakeholder = DescriptorPublicKey::from_str("xpub6Br1DUfrzxTVGo1sanuKDCUmSxDfLRrxLQBqpMqygkQLkQWodoyvvGtUV8Rp3r6d6BNYvedBSU8c7whhn2U8haRVxsWwuQiZ9LoFp7jXPQA/*").unwrap();
let first_manager = DescriptorPublicKey::from_str("xpub6Duq1ob3cQ8Wxees2fTGNK2wTsVjgTPQcKJiPquXY2rQJTDjeCxkXFxTCGhcunFDt26Ddz45KQu7pbLmmUGG2PXTRVx3iDpBPEhdrijJf4U/*").unwrap();
let second_manager = DescriptorPublicKey::from_str("xpub6EWL35hY9uZZs5Ljt6J3G2ZK1Tu4GPVkFdeGvMknG3VmwVRHhtadCaw5hdRDBgrmx1nPVHWjGBb5xeuC1BfbJzjjcic2gNm1aA7ywWjj7G8/*").unwrap();
let unvault_descriptor = scripts::UnvaultDescriptor::new(
vec![first_stakeholder, second_stakeholder, third_stakeholder],
vec![first_manager, second_manager],
1,
// No cosigning server
vec![],
// CSV
42
).expect("Compiling descriptor");
println!("Unvault descriptor: {}", unvault_descriptor);
let desc_str = unvault_descriptor.to_string();
assert_eq!(unvault_descriptor, scripts::UnvaultDescriptor::from_str(&desc_str).unwrap());
let secp = secp256k1::Secp256k1::verification_only();
println!("Tenth child witness script: {}", unvault_descriptor.derive(bip32::ChildNumber::from(10), &secp).inner().explicit_script());
With Cosigning Servers
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 third_stakeholder = DescriptorPublicKey::from_str("xpub6Br1DUfrzxTVGo1sanuKDCUmSxDfLRrxLQBqpMqygkQLkQWodoyvvGtUV8Rp3r6d6BNYvedBSU8c7whhn2U8haRVxsWwuQiZ9LoFp7jXPQA/*").unwrap();
let first_cosig = DescriptorPublicKey::from_str("02a489e0ea42b56148d212d325b7c67c6460483ff931c303ea311edfef667c8f35").unwrap();
let second_cosig = DescriptorPublicKey::from_str("02767e6dde4877dcbf64de8a45fe1a0575dfc6b0ed06648f1022412c172ebd875c").unwrap();
let third_cosig = DescriptorPublicKey::from_str("0371cdea381b365ea159a3cf4f14029d1bff5b36b4cf12ac9e42be6955d2ed4ecf").unwrap();
let first_manager = DescriptorPublicKey::from_str("xpub6Duq1ob3cQ8Wxees2fTGNK2wTsVjgTPQcKJiPquXY2rQJTDjeCxkXFxTCGhcunFDt26Ddz45KQu7pbLmmUGG2PXTRVx3iDpBPEhdrijJf4U/*").unwrap();
let second_manager = DescriptorPublicKey::from_str("xpub6EWL35hY9uZZs5Ljt6J3G2ZK1Tu4GPVkFdeGvMknG3VmwVRHhtadCaw5hdRDBgrmx1nPVHWjGBb5xeuC1BfbJzjjcic2gNm1aA7ywWjj7G8/*").unwrap();
let unvault_descriptor = scripts::UnvaultDescriptor::new(
vec![first_stakeholder, second_stakeholder, third_stakeholder],
vec![first_manager, second_manager],
1,
// Cosigning servers
vec![first_cosig, second_cosig, third_cosig],
// CSV
42
).expect("Compiling descriptor");
println!("Unvault descriptor: {}", unvault_descriptor);
let desc_str = unvault_descriptor.to_string();
assert_eq!(unvault_descriptor, scripts::UnvaultDescriptor::from_str(&desc_str).unwrap());
let secp = secp256k1::Secp256k1::verification_only();
println!("Tenth child witness script: {}", unvault_descriptor.derive(bip32::ChildNumber::from(10), &secp).inner().explicit_script());
Errors
- If the stakeholders and managers
DescriptorPublickKey
s are not wildcards (can be derived from). - If the cosigning servers public keys vector is both not empty and not of the same length as the stakeholders public keys vec
- If the policy compilation to miniscript failed (eg if a key is used twice)
Get the relative locktime in blocks contained in the Unvault descriptor
Get the minimum number of managers required to sign along with the timelock and the (optional) Cosigning Servers
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 UnvaultDescriptor
impl Send for UnvaultDescriptor
impl Sync for UnvaultDescriptor
impl Unpin for UnvaultDescriptor
impl UnwindSafe for UnvaultDescriptor
Blanket Implementations
Mutably borrows from an owned value. Read more