Add derivation_index to GetAddressResult
The derivation index is required for for client to derive and verify the address on hardware wallets. Co-Authored-By: Antoine Poinsot <darosior@protonmail.com>
This commit is contained in:
parent
bd71cd646c
commit
33384c89b5
@ -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<String, String>,
|
||||
}
|
||||
|
||||
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,
|
||||
|
||||
@ -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):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user