From 1a13b7a6f820e92ff436198bffc78b8ad785a758 Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Thu, 23 Mar 2023 19:11:39 +0100 Subject: [PATCH] descriptors: rename InheritanceDescriptor into SinglePathLianaDesc It was named at a time where there was an over emphasis on inheritance as a Liana usecase. In addition, "SinglePath" reflects better it is only one part of the main, multipath, Liana descriptor. --- src/bitcoin/mod.rs | 6 +++--- src/bitcoin/poller/looper.rs | 6 +++--- src/commands/mod.rs | 2 +- src/descriptors/mod.rs | 34 +++++++++++++++++----------------- src/testutils.rs | 2 +- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/bitcoin/mod.rs b/src/bitcoin/mod.rs index 20c22b0c..9aa2732e 100644 --- a/src/bitcoin/mod.rs +++ b/src/bitcoin/mod.rs @@ -55,7 +55,7 @@ pub trait BitcoinInterface: Send { fn received_coins( &self, tip: &BlockChainTip, - descs: &[descriptors::InheritanceDescriptor], + descs: &[descriptors::SinglePathLianaDesc], ) -> Vec; /// Get all coins that were confirmed, and at what height and time. Along with "expired" @@ -131,7 +131,7 @@ impl BitcoinInterface for d::BitcoinD { fn received_coins( &self, tip: &BlockChainTip, - descs: &[descriptors::InheritanceDescriptor], + descs: &[descriptors::SinglePathLianaDesc], ) -> Vec { let lsb_res = self.list_since_block(&tip.hash); @@ -338,7 +338,7 @@ impl BitcoinInterface for sync::Arc> fn received_coins( &self, tip: &BlockChainTip, - descs: &[descriptors::InheritanceDescriptor], + descs: &[descriptors::SinglePathLianaDesc], ) -> Vec { self.lock().unwrap().received_coins(tip, descs) } diff --git a/src/bitcoin/poller/looper.rs b/src/bitcoin/poller/looper.rs index d94bc07c..99ec8a3d 100644 --- a/src/bitcoin/poller/looper.rs +++ b/src/bitcoin/poller/looper.rs @@ -28,7 +28,7 @@ fn update_coins( bit: &impl BitcoinInterface, db_conn: &mut Box, previous_tip: &BlockChainTip, - descs: &[descriptors::InheritanceDescriptor], + descs: &[descriptors::SinglePathLianaDesc], secp: &secp256k1::Secp256k1, ) -> UpdatedCoins { let curr_coins = db_conn.coins(CoinType::All); @@ -189,7 +189,7 @@ fn new_tip(bit: &impl BitcoinInterface, current_tip: &BlockChainTip) -> TipUpdat fn updates( bit: &impl BitcoinInterface, db: &impl DatabaseInterface, - descs: &[descriptors::InheritanceDescriptor], + descs: &[descriptors::SinglePathLianaDesc], secp: &secp256k1::Secp256k1, ) { let mut db_conn = db.connection(); @@ -238,7 +238,7 @@ fn updates( fn rescan_check( bit: &impl BitcoinInterface, db: &impl DatabaseInterface, - descs: &[descriptors::InheritanceDescriptor], + descs: &[descriptors::SinglePathLianaDesc], secp: &secp256k1::Secp256k1, ) { log::debug!("Checking the state of an ongoing rescan if there is any"); diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 7449b8fe..379141f8 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -216,7 +216,7 @@ fn serializable_size(t: &T) -> u64 { impl DaemonControl { // Get the derived descriptor for this coin - fn derived_desc(&self, coin: &Coin) -> descriptors::DerivedInheritanceDescriptor { + fn derived_desc(&self, coin: &Coin) -> descriptors::DerivedSinglePathLianaDesc { let desc = if coin.is_change { self.config.main_descriptor.change_descriptor() } else { diff --git a/src/descriptors/mod.rs b/src/descriptors/mod.rs index 3744b87f..05b55bab 100644 --- a/src/descriptors/mod.rs +++ b/src/descriptors/mod.rs @@ -59,23 +59,23 @@ impl From for LianaDescError { } } -/// An [InheritanceDescriptor] that contains multipath keys for (and only for) the receive keychain +/// An [SinglePathLianaDesc] that contains multipath keys for (and only for) the receive keychain /// and the change keychain. #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub struct LianaDescriptor { multi_desc: descriptor::Descriptor, - receive_desc: InheritanceDescriptor, - change_desc: InheritanceDescriptor, + receive_desc: SinglePathLianaDesc, + change_desc: SinglePathLianaDesc, } /// A Miniscript descriptor with a main, unencombered, branch (the main owner of the coins) /// and a timelocked branch (the heir). All keys in this descriptor are singlepath. #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -pub struct InheritanceDescriptor(descriptor::Descriptor); +pub struct SinglePathLianaDesc(descriptor::Descriptor); /// Derived (containing only raw Bitcoin public keys) version of the inheritance descriptor. #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -pub struct DerivedInheritanceDescriptor(descriptor::Descriptor); +pub struct DerivedSinglePathLianaDesc(descriptor::Descriptor); impl fmt::Display for LianaDescriptor { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { @@ -103,8 +103,8 @@ impl str::FromStr for LianaDescriptor { .expect("Can't error, all paths have the same length") .into_iter(); assert_eq!(singlepath_descs.len(), 2); - let receive_desc = InheritanceDescriptor(singlepath_descs.next().expect("First of 2")); - let change_desc = InheritanceDescriptor(singlepath_descs.next().expect("Second of 2")); + let receive_desc = SinglePathLianaDesc(singlepath_descs.next().expect("First of 2")); + let change_desc = SinglePathLianaDesc(singlepath_descs.next().expect("Second of 2")); Ok(LianaDescriptor { multi_desc: desc, @@ -114,13 +114,13 @@ impl str::FromStr for LianaDescriptor { } } -impl fmt::Display for InheritanceDescriptor { +impl fmt::Display for SinglePathLianaDesc { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.0) } } -impl PartialEq> for InheritanceDescriptor { +impl PartialEq> for SinglePathLianaDesc { fn eq(&self, other: &descriptor::Descriptor) -> bool { self.0.eq(other) } @@ -141,8 +141,8 @@ impl LianaDescriptor { .expect("Can't error, all paths have the same length") .into_iter(); assert_eq!(singlepath_descs.len(), 2); - let receive_desc = InheritanceDescriptor(singlepath_descs.next().expect("First of 2")); - let change_desc = InheritanceDescriptor(singlepath_descs.next().expect("Second of 2")); + let receive_desc = SinglePathLianaDesc(singlepath_descs.next().expect("First of 2")); + let change_desc = SinglePathLianaDesc(singlepath_descs.next().expect("Second of 2")); LianaDescriptor { multi_desc, @@ -163,12 +163,12 @@ impl LianaDescriptor { } /// Get the descriptor for receiving addresses. - pub fn receive_descriptor(&self) -> &InheritanceDescriptor { + pub fn receive_descriptor(&self) -> &SinglePathLianaDesc { &self.receive_desc } /// Get the descriptor for change addresses. - pub fn change_descriptor(&self) -> &InheritanceDescriptor { + pub fn change_descriptor(&self) -> &SinglePathLianaDesc { &self.change_desc } @@ -289,7 +289,7 @@ impl LianaDescriptor { } } -impl InheritanceDescriptor { +impl SinglePathLianaDesc { /// Derive this descriptor at a given index for a receiving address. /// /// # Panics @@ -298,7 +298,7 @@ impl InheritanceDescriptor { &self, index: bip32::ChildNumber, secp: &secp256k1::Secp256k1, - ) -> DerivedInheritanceDescriptor { + ) -> DerivedSinglePathLianaDesc { assert!(index.is_normal()); // Unfortunately we can't just use `self.0.at_derivation_index().derived_descriptor()` @@ -338,7 +338,7 @@ impl InheritanceDescriptor { ); } - DerivedInheritanceDescriptor( + DerivedSinglePathLianaDesc( self.0 .translate_pk(&mut Derivator(index.into(), secp)) .expect( @@ -351,7 +351,7 @@ impl InheritanceDescriptor { /// Map of a raw public key to the xpub used to derive it and its derivation path pub type Bip32Deriv = BTreeMap; -impl DerivedInheritanceDescriptor { +impl DerivedSinglePathLianaDesc { pub fn address(&self, network: bitcoin::Network) -> bitcoin::Address { self.0 .address(network) diff --git a/src/testutils.rs b/src/testutils.rs index 33d5e8dd..482fdf67 100644 --- a/src/testutils.rs +++ b/src/testutils.rs @@ -60,7 +60,7 @@ impl BitcoinInterface for DummyBitcoind { fn received_coins( &self, _: &BlockChainTip, - _: &[descriptors::InheritanceDescriptor], + _: &[descriptors::SinglePathLianaDesc], ) -> Vec { Vec::new() }