diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 2d0c3014..8fbb363f 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -306,7 +306,7 @@ impl DaemonControl { .receive_descriptor() .derive(index, &self.secp) .address(self.config.bitcoin_config.network); - GetAddressResult::new(address) + GetAddressResult::new(address, index) } /// list addresses @@ -945,7 +945,17 @@ pub struct GetInfoResult { #[derive(Debug, Clone, Serialize, Deserialize)] pub struct GetAddressResult { #[serde(deserialize_with = "deser_addr_assume_checked")] - address: bitcoin::Address, + pub address: bitcoin::Address, + pub derivation_index: bip32::ChildNumber, +} + +impl GetAddressResult { + pub fn new(address: bitcoin::Address, derivation_index: bip32::ChildNumber) -> Self { + Self { + address, + derivation_index, + } + } } #[derive(Debug, Clone, Serialize, Deserialize)] @@ -953,16 +963,6 @@ pub struct GetLabelsResult { pub labels: HashMap, } -impl GetAddressResult { - pub fn new(address: bitcoin::Address) -> Self { - Self { address } - } - - pub fn address(&self) -> &bitcoin::Address { - &self.address - } -} - #[derive(Debug, Clone, Serialize, PartialEq, Eq)] pub struct AddressInfo { index: u32, diff --git a/tests/test_rpc.py b/tests/test_rpc.py index e492da65..f1bed23b 100644 --- a/tests/test_rpc.py +++ b/tests/test_rpc.py @@ -35,6 +35,8 @@ def test_getaddress(lianad): assert "address" in res # We'll get a new one at every call assert res["address"] != lianad.rpc.getnewaddress()["address"] + # new address has derivation_index higher than the previous one + assert lianad.rpc.getnewaddress()["derivation_index"] == res["derivation_index"] + 2 def test_listaddresses(lianad):