have validateaddress give useful parent chain addr info

This commit is contained in:
Gregory Sanders 2019-04-04 10:25:39 -04:00
parent 894d76e7c8
commit 9e56c87ec5

View file

@ -56,6 +56,12 @@ static UniValue validateaddress(const JSONRPCRequest& request)
" \"witness_program\" : \"hex\" (string, optional) The hex value of the witness program\n"
" \"confidential_key\" : \"hex\", (string) The hex value of the raw blinding public key for that address, if any. \"\" if none.\n"
" \"unconfidential\" : \"address\", (string) The address without confidentiality key.\n"
" \"parent_address_info\": (obj) If the address isvalid_parent, this object contains details about the parent address type.\n"
" {\n"
" \"address\" : \"address\",\n"
" \"scriptPubKey\" : \"hex\",\n"
" ...\n"
" }\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("validateaddress", "\"1PSSGeFHDnKNxiEyFrD1wcEaHr9hrQDDWc\"")
@ -82,6 +88,20 @@ static UniValue validateaddress(const JSONRPCRequest& request)
UniValue blind_detail = DescribeBlindAddress(dest);
ret.pushKVs(blind_detail);
}
if (is_valid_parent) {
UniValue parent_info(UniValue::VOBJ);
std::string currentAddress = EncodeParentDestination(parent_dest);
parent_info.pushKV("address", currentAddress);
CScript scriptPubKey = GetScriptForDestination(parent_dest);
parent_info.pushKV("scriptPubKey", HexStr(scriptPubKey.begin(), scriptPubKey.end()));
UniValue detail = DescribeAddress(parent_dest);
parent_info.pushKVs(detail);
UniValue blind_detail = DescribeBlindAddress(parent_dest);
parent_info.pushKVs(blind_detail);
ret.pushKV("parent_address_info", parent_info);
}
return ret;
}