stratum: support for MAC P2SH masternodes too (#266)

note: a field "isscript" should be added to getblocktemplate masternode/superblock objects
if the type of address can vary over time... 
Code may be refactored later (common func and p2sh fields in coind object)
This commit is contained in:
Nico 2018-05-07 15:41:20 +02:00 committed by Tanguy Pruvot
parent db7a145c0b
commit ed97818e61

View file

@ -321,7 +321,20 @@ void coinbase_create(YAAMP_COIND *coind, YAAMP_JOB_TEMPLATE *templ, json_value *
npayees++;
available -= amount;
base58_decode(payee, script_payee);
job_pack_tx(coind, script_dests, amount, script_payee);
bool masternode_use_p2sh = (strcmp(coind->symbol, "MAC") == 0);
if(masternode_use_p2sh) {
char eamount[32] = { 0 };
char coinb2_part[256];
char coinb2_len[4];
sprintf(coinb2_part, "a9%02x%s87", (unsigned int)(strlen(script_payee) >> 1) & 0xFF, script_payee);
sprintf(coinb2_len, "%02x", (unsigned int)(strlen(coinb2_part) >> 1) & 0xFF);
encode_tx_value(eamount, amount);
strcat(script_dests, eamount);
strcat(script_dests, coinb2_len);
strcat(script_dests, coinb2_part);
} else {
job_pack_tx(coind, script_dests, amount, script_payee);
}
}
}
sprintf(payees, "%02x", npayees);