Skip to content

Commit 79053a5

Browse files
committed
[rpc] [wallet] Add 'hdmasterkeyid' alias return values.
Restores the return value in getwalletinfo() and getaddressinfo() RPC methods for backwards compatibility
1 parent c75c351 commit 79053a5

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/wallet/rpcwallet.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2926,6 +2926,7 @@ static UniValue getwalletinfo(const JSONRPCRequest& request)
29262926
" \"unlocked_until\": ttt, (numeric) the timestamp in seconds since epoch (midnight Jan 1 1970 GMT) that the wallet is unlocked for transfers, or 0 if the wallet is locked\n"
29272927
" \"paytxfee\": x.xxxx, (numeric) the transaction fee configuration, set in " + CURRENCY_UNIT + "/kB\n"
29282928
" \"hdseedid\": \"<hash160>\" (string, optional) the Hash160 of the HD seed (only present when HD is enabled)\n"
2929+
" \"hdmasterkeyid\": \"<hash160>\" (string, optional) alias for hdseedid retained for backwards-compatibility. Will be removed in V0.18.\n"
29292930
"}\n"
29302931
"\nExamples:\n"
29312932
+ HelpExampleCli("getwalletinfo", "")
@@ -2957,8 +2958,10 @@ static UniValue getwalletinfo(const JSONRPCRequest& request)
29572958
obj.pushKV("unlocked_until", pwallet->nRelockTime);
29582959
}
29592960
obj.pushKV("paytxfee", ValueFromAmount(pwallet->m_pay_tx_fee.GetFeePerK()));
2960-
if (!seed_id.IsNull())
2961+
if (!seed_id.IsNull()) {
29612962
obj.pushKV("hdseedid", seed_id.GetHex());
2963+
obj.pushKV("hdmasterkeyid", seed_id.GetHex());
2964+
}
29622965
return obj;
29632966
}
29642967

@@ -3955,6 +3958,7 @@ UniValue getaddressinfo(const JSONRPCRequest& request)
39553958
" \"timestamp\" : timestamp, (number, optional) The creation time of the key if available in seconds since epoch (Jan 1 1970 GMT)\n"
39563959
" \"hdkeypath\" : \"keypath\" (string, optional) The HD keypath if the key is HD and available\n"
39573960
" \"hdseedid\" : \"<hash160>\" (string, optional) The Hash160 of the HD seed\n"
3961+
" \"hdmasterkeyid\" : \"<hash160>\" (string, optional) alias for hdseedid maintained for backwards compatibility. Will be removed in V0.18.\n"
39583962
" \"labels\" (object) Array of labels associated with the address.\n"
39593963
" [\n"
39603964
" { (json object of label data)\n"
@@ -4015,6 +4019,7 @@ UniValue getaddressinfo(const JSONRPCRequest& request)
40154019
if (!meta->hdKeypath.empty()) {
40164020
ret.pushKV("hdkeypath", meta->hdKeypath);
40174021
ret.pushKV("hdseedid", meta->hd_seed_id.GetHex());
4022+
ret.pushKV("hdmasterkeyid", meta->hd_seed_id.GetHex());
40184023
}
40194024
}
40204025

test/functional/wallet_hd.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def run_test(self):
3030

3131
# Make sure we use hd, keep masterkeyid
3232
masterkeyid = self.nodes[1].getwalletinfo()['hdseedid']
33+
assert_equal(masterkeyid, self.nodes[1].getwalletinfo()['hdmasterkeyid'])
3334
assert_equal(len(masterkeyid), 40)
3435

3536
# create an internal key
@@ -55,6 +56,7 @@ def run_test(self):
5556
hd_info = self.nodes[1].getaddressinfo(hd_add)
5657
assert_equal(hd_info["hdkeypath"], "m/0'/0'/"+str(i)+"'")
5758
assert_equal(hd_info["hdseedid"], masterkeyid)
59+
assert_equal(hd_info["hdmasterkeyid"], masterkeyid)
5860
self.nodes[0].sendtoaddress(hd_add, 1)
5961
self.nodes[0].generate(1)
6062
self.nodes[0].sendtoaddress(non_hd_add, 1)
@@ -84,6 +86,7 @@ def run_test(self):
8486
hd_info_2 = self.nodes[1].getaddressinfo(hd_add_2)
8587
assert_equal(hd_info_2["hdkeypath"], "m/0'/0'/"+str(i)+"'")
8688
assert_equal(hd_info_2["hdseedid"], masterkeyid)
89+
assert_equal(hd_info_2["hdmasterkeyid"], masterkeyid)
8790
assert_equal(hd_add, hd_add_2)
8891
connect_nodes_bi(self.nodes, 0, 1)
8992
self.sync_all()

test/functional/wallet_keypool.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def run_test(self):
1616
addr_before_encrypting = nodes[0].getnewaddress()
1717
addr_before_encrypting_data = nodes[0].getaddressinfo(addr_before_encrypting)
1818
wallet_info_old = nodes[0].getwalletinfo()
19+
assert_equal(wallet_info_old['hdseedid'], wallet_info_old['hdmasterkeyid'])
1920
assert(addr_before_encrypting_data['hdseedid'] == wallet_info_old['hdseedid'])
2021

2122
# Encrypt wallet and wait to terminate
@@ -26,6 +27,7 @@ def run_test(self):
2627
addr = nodes[0].getnewaddress()
2728
addr_data = nodes[0].getaddressinfo(addr)
2829
wallet_info = nodes[0].getwalletinfo()
30+
assert_equal(wallet_info['hdseedid'], wallet_info['hdmasterkeyid'])
2931
assert(addr_before_encrypting_data['hdseedid'] != wallet_info['hdseedid'])
3032
assert(addr_data['hdseedid'] == wallet_info['hdseedid'])
3133
assert_raises_rpc_error(-12, "Error: Keypool ran out, please call keypoolrefill first", nodes[0].getnewaddress)

0 commit comments

Comments
 (0)