44 #include <condition_variable>
90 int nShift = (blockindex->
nBits >> 24) & 0xff;
92 (double)0x0000ffff / (
double)(blockindex->
nBits & 0x00ffffff);
111 if (next && next->
pprev == blockindex) {
115 return blockindex == tip ? 1 : -1;
127 result.
pushKV(
"confirmations", confirmations);
138 result.
pushKV(
"nTx", (uint64_t)blockindex->
nTx);
140 if (blockindex->
pprev)
156 result.
pushKV(
"confirmations", confirmations);
165 for(
const auto& tx : block.
vtx)
183 result.
pushKV(
"nTx", (uint64_t)blockindex->
nTx);
185 if (blockindex->
pprev)
195 "\nReturns the height of the most-work fully-validated chain.\n"
196 "The genesis block has height 0.\n",
215 "\nReturns the hash of the best (tip) block in the most-work fully-validated chain.\n",
236 latestblock.height = pindex->
nHeight;
244 "\nWaits for a specific new block and returns useful info about it.\n"
245 "\nReturns the current block on timeout or exit.\n",
247 {
"timeout",
RPCArg::Type::NUM,
"0",
"Time in milliseconds to wait for a response. 0 indicates no timeout."},
262 if (!request.params[0].isNull())
263 timeout = request.params[0].
get_int();
286 "\nWaits for a specific new block and returns useful info about it.\n"
287 "\nReturns the current block on timeout or exit.\n",
290 {
"timeout",
RPCArg::Type::NUM,
"0",
"Time in milliseconds to wait for a response. 0 indicates no timeout."},
299 HelpExampleCli(
"waitforblock",
"\"0000000000079f8ef3d2c688c244eb7a4570b24c9ed7b4a8c619eb02596f8862\" 1000")
300 +
HelpExampleRpc(
"waitforblock",
"\"0000000000079f8ef3d2c688c244eb7a4570b24c9ed7b4a8c619eb02596f8862\", 1000")
308 if (!request.params[1].isNull())
309 timeout = request.params[1].get_int();
332 "\nWaits for (at least) block height and returns the height and hash\n"
333 "of the current tip.\n"
334 "\nReturns the current block on timeout or exit.\n",
337 {
"timeout",
RPCArg::Type::NUM,
"0",
"Time in milliseconds to wait for a response. 0 indicates no timeout."},
353 int height = request.params[0].
get_int();
355 if (!request.params[1].isNull())
356 timeout = request.params[1].get_int();
377 return RPCHelpMan{
"syncwithvalidationinterfacequeue",
378 "\nWaits for the validation interface queue to catch up on everything that was there when we entered this function.\n",
396 "\nReturns the proof-of-work difficulty as a multiple of the minimum difficulty.\n",
399 RPCResult::Type::NUM,
"",
"the proof-of-work difficulty as a multiple of the minimum difficulty."},
413 RPCResult{
RPCResult::Type::NUM,
"vsize",
"virtual transaction size as defined in BIP 141. This is different from actual serialized size for witness transactions as witness data is discounted."},
438 RPCResult{
RPCResult::Type::BOOL,
"unbroadcast",
"Whether this transaction is currently unbroadcast (initial broadcast not yet acknowledged by any peers)"},
450 info.pushKV(
"fees", fees);
452 info.pushKV(
"vsize", (
int)e.GetTxSize());
453 info.pushKV(
"weight", (
int)e.GetTxWeight());
457 info.pushKV(
"height", (
int)e.GetHeight());
458 info.pushKV(
"descendantcount", e.GetCountWithDescendants());
459 info.pushKV(
"descendantsize", e.GetSizeWithDescendants());
460 info.pushKV(
"descendantfees", e.GetModFeesWithDescendants());
461 info.pushKV(
"ancestorcount", e.GetCountWithAncestors());
462 info.pushKV(
"ancestorsize", e.GetSizeWithAncestors());
463 info.pushKV(
"ancestorfees", e.GetModFeesWithAncestors());
464 info.pushKV(
"wtxid", pool.vTxHashes[e.vTxHashesIdx].first.ToString());
466 std::set<std::string> setDepends;
474 for (
const std::string& dep : setDepends)
479 info.pushKV(
"depends", depends);
485 spent.
push_back(child.GetTx().GetHash().ToString());
488 info.pushKV(
"spentby", spent);
491 bool rbfStatus =
false;
499 info.pushKV(
"bip125-replaceable", rbfStatus);
500 info.pushKV(
"unbroadcast", pool.IsUnbroadcastTx(tx.
GetHash()));
506 if (include_mempool_sequence) {
522 uint64_t mempool_sequence;
523 std::vector<uint256> vtxid;
530 for (
const uint256& hash : vtxid)
533 if (!include_mempool_sequence) {
538 o.
pushKV(
"mempool_sequence", mempool_sequence);
547 "\nReturns all transaction ids in memory pool as a json array of string transaction ids.\n"
548 "\nHint: use getmempoolentry to fetch a specific transaction from the mempool.\n",
550 {
"verbose",
RPCArg::Type::BOOL,
"false",
"True for a json object, false for array of transaction ids"},
551 {
"mempool_sequence",
RPCArg::Type::BOOL,
"false",
"If verbose=false, returns a json object with transaction list and mempool sequence number attached."},
564 RPCResult{
"for verbose = false and mempool_sequence = true",
580 bool fVerbose =
false;
581 if (!request.params[0].isNull())
582 fVerbose = request.params[0].
get_bool();
584 bool include_mempool_sequence =
false;
585 if (!request.params[1].isNull()) {
586 include_mempool_sequence = request.params[1].get_bool();
597 "\nIf txid is in the mempool, returns all in-mempool ancestors.\n",
600 {
"verbose",
RPCArg::Type::BOOL,
"false",
"True for a json object, false for array of transaction ids"},
618 bool fVerbose =
false;
619 if (!request.params[1].isNull())
620 fVerbose = request.params[1].
get_bool();
628 if (
it == mempool.mapTx.end()) {
633 uint64_t noLimit = std::numeric_limits<uint64_t>::max();
640 o.
push_back(ancestorIt->GetTx().GetHash().ToString());
661 "\nIf txid is in the mempool, returns all in-mempool descendants.\n",
664 {
"verbose",
RPCArg::Type::BOOL,
"false",
"True for a json object, false for array of transaction ids"},
682 bool fVerbose =
false;
683 if (!request.params[1].isNull())
684 fVerbose = request.params[1].
get_bool();
692 if (
it == mempool.mapTx.end()) {
699 setDescendants.erase(
it);
704 o.
push_back(descendantIt->GetTx().GetHash().ToString());
726 "\nReturns mempool data for given transaction\n",
744 if (
it == mempool.mapTx.end()) {
759 "\nReturns hash of block in best-block-chain at height provided.\n",
773 int nHeight = request.params[0].get_int();
786 "\nIf verbose is false, returns a string that is serialized, hex-encoded data for blockheader 'hash'.\n"
787 "If verbose is true, returns an Object with information about blockheader <hash>.\n",
790 {
"verbose",
RPCArg::Type::BOOL,
"true",
"true for a json object, false for the hex-encoded data"},
797 {
RPCResult::Type::NUM,
"confirmations",
"The number of confirmations, or -1 if the block is not on the main chain"},
816 HelpExampleCli(
"getblockheader",
"\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"")
817 +
HelpExampleRpc(
"getblockheader",
"\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"")
823 bool fVerbose =
true;
824 if (!request.params[1].isNull())
825 fVerbose = request.params[1].get_bool();
843 std::string strHex =
HexStr(ssBlock);
886 "\nIf verbosity is 0, returns a string that is serialized, hex-encoded data for block 'hash'.\n"
887 "If verbosity is 1, returns an Object with information about block <hash>.\n"
888 "If verbosity is 2, returns an Object with information about block <hash> and information about each transaction. \n",
891 {
"verbosity|verbose",
RPCArg::Type::NUM,
"1",
"0 for hex-encoded data, 1 for a json object, and 2 for json object with transaction data"},
900 {
RPCResult::Type::NUM,
"confirmations",
"The number of confirmations, or -1 if the block is not on the main chain"},
915 {
RPCResult::Type::STR_HEX,
"chainwork",
"Expected number of hashes required to produce the chain up to this block (in hex)"},
928 {
RPCResult::Type::ELISION,
"",
"The transactions in the format of the getrawtransaction RPC. Different from verbosity = 1 \"tx\" result"},
934 HelpExampleCli(
"getblock",
"\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"")
935 +
HelpExampleRpc(
"getblock",
"\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"")
942 if (!request.params[1].isNull()) {
943 if(request.params[1].isNum())
944 verbosity = request.params[1].get_int();
946 verbosity = request.params[1].get_bool() ? 1 : 0;
968 std::string strHex =
HexStr(ssBlock);
972 return blockToJSON(block, tip, pblockindex, verbosity >= 2);
982 " to prune blocks whose block time is at least 2 hours older than the provided timestamp."},
997 int heightParam = request.params[0].get_int();
1003 if (heightParam > 1000000000) {
1009 heightParam = pindex->
nHeight;
1012 unsigned int height = (
unsigned int) heightParam;
1016 else if (height > chainHeight)
1019 LogPrint(
BCLog::RPC,
"Attempt to prune blocks close to the tip. Retaining the minimum number of blocks.\n");
1027 block = block->
pprev;
1029 return uint64_t(block->
nHeight);
1037 "\nReturns statistics about the unspent transaction output set.\n"
1038 "Note this call may take some time.\n",
1040 {
"hash_type",
RPCArg::Type::STR,
"hash_serialized_2",
"Which UTXO set hash should be calculated. Options: 'hash_serialized_2' (the legacy algorithm), 'none'."},
1050 {
RPCResult::Type::STR_HEX,
"hash_serialized_2",
"The serialized hash (only present if 'hash_serialized_2' hash_type is chosen)"},
1091 "\nReturns details about an unspent transaction output.\n",
1095 {
"include_mempool",
RPCArg::Type::BOOL,
"true",
"Whether to include the mempool. Note that an unspent output that is spent in the mempool won't appear."},
1115 "\nGet unspent transactions\n"
1117 "\nView the details\n"
1119 "\nAs a JSON-RPC call\n"
1129 int n = request.params[1].get_int();
1131 bool fMempool =
true;
1132 if (!request.params[2].isNull())
1133 fMempool = request.params[2].get_bool();
1146 if (!coins_view->
GetCoin(out, coin)) {
1154 ret.
pushKV(
"confirmations", 0);
1161 ret.
pushKV(
"scriptPubKey", o);
1172 "\nVerifies blockchain database.\n",
1186 const int check_level(request.params[0].isNull() ?
DEFAULT_CHECKLEVEL : request.params[0].get_int());
1187 const int check_depth{request.params[1].isNull() ?
DEFAULT_CHECKBLOCKS : request.params[1].get_int()};
1203 if (height == std::numeric_limits<int>::max())
return;
1206 rv.
pushKV(
"type",
"buried");
1210 rv.
pushKV(
"height", height);
1211 softforks.pushKV(
name, rv);
1220 if (consensusParams.vDeployments[
id].nTimeout <= 1230768000)
return;
1224 switch (thresholdState) {
1233 bip9.
pushKV(
"bit", consensusParams.vDeployments[
id].bit);
1235 bip9.
pushKV(
"start_time", consensusParams.vDeployments[
id].nStartTime);
1236 bip9.
pushKV(
"timeout", consensusParams.vDeployments[
id].nTimeout);
1238 bip9.
pushKV(
"since", since_height);
1248 bip9.
pushKV(
"statistics", statsUV);
1252 rv.
pushKV(
"type",
"bip9");
1255 rv.
pushKV(
"height", since_height);
1259 softforks.pushKV(
name, rv);
1265 "Returns an object containing various state info regarding blockchain processing.\n",
1271 {
RPCResult::Type::NUM,
"blocks",
"the height of the most-work fully-validated chain. The genesis block has height 0"},
1277 {
RPCResult::Type::BOOL,
"initialblockdownload",
"(debug information) estimate of whether this node is in Initial Block Download mode"},
1279 {
RPCResult::Type::NUM,
"size_on_disk",
"the estimated size of the block and undo files on disk"},
1281 {
RPCResult::Type::NUM,
"pruneheight",
"lowest-height complete block stored (only present if pruning is enabled)"},
1282 {
RPCResult::Type::BOOL,
"automatic_pruning",
"whether automatic pruning is enabled (only present if pruning is enabled)"},
1283 {
RPCResult::Type::NUM,
"prune_target_size",
"the target size used by pruning (only present if automatic pruning is enabled)"},
1291 {
RPCResult::Type::STR,
"status",
"one of \"defined\", \"started\", \"locked_in\", \"active\", \"failed\""},
1292 {
RPCResult::Type::NUM,
"bit",
"the bit (0-28) in the block version field used to signal this softfork (only for \"started\" status)"},
1293 {
RPCResult::Type::NUM_TIME,
"start_time",
"the minimum median time past of a block at which the bit gains its meaning"},
1294 {
RPCResult::Type::NUM_TIME,
"timeout",
"the median time past of a block at which the deployment is considered failed if not yet locked in"},
1296 {
RPCResult::Type::OBJ,
"statistics",
"numeric statistics about BIP9 signalling for a softfork (only for \"started\" status)",
1299 {
RPCResult::Type::NUM,
"threshold",
"the number of blocks with the version bit set required to activate the feature"},
1300 {
RPCResult::Type::NUM,
"elapsed",
"the number of blocks elapsed since the beginning of the current period"},
1301 {
RPCResult::Type::NUM,
"count",
"the number of blocks with the version bit set in the current period"},
1302 {
RPCResult::Type::BOOL,
"possible",
"returns false if there are not enough blocks left in this period to pass activation threshold"},
1305 {
RPCResult::Type::NUM,
"height",
"height of the first block which the rules are or will be enforced (only for \"buried\" type, or \"bip9\" type with \"active\" status)"},
1306 {
RPCResult::Type::BOOL,
"active",
"true if the rules are enforced for the mempool and the next block"},
1336 block = block->
pprev;
1342 bool automatic_pruning = (
gArgs.
GetArg(
"-prune", 0) != 1);
1343 obj.
pushKV(
"automatic_pruning", automatic_pruning);
1344 if (automatic_pruning) {
1358 obj.
pushKV(
"softforks", softforks);
1384 "Return information about all known tips in the block tree,"
1385 " including the main chain as well as orphaned branches.\n",
1393 {
RPCResult::Type::NUM,
"branchlen",
"zero for main chain, otherwise length of branch connecting the tip to the main chain"},
1395 "Possible values for status:\n"
1396 "1. \"invalid\" This branch contains at least one invalid block\n"
1397 "2. \"headers-only\" Not all blocks for this branch are available, but the headers are valid\n"
1398 "3. \"valid-headers\" All blocks are available for this branch, but they were never fully validated\n"
1399 "4. \"valid-fork\" This branch is not part of the active chain, but is fully validated\n"
1400 "5. \"active\" This is the tip of the active main chain, which is certainly valid"},
1418 std::set<const CBlockIndex*, CompareBlocksByHeight> setTips;
1419 std::set<const CBlockIndex*> setOrphans;
1420 std::set<const CBlockIndex*> setPrevs;
1422 for (
const std::pair<const uint256, CBlockIndex*>& item : chainman.
BlockIndex()) {
1424 setOrphans.insert(item.second);
1425 setPrevs.insert(item.second->pprev);
1429 for (std::set<const CBlockIndex*>::iterator
it = setOrphans.begin();
it != setOrphans.end(); ++
it) {
1430 if (setPrevs.erase(*
it) == 0) {
1431 setTips.insert(*
it);
1442 obj.
pushKV(
"height", block->nHeight);
1443 obj.
pushKV(
"hash", block->phashBlock->GetHex());
1446 obj.
pushKV(
"branchlen", branchLen);
1455 }
else if (!block->HaveTxsDownloaded()) {
1457 status =
"headers-only";
1460 status =
"valid-fork";
1463 status =
"valid-headers";
1468 obj.
pushKV(
"status", status);
1488 ret.
pushKV(
"maxmempool", (int64_t) maxmempool);
1498 "\nReturns details on the active state of the TX memory pool.\n",
1505 {
RPCResult::Type::NUM,
"bytes",
"Sum of all virtual transaction sizes as defined in BIP 141. Differs from actual serialized size because witness data is discounted"},
1510 {
RPCResult::Type::NUM,
"unbroadcastcount",
"Current number of transactions that haven't passed initial broadcast yet"}
1526 "\nTreats a block as if it were received before others with the same work.\n"
1527 "\nA later preciousblock call can override the effect of an earlier one.\n"
1528 "\nThe effects of preciousblock are not retained across restarts.\n",
1565 "\nPermanently marks a block as invalid, as if it violated a consensus rule.\n",
1605 "\nRemoves invalidity status of a block, its ancestors and its descendants, reconsider them for activation.\n"
1606 "This can be used to undo the effects of invalidateblock.\n",
1644 "\nCompute statistics about the total number and rate of transactions in the chain.\n",
1646 {
"nblocks",
RPCArg::Type::NUM,
"one month",
"Size of the window in number of blocks"},
1653 {
RPCResult::Type::NUM,
"txcount",
"The total number of transactions in the chain up to that point"},
1655 {
RPCResult::Type::NUM,
"window_final_block_height",
"The height of the final block in the window."},
1657 {
RPCResult::Type::NUM,
"window_tx_count",
"The number of transactions in the window. Only returned if \"window_block_count\" is > 0"},
1658 {
RPCResult::Type::NUM,
"window_interval",
"The elapsed time in the window in seconds. Only returned if \"window_block_count\" is > 0"},
1659 {
RPCResult::Type::NUM,
"txrate",
"The average rate of transactions per second in the window. Only returned if \"window_interval\" is > 0"},
1670 if (request.params[1].isNull()) {
1687 if (request.params[0].isNull()) {
1688 blockcount = std::max(0, std::min(blockcount, pindex->
nHeight - 1));
1690 blockcount = request.params[0].get_int();
1692 if (blockcount < 0 || (blockcount > 0 && blockcount >= pindex->
nHeight)) {
1706 ret.
pushKV(
"window_block_count", blockcount);
1707 if (blockcount > 0) {
1708 ret.
pushKV(
"window_tx_count", nTxDiff);
1709 ret.
pushKV(
"window_interval", nTimeDiff);
1710 if (nTimeDiff > 0) {
1711 ret.
pushKV(
"txrate", ((
double)nTxDiff) / nTimeDiff);
1720 template<
typename T>
1723 size_t size = scores.size();
1728 std::sort(scores.begin(), scores.end());
1729 if (size % 2 == 0) {
1730 return (scores[size / 2 - 1] + scores[size / 2]) / 2;
1732 return scores[size / 2];
1738 if (scores.empty()) {
1742 std::sort(scores.begin(), scores.end());
1746 total_weight / 10.0, total_weight / 4.0, total_weight / 2.0, (total_weight * 3.0) / 4.0, (total_weight * 9.0) / 10.0
1749 int64_t next_percentile_index = 0;
1750 int64_t cumulative_weight = 0;
1751 for (
const auto& element : scores) {
1752 cumulative_weight += element.second;
1753 while (next_percentile_index < NUM_GETBLOCKSTATS_PERCENTILES && cumulative_weight >= weights[next_percentile_index]) {
1754 result[next_percentile_index] = element.first;
1755 ++next_percentile_index;
1761 result[i] = scores.back().first;
1765 template<
typename T>
1766 static inline bool SetHasKeys(
const std::set<T>& set) {
return false;}
1767 template<
typename T,
typename Tk,
typename... Args>
1768 static inline bool SetHasKeys(
const std::set<T>& set,
const Tk& key,
const Args&... args)
1770 return (set.count(key) != 0) ||
SetHasKeys(set, args...);
1779 "\nCompute per block statistics for a given window. All amounts are in satoshis.\n"
1780 "It won't work for some heights with pruning.\n",
1797 {
RPCResult::Type::ARR_FIXED,
"feerate_percentiles",
"Feerates at the 10th, 25th, 50th, 75th, and 90th percentile weight unit (in satoshis per virtual byte)",
1822 {
RPCResult::Type::NUM,
"total_out",
"Total amount in all outputs (excluding coinbase and thus reward [ie subsidy + totalfee])"},
1827 {
RPCResult::Type::NUM,
"utxo_increase",
"The increase/decrease in the number of unspent outputs"},
1828 {
RPCResult::Type::NUM,
"utxo_size_inc",
"The increase/decrease in size for the utxo index (not discounting op_return and similar)"},
1831 HelpExampleCli(
"getblockstats", R
"('"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09"' '["minfeerate","avgfeerate"]')") +
1832 HelpExampleCli("getblockstats", R
"(1000 '["minfeerate","avgfeerate"]')") +
1833 HelpExampleRpc("getblockstats", R
"("00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09", ["minfeerate","avgfeerate"])") +
1834 HelpExampleRpc("getblockstats", R
"(1000, ["minfeerate","avgfeerate"])")
1841 if (request.params[0].isNum()) {
1842 const int height = request.params[0].get_int();
1847 if (height > current_tip) {
1865 std::set<std::string> stats;
1866 if (!request.params[1].isNull()) {
1868 for (
unsigned int i = 0; i < stats_univalue.
size(); i++) {
1869 const std::string stat = stats_univalue[i].
get_str();
1877 const bool do_all = stats.size() == 0;
1878 const bool do_mediantxsize = do_all || stats.count(
"mediantxsize") != 0;
1879 const bool do_medianfee = do_all || stats.count(
"medianfee") != 0;
1880 const bool do_feerate_percentiles = do_all || stats.count(
"feerate_percentiles") != 0;
1881 const bool loop_inputs = do_all || do_medianfee || do_feerate_percentiles ||
1882 SetHasKeys(stats,
"utxo_size_inc",
"totalfee",
"avgfee",
"avgfeerate",
"minfee",
"maxfee",
"minfeerate",
"maxfeerate");
1883 const bool loop_outputs = do_all || loop_inputs || stats.count(
"total_out");
1884 const bool do_calculate_size = do_mediantxsize ||
1885 SetHasKeys(stats,
"total_size",
"avgtxsize",
"mintxsize",
"maxtxsize",
"swtotal_size");
1886 const bool do_calculate_weight = do_all ||
SetHasKeys(stats,
"total_weight",
"avgfeerate",
"swtotal_weight",
"avgfeerate",
"feerate_percentiles",
"minfeerate",
"maxfeerate");
1887 const bool do_calculate_sw = do_all ||
SetHasKeys(stats,
"swtxs",
"swtotal_size",
"swtotal_weight");
1896 int64_t maxtxsize = 0;
1898 int64_t outputs = 0;
1899 int64_t swtotal_size = 0;
1900 int64_t swtotal_weight = 0;
1902 int64_t total_size = 0;
1903 int64_t total_weight = 0;
1904 int64_t utxo_size_inc = 0;
1905 std::vector<CAmount> fee_array;
1906 std::vector<std::pair<CAmount, int64_t>> feerate_array;
1907 std::vector<int64_t> txsize_array;
1909 for (
size_t i = 0; i < block.
vtx.size(); ++i) {
1910 const auto& tx = block.
vtx.at(i);
1911 outputs += tx->vout.size();
1915 for (
const CTxOut& out : tx->vout) {
1916 tx_total_out += out.
nValue;
1921 if (tx->IsCoinBase()) {
1925 inputs += tx->vin.size();
1926 total_out += tx_total_out;
1928 int64_t tx_size = 0;
1929 if (do_calculate_size) {
1931 tx_size = tx->GetTotalSize();
1932 if (do_mediantxsize) {
1933 txsize_array.push_back(tx_size);
1935 maxtxsize = std::max(maxtxsize, tx_size);
1936 mintxsize = std::min(mintxsize, tx_size);
1937 total_size += tx_size;
1941 if (do_calculate_weight) {
1943 total_weight += weight;
1946 if (do_calculate_sw && tx->HasWitness()) {
1948 swtotal_size += tx_size;
1949 swtotal_weight += weight;
1954 const auto& txundo = blockUndo.
vtxundo.at(i - 1);
1955 for (
const Coin& coin: txundo.vprevout) {
1958 tx_total_in += prevoutput.
nValue;
1962 CAmount txfee = tx_total_in - tx_total_out;
1965 fee_array.push_back(txfee);
1967 maxfee = std::max(maxfee, txfee);
1968 minfee = std::min(minfee, txfee);
1973 if (do_feerate_percentiles) {
1974 feerate_array.emplace_back(std::make_pair(feerate, weight));
1976 maxfeerate = std::max(maxfeerate, feerate);
1977 minfeerate = std::min(minfeerate, feerate);
1986 feerates_res.
push_back(feerate_percentiles[i]);
1990 ret_all.
pushKV(
"avgfee", (block.
vtx.size() > 1) ? totalfee / (block.
vtx.size() - 1) : 0);
1992 ret_all.
pushKV(
"avgtxsize", (block.
vtx.size() > 1) ? total_size / (block.
vtx.size() - 1) : 0);
1994 ret_all.
pushKV(
"feerate_percentiles", feerates_res);
1996 ret_all.
pushKV(
"ins", inputs);
1997 ret_all.
pushKV(
"maxfee", maxfee);
1998 ret_all.
pushKV(
"maxfeerate", maxfeerate);
1999 ret_all.
pushKV(
"maxtxsize", maxtxsize);
2004 ret_all.
pushKV(
"minfeerate", (minfeerate ==
MAX_MONEY) ? 0 : minfeerate);
2006 ret_all.
pushKV(
"outs", outputs);
2008 ret_all.
pushKV(
"swtotal_size", swtotal_size);
2009 ret_all.
pushKV(
"swtotal_weight", swtotal_weight);
2010 ret_all.
pushKV(
"swtxs", swtxs);
2012 ret_all.
pushKV(
"total_out", total_out);
2013 ret_all.
pushKV(
"total_size", total_size);
2014 ret_all.
pushKV(
"total_weight", total_weight);
2015 ret_all.
pushKV(
"totalfee", totalfee);
2016 ret_all.
pushKV(
"txs", (int64_t)block.
vtx.size());
2017 ret_all.
pushKV(
"utxo_increase", outputs - inputs);
2018 ret_all.
pushKV(
"utxo_size_inc", utxo_size_inc);
2025 for (
const std::string& stat : stats) {
2026 const UniValue& value = ret_all[stat];
2040 "\nDumps the mempool to disk. It will fail until the previous dump is fully loaded.\n",
2066 bool FindScriptPubKey(std::atomic<int>& scan_progress,
const std::atomic<bool>& should_abort, int64_t&
count,
CCoinsViewCursor* cursor,
const std::set<CScript>& needles, std::map<COutPoint, Coin>& out_results, std::function<
void()>& interruption_point)
2070 while (cursor->
Valid()) {
2073 if (!cursor->
GetKey(key) || !cursor->
GetValue(coin))
return false;
2074 if (++
count % 8192 == 0) {
2075 interruption_point();
2081 if (
count % 256 == 0) {
2084 scan_progress = (int)(high * 100.0 / 65536.0 + 0.5);
2087 out_results.emplace(key, coin);
2091 scan_progress = 100;
2126 "\nEXPERIMENTAL warning: this call may be removed or changed in future releases.\n"
2127 "\nScans the unspent transaction output set for entries that match certain output descriptors.\n"
2128 "Examples of output descriptors are:\n"
2129 " addr(<address>) Outputs whose scriptPubKey corresponds to the specified address (does not include P2PK)\n"
2130 " raw(<hex script>) Outputs whose scriptPubKey equals the specified hex scripts\n"
2131 " combo(<pubkey>) P2PK, P2PKH, P2WPKH, and P2SH-P2WPKH outputs for the given pubkey\n"
2132 " pkh(<pubkey>) P2PKH outputs for the given pubkey\n"
2133 " sh(multi(<n>,<pubkey>,<pubkey>,...)) P2SH-multisig outputs for the given threshold and pubkeys\n"
2134 "\nIn the above, <pubkey> either refers to a fixed public key in hexadecimal notation, or to an xpub/xprv optionally followed by one\n"
2135 "or more path elements separated by \"/\", and optionally ending in \"/*\" (unhardened), or \"/*'\" or \"/*h\" (hardened) to specify all\n"
2136 "unhardened or hardened child keys.\n"
2137 "In the latter case, a range needs to be specified by below if different from 1000.\n"
2138 "For more information on output descriptors, see the documentation in the doc/descriptors.md file.\n",
2141 " \"start\" for starting a scan\n"
2142 " \"abort\" for aborting the current scan (returns true when abort was successful)\n"
2143 " \"status\" for progress report (in %) of the current scan"},
2145 " Every scan object is either a string descriptor or an object:",
2151 {
"range",
RPCArg::Type::RANGE,
"1000",
"The range of HD chain indexes to explore (either end or [begin,end])"},
2155 "[scanobjects,...]"},
2181 RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VARR});
2184 if (request.params[0].get_str() ==
"status") {
2192 }
else if (request.params[0].get_str() ==
"abort") {
2201 }
else if (request.params[0].get_str() ==
"start") {
2207 if (request.params.size() < 2) {
2211 std::set<CScript> needles;
2212 std::map<CScript, std::string> descriptors;
2219 for (
const auto& script : scripts) {
2221 needles.emplace(script);
2222 descriptors.emplace(std::move(script), std::move(inferred));
2228 std::vector<CTxOut> input_txos;
2229 std::map<COutPoint, Coin> coins;
2233 std::unique_ptr<CCoinsViewCursor> pcursor;
2238 pcursor = std::unique_ptr<CCoinsViewCursor>(::
ChainstateActive().CoinsDB().Cursor());
2245 result.
pushKV(
"success", res);
2250 for (
const auto&
it : coins) {
2252 const Coin& coin =
it.second;
2254 input_txos.push_back(txo);
2259 unspent.
pushKV(
"vout", (int32_t)outpoint.
n);
2267 result.
pushKV(
"unspents", unspents);
2280 "\nRetrieve a BIP 157 content filter for a particular block.\n",
2292 HelpExampleCli(
"getblockfilter",
"\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\" \"basic\"") +
2293 HelpExampleRpc(
"getblockfilter",
"\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\", \"basic\"")
2298 std::string filtertype_name =
"basic";
2299 if (!request.params[1].isNull()) {
2300 filtertype_name = request.params[1].get_str();
2314 bool block_was_connected;
2331 std::string errmsg =
"Filter not found.";
2333 if (!block_was_connected) {
2335 errmsg +=
" Block was not connected to active chain.";
2336 }
else if (!index_ready) {
2338 errmsg +=
" Block filters are still in the process of being indexed.";
2341 errmsg +=
" This error is unexpected and indicates index corruption.";
2364 "\nWrite the serialized UTXO set to disk.\n",
2370 "path to the output file. If relative, will be prefixed by datadir."},
2386 fs::path path = fs::absolute(request.params[0].get_str(),
GetDataDir());
2389 fs::path temppath = fs::absolute(request.params[0].get_str() +
".incomplete",
GetDataDir());
2391 if (fs::exists(path)) {
2394 path.string() +
" already exists. If you are sure this is what you want, "
2395 "move it out of the way first");
2400 std::unique_ptr<CCoinsViewCursor> pcursor;
2426 pcursor = std::unique_ptr<CCoinsViewCursor>(::
ChainstateActive().CoinsDB().Cursor());
2437 unsigned int iter{0};
2439 while (pcursor->Valid()) {
2442 if (pcursor->GetKey(key) && pcursor->GetValue(coin)) {
2451 fs::rename(temppath, path);
2457 result.
pushKV(
"path", path.string());
2470 {
"blockchain",
"getchaintxstats", &
getchaintxstats, {
"nblocks",
"blockhash"} },
2471 {
"blockchain",
"getblockstats", &
getblockstats, {
"hash_or_height",
"stats"} },
2474 {
"blockchain",
"getblock", &
getblock, {
"blockhash",
"verbosity|verbose"} },
2475 {
"blockchain",
"getblockhash", &
getblockhash, {
"height"} },
2476 {
"blockchain",
"getblockheader", &
getblockheader, {
"blockhash",
"verbose"} },
2483 {
"blockchain",
"getrawmempool", &
getrawmempool, {
"verbose",
"mempool_sequence"} },
2484 {
"blockchain",
"gettxout", &
gettxout, {
"txid",
"n",
"include_mempool"} },
2487 {
"blockchain",
"savemempool", &
savemempool, {} },
2488 {
"blockchain",
"verifychain", &
verifychain, {
"checklevel",
"nblocks"} },
2490 {
"blockchain",
"preciousblock", &
preciousblock, {
"blockhash"} },
2491 {
"blockchain",
"scantxoutset", &
scantxoutset, {
"action",
"scanobjects"} },
2492 {
"blockchain",
"getblockfilter", &
getblockfilter, {
"blockhash",
"filtertype"} },
2498 {
"hidden",
"waitforblock", &
waitforblock, {
"blockhash",
"timeout"} },
2504 for (
const auto& c : commands) {
bool MoneyRange(const CAmount &nValue)
int64_t CAmount
Amount in satoshis (Can be negative)
static const CAmount MAX_MONEY
No amount larger than this (in satoshi) is valid.
static RPCHelpMan getblock()
static int ComputeNextBlockAndDepth(const CBlockIndex *tip, const CBlockIndex *blockindex, const CBlockIndex *&next)
static RPCHelpMan getdifficulty()
static std::atomic< bool > g_scan_in_progress
static bool SetHasKeys(const std::set< T > &set)
static RPCHelpMan reconsiderblock()
static T CalculateTruncatedMedian(std::vector< T > &scores)
static RPCHelpMan invalidateblock()
static RPCHelpMan getmempoolinfo()
NodeContext & EnsureNodeContext(const util::Ref &context)
static RPCHelpMan syncwithvalidationinterfacequeue()
UniValue blockToJSON(const CBlock &block, const CBlockIndex *tip, const CBlockIndex *blockindex, bool txDetails)
Block description to JSON.
static RPCHelpMan getchaintips()
static RPCHelpMan gettxoutsetinfo()
static void entryToJSON(const CTxMemPool &pool, UniValue &info, const CTxMemPoolEntry &e) EXCLUSIVE_LOCKS_REQUIRED(pool.cs)
static RPCHelpMan getblockstats()
static std::vector< RPCResult > MempoolEntryDescription()
CTxMemPool & EnsureMemPool(const util::Ref &context)
static RPCHelpMan preciousblock()
static constexpr size_t PER_UTXO_OVERHEAD
double GetDifficulty(const CBlockIndex *blockindex)
Get the difficulty of the net wrt to the given block index.
static RPCHelpMan getrawmempool()
static RPCHelpMan scantxoutset()
static RPCHelpMan getmempoolentry()
static std::condition_variable cond_blockchange
void CalculatePercentilesByWeight(CAmount result[NUM_GETBLOCKSTATS_PERCENTILES], std::vector< std::pair< CAmount, int64_t >> &scores, int64_t total_weight)
Used by getblockstats to get feerates at different percentiles by weight
static Mutex cs_blockchange
static std::atomic< int > g_scan_progress
RAII object to prevent concurrency issue when scanning the txout set.
UniValue MempoolInfoToJSON(const CTxMemPool &pool)
Mempool information to JSON.
static RPCHelpMan getblockfilter()
static RPCHelpMan getbestblockhash()
static CBlockUndo GetUndoChecked(const CBlockIndex *pblockindex)
RPCHelpMan getblockchaininfo()
static RPCHelpMan getchaintxstats()
static RPCHelpMan waitforblock()
static RPCHelpMan getblockhash()
void RegisterBlockchainRPCCommands(CRPCTable &t)
Register block chain RPC commands.
static RPCHelpMan gettxout()
UniValue MempoolToJSON(const CTxMemPool &pool, bool verbose, bool include_mempool_sequence)
Mempool to JSON.
ChainstateManager & EnsureChainman(const util::Ref &context)
static RPCHelpMan verifychain()
static std::atomic< bool > g_should_abort_scan
UniValue blockheaderToJSON(const CBlockIndex *tip, const CBlockIndex *blockindex)
Block header to JSON.
static void BuriedForkDescPushBack(UniValue &softforks, const std::string &name, int height) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
static CBlock GetBlockChecked(const CBlockIndex *pblockindex)
static RPCHelpMan waitforblockheight()
static void BIP9SoftForkDescPushBack(UniValue &softforks, const std::string &name, const Consensus::Params &consensusParams, Consensus::DeploymentPos id) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
static RPCHelpMan pruneblockchain()
static CUpdatedBlock latestblock GUARDED_BY(cs_blockchange)
static RPCHelpMan getblockheader()
static RPCHelpMan getmempooldescendants()
static RPCHelpMan dumptxoutset()
Serialize the UTXO set to a file for loading elsewhere.
static RPCHelpMan getblockcount()
static RPCHelpMan waitfornewblock()
static RPCHelpMan getmempoolancestors()
static RPCHelpMan savemempool()
void RPCNotifyBlockChange(const CBlockIndex *pindex)
Callback for when block tip changed.
static constexpr int NUM_GETBLOCKSTATS_PERCENTILES
bool BlockFilterTypeByName(const std::string &name, BlockFilterType &filter_type)
Find a filter type by its human-readable name.
BlockFilterIndex * GetBlockFilterIndex(BlockFilterType filter_type)
Get a block filter index by type.
@ BLOCK_VALID_SCRIPTS
Scripts & signatures ok. Implies all parents are also at least SCRIPTS.
@ BLOCK_VALID_TREE
All parent headers found, difficulty matches, timestamp >= median previous, checkpoint.
@ BLOCK_HAVE_DATA
full block available in blk*.dat
static constexpr int64_t TIMESTAMP_WINDOW
Timestamp window used as a grace period by code that compares external timestamps (such as timestamps...
const CChainParams & Params()
Return the currently selected parameters.
#define CHECK_NONFATAL(condition)
Throw a NonFatalCheckError when the condition evaluates to false.
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
bool BlockUntilSyncedToCurrentChain() const
Blocks the current thread until the index is caught up to the current state of the block chain.
Complete block filter struct as defined in BIP 157.
const std::vector< unsigned char > & GetEncodedFilter() const
BlockFilterIndex is used to store and retrieve block filters, hashes, and headers for a range of bloc...
bool LookupFilterHeader(const CBlockIndex *block_index, uint256 &header_out)
Get a single filter header by block.
bool LookupFilter(const CBlockIndex *block_index, BlockFilter &filter_out) const
Get a single filter by block.
Non-refcounted RAII wrapper for FILE*.
std::vector< CTransactionRef > vtx
The block chain is a tree shaped structure starting with the genesis block at the root,...
CBlockIndex * pprev
pointer to the index of the predecessor of this block
CBlockHeader GetBlockHeader() const
arith_uint256 nChainWork
(memory only) Total amount of work (expected number of hashes) in the chain up to and including this ...
uint256 GetBlockHash() const
int64_t GetBlockTime() const
int64_t GetMedianTimePast() const
unsigned int nTx
Number of transactions in this block.
bool IsValid(enum BlockStatus nUpTo=BLOCK_VALID_TRANSACTIONS) const
Check whether this block index entry is valid up to the passed validity level.
int32_t nVersion
block header
CBlockIndex * GetAncestor(int height)
Efficiently find an ancestor of this block.
int nHeight
height of the entry in the chain. The genesis block has height 0
uint32_t nStatus
Verification status of this block. See enum BlockStatus.
unsigned int nChainTx
(memory only) Number of transactions in the chain up to and including this block.
Undo information for a CBlock.
std::vector< CTxUndo > vtxundo
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or nullptr if none.
CBlockIndex * FindEarliestAtLeast(int64_t nTime, int height) const
Find the earliest block with timestamp equal or greater than the given time and height equal or great...
int Height() const
Return the maximal height in the chain.
const CBlockIndex * FindFork(const CBlockIndex *pindex) const
Find the last common block between this chain and a block index entry.
bool Contains(const CBlockIndex *pindex) const
Efficiently check whether a block is present in this chain.
const Consensus::Params & GetConsensus() const
uint64_t PruneAfterHeight() const
CCoinsViewCache & CoinsTip() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
void ForceFlushStateToDisk()
Unconditionally flush all changes to disk.
CCoinsView that adds a memory cache for transactions to another CCoinsView.
uint256 GetBestBlock() const override
Retrieve the block hash whose state this CCoinsView currently represents.
bool GetCoin(const COutPoint &outpoint, Coin &coin) const override
Retrieve the Coin (unspent transaction output) for a given outpoint.
Cursor for iterating over CoinsView state.
virtual bool Valid() const =0
virtual bool GetKey(COutPoint &key) const =0
virtual bool GetValue(Coin &coin) const =0
Abstract view on the open txout dataset.
CCoinsView that brings transactions from a mempool into view.
bool GetCoin(const COutPoint &outpoint, Coin &coin) const override
Retrieve the Coin (unspent transaction output) for a given outpoint.
Double ended buffer combining vector and stream-like interfaces.
CAmount GetFeePerK() const
Return the fee in satoshis for a size of 1000 bytes.
An outpoint - a combination of a transaction hash and an index n into its vout.
void appendCommand(const std::string &name, const CRPCCommand *pcmd)
Appends a CRPCCommand to the dispatch table.
The basic transaction that is broadcasted on the network and contained in blocks.
const uint256 & GetHash() const
const std::vector< CTxIn > vin
An input of a transaction.
CTxMemPoolEntry stores data about the corresponding transaction, as well as data about all in-mempool...
const CTransaction & GetTx() const
std::set< CTxMemPoolEntryRef, CompareIteratorByHash > Children
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it.
CFeeRate GetMinFee(size_t sizelimit) const
The minimum fee to get into the mempool, which may itself not be enough for larger-sized transactions...
size_t DynamicMemoryUsage() const
bool CalculateMemPoolAncestors(const CTxMemPoolEntry &entry, setEntries &setAncestors, uint64_t limitAncestorCount, uint64_t limitAncestorSize, uint64_t limitDescendantCount, uint64_t limitDescendantSize, std::string &errString, bool fSearchForParents=true) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Try to calculate all in-mempool ancestors of entry.
std::set< txiter, CompareIteratorByHash > setEntries
std::set< uint256 > GetUnbroadcastTxs() const
Returns transactions in unbroadcast set.
void queryHashes(std::vector< uint256 > &vtxid) const
uint64_t GetSequence() const EXCLUSIVE_LOCKS_REQUIRED(cs)
indexed_transaction_set::nth_index< 0 >::type::const_iterator txiter
void CalculateDescendants(txiter it, setEntries &setDescendants) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Populate setDescendants with all in-mempool descendants of hash.
unsigned long size() const
uint64_t GetTotalTxSize() const EXCLUSIVE_LOCKS_REQUIRED(cs)
bool isSpent(const COutPoint &outpoint) const
An output of a transaction.
RAII wrapper for VerifyDB: Verify consistency of the block and coin databases.
bool VerifyDB(const CChainParams &chainparams, CCoinsView *coinsview, int nCheckLevel, int nCheckDepth)
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
CChain & ActiveChain() const
BlockMap & BlockIndex() EXCLUSIVE_LOCKS_REQUIRED(
CTxOut out
unspent transaction output
uint32_t nHeight
at which height this containing transaction was included in the active block chain
unsigned int fCoinBase
whether containing transaction was a coinbase
const std::string & get_str() const
void __pushKV(const std::string &key, const UniValue &val)
const std::vector< UniValue > & getValues() const
bool push_back(const UniValue &val)
const UniValue & get_array() const
bool pushKV(const std::string &key, const UniValue &val)
std::string ToString() const
std::string ToString() const
std::string GetHex() const
std::string GetHex() const
Type-safe dynamic reference.
static const int CLIENT_VERSION
bitcoind-res.rc includes this file, but it cannot cope with real c++ code.
static bool GetUTXOStats(CCoinsView *view, CCoinsStats &stats, T hash_obj, const std::function< void()> &interruption_point)
Calculate statistics about the unspent transaction output set.
static int64_t GetBlockWeight(const CBlock &block)
static int64_t GetTransactionWeight(const CTransaction &tx)
static const unsigned int MAX_BLOCK_SERIALIZED_SIZE
The maximum allowed size for a serialized block, in bytes (only for buffer size limits)
static const int WITNESS_SCALE_FACTOR
void ScriptPubKeyToUniv(const CScript &scriptPubKey, UniValue &out, bool fIncludeHex)
UniValue ValueFromAmount(const CAmount &amount)
void TxToUniv(const CTransaction &tx, const uint256 &hashBlock, UniValue &entry, bool include_hex=true, int serialize_flags=0)
std::unique_ptr< Descriptor > InferDescriptor(const CScript &script, const SigningProvider &provider)
Find a descriptor for the specified script, using information from provider where possible.
const std::string CURRENCY_UNIT
#define LogPrint(category,...)
FILE * fopen(const fs::path &p, const char *mode)
std::deque< CInv >::iterator it
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
RBFTransactionState IsRBFOptIn(const CTransaction &tx, const CTxMemPool &pool)
Determine whether an unconfirmed transaction is signaling opt-in to RBF according to BIP 125 This inv...
RBFTransactionState
The rbf state of unconfirmed transactions.
@ UNKNOWN
Unconfirmed tx that does not signal rbf and is not in the mempool.
@ REPLACEABLE_BIP125
Either this tx or a mempool ancestor signals rbf.
static const unsigned int DEFAULT_MAX_MEMPOOL_SIZE
Default for -maxmempool, maximum megabytes of mempool memory usage.
static const int SERIALIZE_TRANSACTION_NO_WITNESS
A flag that is ORed into the protocol version to designate that a transaction should be (un)serialize...
UniValue JSONRPCError(int code, const std::string &message)
@ RPC_MISC_ERROR
General application defined errors.
@ RPC_CLIENT_MEMPOOL_DISABLED
Chain errors.
@ RPC_INVALID_PARAMETER
Invalid, missing or duplicate parameter.
@ RPC_DATABASE_ERROR
Database error.
@ RPC_INVALID_ADDRESS_OR_KEY
Invalid address or key.
size_t GetSerializeSize(const T &t, int nVersion=0)
bool IsRPCRunning()
Query whether RPC is running.
int RPCSerializationFlags()
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
auto Join(const std::vector< T > &list, const BaseType &separator, UnaryOp unary_op) -> decltype(unary_op(list.at(0)))
Join a list of items.
Display status of an in-progress BIP9 softfork.
int count
Number of blocks with the version bit set since the beginning of the current period.
int elapsed
Number of blocks elapsed since the beginning of the current period.
int threshold
Number of blocks with the version bit set required to activate the softfork.
bool possible
False if there are not enough blocks left in this period to pass activation threshold.
int period
Length of blocks of the BIP9 signalling period.
uint64_t nTransactionOutputs
uint64_t coins_count
The number of coins contained.
Comparison function for sorting the getchaintips heads.
bool operator()(const CBlockIndex *a, const CBlockIndex *b) const
Parameters that influence chain consensus.
int BIP65Height
Block height at which BIP65 becomes active.
int CSVHeight
Block height at which CSV (BIP68, BIP112 and BIP113) becomes active.
int SegwitHeight
Block height at which Segwit (BIP141, BIP143 and BIP147) becomes active.
int BIP34Height
Block height and hash at which BIP34 becomes active.
int BIP66Height
Block height at which BIP66 becomes active.
int64_t nPowTargetSpacing
NodeContext struct containing references to chain state and connection state.
std::unique_ptr< CTxMemPool > mempool
ChainstateManager * chainman
std::function< void()> rpc_interruption_point
@ RANGE
Special type that is a NUM or [NUM,NUM].
@ STR_HEX
Special type that is a STR with only hex chars.
@ OMITTED
Optional argument with default value omitted because they are implicitly clear.
@ ELISION
Special type to denote elision (...)
@ NUM_TIME
Special numeric to denote unix epoch time.
@ ARR_FIXED
Special array that has a fixed number of entries.
@ OBJ_DYN
Special dictionary with keys that are not literals.
@ STR_HEX
Special string with only hex chars.
@ STR_AMOUNT
Special string to represent a floating point amount.
#define WAIT_LOCK(cs, name)
#define AssertLockNotHeld(cs)
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
const fs::path & GetDataDir(bool fNetSpecific)
#define EXCLUSIVE_LOCKS_REQUIRED(...)
int64_t count_seconds(std::chrono::seconds t)
Helper to count the seconds of a duration.
static const uint32_t MEMPOOL_HEIGHT
Fake height value used in Coin to signify they are only in the memory pool (since 0....
const UniValue NullUniValue
CoinStatsHashType ParseHashType(const UniValue ¶m, const CoinStatsHashType default_type)
void RPCTypeCheck(const UniValue ¶ms, const std::list< UniValueType > &typesExpected, bool fAllowNull)
Type-check arguments; throws JSONRPCError if wrong type given.
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
std::vector< CScript > EvalDescriptorStringOrObject(const UniValue &scanobject, FlatSigningProvider &provider)
Evaluate a descriptor given as a string, or as a {"desc":...,"range":...} object, with default range ...
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
const std::string UNIX_EPOCH_TIME
String used to describe UNIX epoch time in documentation, factored out to a constant for consistency.
uint256 ParseHashV(const UniValue &v, std::string strName)
Utilities: convert hex-encoded Values (throws error if not hex).
uint64_t nPruneTarget
Number of MiB of block files that we're trying to stay below.
BIP9Stats VersionBitsTipStatistics(const Consensus::Params ¶ms, Consensus::DeploymentPos pos)
Get the numerical statistics for the BIP9 state for a given deployment at the current tip.
void PruneBlockFilesManual(int nManualPruneHeight)
Prune block files up to a given height.
bool UndoReadFromDisk(CBlockUndo &blockundo, const CBlockIndex *pindex)
void ResetBlockFailureFlags(CBlockIndex *pindex)
Remove invalidity status from a block and its descendants.
double GuessVerificationProgress(const ChainTxData &data, const CBlockIndex *pindex)
Guess how far we are in the verification process at the given block index require cs_main if pindex h...
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params &consensusParams)
bool InvalidateBlock(BlockValidationState &state, const CChainParams &chainparams, CBlockIndex *pindex)
Mark a block as invalid.
bool DumpMempool(const CTxMemPool &pool)
Dump the mempool to disk.
CFeeRate minRelayTxFee
A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation)
uint64_t CalculateCurrentUsage()
BLOCK PRUNING CODE.
CChain & ChainActive()
Please prefer the identical ChainstateManager::ActiveChain.
CChainState & ChainstateActive()
Please prefer the identical ChainstateManager::ActiveChainstate.
bool PreciousBlock(BlockValidationState &state, const CChainParams ¶ms, CBlockIndex *pindex)
Mark a block as precious and reorganize.
bool ReadBlockFromDisk(CBlock &block, const FlatFilePos &pos, const Consensus::Params &consensusParams)
Functions for disk access for blocks.
AssertLockHeld(mempool.cs)
CBlockIndex * LookupBlockIndex(const uint256 &hash)
const std::vector< std::string > CHECKLEVEL_DOC
Documentation for argument 'checklevel'.
ThresholdState VersionBitsTipState(const Consensus::Params ¶ms, Consensus::DeploymentPos pos)
Get the BIP9 state for a given deployment at the current tip.
bool fPruneMode
True if we're running in -prune mode.
bool ActivateBestChain(BlockValidationState &state, const CChainParams &chainparams, std::shared_ptr< const CBlock > pblock)
Find the best known block, and make it the tip of the block chain.
int VersionBitsTipStateSinceHeight(const Consensus::Params ¶ms, Consensus::DeploymentPos pos)
Get the block height at which the BIP9 deployment switched into the state for the block building on t...
CBlockIndex * pindexBestHeader
Best header we've seen so far (used for getheaders queries' starting points).
static const unsigned int DEFAULT_CHECKLEVEL
static const unsigned int MIN_BLOCKS_TO_KEEP
Block files containing a block-height within MIN_BLOCKS_TO_KEEP of ChainActive().Tip() will not be pr...
bool IsBlockPruned(const CBlockIndex *pblockindex)
Check whether the block associated with this index entry is pruned or not.
static const signed int DEFAULT_CHECKBLOCKS
void SyncWithValidationInterfaceQueue()
This is a synonym for the following, which asserts certain locks are not held: std::promise<void> pro...
static const int PROTOCOL_VERSION
network protocol versioning
ThresholdState
BIP 9 defines a finite-state-machine to deploy a softfork in multiple stages.
bilingual_str GetWarnings(bool verbose)
Format a string that describes several potential problems detected by the core.