From 3105b86a28444097e20e14261ffbfd5448b2854b Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Thu, 20 Oct 2022 18:33:09 +0200 Subject: [PATCH] Use my own fork of rust-miniscript It supports multipath descriptors. We'll need to find a solution for the release --- Cargo.lock | 3 +-- Cargo.toml | 3 ++- src/descriptors.rs | 16 +++++++++++++--- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dea18ca3..12079160 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -256,8 +256,7 @@ dependencies = [ [[package]] name = "miniscript" version = "8.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4975078076f0b7b914a3044ad7432d2a7fcec38edb855afdc672e24ca35b69" +source = "git+https://github.com/darosior/rust-miniscript?branch=multipath_descriptors_on_8.0#7d756f2ab066d85d299f711f953ebda15f14e832" dependencies = [ "bitcoin", "serde", diff --git a/Cargo.toml b/Cargo.toml index 35a61ff4..36033c17 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,8 @@ jsonrpc_server = [] [dependencies] # For managing transactions (it re-exports the bitcoin crate) -miniscript = { version = "8.0", features = ["serde"] } +# TODO: don't use my fork for a real release.. +miniscript = { git = "https://github.com/darosior/rust-miniscript", branch = "multipath_descriptors_on_8.0", features = ["serde"] } # Don't reinvent the wheel dirs = "3.0" diff --git a/src/descriptors.rs b/src/descriptors.rs index 4336903c..8a595f46 100644 --- a/src/descriptors.rs +++ b/src/descriptors.rs @@ -125,6 +125,10 @@ impl MiniscriptKey for DerivedPublicKey { fn is_x_only_key(&self) -> bool { false } + + fn num_der_paths(&self) -> usize { + 0 + } } impl ToPublicKey for DerivedPublicKey { @@ -164,7 +168,8 @@ fn csv_check(csv_value: u32) -> Result<(), DescCreationError> { fn is_unhardened_deriv(key: &descriptor::DescriptorPublicKey) -> bool { match *key { - descriptor::DescriptorPublicKey::Single(..) => false, + descriptor::DescriptorPublicKey::Single(..) + | descriptor::DescriptorPublicKey::MultiXPub(..) => false, descriptor::DescriptorPublicKey::XPub(ref xpub) => { xpub.wildcard == descriptor::Wildcard::Unhardened } @@ -342,10 +347,15 @@ impl InheritanceDescriptor { &mut self, pk: &descriptor::DescriptorPublicKey, ) -> Result { - let definite_key = pk.clone().at_derivation_index(self.0); + let definite_key = pk + .clone() + .at_derivation_index(self.0) + .expect("We disallow multipath keys."); let origin = ( definite_key.master_fingerprint(), - definite_key.full_derivation_path(), + definite_key + .full_derivation_path() + .expect("We disallow multipath keys."), ); let key = definite_key.derive_public_key(self.1)?; Ok(DerivedPublicKey { origin, key })