Skip to content

Commit

Permalink
add BTSC support
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron3481 committed Feb 20, 2023
1 parent 0aa54e5 commit ff7adc4
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 5 deletions.
10 changes: 5 additions & 5 deletions stratum/client_submit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,8 @@ bool client_submit(YAAMP_CLIENT* client, json_value* json_params)
if (!client_ask_stats(client)) client->stats = false;
}

double share_diff = diff_to_target(hash_int);
double coin_diff = diff_to_target(coin_target);
uint64_t share_diff = diff_to_target(hash_int);
uint64_t coin_diff = diff_to_target(coin_target);
// if (g_current_algo->diff_multiplier != 0) {
// share_diff = share_diff / g_current_algo->diff_multiplier;
// }
Expand All @@ -572,14 +572,14 @@ bool client_submit(YAAMP_CLIENT* client, json_value* json_params)
if (map_it != hash_map.end()) {
if (map_it->second < share_diff) {
hash_map[map_it->first] = share_diff;
debuglog("%s => submit %s (uid %d) with session max DIFF = %.3f / %.3f\n", job->coind->symbol,client->sock->ip, client->userid,
debuglog("%s => submit %s (uid %d) with session max DIFF = %08lx / %08lx\n", job->coind->symbol,client->sock->ip, client->userid,
share_diff , coin_diff);
}
}
else {
hash_map[job->coind->symbol] = share_diff;
debuglog("%s => submit %s (uid %d) with session max DIFF = %.3f / %.3f\n", job->coind->symbol, client->sock->ip, client->userid,
share_diff , coin_diff);
debuglog("%s => submit %s (uid %d) with session max DIFF = %08lx / %08lx\n", job->coind->symbol, client->sock->ip, client->userid,
share_diff, coin_diff);
}

//if (fmod(share_diff, 9) < 1)
Expand Down
58 changes: 58 additions & 0 deletions stratum/coinbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,64 @@ void coinbase_create(YAAMP_COIND* coind, YAAMP_JOB_TEMPLATE* templ, json_value*
return;
}

else if (strcmp(coind->symbol, "BTSC") == 0)
{
char payees[4];
int npayees = 1;
char script_dests[4096] = { 0 };

json_value* smartnode = json_get_object(json_result, "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, "FITA") == 0)
{
char payees[4];
Expand Down

0 comments on commit ff7adc4

Please sign in to comment.