Extend validateaddress to check parent address validity.

This commit is contained in:
Gregory Sanders 2019-01-11 12:34:36 -05:00
parent 85bcda52fc
commit 7e63ce39e8

View file

@ -49,6 +49,7 @@ static UniValue validateaddress(const JSONRPCRequest& request)
"\nResult:\n"
"{\n"
" \"isvalid\" : true|false, (boolean) If the address is valid or not. If not, this is the only property returned.\n"
" \"isvalid_parent\" : true|false (boolean) If the address is valid or not for parent chain. Valid or not, no additional details will be appended unlike `isvalid`.\n"
" \"address\" : \"address\", (string) The bitcoin address validated\n"
" \"scriptPubKey\" : \"hex\", (string) The hex encoded scriptPubKey generated by the address\n"
" \"isscript\" : true|false, (boolean) If the key is a script\n"
@ -62,10 +63,12 @@ static UniValue validateaddress(const JSONRPCRequest& request)
);
CTxDestination dest = DecodeDestination(request.params[0].get_str());
CTxDestination parent_dest = DecodeParentDestination(request.params[0].get_str());
bool isValid = IsValidDestination(dest);
bool is_valid_parent = IsValidDestination(parent_dest);
UniValue ret(UniValue::VOBJ);
ret.pushKV("isvalid", isValid);
ret.pushKV("isvalid_parent", is_valid_parent);
if (isValid)
{