Add devtax address and scriptpub to getblocktemplate output

This commit is contained in:
Duke
2023-06-23 09:13:11 -04:00
parent 9f92bdd7dc
commit 479ed54ff0
5 changed files with 71 additions and 45 deletions

View File

@@ -50,6 +50,8 @@ using namespace std;
#include "hush_defs.h"
extern int32_t ASSETCHAINS_FOUNDERS;
extern std::string devtax_scriptpub_for_height(uint32_t height);
extern std::string devtax_address_for_height(uint32_t height);
uint64_t the_commission(const CBlock *pblock,int32_t height);
int32_t hush_blockload(CBlock& block,CBlockIndex *pindex);
arith_uint256 hush_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc);
@@ -161,7 +163,6 @@ UniValue getnetworkhashps(const UniValue& params, bool fHelp, const CPubKey& myp
}
#ifdef ENABLE_MINING
extern bool VERUS_MINTBLOCKS;
UniValue getgenerate(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
if (fHelp || params.size() != 0)
@@ -570,9 +571,6 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp, const CPubKey& myp
" }\n"
" ,...\n"
" ],\n"
// " \"coinbaseaux\" : { (json object) data that should be included in the coinbase's scriptSig content\n"
// " \"flags\" : \"flags\" (string) \n"
// " },\n"
// " \"coinbasevalue\" : n, (numeric) maximum allowable input to coinbase transaction, including the generation award and transaction fees (in Satoshis)\n"
" \"coinbasetxn\" : { ... }, (json object) information for coinbase transaction\n"
" \"target\" : \"xxxx\", (string) The hash target\n"
@@ -801,19 +799,23 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp, const CPubKey& myp
int index_in_template = i - 1;
entry.push_back(Pair("fee", pblocktemplate->vTxFees[index_in_template]));
entry.push_back(Pair("sigops", pblocktemplate->vTxSigOps[index_in_template]));
uint32_t nHeight = chainActive.LastTip()->GetHeight()+1;
if (tx.IsCoinBase() && coinbasetxn == true ) {
// Show founders' reward if it is required
if (ASSETCHAINS_FOUNDERS && pblock->vtx[0].vout.size() > 1) {
// Correct this if GetBlockTemplate changes the order
entry.push_back(Pair("foundersreward", (int64_t)tx.vout[1].nValue));
entry.push_back(Pair("foundersrewardaddress", devtax_address_for_height(nHeight)));
entry.push_back(Pair("foundersrewardscriptpub", devtax_scriptpub_for_height(nHeight)));
}
CAmount nReward = GetBlockSubsidy(chainActive.LastTip()->GetHeight()+1, Params().GetConsensus());
CAmount nReward = GetBlockSubsidy(nHeight, Params().GetConsensus());
entry.push_back(Pair("coinbasevalue", nReward));
entry.push_back(Pair("required", true));
txCoinbase = entry;
} else
} else {
transactions.push_back(entry);
}
}
UniValue aux(UniValue::VOBJ);
@@ -839,7 +841,6 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp, const CPubKey& myp
assert(txCoinbase.isObject());
result.push_back(Pair("coinbasetxn", txCoinbase));
} // else {
// result.push_back(Pair("coinbaseaux", aux));
// result.push_back(Pair("coinbasevalue", (int64_t)pblock->vtx[0].vout[0].nValue));
//}
result.push_back(Pair("longpollid", chainActive.LastTip()->GetBlockHash().GetHex() + i64tostr(nTransactionsUpdatedLast)));
@@ -1037,7 +1038,7 @@ UniValue getblocksubsidy(const UniValue& params, bool fHelp, const CPubKey& mypk
result.push_back(Pair("miner", ValueFromAmount(nReward)));
// the value of ASSETCHAINS_SCRIPTPUB is not used here, this is just a check if it exists
// so we don't need to call scriptpub_for_height()
// so we don't need to call devtax_scriptpub_for_height()
if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 || ASSETCHAINS_SCRIPTPUB.size() > 1 )
{
if ( ASSETCHAINS_FOUNDERS == 0 && ASSETCHAINS_COMMISSION != 0 )