Skip to content

Commit b1c7b24

Browse files
committed
[Wallet] report optional HDKeypath/HDMasterKeyId in validateaddress
1 parent 5b95dd2 commit b1c7b24

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/rpc/misc.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ UniValue validateaddress(const UniValue& params, bool fHelp)
166166
" \"pubkey\" : \"publickeyhex\", (string) The hex value of the raw public key\n"
167167
" \"iscompressed\" : true|false, (boolean) If the address is compressed\n"
168168
" \"account\" : \"account\" (string) DEPRECATED. The account associated with the address, \"\" is the default account\n"
169+
" \"hdkeypath\" : \"keypath\" (string, optional) The HD keypath if the key is HD and available\n"
170+
" \"hdmasterkeyid\" : \"<hash160>\" (string, optional) The Hash160 of the HD master pubkey\n"
169171
"}\n"
170172
"\nExamples:\n"
171173
+ HelpExampleCli("validateaddress", "\"1PSSGeFHDnKNxiEyFrD1wcEaHr9hrQDDWc\"")
@@ -200,6 +202,12 @@ UniValue validateaddress(const UniValue& params, bool fHelp)
200202
ret.pushKVs(detail);
201203
if (pwalletMain && pwalletMain->mapAddressBook.count(dest))
202204
ret.push_back(Pair("account", pwalletMain->mapAddressBook[dest].name));
205+
CKeyID keyID;
206+
if (pwalletMain && address.GetKeyID(keyID) && pwalletMain->mapKeyMetadata.count(keyID) && !pwalletMain->mapKeyMetadata[keyID].hdKeypath.empty())
207+
{
208+
ret.push_back(Pair("hdkeypath", pwalletMain->mapKeyMetadata[keyID].hdKeypath));
209+
ret.push_back(Pair("hdmasterkeyid", pwalletMain->mapKeyMetadata[keyID].hdMasterKeyID.GetHex()));
210+
}
203211
#endif
204212
}
205213
return ret;

0 commit comments

Comments
 (0)