mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-08-23 17:37:25 +00:00
stratum: handle p2sh addresses for all coinbase variants
allow to mine on non-legacy addresses....
This commit is contained in:
parent
b6f212ee6c
commit
ca0c6271a0
1 changed files with 28 additions and 29 deletions
|
@ -14,24 +14,6 @@ static void encode_tx_value(char *encoded, json_int_t value)
|
|||
TX_VALUE(value, 32), TX_VALUE(value, 40), TX_VALUE(value, 48), TX_VALUE(value, 56));
|
||||
}
|
||||
|
||||
static void job_pack_tx(YAAMP_COIND *coind, char *data, json_int_t amount, char *key)
|
||||
{
|
||||
int ol = strlen(data);
|
||||
char evalue[32];
|
||||
encode_tx_value(evalue, amount);
|
||||
|
||||
sprintf(data+strlen(data), "%s", evalue);
|
||||
|
||||
if(coind->pos && !key)
|
||||
sprintf(data+strlen(data), "2321%sac", coind->pubkey);
|
||||
|
||||
else
|
||||
sprintf(data+strlen(data), "1976a914%s88ac", key? key: coind->script_pubkey);
|
||||
|
||||
// debuglog("pack tx %s\n", data+ol);
|
||||
// debuglog("pack tx %lld\n", amount);
|
||||
}
|
||||
|
||||
static void p2sh_pack_tx(YAAMP_COIND *coind, char *data, json_int_t amount, char *payee)
|
||||
{
|
||||
char evalue[32];
|
||||
|
@ -45,6 +27,29 @@ static void p2sh_pack_tx(YAAMP_COIND *coind, char *data, json_int_t amount, char
|
|||
strcat(data, coinb2_part);
|
||||
}
|
||||
|
||||
static void job_pack_tx(YAAMP_COIND *coind, char *data, json_int_t amount, char *key)
|
||||
{
|
||||
int ol = strlen(data);
|
||||
char evalue[32];
|
||||
|
||||
if(coind->p2sh_address && !key) {
|
||||
p2sh_pack_tx(coind, data, amount, coind->script_pubkey);
|
||||
return;
|
||||
}
|
||||
|
||||
encode_tx_value(evalue, amount);
|
||||
sprintf(data+strlen(data), "%s", evalue);
|
||||
|
||||
if(coind->pos && !key)
|
||||
sprintf(data+strlen(data), "2321%sac", coind->pubkey);
|
||||
|
||||
else
|
||||
sprintf(data+strlen(data), "1976a914%s88ac", key? key: coind->script_pubkey);
|
||||
|
||||
// debuglog("pack tx %s\n", data+ol);
|
||||
// debuglog("pack tx %lld\n", amount);
|
||||
}
|
||||
|
||||
void coinbase_aux(YAAMP_JOB_TEMPLATE *templ, char *aux_script)
|
||||
{
|
||||
vector<string> hashlist = coind_aux_hashlist(templ->auxs, templ->auxs_size);
|
||||
|
@ -324,11 +329,10 @@ void coinbase_create(YAAMP_COIND *coind, YAAMP_JOB_TEMPLATE *templ, json_value *
|
|||
available -= amount;
|
||||
base58_decode(payee, script_payee);
|
||||
bool superblock_use_p2sh = (strcmp(coind->symbol, "MAC") == 0);
|
||||
if(superblock_use_p2sh) {
|
||||
if(superblock_use_p2sh)
|
||||
p2sh_pack_tx(coind, script_dests, amount, script_payee);
|
||||
} else {
|
||||
else
|
||||
job_pack_tx(coind, script_dests, amount, script_payee);
|
||||
}
|
||||
//debuglog("%s superblock %s %u\n", coind->symbol, payee, amount);
|
||||
}
|
||||
}
|
||||
|
@ -342,22 +346,17 @@ void coinbase_create(YAAMP_COIND *coind, YAAMP_JOB_TEMPLATE *templ, json_value *
|
|||
available -= amount;
|
||||
base58_decode(payee, script_payee);
|
||||
bool masternode_use_p2sh = (strcmp(coind->symbol, "MAC") == 0);
|
||||
if(masternode_use_p2sh) {
|
||||
if(masternode_use_p2sh)
|
||||
p2sh_pack_tx(coind, script_dests, amount, script_payee);
|
||||
} else {
|
||||
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);
|
||||
if (coind->p2sh_address) { // "MAC 0.16"
|
||||
p2sh_pack_tx(coind, templ->coinb2, available, coind->script_pubkey);
|
||||
} else {
|
||||
job_pack_tx(coind, templ->coinb2, available, NULL);
|
||||
}
|
||||
job_pack_tx(coind, templ->coinb2, available, NULL);
|
||||
strcat(templ->coinb2, "00000000"); // locktime
|
||||
coind->reward = (double)available/100000000*coind->reward_mul;
|
||||
//debuglog("%s %d dests %s\n", coind->symbol, npayees, script_dests);
|
||||
|
|
Loading…
Add table
Reference in a new issue