37 if (target < 1 || (
unsigned int)target > max_target) {
40 return (
unsigned int)target;
48 static UniValue GetNetworkHashPS(
int lookup,
int height) {
54 if (pb ==
nullptr || !pb->
nHeight)
67 int64_t maxTime = minTime;
68 for (
int i = 0; i < lookup; i++) {
71 minTime = std::min(time, minTime);
72 maxTime = std::max(time, maxTime);
76 if (minTime == maxTime)
80 int64_t timeDiff = maxTime - minTime;
88 throw std::runtime_error(
89 "getnetworkhashps ( nblocks height )\n" 90 "\nReturns the estimated network hashes per second based on the last n blocks.\n" 91 "Pass in [blocks] to override # of blocks, -1 specifies since last difficulty change.\n" 92 "Pass in [height] to estimate the network speed at the time when a certain block was found.\n" 94 "1. nblocks (numeric, optional, default=120) The number of blocks, or -1 for blocks since last difficulty change.\n" 95 "2. height (numeric, optional, default=-1) To estimate at the time of the given height.\n" 97 "x (numeric) Hashes per second estimated\n" 110 throw std::runtime_error(
112 "\nReturns the hashes per second of this node's miner." 114 "x (numeric) Hashes per second\n" 124 UniValue generateBlocks(std::shared_ptr<CReserveScript> coinbaseScript,
int nGenerate, uint64_t nMaxTries,
bool keepScript)
126 static const int nInnerLoopCount = 0x10000;
133 nHeightEnd = nHeight+nGenerate;
135 unsigned int nExtraNonce = 0;
139 std::unique_ptr<CBlockTemplate> pblocktemplate(
BlockAssembler(
Params()).CreateNewBlock(coinbaseScript->reserveScript));
140 if (!pblocktemplate.get())
142 CBlock *pblock = &pblocktemplate->block;
151 if (nMaxTries == 0) {
154 if (pblock->
nNonce == nInnerLoopCount) {
157 std::shared_ptr<const CBlock> shared_pblock = std::make_shared<const CBlock>(*pblock);
161 blockHashes.
push_back(pblock->GetHash().GetHex());
166 coinbaseScript->KeepScript();
175 throw std::runtime_error(
176 "generatetoaddress nblocks address (maxtries)\n" 177 "\nMine blocks immediately to a specified address (before the RPC call returns)\n" 179 "1. nblocks (numeric, required) How many blocks are generated immediately.\n" 180 "2. address (string, required) The address to send the newly generated bitcoin to.\n" 181 "3. maxtries (numeric, optional) How many iterations to try (default = 1000000).\n" 183 "[ blockhashes ] (array) hashes of blocks generated\n" 185 "\nGenerate 11 blocks to myaddress\n" 187 +
"If you are running the bitcoin core wallet, you can get a new address to send the newly generated bitcoin to with:\n" 192 uint64_t nMaxTries = 1000000000;
202 std::shared_ptr<CReserveScript> coinbaseScript = std::make_shared<CReserveScript>();
205 return generateBlocks(coinbaseScript, nGenerate, nMaxTries,
false);
211 throw std::runtime_error(
213 "\nReturns a json object containing mining-related information." 216 " \"blocks\": nnn, (numeric) The current block\n" 217 " \"currentblockweight\": nnn, (numeric) The last block weight\n" 218 " \"currentblocktx\": nnn, (numeric) The last block transaction\n" 219 " \"difficulty\": xxx.xxxxx (numeric) The current difficulty\n" 220 " \"localhashps\": nnn, (numeric) The local node's hashes per second\n" 221 " \"networkhashps\": nnn, (numeric) The network hashes per second\n" 222 " \"pooledtx\": n (numeric) The size of the mempool\n" 223 " \"chain\": \"xxxx\", (string) current network name as defined in BIP70 (main, test, regtest)\n" 224 " \"warnings\": \"...\" (string) any network and blockchain warnings\n" 239 obj.pushKV(
"localhashps", getlocalhashps(request));
240 obj.pushKV(
"networkhashps", getnetworkhashps(request));
242 obj.pushKV(
"chain",
Params().NetworkIDString());
252 throw std::runtime_error(
253 "prioritisetransaction <txid> <dummy value> <fee delta>\n" 254 "Accepts the transaction into mined blocks at a higher (or lower) priority\n" 256 "1. \"txid\" (string, required) The transaction id.\n" 257 "2. dummy (numeric, optional) API-Compatibility for previous API. Must be zero or null.\n" 258 " DEPRECATED. For forward compatibility use named arguments and omit this parameter.\n" 259 "3. fee_delta (numeric, required) The fee value (in satoshis) to add (or subtract, if negative).\n" 260 " Note, that this value is not a fee rate. It is a value to modify absolute fee of the TX.\n" 261 " The fee is not actually paid, only the algorithm for selecting transactions into a block\n" 262 " considers the transaction as it would have paid a higher (or lower) fee.\n" 264 "true (boolean) Returns true\n" 295 if (strRejectReason.empty())
297 return strRejectReason;
305 std::string s = vbinfo.
name;
307 s.insert(s.begin(),
'!');
315 throw std::runtime_error(
316 "getblocktemplate ( TemplateRequest )\n" 317 "\nIf the request parameters include a 'mode' key, that is used to explicitly select between the default 'template' request or a 'proposal'.\n" 318 "It returns data needed to construct a block to work on.\n" 319 "For full specification, see BIPs 22, 23, 9, and 145:\n" 320 " https://github.com/bitcoin/bips/blob/master/bip-0022.mediawiki\n" 321 " https://github.com/bitcoin/bips/blob/master/bip-0023.mediawiki\n" 322 " https://github.com/bitcoin/bips/blob/master/bip-0009.mediawiki#getblocktemplate_changes\n" 323 " https://github.com/bitcoin/bips/blob/master/bip-0145.mediawiki\n" 326 "1. template_request (json object, optional) A json object in the following spec\n" 328 " \"mode\":\"template\" (string, optional) This must be set to \"template\", \"proposal\" (see BIP 23), or omitted\n" 329 " \"capabilities\":[ (array, optional) A list of strings\n" 330 " \"support\" (string) client side supported feature, 'longpoll', 'coinbasetxn', 'coinbasevalue', 'proposal', 'serverlist', 'workid'\n" 333 " \"rules\":[ (array, optional) A list of strings\n" 334 " \"support\" (string) client side supported softfork deployment\n" 342 " \"version\" : n, (numeric) The preferred block version\n" 343 " \"rules\" : [ \"rulename\", ... ], (array of strings) specific block rules that are to be enforced\n" 344 " \"vbavailable\" : { (json object) set of pending, supported versionbit (BIP 9) softfork deployments\n" 345 " \"rulename\" : bitnumber (numeric) identifies the bit number as indicating acceptance and readiness for the named softfork rule\n" 348 " \"vbrequired\" : n, (numeric) bit mask of versionbits the server requires set in submissions\n" 349 " \"previousblockhash\" : \"xxxx\", (string) The hash of current highest block\n" 350 " \"transactions\" : [ (array) contents of non-coinbase transactions that should be included in the next block\n" 352 " \"data\" : \"xxxx\", (string) transaction data encoded in hexadecimal (byte-for-byte)\n" 353 " \"txid\" : \"xxxx\", (string) transaction id encoded in little-endian hexadecimal\n" 354 " \"hash\" : \"xxxx\", (string) hash encoded in little-endian hexadecimal (including witness data)\n" 355 " \"depends\" : [ (array) array of numbers \n" 356 " n (numeric) transactions before this one (by 1-based index in 'transactions' list) that must be present in the final block if this one is\n" 359 " \"fee\": n, (numeric) difference in value between transaction inputs and outputs (in satoshis); for coinbase transactions, this is a negative Number of the total collected block fees (ie, not including the block subsidy); if key is not present, fee is unknown and clients MUST NOT assume there isn't one\n" 360 " \"sigops\" : n, (numeric) total SigOps cost, as counted for purposes of block limits; if key is not present, sigop cost is unknown and clients MUST NOT assume it is zero\n" 361 " \"weight\" : n, (numeric) total transaction weight, as counted for purposes of block limits\n" 365 " \"coinbaseaux\" : { (json object) data that should be included in the coinbase's scriptSig content\n" 366 " \"flags\" : \"xx\" (string) key name is to be ignored, and value included in scriptSig\n" 368 " \"coinbasevalue\" : n, (numeric) maximum allowable input to coinbase transaction, including the generation award and transaction fees (in satoshis)\n" 369 " \"coinbasetxn\" : { ... }, (json object) information for coinbase transaction\n" 370 " \"target\" : \"xxxx\", (string) The hash target\n" 371 " \"mintime\" : xxx, (numeric) The minimum timestamp appropriate for next block time in seconds since epoch (Jan 1 1970 GMT)\n" 372 " \"mutable\" : [ (array of string) list of ways the block template may be changed \n" 373 " \"value\" (string) A way the block template may be changed, e.g. 'time', 'transactions', 'prevblock'\n" 376 " \"noncerange\" : \"00000000ffffffff\",(string) A range of valid nonces\n" 377 " \"sigoplimit\" : n, (numeric) limit of sigops in blocks\n" 378 " \"sizelimit\" : n, (numeric) limit of block size\n" 379 " \"weightlimit\" : n, (numeric) limit of block weight\n" 380 " \"curtime\" : ttt, (numeric) current timestamp in seconds since epoch (Jan 1 1970 GMT)\n" 381 " \"bits\" : \"xxxxxxxx\", (string) compressed target of next block\n" 382 " \"height\" : n (numeric) The height of the next block\n" 392 std::string strMode =
"template";
394 std::set<std::string> setClientRules;
395 int64_t nMaxVersionPreVB = -1;
402 else if (modeval.
isNull())
410 if (strMode ==
"proposal")
413 if (!dataval.
isStr())
426 return "duplicate-invalid";
427 return "duplicate-inconclusive";
433 return "inconclusive-not-best-prevblk";
436 return BIP22ValidationResult(state);
441 for (
unsigned int i = 0; i < aClientRules.
size(); ++i) {
442 const UniValue& v = aClientRules[i];
443 setClientRules.insert(v.
get_str());
448 if (uvMaxVersion.
isNum()) {
449 nMaxVersionPreVB = uvMaxVersion.
get_int64();
454 if (strMode !=
"template")
466 static unsigned int nTransactionsUpdatedLast;
473 unsigned int nTransactionsUpdatedLastLP;
478 std::string lpstr = lpval.
get_str();
480 hashWatchedChain =
ParseHashV(lpstr.substr(0, 64),
"longpollid");
481 nTransactionsUpdatedLastLP =
atoi64(lpstr.substr(64));
487 nTransactionsUpdatedLastLP = nTransactionsUpdatedLast;
493 checktxtime = std::chrono::steady_clock::now() + std::chrono::minutes(1);
498 if (
g_best_block_cv.wait_until(lock, checktxtime) == std::cv_status::timeout)
503 checktxtime += std::chrono::seconds(10);
522 static int64_t nStart;
523 static std::unique_ptr<CBlockTemplate> pblocktemplate;
526 static bool fLastTemplateSupportsSegwit =
true;
529 fLastTemplateSupportsSegwit != fSupportsSegwit)
532 pindexPrev =
nullptr;
538 fLastTemplateSupportsSegwit = fSupportsSegwit;
547 pindexPrev = pindexPrevNew;
550 CBlock* pblock = &pblocktemplate->block;
554 UpdateTime(pblock, consensusParams, pindexPrev);
558 const bool fPreSegWit =
false;
563 std::map<uint256, int64_t> setTxIndex;
565 for (
const auto& it : pblock->
vtx) {
568 setTxIndex[txHash] = i++;
576 entry.pushKV(
"txid", txHash.
GetHex());
585 entry.pushKV(
"depends", deps);
587 int index_in_template = i - 1;
588 entry.pushKV(
"fee", pblocktemplate->vTxFees[index_in_template]);
589 int64_t nTxSigOps = pblocktemplate->vTxSigOpsCost[index_in_template];
591 assert(nTxSigOps % WITNESS_SCALE_FACTOR == 0);
592 nTxSigOps /= WITNESS_SCALE_FACTOR;
594 entry.pushKV(
"sigops", nTxSigOps);
595 entry.pushKV(
"weight", GetTransactionWeight(tx));
597 transactions.push_back(entry);
606 aMutable.push_back(
"time");
607 aMutable.push_back(
"transactions");
608 aMutable.push_back(
"prevblock");
611 result.pushKV(
"capabilities", aCaps);
630 vbavailable.pushKV(gbt_vb_name(pos), consensusParams.
vDeployments[pos].
bit);
631 if (setClientRules.find(vbinfo.
name) == setClientRules.end()) {
643 aRules.push_back(gbt_vb_name(pos));
644 if (setClientRules.find(vbinfo.
name) == setClientRules.end()) {
655 result.pushKV(
"version", pblock->
nVersion);
656 result.pushKV(
"rules", aRules);
657 result.pushKV(
"vbavailable", vbavailable);
658 result.pushKV(
"vbrequired",
int(0));
660 if (nMaxVersionPreVB >= 2) {
665 aMutable.push_back(
"version/force");
669 result.pushKV(
"transactions", transactions);
670 result.pushKV(
"coinbaseaux", aux);
671 result.pushKV(
"coinbasevalue", (int64_t)pblock->
vtx[0]->vout[0].nValue);
673 result.pushKV(
"target", hashTarget.
GetHex());
675 result.pushKV(
"mutable", aMutable);
676 result.pushKV(
"noncerange",
"00000000ffffffff");
677 int64_t nSigOpLimit = MAX_BLOCK_SIGOPS_COST;
678 int64_t nSizeLimit = MAX_BLOCK_SERIALIZED_SIZE;
680 assert(nSigOpLimit % WITNESS_SCALE_FACTOR == 0);
681 nSigOpLimit /= WITNESS_SCALE_FACTOR;
682 assert(nSizeLimit % WITNESS_SCALE_FACTOR == 0);
683 nSizeLimit /= WITNESS_SCALE_FACTOR;
685 result.pushKV(
"sigoplimit", nSigOpLimit);
686 result.pushKV(
"sizelimit", nSizeLimit);
688 result.pushKV(
"weightlimit", (int64_t)MAX_BLOCK_WEIGHT);
692 result.pushKV(
"height", (int64_t)(pindexPrev->
nHeight+1));
694 if (!pblocktemplate->vchCoinbaseCommitment.empty() && fSupportsSegwit) {
695 result.pushKV(
"default_witness_commitment",
HexStr(pblocktemplate->vchCoinbaseCommitment.begin(), pblocktemplate->vchCoinbaseCommitment.end()));
723 throw std::runtime_error(
724 "submitblock \"hexdata\" ( \"dummy\" )\n" 725 "\nAttempts to submit new block to network.\n" 726 "See https://en.bitcoin.it/wiki/BIP_0022 for full specification.\n" 729 "1. \"hexdata\" (string, required) the hex-encoded block data to submit\n" 730 "2. \"dummy\" (optional) dummy value, for compatibility with BIP22. This value is ignored.\n" 738 std::shared_ptr<CBlock> blockptr = std::make_shared<CBlock>();
739 CBlock& block = *blockptr;
744 if (block.vtx.empty() || !block.vtx[0]->IsCoinBase()) {
748 uint256 hash = block.GetHash();
757 return "duplicate-invalid";
775 if (!new_block && accepted) {
779 return "inconclusive";
781 return BIP22ValidationResult(sc.state);
787 throw std::runtime_error(
788 "submitheader \"hexdata\"\n" 789 "\nDecode the given hexdata as a header and submit it as a candidate chain tip if valid." 790 "\nThrows when the header is invalid.\n" 792 "1. \"hexdata\" (string, required) the hex-encoded block header data\n" 823 throw std::runtime_error(
824 "estimatesmartfee conf_target (\"estimate_mode\")\n" 825 "\nEstimates the approximate fee per kilobyte needed for a transaction to begin\n" 826 "confirmation within conf_target blocks if possible and return the number of blocks\n" 827 "for which the estimate is valid. Uses virtual transaction size as defined\n" 828 "in BIP 141 (witness data is discounted).\n" 830 "1. conf_target (numeric) Confirmation target in blocks (1 - 1008)\n" 831 "2. \"estimate_mode\" (string, optional, default=CONSERVATIVE) The fee estimate mode.\n" 832 " Whether to return a more conservative estimate which also satisfies\n" 833 " a longer history. A conservative estimate potentially returns a\n" 834 " higher feerate and is more likely to be sufficient for the desired\n" 835 " target, but is not as responsive to short term drops in the\n" 836 " prevailing fee market. Must be one of:\n" 839 " \"CONSERVATIVE\"\n" 842 " \"feerate\" : x.x, (numeric, optional) estimate fee rate in " +
CURRENCY_UNIT +
"/kB\n" 843 " \"errors\": [ str... ] (json array of strings, optional) Errors encountered during processing\n" 844 " \"blocks\" : n (numeric) block number where estimate was found\n" 847 "The request target will be clamped between 2 and the highest target\n" 848 "fee estimation is able to return based on how long it has been running.\n" 849 "An error is returned if not enough transactions and blocks\n" 850 "have been observed to make an estimate for any number of blocks.\n" 858 bool conservative =
true;
874 errors.push_back(
"Insufficient data or no feerate found");
875 result.pushKV(
"errors", errors);
884 throw std::runtime_error(
885 "estimaterawfee conf_target (threshold)\n" 886 "\nWARNING: This interface is unstable and may disappear or change!\n" 887 "\nWARNING: This is an advanced API call that is tightly coupled to the specific\n" 888 " implementation of fee estimation. The parameters it can be called with\n" 889 " and the results it returns will change if the internal implementation changes.\n" 890 "\nEstimates the approximate fee per kilobyte needed for a transaction to begin\n" 891 "confirmation within conf_target blocks if possible. Uses virtual transaction size as\n" 892 "defined in BIP 141 (witness data is discounted).\n" 894 "1. conf_target (numeric) Confirmation target in blocks (1 - 1008)\n" 895 "2. threshold (numeric, optional) The proportion of transactions in a given feerate range that must have been\n" 896 " confirmed within conf_target in order to consider those feerates as high enough and proceed to check\n" 897 " lower buckets. Default: 0.95\n" 900 " \"short\" : { (json object, optional) estimate for short time horizon\n" 901 " \"feerate\" : x.x, (numeric, optional) estimate fee rate in " +
CURRENCY_UNIT +
"/kB\n" 902 " \"decay\" : x.x, (numeric) exponential decay (per block) for historical moving average of confirmation data\n" 903 " \"scale\" : x, (numeric) The resolution of confirmation targets at this time horizon\n" 904 " \"pass\" : { (json object, optional) information about the lowest range of feerates to succeed in meeting the threshold\n" 905 " \"startrange\" : x.x, (numeric) start of feerate range\n" 906 " \"endrange\" : x.x, (numeric) end of feerate range\n" 907 " \"withintarget\" : x.x, (numeric) number of txs over history horizon in the feerate range that were confirmed within target\n" 908 " \"totalconfirmed\" : x.x, (numeric) number of txs over history horizon in the feerate range that were confirmed at any point\n" 909 " \"inmempool\" : x.x, (numeric) current number of txs in mempool in the feerate range unconfirmed for at least target blocks\n" 910 " \"leftmempool\" : x.x, (numeric) number of txs over history horizon in the feerate range that left mempool unconfirmed after target\n" 912 " \"fail\" : { ... }, (json object, optional) information about the highest range of feerates to fail to meet the threshold\n" 913 " \"errors\": [ str... ] (json array of strings, optional) Errors encountered during processing\n" 915 " \"medium\" : { ... }, (json object, optional) estimate for medium time horizon\n" 916 " \"long\" : { ... } (json object) estimate for long time horizon\n" 919 "Results are returned for any horizon which tracks blocks up to the confirmation target.\n" 927 double threshold = 0.95;
931 if (threshold < 0 || threshold > 1) {
948 passbucket.pushKV(
"startrange", round(buckets.
pass.
start));
949 passbucket.pushKV(
"endrange", round(buckets.
pass.
end));
950 passbucket.pushKV(
"withintarget", round(buckets.
pass.
withinTarget * 100.0) / 100.0);
951 passbucket.pushKV(
"totalconfirmed", round(buckets.
pass.
totalConfirmed * 100.0) / 100.0);
952 passbucket.pushKV(
"inmempool", round(buckets.
pass.
inMempool * 100.0) / 100.0);
953 passbucket.pushKV(
"leftmempool", round(buckets.
pass.
leftMempool * 100.0) / 100.0);
955 failbucket.pushKV(
"startrange", round(buckets.
fail.
start));
956 failbucket.pushKV(
"endrange", round(buckets.
fail.
end));
957 failbucket.pushKV(
"withintarget", round(buckets.
fail.
withinTarget * 100.0) / 100.0);
958 failbucket.pushKV(
"totalconfirmed", round(buckets.
fail.
totalConfirmed * 100.0) / 100.0);
959 failbucket.pushKV(
"inmempool", round(buckets.
fail.
inMempool * 100.0) / 100.0);
960 failbucket.pushKV(
"leftmempool", round(buckets.
fail.
leftMempool * 100.0) / 100.0);
965 horizon_result.pushKV(
"decay", buckets.
decay);
966 horizon_result.pushKV(
"scale", (
int)buckets.
scale);
967 horizon_result.pushKV(
"pass", passbucket);
969 if (buckets.
fail.
start != -1) horizon_result.pushKV(
"fail", failbucket);
972 horizon_result.pushKV(
"decay", buckets.
decay);
973 horizon_result.pushKV(
"scale", (
int)buckets.
scale);
974 horizon_result.pushKV(
"fail", failbucket);
975 errors.push_back(
"Insufficient data or no feerate found which meets threshold");
976 horizon_result.pushKV(
"errors",errors);
986 throw std::runtime_error(
988 "\nReturn if the server is set to generate coins or not. The default is false.\n" 989 "It is set with the command line argument -gen (or " + std::string(
BITCOIN_CONF_FILENAME) +
" setting gen)\n" 990 "It can also be set with the setgenerate call.\n" 992 "true|false (boolean) If the server is set to generate coins or not\n" 1003 throw std::runtime_error(
1004 "setgenerate generate ( genproclimit )\n" 1005 "\nSet 'generate' true or false to turn generation on or off.\n" 1006 "Generation is limited to 'genproclimit' processors, -1 is unlimited.\n" 1007 "See the getgenerate call for the current setting.\n" 1009 "1. generate (boolean, required) Set to true to turn on generation, false to turn off.\n" 1010 "2. genproclimit (numeric, optional) Set the processor limit for when generation is on. Can be -1 for unlimited.\n" 1012 "\nSet the generation on with a limit of one processor\n" 1014 "\nCheck the setting\n" 1016 "\nTurn off generation\n" 1018 "\nUsing json rpc\n" 1023 bool fGenerate =
true;
1026 int nGenProcLimit =
gArgs.
GetArg(
"-genproclimit", DEFAULT_GENERATE_THREADS);
1030 if (nGenProcLimit == 0)
1038 nGenProcLimit = nGenProcLimit >= 0 ? nGenProcLimit : numCores;
1039 std::string msg = std::to_string(nGenProcLimit) +
" of " + std::to_string(numCores);
1046 {
"mining",
"getnetworkhashps", &getnetworkhashps, {
"nblocks",
"height"} },
1047 {
"mining",
"getlocalhashps", &getlocalhashps, {} },
1048 {
"mining",
"getmininginfo", &getmininginfo, {} },
1049 {
"mining",
"prioritisetransaction", &prioritisetransaction, {
"txid",
"dummy",
"fee_delta"} },
1050 {
"mining",
"getblocktemplate", &getblocktemplate, {
"template_request"} },
1051 {
"mining",
"submitblock", &submitblock, {
"hexdata",
"dummy"} },
1052 {
"mining",
"submitheader", &submitheader, {
"hexdata"} },
1054 {
"generating",
"getgenerate", &
getgenerate, {} },
1055 {
"generating",
"setgenerate", &
setgenerate, {
"generate",
"genproclimit"} },
1057 {
"generating",
"generatetoaddress", &generatetoaddress, {
"nblocks",
"address",
"maxtries"} },
1059 {
"util",
"estimatesmartfee", &estimatesmartfee, {
"conf_target",
"estimate_mode"} },
1061 {
"hidden",
"estimaterawfee", &estimaterawfee, {
"conf_target",
"threshold"} },
1067 for (
unsigned int vcidx = 0; vcidx <
ARRAYLEN(commands); vcidx++)
arith_uint256 nChainWork
(memory only) Total amount of work (expected number of hashes) in the chain up to and including this ...
bool DecodeHexBlk(CBlock &, const std::string &strHexBlk)
std::condition_variable g_best_block_cv
Ran out of memory during operation.
Bitcoin RPC command dispatcher.
int64_t GetBlockTime() const
bool FeeModeFromString(const std::string &mode_string, FeeEstimateMode &fee_estimate_mode)
CBlockIndex * pprev
pointer to the index of the predecessor of this block
UniValue setgenerate(const JSONRPCRequest &request)
uint32_t nStatus
Verification status of this block. See enum BlockStatus.
const char *const BITCOIN_CONF_FILENAME
int64_t UpdateTime(CBlockHeader *pblock, const Consensus::Params &consensusParams, const CBlockIndex *pindexPrev)
bool IsRPCRunning()
Query whether RPC is running.
bool gbt_force
Whether GBT clients can safely ignore this rule in simplified usage.
void RegisterMiningRPCCommands(CRPCTable &t)
Register mining RPC commands.
int Height() const
Return the maximal height in the chain.
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination is a CNoDestination.
UniValue ValueFromAmount(const CAmount &amount)
std::string HexStr(const T itbegin, const T itend, bool fSpaces=false)
void BlockChecked(const CBlock &block, const CValidationState &stateIn) override
Notifies listeners of a block validation result.
std::string StringForFeeEstimateHorizon(FeeEstimateHorizon horizon)
const std::string & get_str() const
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
const std::string CURRENCY_UNIT
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
double GetDifficulty(const CBlockIndex *blockindex)
Get the difficulty of the net wrt to the given block index.
int64_t get_int64() const
uint32_t VersionBitsMask(const Consensus::Params ¶ms, Consensus::DeploymentPos pos)
void UnregisterValidationInterface(CValidationInterface *pwalletIn)
Unregister a wallet from core.
std::string GetWarnings(const std::string &strFor)
Format a string that describes several potential problems detected by the core.
bool DecodeHexBlockHeader(CBlockHeader &, const std::string &hex_header)
submitblock_StateCatcher(const uint256 &hashIn)
bool ProcessNewBlock(const CChainParams &chainparams, const std::shared_ptr< const CBlock > pblock, bool fForceProcessing, bool *fNewBlock)
Process an incoming block.
bool SoftSetArg(const std::string &strArg, const std::string &strValue)
Set an argument if it doesn't already have a value.
bool appendCommand(const std::string &name, const CRPCCommand *pcmd)
Appends a CRPCCommand to the dispatch table.
Implement this to subscribe to events generated in validation.
const std::vector< CTxIn > vin
Invalid, missing or duplicate parameter.
uint256 ParseHashV(const UniValue &v, std::string strName)
Utilities: convert hex-encoded Values (throws error if not hex).
const UniValue & find_value(const UniValue &obj, const std::string &name)
bool ProcessNewBlockHeaders(const std::vector< CBlockHeader > &headers, CValidationState &state, const CChainParams &chainparams, const CBlockIndex **ppindex, CBlockHeader *first_invalid)
Process incoming block headers.
uint64_t nLastBlockWeight
UniValue generateBlocks(std::shared_ptr< CReserveScript > coinbaseScript, int nGenerate, uint64_t nMaxTries, bool keepScript)
Generate blocks (mine)
int64_t CAmount
Amount in satoshis (Can be negative)
uint256 GetBlockHash() const
General error during transaction or block submission.
bool IsValid(enum BlockStatus nUpTo=BLOCK_VALID_TRANSACTIONS) const
Check whether this block index entry is valid up to the passed validity level.
CBlockPolicyEstimator feeEstimator
bool push_back(const UniValue &val)
bool MineBlocksOnDemand() const
Make miner stop after a block is found.
Scripts & signatures ok. Implies all parents are also at least SCRIPTS.
#define LEAVE_CRITICAL_SECTION(cs)
CFeeRate estimateRawFee(int confTarget, double successThreshold, FeeEstimateHorizon horizon, EstimationResult *result=nullptr) const
Return a specific fee estimate calculation with a given success threshold and time horizon...
An input of a transaction.
boost::variant< CNoDestination, CKeyID, CScriptID, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
const uint256 & GetWitnessHash() const
const uint256 & GetHash() const
CFeeRate estimateSmartFee(int confTarget, FeeCalculation *feeCalc, bool conservative) const
Estimate feerate needed to get be included in a block within confTarget blocks.
std::string GetRejectReason() const
Unexpected type was passed as parameter.
bool IsInitialBlockDownload()
Check whether we are doing an initial block download (synchronizing from disk or network) ...
Generate a new block, without valid proof-of-work.
void RPCTypeCheck(const UniValue ¶ms, const std::list< UniValueType > &typesExpected, bool fAllowNull)
Type-check arguments; throws JSONRPCError if wrong type given.
#define WAIT_LOCK(cs, name)
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
UniValue getgenerate(const JSONRPCRequest &request)
Parameters that influence chain consensus.
bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params ¶ms)
Check whether a block hash satisfies the proof-of-work requirement specified by nBits.
CScript COINBASE_FLAGS
Constant stuff for coinbase transactions we create:
256-bit unsigned big integer.
int64_t GetMedianTimePast() const
VersionBitsCache versionbitscache
int64_t DifficultyAdjustmentInterval() const
void RegisterValidationInterface(CValidationInterface *pwalletIn)
Register a wallet to receive updates from core.
void IncrementExtraNonce(CBlock *pblock, const CBlockIndex *pindexPrev, unsigned int &nExtraNonce)
Modify the extranonce in a block.
#define ENTER_CRITICAL_SECTION(cs)
unsigned int HighestTargetTracked(FeeEstimateHorizon horizon) const
Calculation of highest target that estimates are tracked for.
Capture information about block/transaction validation.
CTxDestination DecodeDestination(const std::string &str)
std::vector< CTransactionRef > vtx
const struct VBDeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION_BITS_DEPLOYMENTS]
std::string FormatStateMessage(const CValidationState &state)
Convert CValidationState to a human-readable message for logging.
const char * name
Deployment name.
The block chain is a tree shaped structure starting with the genesis block at the root...
const CChainParams & Params()
Return the currently selected parameters.
Serialized script, used inside transaction inputs and outputs.
const UniValue & get_obj() const
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
void RPCTypeCheckArgument(const UniValue &value, const UniValueType &typeExpected)
Type-check one argument; throws JSONRPCError if wrong type given.
bool TestBlockValidity(CValidationState &state, const CChainParams &chainparams, const CBlock &block, CBlockIndex *pindexPrev, bool fCheckPOW, bool fCheckMerkleRoot)
Check a block is completely valid from start to finish (only works on top of our current best block) ...
clock::time_point time_point
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or nullptr if none.
std::string GetHex() const
int64_t atoi64(const char *psz)
unsigned int ParseConfirmTarget(const UniValue &value)
Check bounds on a command line confirm target.
std::string EncodeHexTx(const CTransaction &tx, const int serializeFlags=0)
Fee rate in satoshis per kilobyte: CAmount / kB.
std::unique_ptr< CConnman > g_connman
const UniValue NullUniValue
std::string i64tostr(int64_t n)
unsigned int GetTransactionsUpdated() const
arith_uint256 & SetCompact(uint32_t nCompact, bool *pfNegative=nullptr, bool *pfOverflow=nullptr)
The "compact" format is a representation of a whole number N using an unsigned 32bit number similar t...
UniValue JSONRPCError(int code, const std::string &message)
No valid connection manager instance found.
std::string GetHex() const
Force estimateSmartFee to use non-conservative estimates.
int64_t GetTime()
GetTimeMicros() and GetTimeMillis() both return the system time, but in different units...
The basic transaction that is broadcasted on the network and contained in blocks. ...
int nHeight
height of the entry in the chain. The genesis block has height 0
const Consensus::Params & GetConsensus() const
int bit
Bit position to select the particular bit in nVersion.
int GenerateBSHA3s(bool fGenerate, int nThreads, const CChainParams &chainparams)
Still downloading initial blocks.
CChain & chainActive
The currently-connected chain of blocks (protected by cs_main).
ThresholdState VersionBitsState(const CBlockIndex *pindexPrev, const Consensus::Params ¶ms, Consensus::DeploymentPos pos, VersionBitsCache &cache)
std::unique_ptr< CBlockTemplate > CreateNewBlock(const CScript &scriptPubKeyIn, bool fMineWitnessTx=true)
Construct a new block template with coinbase to scriptPubKeyIn.
void PrioritiseTransaction(const uint256 &hash, const CAmount &nFeeDelta)
Affect CreateNewBlock prioritisation of transactions.
CAmount GetFeePerK() const
Return the fee in satoshis for a size of 1000 bytes.
void UpdateUncommittedBlockStructures(CBlock &block, const CBlockIndex *pindexPrev, const Consensus::Params &consensusParams)
Update uncommitted block structures (currently: only the witness reserved value). ...
BIP9Deployment vDeployments[MAX_VERSION_BITS_DEPLOYMENTS]
std::string itostr(int n)
Error parsing or validating structure in raw format.
CBlockIndex * LookupBlockIndex(const uint256 &hash)