From 05e98578ade2b5d3b8b6f6b175a391f106d5cb7c Mon Sep 17 00:00:00 2001 From: Malcolm MacLeod Date: Tue, 10 Jul 2018 13:27:46 +0200 Subject: [PATCH 1/2] Implement basic changes for PoW2 phase 3 activation. --- sql/labels.json | 2 +- stratum/coinbase.cpp | 21 ++++++++++++++++++++- stratum/coind_template.cpp | 22 ++++++++++++++++++++++ stratum/job.h | 7 +++++++ 4 files changed, 50 insertions(+), 2 deletions(-) diff --git a/sql/labels.json b/sql/labels.json index 4d9190876..e41710e71 100644 --- a/sql/labels.json +++ b/sql/labels.json @@ -556,7 +556,7 @@ "NIST5":"N5Coin", "NJA":"Ninjacoin", "NKT":"NakamotoDark", -"NLG":"GuldenCoin", +"NLG":"Gulden", "NMB":"Nimbus", "NMC":"Namecoin", "NOAH":"NoahCoin", diff --git a/stratum/coinbase.cpp b/stratum/coinbase.cpp index 31f868e6f..392a70388 100644 --- a/stratum/coinbase.cpp +++ b/stratum/coinbase.cpp @@ -520,7 +520,19 @@ void coinbase_create(YAAMP_COIND *coind, YAAMP_JOB_TEMPLATE *templ, json_value * strcat(templ->coinb2, "01"); } } - + // When Gulden is in phase 3 it is required that the miner deducts the witness subsidy from the reward, it instead gets paid to the witness. + else if(strcmp(coind->symbol, "NLG") == 0) + { + if (templ->has_pow2_witness_data) + { + strcat(templ->coinb2, "03"); + available -= templ->pow2_subsidy; + } + else + { + strcat(templ->coinb2, "01"); + } + } else if (templ->has_segwit_txs) { strcat(templ->coinb2, "02"); strcat(templ->coinb2, commitment); @@ -530,6 +542,13 @@ void coinbase_create(YAAMP_COIND *coind, YAAMP_JOB_TEMPLATE *templ, json_value * job_pack_tx(coind, templ->coinb2, available, NULL); + // Append witness data after normal coinbase outputs - witness data is already hex encoded and already contains amounts. + if(strcmp(coind->symbol, "NLG") == 0 && templ->has_pow2_witness_data) + { + strcat(templ->coinb2, templ->pow2_aux_1); + strcat(templ->coinb2, templ->pow2_aux_2); + } + //if(coind->txmessage) // strcat(templ->coinb2, "00"); diff --git a/stratum/coind_template.cpp b/stratum/coind_template.cpp index 33ecc6259..a313541c5 100644 --- a/stratum/coind_template.cpp +++ b/stratum/coind_template.cpp @@ -394,6 +394,28 @@ YAAMP_JOB_TEMPLATE *coind_create_template(YAAMP_COIND *coind) templ->has_segwit_txs = false; + templ->has_pow2_witness_data = false; + + if (strcmp(coind->symbol, "NLG") == 0) + { + + json_value* pow2_aux_1_val = json_get_val(json_result, "pow2_aux1"); + json_value* pow2_aux_2_val = json_get_val(json_result, "pow2_aux2"); + if (pow2_aux_1_val && json_is_string(pow2_aux_1_val) && pow2_aux_2_val && json_is_string(pow2_aux_2_val)) + { + const char* pow2_aux_1 = json_get_string(json_result, "pow2_aux1"); + const char* pow2_aux_2 = json_get_string(json_result, "pow2_aux2"); + if(pow2_aux_1 && strlen(pow2_aux_1) && pow2_aux_2 && strlen(pow2_aux_2)) + { + strcpy(templ->pow2_aux_1, pow2_aux_1); + strcpy(templ->pow2_aux_2, pow2_aux_2); + templ->has_pow2_witness_data = true; + templ->pow2_subsidy = json_get_int(json_result, "pow2_subsidy"); + } + } + } + + templ->has_filtered_txs = false; templ->filtered_txs_fee = 0; diff --git a/stratum/job.h b/stratum/job.h index aef4bdbe1..435591ec9 100644 --- a/stratum/job.h +++ b/stratum/job.h @@ -61,6 +61,13 @@ struct YAAMP_JOB_TEMPLATE int auxs_size; YAAMP_COIND_AUX *auxs[MAX_AUXS]; + + // Start of Gulden specific data for phase 3 witnessing + bool has_pow2_witness_data; + int pow2_subsidy; + char pow2_aux_1[2048]; + char pow2_aux_2[2048]; + // End of Gulden spcific data for phase 3 witnessing }; #define YAAMP_JOB_MAXSUBIDS 200 From efe1044481d3b830f23e2e29ba6b55ca4f07bf5b Mon Sep 17 00:00:00 2001 From: Malcolm MacLeod Date: Tue, 10 Jul 2018 17:46:09 +0200 Subject: [PATCH 2/2] Additional small change. --- stratum/coinbase.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stratum/coinbase.cpp b/stratum/coinbase.cpp index 392a70388..530eae4c3 100644 --- a/stratum/coinbase.cpp +++ b/stratum/coinbase.cpp @@ -526,7 +526,8 @@ void coinbase_create(YAAMP_COIND *coind, YAAMP_JOB_TEMPLATE *templ, json_value * if (templ->has_pow2_witness_data) { strcat(templ->coinb2, "03"); - available -= templ->pow2_subsidy; + //Below line is (probably) not necessary - uncomment this if your pool is earning the wrong subsidy in phase 3. + //available -= templ->pow2_subsidy; } else {