diff --git a/stratum/client_submit.cpp b/stratum/client_submit.cpp index 3254e2d..ca141f5 100644 --- a/stratum/client_submit.cpp +++ b/stratum/client_submit.cpp @@ -258,7 +258,7 @@ static void client_do_submit(YAAMP_CLIENT *client, YAAMP_JOB *job, YAAMP_JOB_VAL target_to_diff(coin_target), target_to_diff(hash_int), hash1, submitvalues->hash_be); - if(coind->noblocknotifiy) { + if(coind->noblocknotify) { // DCR go wallet doesnt handle blocknotify= config (yet) // required to store the user id and the user diff sleep(1); diff --git a/stratum/coind.cpp b/stratum/coind.cpp index e6c8fa4..0b0ae5c 100644 --- a/stratum/coind.cpp +++ b/stratum/coind.cpp @@ -156,6 +156,14 @@ void coind_init(YAAMP_COIND *coind) //sprintf(account, "default"); } + // todo: db field + if(!strcmp(coind->symbol, "XVG") || !strcmp(coind->symbol2, "XVG")) { + coind->multialgos = true; + } + if(!strcmp(coind->symbol, "DGB") || !strcmp(coind->symbol2, "DGB")) { + coind->multialgos = true; + } + bool valid = coind_validate_address(coind); if(valid) return; diff --git a/stratum/coind.h b/stratum/coind.h index 521a6ac..166a0aa 100644 --- a/stratum/coind.h +++ b/stratum/coind.h @@ -65,7 +65,8 @@ public: bool usegetwork; bool usememorypool; bool hasmasternodes; - bool noblocknotifiy; + bool noblocknotify; + bool multialgos; // pow_hash field (or mined_hash) YAAMP_JOB *job; // YAAMP_JOB_TEMPLATE *templ; diff --git a/stratum/share.cpp b/stratum/share.cpp index 1a764f8..1e425f2 100644 --- a/stratum/share.cpp +++ b/stratum/share.cpp @@ -225,9 +225,43 @@ void block_add(int userid, int workerid, int coinid, int height, double difficul } // called from blocknotify tool -void block_confirm(int coinid, const char *hash) +void block_confirm(int coinid, const char *blockhash) { - if(strlen(hash) > 65) return; + char hash[192]; + if(strlen(blockhash) < 64) return; + + snprintf(hash, 161, "%s", blockhash); + + // required for multi algos wallets where pow hash is not the blockhash + g_list_coind.Enter(); + for(CLI li = g_list_coind.first; li ; li = li->next) + { + YAAMP_COIND *coind = (YAAMP_COIND *)li->data; + if(coind->id != coinid || coind->deleted) continue; + + if(coind->multialgos) { + char params[192]; + sprintf(params, "[\"%s\"]", blockhash); + json_value *json = rpc_call(&coind->rpc, "getblock", params); + if(!json) { + debuglog("%s: error getblock, no answer\n", __func__); + break; + } + json_value *json_res = json_get_object(json, "result"); + if(!json_res) { + debuglog("%s: error getblock, no result\n", __func__); + break; + } + const char *h1 = json_get_string(json_res, "pow_hash"); // DGB, MYR, J + const char *h2 = json_get_string(json_res, "mined_hash"); // XVG + if (h1) snprintf(hash, 161, "%s", h1); + else if (h2) snprintf(hash, 161, "%s", h2); + //debuglog("%s: getblock %s -> pow %s\n", __func__, blockhash, hash); + json_value_free(json_res); + break; + } + } + g_list_coind.Leave(); for(CLI li = g_list_block.first; li; li = li->next) { @@ -237,7 +271,7 @@ void block_confirm(int coinid, const char *hash) if(strcmp(block->hash1, hash) && strcmp(block->hash2, hash)) continue; debuglog("*** CONFIRMED %d : %s\n", block->height, block->hash2); - strncpy(block->hash, hash, 65); + strncpy(block->hash, blockhash, 65); block->confirmed = true; return;