stratum: detect if master wallet is p2sh + mn started field

This commit is contained in:
Tanguy Pruvot 2018-05-11 10:12:30 +02:00
parent a98b631a87
commit 495dcbba00
4 changed files with 12 additions and 3 deletions

View file

@ -320,9 +320,10 @@ 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) {
if (payee && amount && started) {
npayees++;
available -= amount;
base58_decode(payee, script_payee);
@ -338,7 +339,11 @@ void coinbase_create(YAAMP_COIND *coind, YAAMP_JOB_TEMPLATE *templ, json_value *
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);
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);
}
strcat(templ->coinb2, "00000000"); // locktime
coind->reward = (double)available/100000000*coind->reward_mul;
//debuglog("%s %d dests %s\n", coind->symbol, npayees, script_dests);

View file

@ -139,6 +139,8 @@ bool coind_validate_address(YAAMP_COIND *coind)
if (!base58_decode(coind->wallet, coind->script_pubkey))
stratumlog("Warning: unable to decode %s %s script pubkey\n", coind->symbol, coind->wallet);
coind->p2sh_address = json_get_bool(json_result, "isscript");
// if base58 decode fails
if (!strlen(coind->script_pubkey)) {
const char *pk = json_get_string(json_result, "scriptPubKey");

View file

@ -35,6 +35,7 @@ public:
char pubkey[1024];
char script_pubkey[1024];
bool p2sh_address;
bool pos;
bool hassubmitblock;

View file

@ -145,7 +145,8 @@ function BackendCoinsUpdate()
}
else if(isset($template['masternode']) && arraySafeVal($template,'masternode_payments_enforced')) {
$coin->reward -= arraySafeVal($template['masternode'],'amount',0)/100000000;
if (arraySafeVal($template,'masternode_payments_started'))
$coin->reward -= arraySafeVal($template['masternode'],'amount',0)/100000000;
$coin->hasmasternodes = true;
}