From ed97818e612c3b0eb6017bf75b5eefe5db8f9998 Mon Sep 17 00:00:00 2001 From: Nico Date: Mon, 7 May 2018 15:41:20 +0200 Subject: [PATCH] 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) --- stratum/coinbase.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/stratum/coinbase.cpp b/stratum/coinbase.cpp index ee23e63..06bb4c6 100644 --- a/stratum/coinbase.cpp +++ b/stratum/coinbase.cpp @@ -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);