add disablecb option to getblocktemplate
This commit is contained in:
@@ -518,7 +518,6 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string strMode = "template";
|
||||
UniValue lpval = NullUniValue;
|
||||
// TODO: Re-enable coinbasevalue once a specification has been written
|
||||
bool coinbasetxn = true;
|
||||
@@ -530,12 +529,15 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
|
||||
strMode = modeval.get_str();
|
||||
else if (modeval.isNull())
|
||||
{
|
||||
/* Do nothing */
|
||||
std::string strMode = "template";
|
||||
}
|
||||
else
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode");
|
||||
lpval = find_value(oparam, "longpollid");
|
||||
|
||||
if (strMode == "disablecb")
|
||||
coinbasetxn = false;
|
||||
|
||||
if (strMode == "proposal")
|
||||
{
|
||||
const UniValue& dataval = find_value(oparam, "data");
|
||||
@@ -567,7 +569,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
|
||||
}
|
||||
}
|
||||
|
||||
if (strMode != "template")
|
||||
if (strMode != "template" || strMode != "disablecb")
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode");
|
||||
|
||||
if (vNodes.empty())
|
||||
@@ -694,17 +696,17 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
|
||||
entry.push_back(Pair("fee", pblocktemplate->vTxFees[index_in_template]));
|
||||
entry.push_back(Pair("sigops", pblocktemplate->vTxSigOps[index_in_template]));
|
||||
|
||||
//if (tx.IsCoinBase()) {
|
||||
if (tx.IsCoinBase() && coinbasetxn == true ) {
|
||||
// Show founders' reward if it is required
|
||||
//if (pblock->vtx[0].vout.size() > 1) {
|
||||
// Correct this if GetBlockTemplate changes the order
|
||||
// entry.push_back(Pair("foundersreward", (int64_t)tx.vout[1].nValue));
|
||||
//}
|
||||
// CAmount nReward = GetBlockSubsidy(chainActive.LastTip()->nHeight+1, Params().GetConsensus());
|
||||
// entry.push_back(Pair("coinbasevalue", nReward));
|
||||
// entry.push_back(Pair("required", true));
|
||||
// txCoinbase = entry;
|
||||
// } else
|
||||
CAmount nReward = GetBlockSubsidy(chainActive.LastTip()->nHeight+1, Params().GetConsensus());
|
||||
entry.push_back(Pair("coinbasevalue", nReward));
|
||||
entry.push_back(Pair("required", true));
|
||||
txCoinbase = entry;
|
||||
} else
|
||||
transactions.push_back(entry);
|
||||
}
|
||||
|
||||
@@ -726,12 +728,12 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
|
||||
result.push_back(Pair("version", pblock->nVersion));
|
||||
result.push_back(Pair("previousblockhash", pblock->hashPrevBlock.GetHex()));
|
||||
result.push_back(Pair("transactions", transactions));
|
||||
//if (coinbasetxn) {
|
||||
// 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));
|
||||
if (coinbasetxn) {
|
||||
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)));
|
||||
if ( ASSETCHAINS_STAKED != 0 )
|
||||
|
||||
Reference in New Issue
Block a user