From 9e56c87ec5334744789275073b5bed57ccfdd33d Mon Sep 17 00:00:00 2001 From: Gregory Sanders Date: Thu, 4 Apr 2019 10:25:39 -0400 Subject: [PATCH] have validateaddress give useful parent chain addr info --- src/rpc/misc.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index de233ddfa5..8130a725a5 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -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; }