Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement basic changes for PoW2 phase 3 activation. #283

Open
wants to merge 2 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sql/labels.json
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@
"NIST5":"N5Coin",
"NJA":"Ninjacoin",
"NKT":"NakamotoDark",
"NLG":"GuldenCoin",
"NLG":"Gulden",
"NMB":"Nimbus",
"NMC":"Namecoin",
"NOAH":"NoahCoin",
Expand Down
22 changes: 21 additions & 1 deletion stratum/coinbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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");

Expand Down
22 changes: 22 additions & 0 deletions stratum/coind_template.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
7 changes: 7 additions & 0 deletions stratum/job.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down