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.
This commit is contained in:
Antoine Poinsot 2023-03-23 19:11:39 +01:00
parent 8d1c6de5dd
commit 1a13b7a6f8
No known key found for this signature in database
GPG Key ID: E13FC145CD3F4304
5 changed files with 25 additions and 25 deletions

View File

@ -55,7 +55,7 @@ pub trait BitcoinInterface: Send {
fn received_coins(
&self,
tip: &BlockChainTip,
descs: &[descriptors::InheritanceDescriptor],
descs: &[descriptors::SinglePathLianaDesc],
) -> Vec<UTxO>;
/// 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<UTxO> {
let lsb_res = self.list_since_block(&tip.hash);
@ -338,7 +338,7 @@ impl BitcoinInterface for sync::Arc<sync::Mutex<dyn BitcoinInterface + 'static>>
fn received_coins(
&self,
tip: &BlockChainTip,
descs: &[descriptors::InheritanceDescriptor],
descs: &[descriptors::SinglePathLianaDesc],
) -> Vec<UTxO> {
self.lock().unwrap().received_coins(tip, descs)
}

View File

@ -28,7 +28,7 @@ fn update_coins(
bit: &impl BitcoinInterface,
db_conn: &mut Box<dyn DatabaseConnection>,
previous_tip: &BlockChainTip,
descs: &[descriptors::InheritanceDescriptor],
descs: &[descriptors::SinglePathLianaDesc],
secp: &secp256k1::Secp256k1<secp256k1::VerifyOnly>,
) -> 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<secp256k1::VerifyOnly>,
) {
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<secp256k1::VerifyOnly>,
) {
log::debug!("Checking the state of an ongoing rescan if there is any");

View File

@ -216,7 +216,7 @@ fn serializable_size<T: bitcoin::consensus::Encodable + ?Sized>(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 {

View File

@ -59,23 +59,23 @@ impl From<LianaPolicyError> 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<descriptor::DescriptorPublicKey>,
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<descriptor::DescriptorPublicKey>);
pub struct SinglePathLianaDesc(descriptor::Descriptor<descriptor::DescriptorPublicKey>);
/// Derived (containing only raw Bitcoin public keys) version of the inheritance descriptor.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct DerivedInheritanceDescriptor(descriptor::Descriptor<DerivedPublicKey>);
pub struct DerivedSinglePathLianaDesc(descriptor::Descriptor<DerivedPublicKey>);
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<descriptor::Descriptor<descriptor::DescriptorPublicKey>> for InheritanceDescriptor {
impl PartialEq<descriptor::Descriptor<descriptor::DescriptorPublicKey>> for SinglePathLianaDesc {
fn eq(&self, other: &descriptor::Descriptor<descriptor::DescriptorPublicKey>) -> 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<impl secp256k1::Verification>,
) -> 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<secp256k1::PublicKey, (bip32::Fingerprint, bip32::DerivationPath)>;
impl DerivedInheritanceDescriptor {
impl DerivedSinglePathLianaDesc {
pub fn address(&self, network: bitcoin::Network) -> bitcoin::Address {
self.0
.address(network)

View File

@ -60,7 +60,7 @@ impl BitcoinInterface for DummyBitcoind {
fn received_coins(
&self,
_: &BlockChainTip,
_: &[descriptors::InheritanceDescriptor],
_: &[descriptors::SinglePathLianaDesc],
) -> Vec<UTxO> {
Vec::new()
}