Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/mining.cpp
Show First 20 Lines • Show All 614 Lines • ▼ Show 20 Lines | static UniValue getblocktemplate(const Config &config, | ||||
// Update nTime | // Update nTime | ||||
UpdateTime(pblock, config.GetChainParams(), pindexPrev); | UpdateTime(pblock, config.GetChainParams(), pindexPrev); | ||||
pblock->nNonce = 0; | pblock->nNonce = 0; | ||||
UniValue aCaps(UniValue::VARR); | UniValue aCaps(UniValue::VARR); | ||||
aCaps.push_back("proposal"); | aCaps.push_back("proposal"); | ||||
Amount coinbasevalue = Amount::zero(); | |||||
UniValue transactions(UniValue::VARR); | UniValue transactions(UniValue::VARR); | ||||
transactions.reserve(pblock->vtx.size()); | transactions.reserve(pblock->vtx.size()); | ||||
int index_in_template = 0; | int index_in_template = 0; | ||||
for (const auto &it : pblock->vtx) { | for (const auto &it : pblock->vtx) { | ||||
const CTransaction &tx = *it; | const CTransaction &tx = *it; | ||||
uint256 txId = tx.GetId(); | const TxId txId = tx.GetId(); | ||||
if (tx.IsCoinBase()) { | if (tx.IsCoinBase()) { | ||||
index_in_template++; | index_in_template++; | ||||
for (const auto &o : pblock->vtx[0]->vout) { | |||||
coinbasevalue += o.nValue; | |||||
} | |||||
continue; | continue; | ||||
} | } | ||||
UniValue entry(UniValue::VOBJ); | UniValue entry(UniValue::VOBJ); | ||||
entry.reserve(5); | entry.reserve(5); | ||||
entry.__pushKV("data", EncodeHexTx(tx)); | entry.__pushKV("data", EncodeHexTx(tx)); | ||||
entry.__pushKV("txid", txId.GetHex()); | entry.__pushKV("txid", txId.GetHex()); | ||||
entry.__pushKV("hash", tx.GetHash().GetHex()); | entry.__pushKV("hash", tx.GetHash().GetHex()); | ||||
Show All 20 Lines | static UniValue getblocktemplate(const Config &config, | ||||
UniValue result(UniValue::VOBJ); | UniValue result(UniValue::VOBJ); | ||||
result.pushKV("capabilities", aCaps); | result.pushKV("capabilities", aCaps); | ||||
result.pushKV("version", pblock->nVersion); | result.pushKV("version", pblock->nVersion); | ||||
result.pushKV("previousblockhash", pblock->hashPrevBlock.GetHex()); | result.pushKV("previousblockhash", pblock->hashPrevBlock.GetHex()); | ||||
result.pushKV("transactions", transactions); | result.pushKV("transactions", transactions); | ||||
result.pushKV("coinbaseaux", aux); | result.pushKV("coinbaseaux", aux); | ||||
result.pushKV("coinbasevalue", | result.pushKV("coinbasevalue", int64_t(coinbasevalue / SATOSHI)); | ||||
int64_t(pblock->vtx[0]->vout[0].nValue / SATOSHI)); | |||||
result.pushKV("longpollid", ::ChainActive().Tip()->GetBlockHash().GetHex() + | result.pushKV("longpollid", ::ChainActive().Tip()->GetBlockHash().GetHex() + | ||||
i64tostr(nTransactionsUpdatedLast)); | i64tostr(nTransactionsUpdatedLast)); | ||||
result.pushKV("target", hashTarget.GetHex()); | result.pushKV("target", hashTarget.GetHex()); | ||||
result.pushKV("mintime", int64_t(pindexPrev->GetMedianTimePast()) + 1); | result.pushKV("mintime", int64_t(pindexPrev->GetMedianTimePast()) + 1); | ||||
result.pushKV("mutable", aMutable); | result.pushKV("mutable", aMutable); | ||||
result.pushKV("noncerange", "00000000ffffffff"); | result.pushKV("noncerange", "00000000ffffffff"); | ||||
result.pushKV("sigoplimit", | result.pushKV("sigoplimit", | ||||
GetMaxBlockSigChecksCount(DEFAULT_MAX_BLOCK_SIZE)); | GetMaxBlockSigChecksCount(DEFAULT_MAX_BLOCK_SIZE)); | ||||
▲ Show 20 Lines • Show All 176 Lines • Show Last 20 Lines |