Skip to content

Commit

Permalink
add exosis block header and masternodes
Browse files Browse the repository at this point in the history
  • Loading branch information
AltPoolEU committed Feb 6, 2019
1 parent a36f11d commit 450decd
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 14 deletions.
7 changes: 7 additions & 0 deletions stratum/client_submit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,23 @@ void build_submit_values(YAAMP_JOB_VALUES *submitvalues, YAAMP_JOB_TEMPLATE *tem
sprintf(submitvalues->header, "%s%s%s%s%s%s%s", templ->version, templ->prevhash_be, submitvalues->merkleroot_be,
ntime, templ->nbits, nonce, templ->extradata_be);
ser_string_be(submitvalues->header, submitvalues->header_be, 36); // 80+64 / sizeof(u32)
} else if (strlen(templ->extradata_be) == 16) { // EXOSIS
sprintf(submitvalues->header, "%s%s%s%s%s%s%s", templ->version, templ->prevhash_be, submitvalues->merkleroot_be,
ntime, templ->nbits, nonce, templ->extradata_be);
ser_string_be(submitvalues->header, submitvalues->header_be, 22); // 80+8 / sizeof(u32)
} else {
sprintf(submitvalues->header, "%s%s%s%s%s%s", templ->version, templ->prevhash_be, submitvalues->merkleroot_be,
ntime, templ->nbits, nonce);
ser_string_be(submitvalues->header, submitvalues->header_be, 20);
}


binlify(submitvalues->header_bin, submitvalues->header_be);

// printf("%s\n", submitvalues->header_be);
int header_len = strlen(submitvalues->header)/2;
if (strlen(templ->extradata_be) == 16) // EXOSIS: moneysupply not hashed
header_len -= 8;
g_current_algo->hash_function((char *)submitvalues->header_bin, (char *)submitvalues->hash_bin, header_len);

hexlify(submitvalues->hash_hex, submitvalues->hash_bin, 32);
Expand Down
46 changes: 32 additions & 14 deletions stratum/coinbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ void coinbase_create(YAAMP_COIND *coind, YAAMP_JOB_TEMPLATE *templ, json_value *
{
char script_dests[2048] = { 0 };
char script_payee[128] = { 0 };
char payees[4]; // addresses count
char payees[512]; // addresses count
int npayees = (templ->has_segwit_txs) ? 2 : 1;
bool masternode_enabled = json_get_bool(json_result, "masternode_payments_enforced");
bool superblocks_enabled = json_get_bool(json_result, "superblocks_enabled");
Expand Down Expand Up @@ -460,25 +460,43 @@ void coinbase_create(YAAMP_COIND *coind, YAAMP_JOB_TEMPLATE *templ, json_value *
}
}
if (masternode_enabled && masternode) {
bool started = json_get_bool(json_result, "masternode_payments_started");
const char *payee = json_get_string(masternode, "payee");
json_int_t amount = json_get_int(masternode, "amount");
if (payee && amount && started) {
npayees++;
available -= amount;
base58_decode(payee, script_payee);
bool masternode_use_p2sh = (strcmp(coind->symbol, "MAC") == 0);
if(masternode_use_p2sh)
p2sh_pack_tx(coind, script_dests, amount, script_payee);
else
job_pack_tx(coind, script_dests, amount, script_payee);
if(!strcmp(coind->algo, "exosis")) {
bool started = json_get_bool(json_result, "masternode_payments_started");
for(int i = 0; i < masternode->u.array.length; i++) {
const char *payee = json_get_string(masternode->u.array.values[i], "payee");
json_int_t amount = json_get_int(masternode->u.array.values[i], "amount");
if (payee && amount && started) {
npayees++;
available -= amount;
base58_decode(payee, script_payee);
bool masternode_use_p2sh = (strcmp(coind->symbol, "MAC") == 0);
if(masternode_use_p2sh)
p2sh_pack_tx(coind, script_dests, amount, script_payee);
else
job_pack_tx(coind, script_dests, amount, script_payee);
}
}
} else {
bool started = json_get_bool(json_result, "masternode_payments_started");
const char *payee = json_get_string(masternode, "payee");
json_int_t amount = json_get_int(masternode, "amount");
if (payee && amount && started) {
npayees++;
available -= amount;
base58_decode(payee, script_payee);
bool masternode_use_p2sh = (strcmp(coind->symbol, "MAC") == 0);
if(masternode_use_p2sh)
p2sh_pack_tx(coind, script_dests, amount, script_payee);
else
job_pack_tx(coind, script_dests, amount, script_payee);
}
}
}
sprintf(payees, "%02x", npayees);
strcat(templ->coinb2, payees);
if (templ->has_segwit_txs) strcat(templ->coinb2, commitment);
strcat(templ->coinb2, script_dests);
job_pack_tx(coind, templ->coinb2, available, NULL);
strcat(templ->coinb2, script_dests);
strcat(templ->coinb2, "00000000"); // locktime
coind->reward = (double)available/100000000*coind->reward_mul;
//debuglog("%s total %u available %u\n", coind->symbol, templ->value, available);
Expand Down
7 changes: 7 additions & 0 deletions stratum/coind_template.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@


#include "stratum.h"

void coind_getauxblock(YAAMP_COIND *coind)
Expand Down Expand Up @@ -344,6 +345,12 @@ YAAMP_JOB_TEMPLATE *coind_create_template(YAAMP_COIND *coind)
ser_string_be2(sc_root, &templ->extradata_be[ 0], 8);
ser_string_be2(sc_utxo, &templ->extradata_be[64], 8);
}
if (!strcmp(coind->algo, "exosis")) {
char sc_moneysupply[16];
sprintf(sc_moneysupply, "%016lx", json_get_int(json_result, "moneysupply"));
strcpy(&templ->extradata_hex[0], sc_moneysupply);
ser_string_be2(sc_moneysupply, &templ->extradata_be[0], 2);
}

if (strcmp(coind->rpcencoding, "DCR") == 0) {
decred_fix_template(coind, templ, json_result);
Expand Down

0 comments on commit 450decd

Please sign in to comment.