Skip to content
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
62 changes: 62 additions & 0 deletions stratum/coinbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ void coinbase_create(YAAMP_COIND *coind, YAAMP_JOB_TEMPLATE *templ, json_value *
char eversion1[32] = "01000000";
if(coind->txmessage)
strcpy(eversion1, "02000000");

const char *coinbase_payload = json_get_string(json_result, "coinbase_payload");
if(coinbase_payload && strlen(coinbase_payload) > 0)
strcpy(eversion1, "03000500");

char script1[4*1024];
sprintf(script1, "%s%s%s08", eheight, templ->flags, etime);
Expand Down Expand Up @@ -285,6 +289,64 @@ void coinbase_create(YAAMP_COIND *coind, YAAMP_JOB_TEMPLATE *templ, json_value *
coind->reward = (double)available / 100000000 * coind->reward_mul;
return;
}
else if(strcmp(coind->symbol, "RTM") == 0)
{
char payees[4];
int npayees = 1;
char script_dests[4096] = { 0 };

json_value* smartnode = json_get_object(json_result, "smartnode");
debuglog("RTM DETECTED Json: RESULT %s\n", smartnode);
bool smartnode_started = json_get_bool(json_result, "smartnode_payments_started");
if (smartnode_started && smartnode)
{
for(int i = 0; i < smartnode->u.array.length; i++)
{
const char *payee = json_get_string(smartnode->u.array.values[i], "payee");
json_int_t amount = json_get_int(smartnode->u.array.values[i], "amount");
if (payee && amount) {
char script_payee[128] = { 0 };
npayees++;
available -= amount;
base58_decode(payee, script_payee);
job_pack_tx(coind, script_dests, amount, script_payee);
}
debuglog("SMARTNODE DETECTED Payee: %s\n", payee);
}
}

json_value* founder = json_get_array(json_result, "founder");
bool founder_payments_started = json_get_bool(json_result, "founder_payments_started");
if (founder_payments_started && founder)
{
const char *founder_payee = json_get_string(founder, "payee");
json_int_t founder_amount = json_get_int(founder, "amount");
if (founder_payee && founder_amount)
{
char founder_script_payee[128] = { 0 };
npayees++;
available -= founder_amount;
base58_decode(founder_payee, founder_script_payee);
job_pack_tx(coind, script_dests, founder_amount, founder_script_payee);
}
debuglog("FOUNDER DETECTED Payee: %s\n", founder_payee);
}

sprintf(payees, "%02x", npayees);
strcat(templ->coinb2, payees);
strcat(templ->coinb2, script_dests);
job_pack_tx(coind, templ->coinb2, available, NULL);
strcat(templ->coinb2, "00000000"); // locktime
if(coinbase_payload && strlen(coinbase_payload) > 0) {
char coinbase_payload_size[18];
ser_compactsize((unsigned int)(strlen(coinbase_payload) >> 1), coinbase_payload_size);
strcat(templ->coinb2, coinbase_payload_size);
strcat(templ->coinb2, coinbase_payload);
}

coind->reward = (double)available / 100000000 * coind->reward_mul;
return;
}
else if(strcmp(coind->symbol, "TUX") == 0) {
char script_payee[1024];
char charity_payee[256] = { 0 };
Expand Down
20 changes: 20 additions & 0 deletions stratum/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,26 @@ void ser_number(int n, char *a)
// printf("ser_number %d, %s\n", n, a);
}

void ser_compactsize(uint64_t nSize, char *a)
{
if (nSize < 253)
{
sprintf(a, "%02lx", nSize);
}
else if (nSize <= (unsigned short)-1)
{
sprintf(a, "%02x%04lx", 253, nSize);
}
else if (nSize <= (unsigned int)-1)
{
sprintf(a, "%02x%08lx", 254, nSize);
}
else
{
sprintf(a, "%02x%016lx", 255, nSize);
}
}

void ser_string_be(const char *input, char *output, int len)
{
for(int i=0; i<len; i++)
Expand Down
1 change: 1 addition & 0 deletions stratum/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ void base64_encode(char *base64, const char *normal);
void base64_decode(char *normal, const char *base64);

void ser_number(int n, char *s);
void ser_compactsize(uint64_t nSize, char *a);

void ser_string_be(const char *input, char *output, int len);
void ser_string_be2(const char *input, char *output, int len);
Expand Down