From 9c45348a3bb91ae3e3287e3ca221ccd4758fd94b Mon Sep 17 00:00:00 2001 From: uhliksk Date: Sat, 20 Apr 2019 12:18:05 +0200 Subject: [PATCH] stratum: fix address ownership check for new bitcoin core based wallets --- stratum/coind.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/stratum/coind.cpp b/stratum/coind.cpp index 1eb83a30f..fd6912c42 100644 --- a/stratum/coind.cpp +++ b/stratum/coind.cpp @@ -115,11 +115,8 @@ bool coind_validate_address(YAAMP_COIND *coind) sprintf(params, "[\"%s\"]", coind->wallet); json_value *json; - bool getaddressinfo = ((strcmp(coind->symbol,"DGB") == 0) || (strcmp(coind->symbol2, "DGB") == 0)); - if(getaddressinfo) - json = rpc_call(&coind->rpc, "getaddressinfo", params); - else - json = rpc_call(&coind->rpc, "validateaddress", params); + bool getaddressinfo = false; + json = rpc_call(&coind->rpc, "validateaddress", params); if(!json) return false; json_value *json_result = json_get_object(json, "result"); @@ -129,6 +126,20 @@ bool coind_validate_address(YAAMP_COIND *coind) return false; } + if(!json_get_bool(json_result, "ismine")) + { + stratumlog("%s wallet is using getaddressinfo.\n", coind->name); + getaddressinfo = true; + json = rpc_call(&coind->rpc, "getaddressinfo", params); + + json_result = json_get_object(json, "result"); + if(!json_result) + { + json_value_free(json); + return false; + } + } + bool isvalid = getaddressinfo || json_get_bool(json_result, "isvalid"); if(!isvalid) stratumlog("%s wallet %s is not valid.\n", coind->name, coind->wallet);