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..530eae4c3 100644 --- a/stratum/coinbase.cpp +++ b/stratum/coinbase.cpp @@ -520,7 +520,20 @@ 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"); + //Below line is (probably) not necessary - uncomment this if your pool is earning the wrong subsidy in phase 3. + //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 +543,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