6 #if defined(HAVE_CONFIG_H)
78 #include <boost/algorithm/string/replace.hpp>
79 #include <boost/signals2/signal.hpp>
80 #include <boost/thread/thread.hpp>
97 #define MIN_CORE_FILEDESCRIPTORS 0
99 #define MIN_CORE_FILEDESCRIPTORS 150
180 static Mutex g_shutdown_mutex;
181 TRY_LOCK(g_shutdown_mutex, lock_shutdown);
182 if (!lock_shutdown)
return;
183 LogPrintf(
"%s: In progress...\n", __func__);
244 if (!est_fileout.
IsNull())
247 LogPrintf(
"%s: Failed to write fee estimates to %s\n", __func__, est_path.string());
255 if (chainstate->CanFlushToDisk()) {
256 chainstate->ForceFlushStateToDisk();
282 if (chainstate->CanFlushToDisk()) {
283 chainstate->ForceFlushStateToDisk();
284 chainstate->ResetCoinsViews();
312 LogPrintf(
"%s: Unable to remove PID file: File does not exist\n", __func__);
314 }
catch (
const fs::filesystem_error& e) {
338 static BOOL WINAPI consoleCtrlHandler(DWORD dwCtrlType)
351 sigemptyset(&sa.sa_mask);
353 sigaction(signal, &sa,
nullptr);
365 rpc_notify_block_change_connection.disconnect();
390 std::vector<std::string> hidden_args = {
391 "-dbcrashratio",
"-forcecompactdb",
393 "-choosedatadir",
"-lang=<lang>",
"-min",
"-resetguisettings",
"-splash",
"-uiplatform"};
399 argsman.
AddArg(
"-assumevalid=<hex>",
strprintf(
"If this block is in the chain assume that it and its ancestors are valid and potentially skip their script verification (0 to verify all, default: %s, testnet: %s, signet: %s)", defaultChainParams->GetConsensus().defaultAssumeValid.GetHex(), testnetChainParams->GetConsensus().defaultAssumeValid.GetHex(), signetChainParams->GetConsensus().defaultAssumeValid.GetHex()),
ArgsManager::ALLOW_ANY,
OptionsCategory::OPTIONS);
418 argsman.
AddArg(
"-par=<n>",
strprintf(
"Set the number of script verification threads (%u to %d, 0 = auto, <0 = leave that many cores free, default: %d)",
422 argsman.
AddArg(
"-prune=<n>",
strprintf(
"Reduce storage requirements by enabling pruning (deleting) of old blocks. This allows the pruneblockchain RPC to be called to delete specific blocks, and enables automatic pruning of old blocks if a target size in MiB is provided. This mode is incompatible with -txindex and -rescan. "
423 "Warning: Reverting this setting requires re-downloading the entire blockchain. "
434 hidden_args.emplace_back(
"-sysperms");
437 argsman.
AddArg(
"-blockfilterindex=<type>",
439 " If <type> is not supplied or if <type> = 1, indexes for all known types are enabled.",
445 argsman.
AddArg(
"-bind=<addr>[:<port>][=onion]",
strprintf(
"Bind to given address and always listen on it (default: 0.0.0.0). Use [host]:port notation for IPv6. Append =onion to tag any incoming connections to that address and port as incoming Tor connections (default: 127.0.0.1:%u=onion, testnet: 127.0.0.1:%u=onion, signet: 127.0.0.1:%u=onion, regtest: 127.0.0.1:%u=onion)", defaultBaseParams->OnionServiceTargetPort(), testnetBaseParams->OnionServiceTargetPort(), signetBaseParams->OnionServiceTargetPort(), regtestBaseParams->OnionServiceTargetPort()),
ArgsManager::ALLOW_ANY |
ArgsManager::NETWORK_ONLY,
OptionsCategory::CONNECTION);
460 argsman.
AddArg(
"-onlynet=<net>",
"Make outgoing connections only through network <net> (ipv4, ipv6 or onion). Incoming connections are not affected by this option. This option can be specified multiple times to allow multiple networks.",
ArgsManager::ALLOW_ANY,
OptionsCategory::CONNECTION);
464 argsman.
AddArg(
"-port=<port>",
strprintf(
"Listen for connections on <port>. Nodes not using the default ports (default: %u, testnet: %u, signet: %u, regtest: %u) are unlikely to get incoming connections.", defaultChainParams->GetDefaultPort(), testnetChainParams->GetDefaultPort(), signetChainParams->GetDefaultPort(), regtestChainParams->GetDefaultPort()),
ArgsManager::ALLOW_ANY |
ArgsManager::NETWORK_ONLY,
OptionsCategory::CONNECTION);
480 hidden_args.emplace_back(
"-upnp");
482 argsman.
AddArg(
"-whitebind=<[permissions@]addr>",
"Bind to the given address and add permission flags to the peers connecting to it. "
486 argsman.
AddArg(
"-whitelist=<[permissions@]IP address or network>",
"Add permission flags to the peers connecting from the given IP address (e.g. 1.2.3.4) or "
487 "CIDR-notated network (e.g. 1.2.3.0/24). Uses the same permissions as "
504 hidden_args.emplace_back(
"-zmqpubhashblock=<address>");
505 hidden_args.emplace_back(
"-zmqpubhashtx=<address>");
506 hidden_args.emplace_back(
"-zmqpubrawblock=<address>");
507 hidden_args.emplace_back(
"-zmqpubrawtx=<address>");
508 hidden_args.emplace_back(
"-zmqpubsequence=<n>");
509 hidden_args.emplace_back(
"-zmqpubhashblockhwm=<n>");
510 hidden_args.emplace_back(
"-zmqpubhashtxhwm=<n>");
511 hidden_args.emplace_back(
"-zmqpubrawblockhwm=<n>");
512 hidden_args.emplace_back(
"-zmqpubrawtxhwm=<n>");
513 hidden_args.emplace_back(
"-zmqpubsequencehwm=<n>");
530 argsman.
AddArg(
"-debug=<category>",
"Output debugging information (default: -nodebug, supplying <category> is optional). "
531 "If <category> is not supplied or if <category> = 1, output all debugging information. <category> can be: " +
LogInstance().LogCategoriesString() +
".",
536 #ifdef HAVE_THREAD_LOCAL
539 hidden_args.emplace_back(
"-logthreadnames");
558 argsman.
AddArg(
"-minrelaytxfee=<amt>",
strprintf(
"Fees (in %s/kB) smaller than this are considered zero fee for relaying, mining and transaction creation (default: %s)",
569 argsman.
AddArg(
"-rpcallowip=<ip>",
"Allow JSON-RPC connections from specified source. Valid for <ip> are a single IP (e.g. 1.2.3.4), a network/netmask (e.g. 1.2.3.4/255.255.255.0) or a network/CIDR (e.g. 1.2.3.4/24). This option can be specified multiple times",
ArgsManager::ALLOW_ANY,
OptionsCategory::RPC);
570 argsman.
AddArg(
"-rpcauth=<userpw>",
"Username and HMAC-SHA-256 hashed password for JSON-RPC connections. The field <userpw> comes in the format: <USERNAME>:<SALT>$<HASH>. A canonical python script is included in share/rpcauth. The client then connects normally using the rpcuser=<USERNAME>/rpcpassword=<PASSWORD> pair of arguments. This option can be specified multiple times",
ArgsManager::ALLOW_ANY |
ArgsManager::SENSITIVE,
OptionsCategory::RPC);
571 argsman.
AddArg(
"-rpcbind=<addr>[:port]",
"Bind to given address to listen for JSON-RPC connections. Do not expose the RPC server to untrusted networks such as the public internet! This option is ignored unless -rpcallowip is also passed. Port is optional and overrides -rpcport. Use [host]:port notation for IPv6. This option can be specified multiple times (default: 127.0.0.1 and ::1 i.e., localhost)",
ArgsManager::ALLOW_ANY |
ArgsManager::NETWORK_ONLY |
ArgsManager::SENSITIVE,
OptionsCategory::RPC);
574 argsman.
AddArg(
"-rpcport=<port>",
strprintf(
"Listen for JSON-RPC connections on <port> (default: %u, testnet: %u, signet: %u, regtest: %u)", defaultBaseParams->RPCPort(), testnetBaseParams->RPCPort(), signetBaseParams->RPCPort(), regtestBaseParams->RPCPort()),
ArgsManager::ALLOW_ANY |
ArgsManager::NETWORK_ONLY,
OptionsCategory::RPC);
579 argsman.
AddArg(
"-rpcwhitelist=<whitelist>",
"Set a whitelist to filter incoming RPC calls for a specific user. The field <whitelist> comes in the format: <USERNAME>:<rpc 1>,<rpc 2>,...,<rpc n>. If multiple whitelists are set for a given user, they are set-intersected. See -rpcwhitelistdefault documentation for information on default whitelist behavior.",
ArgsManager::ALLOW_ANY,
OptionsCategory::RPC);
580 argsman.
AddArg(
"-rpcwhitelistdefault",
"Sets default behavior for rpc whitelisting. Unless rpcwhitelistdefault is set to 0, if any -rpcwhitelist is set, the rpc server acts as if all rpc users are subject to empty-unless-otherwise-specified whitelists. If rpcwhitelistdefault is set to 1 and no -rpcwhitelist is set, rpc server acts as if all rpc users are subject to empty whitelists.",
ArgsManager::ALLOW_BOOL,
OptionsCategory::RPC);
587 hidden_args.emplace_back(
"-daemon");
596 const std::string URL_SOURCE_CODE =
"<https://github.com/bitcoin/bitcoin>";
600 strprintf(
_(
"Please contribute if you find %s useful. "
601 "Visit %s for further information about the software.").translated,
604 strprintf(
_(
"The source code is available from %s.").translated,
608 _(
"This is experimental software.").
translated +
"\n" +
609 strprintf(
_(
"Distributed under the MIT software license, see the accompanying file %s or %s").translated,
"COPYING",
"<https://opensource.org/licenses/MIT>") +
619 if (pBlockIndex !=
nullptr) {
621 LOCK(g_genesis_wait_mutex);
624 g_genesis_wait_cv.notify_all();
650 std::map<std::string, fs::path> mapBlockFiles;
655 LogPrintf(
"Removing unusable blk?????.dat and rev?????.dat files for -reindex with -prune\n");
657 for (fs::directory_iterator
it(blocksdir);
it != fs::directory_iterator();
it++) {
658 if (fs::is_regular_file(*
it) &&
659 it->path().filename().string().length() == 12 &&
660 it->path().filename().string().substr(8,4) ==
".dat")
662 if (
it->path().filename().string().substr(0,3) ==
"blk")
663 mapBlockFiles[
it->path().filename().string().substr(3,5)] =
it->path();
664 else if (
it->path().filename().string().substr(0,3) ==
"rev")
673 int nContigCounter = 0;
674 for (
const std::pair<const std::string, fs::path>& item : mapBlockFiles) {
675 if (
atoi(item.first) == nContigCounter) {
686 std::string cmd = args.
GetArg(
"-startupnotify",
"");
688 std::thread t(runCommand, cmd);
712 LogPrintf(
"Reindexing block file blk%05u.dat...\n", (
unsigned int)nFile);
715 LogPrintf(
"Shutdown requested. Exit %s\n", __func__);
728 for (
const fs::path& path : vImportFiles) {
731 LogPrintf(
"Importing blocks file %s...\n", path.string());
734 LogPrintf(
"Shutdown requested. Exit %s\n", __func__);
738 LogPrintf(
"Warning: Could not open blocks file %s\n", path.string());
749 if (!chainstate->ActivateBestChain(state, chainparams,
nullptr)) {
757 LogPrintf(
"Stopping after block import\n");
808 LogPrintf(
"%s: parameter interaction: -bind set -> setting -listen=1\n", __func__);
812 LogPrintf(
"%s: parameter interaction: -whitebind set -> setting -listen=1\n", __func__);
818 LogPrintf(
"%s: parameter interaction: -connect set -> setting -dnsseed=0\n", __func__);
820 LogPrintf(
"%s: parameter interaction: -connect set -> setting -listen=0\n", __func__);
826 LogPrintf(
"%s: parameter interaction: -proxy set -> setting -listen=0\n", __func__);
830 LogPrintf(
"%s: parameter interaction: -proxy set -> setting -upnp=0\n", __func__);
833 LogPrintf(
"%s: parameter interaction: -proxy set -> setting -discover=0\n", __func__);
839 LogPrintf(
"%s: parameter interaction: -listen=0 -> setting -upnp=0\n", __func__);
841 LogPrintf(
"%s: parameter interaction: -listen=0 -> setting -discover=0\n", __func__);
843 LogPrintf(
"%s: parameter interaction: -listen=0 -> setting -listenonion=0\n", __func__);
849 LogPrintf(
"%s: parameter interaction: -externalip set -> setting -discover=0\n", __func__);
855 LogPrintf(
"%s: parameter interaction: -blocksonly=1 -> setting -whitelistrelay=0\n", __func__);
861 LogPrintf(
"%s: parameter interaction: -whitelistforcerelay=1 -> setting -whitelistrelay=1\n", __func__);
878 #ifdef HAVE_THREAD_LOCAL
886 version_string +=
" (debug build)";
888 version_string +=
" (release build)";
896 int nUserMaxConnections;
899 int64_t peer_connect_timeout;
900 std::set<BlockFilterType> g_enabled_filter_types;
910 std::set_new_handler(std::terminate);
911 LogPrintf(
"Error: Out of memory. Terminating.\n");
922 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
923 _CrtSetReportFile(_CRT_WARN, CreateFileA(
"NUL", GENERIC_WRITE, 0,
nullptr, OPEN_EXISTING, 0, 0));
925 _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
929 HeapSetInformation(
nullptr, HeapEnableTerminationOnCorruption,
nullptr, 0);
949 signal(SIGPIPE, SIG_IGN);
951 SetConsoleCtrlHandler(consoleCtrlHandler,
true);
975 errors +=
strprintf(
_(
"Config setting for %s only applied on %s network when in [%s] section.") +
Untranslated(
"\n"), arg, network, network);
978 if (!errors.
empty()) {
988 if (!warnings.
empty()) {
998 if (blockfilterindex_value ==
"" || blockfilterindex_value ==
"1") {
1000 }
else if (blockfilterindex_value !=
"0") {
1001 const std::vector<std::string> names = args.
GetArgs(
"-blockfilterindex");
1002 for (
const auto&
name : names) {
1007 g_enabled_filter_types.insert(filter_type);
1014 return InitError(
_(
"Cannot set -peerblockfilters without -blockfilterindex."));
1021 if (args.
GetArg(
"-prune", 0)) {
1023 return InitError(
_(
"Prune mode is incompatible with -txindex."));
1024 if (!g_enabled_filter_types.empty()) {
1025 return InitError(
_(
"Prune mode is incompatible with -blockfilterindex."));
1030 size_t nUserBind = args.
GetArgs(
"-bind").size() + args.
GetArgs(
"-whitebind").size();
1036 int nBind = std::max(nUserBind,
size_t(1));
1038 nMaxConnections = std::max(nUserMaxConnections, 0);
1046 int fd_max = FD_SETSIZE;
1050 return InitError(
_(
"Not enough file descriptors available."));
1053 if (nMaxConnections < nUserMaxConnections)
1054 InitWarning(
strprintf(
_(
"Reducing -maxconnections from %d to %d, because of system limitations."), nUserMaxConnections, nMaxConnections));
1059 const std::vector<std::string> categories = args.
GetArgs(
"-debug");
1061 if (std::none_of(categories.begin(), categories.end(),
1062 [](std::string cat){
return cat ==
"0" || cat ==
"none";})) {
1063 for (
const auto& cat : categories) {
1072 for (
const std::string& cat : args.
GetArgs(
"-debugexclude")) {
1085 LogPrintf(
"Validating signatures for all blocks.\n");
1087 if (args.
IsArgSet(
"-minimumchainwork")) {
1088 const std::string minChainWorkStr = args.
GetArg(
"-minimumchainwork",
"");
1104 if (nMempoolSizeMax < 0 || nMempoolSizeMax < nMempoolSizeMin)
1105 return InitError(
strprintf(
_(
"-maxmempool must be at least %d MB"), std::ceil(nMempoolSizeMin / 1000000.0)));
1108 if (args.
IsArgSet(
"-incrementalrelayfee")) {
1116 int64_t nPruneArg = args.
GetArg(
"-prune", 0);
1117 if (nPruneArg < 0) {
1118 return InitError(
_(
"Prune cannot be configured with a negative value."));
1121 if (nPruneArg == 1) {
1122 LogPrintf(
"Block pruning enabled. Use RPC call pruneblockchain(height) to manually prune block and undo files.\n");
1129 LogPrintf(
"Prune configured to target %u MiB on disk for block and undo files.\n",
nPruneTarget / 1024 / 1024);
1139 if (peer_connect_timeout <= 0) {
1143 if (args.
IsArgSet(
"-minrelaytxfee")) {
1158 if (args.
IsArgSet(
"-blockmintxfee")) {
1166 if (args.
IsArgSet(
"-dustrelayfee")) {
1199 if (args.
IsArgSet(
"-proxy") && args.
GetArg(
"-proxy",
"").empty()) {
1200 return InitError(
_(
"No proxy server specified. Use -proxy=<ip> or -proxy=<ip:port>."));
1211 return InitError(
strprintf(
_(
"Cannot write to data directory '%s'; check permissions."), datadir.string()));
1225 LogPrintf(
"Using the '%s' SHA256 implementation\n", sha256_algo);
1291 if (fs::exists(config_file_path)) {
1292 LogPrintf(
"Config file: %s\n", config_file_path.string());
1293 }
else if (args.
IsArgSet(
"-conf")) {
1295 InitWarning(
strprintf(
_(
"The specified config file %s does not exist\n"), config_file_path.string()));
1298 LogPrintf(
"Config file: %s (not found, skipping)\n", config_file_path.string());
1304 LogPrintf(
"Using at most %i automatic connections (%i file descriptors available)\n", nMaxConnections, nFD);
1307 if (args.
IsArgSet(
"-datadir") && !fs::path(args.
GetArg(
"-datadir",
"")).is_absolute()) {
1308 LogPrintf(
"Warning: relative datadir option '%s' specified, which will be interpreted relative to the "
1309 "current working directory '%s'. This is fragile, because if bitcoin is started in the future "
1310 "from a different location, it will be unable to locate the current data files. There could "
1311 "also be data loss if bitcoin is started while in a temporary directory.\n",
1312 args.
GetArg(
"-datadir",
""), fs::current_path().string());
1319 if (script_threads <= 0) {
1326 script_threads = std::max(script_threads - 1, 0);
1331 LogPrintf(
"Script verification uses %d additional threads\n", script_threads);
1332 if (script_threads >= 1) {
1334 for (
int i = 0; i < script_threads; ++i) {
1340 node.
scheduler = MakeUnique<CScheduler>();
1348 }, std::chrono::minutes{1});
1357 client->registerRpcs();
1371 return InitError(
_(
"Unable to start HTTP server. See debug log for details."));
1376 if (!client->verify()) {
1390 node.
connman = MakeUnique<CConnman>(
GetRand(std::numeric_limits<uint64_t>::max()),
GetRand(std::numeric_limits<uint64_t>::max()), args.
GetBoolArg(
"-networkactive",
true));
1399 node.
mempool->setSanityCheck(1.0 / ratio);
1411 std::vector<std::string> uacomments;
1412 for (
const std::string& cmt : args.
GetArgs(
"-uacomment")) {
1414 return InitError(
strprintf(
_(
"User Agent comment (%s) contains unsafe characters."), cmt));
1415 uacomments.push_back(cmt);
1419 return InitError(
strprintf(
_(
"Total length of network version string (%i) exceeds maximum length (%i). Reduce the number or size of uacomments."),
1424 std::set<enum Network> nets;
1425 for (
const std::string& snet : args.
GetArgs(
"-onlynet")) {
1431 for (
int n = 0; n <
NET_MAX; n++) {
1433 if (!nets.count(net))
1444 std::string proxyArg = args.
GetArg(
"-proxy",
"");
1446 if (proxyArg !=
"" && proxyArg !=
"0") {
1466 std::string onionArg = args.
GetArg(
"-onion",
"");
1467 if (onionArg !=
"") {
1468 if (onionArg ==
"0") {
1488 for (
const std::string& strAddr : args.
GetArgs(
"-externalip")) {
1498 fs::path asmap_path = fs::path(args.
GetArg(
"-asmap",
""));
1499 if (asmap_path.empty()) {
1502 if (!asmap_path.is_absolute()) {
1505 if (!fs::exists(asmap_path)) {
1510 if (asmap.size() == 0) {
1515 node.
connman->SetAsmap(std::move(asmap));
1516 LogPrintf(
"Using asmap version %s for IP bucketing\n", asmap_version.
ToString());
1518 LogPrintf(
"Using /16 prefix for IP bucketing\n");
1528 uint64_t nMaxOutboundLimit = 0;
1531 if (args.
IsArgSet(
"-maxuploadtarget")) {
1538 bool fReindexChainState = args.
GetBoolArg(
"-reindex-chainstate",
false);
1542 nTotalCache = std::max(nTotalCache,
nMinDbCache << 20);
1543 nTotalCache = std::min(nTotalCache,
nMaxDbCache << 20);
1544 int64_t nBlockTreeDBCache = std::min(nTotalCache / 8,
nMaxBlockDBCache << 20);
1545 nTotalCache -= nBlockTreeDBCache;
1547 nTotalCache -= nTxIndexCache;
1548 int64_t filter_index_cache = 0;
1549 if (!g_enabled_filter_types.empty()) {
1550 size_t n_indexes = g_enabled_filter_types.size();
1552 filter_index_cache = max_cache / n_indexes;
1553 nTotalCache -= filter_index_cache * n_indexes;
1555 int64_t nCoinDBCache = std::min(nTotalCache / 2, (nTotalCache / 4) + (1 << 23));
1557 nTotalCache -= nCoinDBCache;
1558 int64_t nCoinCacheUsage = nTotalCache;
1561 LogPrintf(
"* Using %.1f MiB for block index database\n", nBlockTreeDBCache * (1.0 / 1024 / 1024));
1563 LogPrintf(
"* Using %.1f MiB for transaction index database\n", nTxIndexCache * (1.0 / 1024 / 1024));
1566 LogPrintf(
"* Using %.1f MiB for %s block filter index database\n",
1569 LogPrintf(
"* Using %.1f MiB for chain state database\n", nCoinDBCache * (1.0 / 1024 / 1024));
1570 LogPrintf(
"* Using %.1f MiB for in-memory UTXO set (plus up to %.1f MiB of unused mempool space)\n", nCoinCacheUsage * (1.0 / 1024 / 1024), nMempoolSizeMax * (1.0 / 1024 / 1024));
1572 bool fLoaded =
false;
1576 return fReset || fReindexChainState || chainstate->CoinsTip().GetBestBlock().IsNull();
1580 uiInterface.InitMessage(
_(
"Loading block index...").translated);
1583 const int64_t load_block_index_start_time =
GetTimeMillis();
1612 strLoadError =
_(
"Error loading block database");
1620 return InitError(
_(
"Incorrect or no genesis block found. Wrong datadir for network?"));
1626 strLoadError =
_(
"You need to rebuild the database using -reindex to go back to unpruned mode. This will redownload the entire blockchain");
1635 strLoadError =
_(
"Error initializing block database");
1642 bool failed_chainstate_init =
false;
1645 chainstate->InitCoinsDB(
1648 fReset || fReindexChainState);
1650 chainstate->CoinsErrorCatcher().AddReadErrCallback([]() {
1652 _(
"Error reading from database, shutting down."),
1658 if (!chainstate->CoinsDB().Upgrade()) {
1659 strLoadError =
_(
"Error upgrading chainstate database");
1660 failed_chainstate_init =
true;
1665 if (!chainstate->ReplayBlocks(chainparams)) {
1666 strLoadError =
_(
"Unable to replay blocks. You will need to rebuild the database using -reindex-chainstate.");
1667 failed_chainstate_init =
true;
1672 chainstate->InitCoinsCache(nCoinCacheUsage);
1673 assert(chainstate->CanFlushToDisk());
1675 if (!is_coinsview_empty(chainstate)) {
1677 if (!chainstate->LoadChainTip(chainparams)) {
1678 strLoadError =
_(
"Error initializing block database");
1679 failed_chainstate_init =
true;
1682 assert(chainstate->m_chain.Tip() !=
nullptr);
1686 if (failed_chainstate_init) {
1689 }
catch (
const std::exception& e) {
1691 strLoadError =
_(
"Error opening block database");
1695 bool failed_rewind{
false};
1703 uiInterface.InitMessage(
_(
"Rewinding blocks...").translated);
1704 if (!chainstate->RewindBlockIndex(chainparams)) {
1706 "Unable to rewind the database to a pre-fork state. "
1707 "You will need to redownload the blockchain");
1708 failed_rewind =
true;
1714 if (failed_rewind) {
1718 bool failed_verification =
false;
1724 if (!is_coinsview_empty(chainstate)) {
1725 uiInterface.InitMessage(
_(
"Verifying blocks...").translated);
1727 LogPrintf(
"Prune: pruned datadir may not have more than %d blocks; only checking available blocks\n",
1731 const CBlockIndex* tip = chainstate->m_chain.Tip();
1734 strLoadError =
_(
"The block database contains a block which appears to be from the future. "
1735 "This may be due to your computer's date and time being set incorrectly. "
1736 "Only rebuild the block database if you are sure that your computer's date and time are correct");
1737 failed_verification =
true;
1745 chainparams, &chainstate->CoinsDB(),
1748 strLoadError =
_(
"Corrupted block database detected");
1749 failed_verification =
true;
1754 }
catch (
const std::exception& e) {
1756 strLoadError =
_(
"Error opening block database");
1757 failed_verification =
true;
1761 if (!failed_verification) {
1771 strLoadError +
Untranslated(
".\n\n") +
_(
"Do you want to rebuild the block database now?"),
1772 strLoadError.
original +
".\nPlease restart with -reindex or -reindex-chainstate to recover.",
1778 LogPrintf(
"Aborted block database rebuild. Exiting.\n");
1791 LogPrintf(
"Shutdown requested. Exiting.\n");
1798 if (!est_filein.
IsNull())
1808 for (
const auto& filter_type : g_enabled_filter_types) {
1815 if (!client->load()) {
1825 LogPrintf(
"Unsetting NODE_NETWORK on prune mode\n");
1830 uiInterface.InitMessage(
_(
"Pruning blockstore...").translated);
1831 chainstate->PruneAndFlush();
1855 boost::signals2::connection block_notify_genesis_wait_connection;
1859 fHaveGenesis =
true;
1863 const std::string block_notify = args.
GetArg(
"-blocknotify",
"");
1864 if (!block_notify.empty()) {
1867 std::string command = block_notify;
1869 std::thread t(runCommand, command);
1875 std::vector<fs::path> vImportFiles;
1876 for (
const std::string& strFile : args.
GetArgs(
"-loadblock")) {
1877 vImportFiles.push_back(strFile);
1891 g_genesis_wait_cv.wait_for(lock, std::chrono::milliseconds(500));
1893 block_notify_genesis_wait_connection.disconnect();
1902 int chain_active_height;
1919 LogPrintf(
"nBestHeight = %d\n", chain_active_height);
1947 for (
const std::string& bind_arg : args.
GetArgs(
"-bind")) {
1949 const size_t index = bind_arg.rfind(
'=');
1950 if (index == std::string::npos) {
1952 connOptions.
vBinds.push_back(bind_addr);
1956 const std::string network_type = bind_arg.substr(index + 1);
1957 if (network_type ==
"onion") {
1958 const std::string truncated_bind_arg = bind_arg.substr(0, index);
1959 if (
Lookup(truncated_bind_arg, bind_addr,
BaseParams().OnionServiceTargetPort(),
false)) {
1973 const auto bind_addr = connOptions.
onion_binds.front();
1975 InitWarning(
strprintf(
_(
"More than one onion bind address is provided. Using %s for the automatically created Tor onion service."), bind_addr.ToStringIPPort()));
1980 for (
const std::string& strBind : args.
GetArgs(
"-whitebind")) {
1987 for (
const auto& net : args.
GetArgs(
"-whitelist")) {
1999 const auto connect = args.
GetArgs(
"-connect");
2000 if (connect.size() != 1 || connect[0] !=
"0") {
std::vector< CService > vBinds
int m_max_outbound_full_relay
std::string SanitizeString(const std::string &str, int rule)
Remove unsafe chars.
void EnableCategory(LogFlags flag)
static const int MAX_BLOCK_RELAY_ONLY_CONNECTIONS
Maximum number of block-relay-only outgoing connections.
void RandomInit()
Initialize global RNG state and log any CPU features that are used.
static const unsigned int DEFAULT_ANCESTOR_SIZE_LIMIT
Default for -limitancestorsize, maximum kilobytes of tx + all in-mempool ancestors.
static void BlockNotifyGenesisWait(const CBlockIndex *pBlockIndex)
static const int DEFAULT_SCRIPTCHECK_THREADS
-par default (number of script-checking threads, 0 = auto)
void ECC_Start()
Initialize the elliptic curve support.
std::unique_ptr< CBaseChainParams > CreateBaseChainParams(const std::string &chain)
Port numbers for incoming Tor connections (8334, 18334, 38334, 18445) have been chosen arbitrarily to...
BlockFilterIndex is used to store and retrieve block filters, hashes, and headers for a range of bloc...
const std::vector< std::string > CHECKLEVEL_DOC
Documentation for argument 'checklevel'.
std::vector< std::unique_ptr< interfaces::ChainClient > > chain_clients
List of all chain clients (wallet processes or other client) connected to node.
uint64_t GetRand(uint64_t nMax) noexcept
Generate a uniform random integer in the range [0..range).
bilingual_str ResolveErrMsg(const std::string &optname, const std::string &strBind)
static const unsigned int DEFAULT_DESCENDANT_LIMIT
Default for -limitdescendantcount, max number of in-mempool descendants.
bool fPruneMode
True if we're running in -prune mode.
void SetupChainParamsBaseOptions(ArgsManager &argsman)
Set the arguments for chainparams.
static void CleanupBlockRevFiles()
const std::vector< std::string > NET_PERMISSIONS_DOC
std::condition_variable g_best_block_cv
void InitLogging(const ArgsManager &args)
Initialize global loggers.
SynchronizationState
Current sync state passed to tip changed callbacks.
BCLog::Logger & LogInstance()
ServiceFlags
nServices flags
const char *const BITCOIN_SETTINGS_FILENAME
static const uint64_t MAX_UPLOAD_TIMEFRAME
The default timeframe for -maxuploadtarget.
bilingual_str AmountErrMsg(const std::string &optname, const std::string &strValue)
#define LogPrint(category,...)
bool DirIsWritable(const fs::path &directory)
FILE * fopen(const fs::path &p, const char *mode)
int m_max_outbound_block_relay
fs::path GetDefaultDataDir()
static const int DEFAULT_HTTP_SERVER_TIMEOUT
static const int64_t nMaxTxIndexCache
Max memory allocated to block tree DB specific cache, if -txindex (MiB)
#define TRY_LOCK(cs, name)
Dummy value to indicate the number of NET_* constants.
static const unsigned int MAX_OP_RETURN_RELAY
Default setting for nMaxDatacarrierBytes.
bool SoftSetBoolArg(const std::string &strArg, bool fValue)
Set a boolean argument if it doesn't already have a value.
void Shutdown(NodeContext &node)
static const std::string REGTEST
void SetRPCWarmupStatus(const std::string &newStatus)
Set the RPC warmup status.
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
static const unsigned int DEFAULT_RPC_SERIALIZE_VERSION
bool BlockFilterTypeByName(const std::string &name, BlockFilterType &filter_type)
Find a filter type by its human-readable name.
int64_t GetTimeMillis()
Returns the system time (not mockable)
CChain & ChainActive()
Please prefer the identical ChainstateManager::ActiveChain.
int GetNumCores()
Return the number of cores available on the current system.
static const unsigned int DEFAULT_MAX_SIG_CACHE_SIZE
static boost::signals2::connection rpc_notify_block_change_connection
std::unique_ptr< BanMan > banman
auto Join(const std::vector< T > &list, const BaseType &separator, UnaryOp unary_op) -> decltype(unary_op(list.at(0)))
Join a list of items.
static const bool DEFAULT_FORCEDNSSEED
static const unsigned int DEFAULT_MAX_MEMPOOL_SIZE
Default for -maxmempool, maximum megabytes of mempool memory usage.
bool LoadGenesisBlock(const CChainParams &chainparams)
Ensures we have a genesis block in the block tree, possibly writing one to disk.
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
std::unique_ptr< CTxMemPool > mempool
static const int DEFAULT_HTTP_WORKQUEUE
static void RegisterAllCoreRPCCommands(CRPCTable &t)
bool fHavePruned
Pruning-related variables and constants.
static void OnRPCStarted()
static const int64_t DEFAULT_MAX_TIP_AGE
const std::list< SectionInfo > GetUnrecognizedSections() const
Log warnings for unrecognized section names in the config file.
static void LogPrintf(const char *fmt, const Args &...args)
void InitWarning(const bilingual_str &str)
Show warning message.
static void HandleSIGTERM(int)
Signal handlers are very limited in what they are allowed to do.
BlockFilterIndex * GetBlockFilterIndex(BlockFilterType filter_type)
Get a block filter index by type.
static const bool DEFAULT_ACCEPT_DATACARRIER
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
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...
static const unsigned int DEFAULT_ANCESTOR_LIMIT
Default for -limitancestorcount, max number of in-mempool ancestors.
const std::string UNIX_EPOCH_TIME
String used to describe UNIX epoch time in documentation, factored out to a constant for consistency...
void FlushUnconfirmed()
Empty mempool transactions on shutdown to record failure to confirm for txs still in mempool...
unsigned int nReceiveFloodSize
void AddHiddenArgs(const std::vector< std::string > &args)
Add many hidden arguments.
static const bool DEFAULT_LOGTHREADNAMES
std::string GetHex() const
CClientUIInterface * uiInterface
const Consensus::Params & GetConsensus() const
void ForEachBlockFilterIndex(std::function< void(BlockFilterIndex &)> fn)
Iterate over all running block filter indexes, invoking fn on each.
bool fAcceptDatacarrier
A data carrying output is an unspendable output containing data.
void ThreadRename(std::string &&)
Rename a thread both in terms of an internal (in-memory) name as well as its system thread name...
std::unique_ptr< interfaces::Chain > chain
void StopREST()
Stop HTTP REST subsystem.
void OnStopped(std::function< void()> slot)
static const unsigned int DEFAULT_INCREMENTAL_RELAY_FEE
Default for -incrementalrelayfee, which sets the minimum feerate increase for mempool limiting or BIP...
static const bool DEFAULT_LISTEN
-listen default
static const bool DEFAULT_LOGTIMEMICROS
std::atomic< bool > m_reopen_file
CChainState stores and provides an API to update our local knowledge of the current best chain...
std::string CopyrightHolders(const std::string &strPrefix)
static const int MAX_ADDNODE_CONNECTIONS
Maximum number of addnode outgoing nodes.
void UnregisterBackgroundSignalScheduler()
Unregister a CScheduler to give callbacks which should run in the background - these callbacks will n...
static void OnRPCStopped()
const CBaseChainParams & BaseParams()
Return the currently selected parameters.
arith_uint256 nMinimumChainWork
Minimum work we will assume exists on some valid chain.
RecursiveMutex g_cs_orphans
const std::set< BlockFilterType > & AllBlockFilterTypes()
Get a list of known filter types.
std::string FormatISO8601DateTime(int64_t nTime)
ISO 8601 formatting is preferred.
static std::unique_ptr< ECCVerifyHandle > globalVerifyHandle
const fs::path & GetBlocksDir()
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system...
void UnregisterAllValidationInterfaces()
Unregister all subscribers.
int RaiseFileDescriptorLimit(int nMinFD)
this function tries to raise the file descriptor limit to the requested number.
static const int64_t nMinDbCache
min. -dbcache (MiB)
std::string SHA256AutoDetect()
Autodetect the best available SHA256 implementation.
void RandAddPeriodic() noexcept
Gather entropy from various expensive sources, and feed them to the PRNG state.
std::string FormatMoney(const CAmount &n)
Money parsing/formatting utilities.
bool InitBlockFilterIndex(BlockFilterType filter_type, size_t n_cache_size, bool f_memory, bool f_wipe)
Initialize a block filter index for the given type if one does not already exist. ...
static const int64_t max_filter_index_cache
Max memory allocated to all block filter index caches combined in MiB.
virtual void Construct(NodeContext &node) const =0
Add wallets that should be opened to list of chain clients.
void InterruptHTTPRPC()
Interrupt HTTP RPC subsystem.
bool ParseMoney(const std::string &money_string, CAmount &nRet)
Parse an amount denoted in full coins.
static void HandleSIGHUP(int)
static const bool DEFAULT_PERMIT_BAREMULTISIG
Default for -permitbaremultisig.
static boost::thread_group threadGroup
bool CheckDiskSpace(const fs::path &dir, uint64_t additional_bytes)
const char *const BITCOIN_CONF_FILENAME
std::string LicenseInfo()
Returns licensing information (for -version)
void StartTorControl(CService onion_service_target)
void InterruptHTTPServer()
Interrupt HTTP server threads.
void SetupServerArgs(NodeContext &node)
Register all arguments with the ArgsManager.
uint64_t nPruneTarget
Number of MiB of block files that we're trying to stay below.
bool SetNameProxy(const proxyType &addrProxy)
Set the name proxy to use for all connections to nodes specified by a hostname.
void ThreadScriptCheck(int worker_num)
Run an instance of the script checking thread.
bool DumpMempool(const CTxMemPool &pool)
Dump the mempool to disk.
static const bool DEFAULT_STOPAFTERBLOCKIMPORT
void RPCNotifyBlockChange(const CBlockIndex *pindex)
Callback for when block tip changed.
void Stop()
Stops the instance from staying in sync with blockchain updates.
std::unique_ptr< Chain > MakeChain(NodeContext &node)
Return implementation of Chain interface.
static const int MAX_FEELER_CONNECTIONS
Maximum number of feeler connections.
arith_uint256 UintToArith256(const uint256 &a)
std::string ToString() const
std::function< void()> rpc_interruption_point
static const std::string MAIN
Chain name strings.
static const bool DEFAULT_PEERBLOCKFILTERS
void LoadMempool(const ArgsManager &args)
Load the persisted mempool from disk.
bool Lookup(const std::string &name, std::vector< CService > &vAddr, int portDefault, bool fAllowLookup, unsigned int nMaxSolutions)
Resolve a service string to its corresponding service.
int64_t CAmount
Amount in satoshis (Can be negative)
std::vector< std::string > GetArgs(const std::string &strArg) const
Return a vector of strings of the given argument.
void SetMockTime(int64_t nMockTimeIn)
For testing.
void SetRPCWarmupFinished()
std::string NetworkIDString() const
Return the network string.
uint256 SerializeHash(const T &obj, int nType=SER_GETHASH, int nVersion=PROTOCOL_VERSION)
Compute the 256-bit hash of an object's serialization.
static const size_t DEFAULT_MAXRECEIVEBUFFER
CBlockPolicyEstimator feeEstimator
bool LockDirectory(const fs::path &directory, const std::string lockfile_name, bool probe_only)
bool IsArgSet(const std::string &strArg) const
Return true if the given argument has been manually set.
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or nullptr if none.
static const bool DEFAULT_PERSIST_MEMPOOL
Default for -persistmempool.
bool InitHTTPServer()
Initialize HTTP server.
Users of this module must hold an ECCVerifyHandle.
int Height() const
Return the maximal height in the chain.
bool AppInitSanityChecks()
Initialization sanity checks: ecc init, sanity checks, dir lock.
bool error(const char *fmt, const Args &...args)
bool LoadBlockIndex(const CChainParams &chainparams) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Load the block tree and coins database from disk, initializing state if we're running with -reindex...
ChainstateManager * chainman
const std::string & ListBlockFilterTypes()
Get a comma-separated list of known filter type names.
static CZMQNotificationInterface * Create()
std::string ToString(const FeeEstimateMode &fee_estimate_mode=FeeEstimateMode::BTC_KVB) const
NodeContext struct containing references to chain state and connection state.
const std::string DEFAULT_TOR_CONTROL
Default control port.
fs::path GetBlockPosFilename(const FlatFilePos &pos)
Translation to a filesystem path.
std::unique_ptr< CConnman > connman
Access to the block database (blocks/index/)
void StopHTTPServer()
Stop HTTP server.
static std::condition_variable g_genesis_wait_cv
void Interrupt(NodeContext &node)
Interrupt threads.
CFeeRate minRelayTxFee
A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation) ...
CBlockIndex * pindexBestHeader
Best header we've seen so far (used for getheaders queries' starting points).
void ECC_Stop()
Deinitialize the elliptic curve support.
std::unique_ptr< TxIndex > g_txindex
The global transaction index, used in GetTransaction. May be null.
const std::set< std::string > GetUnsuitableSectionOnlyArgs() const
Log warnings for options in m_section_only_args when they are specified in the default section but no...
bilingual_str _(const char *psz)
Translation function.
NetEventsInterface * m_msgproc
CChainState & ActiveChainstate() const
The most-work chain.
static const unsigned int DEFAULT_BLOCK_MIN_TX_FEE
Default for -blockmintxfee, which sets the minimum feerate for a transaction in blocks created by min...
static bool AppInitServers(const util::Ref &context, NodeContext &node)
int atoi(const std::string &str)
A combination of a network address (CNetAddr) and a (TCP) port.
std::vector< std::string > vSeedNodes
uint256 uint256S(const char *str)
std::vector< std::string > m_specified_outgoing
void DestroyAllBlockFilterIndexes()
Destroy all open block filter indexes.
RAII wrapper for VerifyDB: Verify consistency of the block and coin databases.
void AddArg(const std::string &name, const std::string &help, unsigned int flags, const OptionsCategory &cat)
Add argument.
const fs::path & GetDataDir(bool fNetSpecific)
static const unsigned int DEFAULT_MIN_RELAY_TX_FEE
Default for -minrelaytxfee, minimum relay fee for transactions.
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate...
static const unsigned int DEFAULT_DESCENDANT_SIZE_LIMIT
Default for -limitdescendantsize, maximum kilobytes of in-mempool descendants.
static const unsigned int DEFAULT_MEMPOOL_EXPIRY
Default for -mempoolexpiry, expiration time for mempool transactions in hours.
static const int DEFAULT_STOPATHEIGHT
Default for -stopatheight.
void InitSignatureCache()
static constexpr std::chrono::minutes DUMP_BANS_INTERVAL
const std::string CURRENCY_UNIT
CMainSignals & GetMainSignals()
static const int64_t nDefaultDbCache
-dbcache default (MiB)
void DisableCategory(LogFlags flag)
void Start()
Start initializes the sync state and registers the instance as a ValidationInterface so that it stays...
static const bool DEFAULT_FEEFILTER
Default for using fee filter.
Block and header tip information.
static void StartupNotify(const ArgsManager &args)
bool InitError(const bilingual_str &str)
Show error message.
static const unsigned int DEFAULT_MAX_PEER_CONNECTIONS
The maximum number of peer connections to maintain.
ChainstateManager g_chainman
#define WAIT_LOCK(cs, name)
const CMessageHeader::MessageStartChars & MessageStart() const
std::atomic_bool fImporting
static const int64_t nDefaultDbBatchSize
-dbbatchsize default (bytes)
static fs::path GetPidFile(const ArgsManager &args)
const std::string CLIENT_NAME
static const int DEFAULT_NAME_LOOKUP
-dns default
std::string GetHex() const
fs::path AbsPathForConfigVal(const fs::path &path, bool net_specific)
Most paths passed as configuration arguments are treated as relative to the datadir if they are not a...
void TraceThread(const char *name, Callable func)
static const char *const DEFAULT_BLOCKFILTERINDEX
static const int DEFAULT_ZMQ_SNDHWM
static NODISCARD bool CreatePidFile(const ArgsManager &args)
static const bool DEFAULT_PROXYRANDOMIZE
bool IsHexNumber(const std::string &str)
Return true if the string is a hex number, optionally prefixed with "0x".
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
int64_t nMaxTipAge
If the tip is older than this (in seconds), the node is considered to be in initial block download...
std::string FormatFullVersion()
std::unique_ptr< PeerManager > peerman
CFeeRate incrementalRelayFee
virtual void AddWalletOptions(ArgsManager &argsman) const =0
Get wallet help string.
Type-safe dynamic reference.
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
uint256 hashAssumeValid
Block hash whose ancestors we will assume to have valid scripts without checking them.
static const int64_t nMaxBlockDBCache
Max memory allocated to block tree DB specific cache, if no -txindex (MiB)
int64_t m_total_coinstip_cache
The total number of bytes available for us to use across all in-memory coins caches.
static void ThreadImport(ChainstateManager &chainman, std::vector< fs::path > vImportFiles, const ArgsManager &args)
bool IsNull() const
Return true if the wrapped FILE* is nullptr, false otherwise.
bool SetProxy(enum Network net, const proxyType &addrProxy)
void StopHTTPRPC()
Stop HTTP RPC subsystem.
enum Network ParseNetwork(const std::string &net_in)
void StartREST(const util::Ref &context)
Start HTTP REST subsystem.
uint64_t nMaxOutboundTimeframe
bool Write(CAutoFile &fileout) const
Write estimation data to a file.
void LoadExternalBlockFile(const CChainParams &chainparams, FILE *fileIn, FlatFilePos *dbp)
Import blocks from an external file.
std::atomic_bool fReindex
CBlockIndex * LookupBlockIndex(const uint256 &hash)
bool IsTestChain() const
If this chain is exclusively used for testing.
void RegisterBackgroundSignalScheduler(CScheduler &scheduler)
Register a CScheduler to give callbacks which should run in the background (may only be called once) ...
std::string get_filesystem_error_message(const fs::filesystem_error &e)
void UnregisterValidationInterface(CValidationInterface *callbacks)
Unregister subscriber.
bool glibcxx_sanity_test()
double verification_progress
std::vector< NetWhitelistPermissions > vWhitelistedRange
std::vector< CService > onion_binds
static bool fFeeEstimatesInitialized
bool StartHTTPRPC(const util::Ref &context)
Start HTTP RPC subsystem.
static const bool DEFAULT_PEERBLOOMFILTERS
void RegisterZMQRPCCommands(CRPCTable &t)
uint256 nMinimumChainWork
The best chain should have at least this much work.
bool g_parallel_script_checks
Whether there are dedicated script-checking threads running.
CChainState & ChainstateActive()
Please prefer the identical ChainstateManager::ActiveChainstate.
static const bool DEFAULT_CHECKPOINTS_ENABLED
const WalletInitInterface & g_wallet_init_interface
#define EXCLUSIVE_LOCKS_REQUIRED(...)
static constexpr unsigned int DEFAULT_MISBEHAVING_BANTIME
static const bool DEFAULT_WHITELISTFORCERELAY
Default for -whitelistforcerelay.
unsigned int nBytesPerSigOp
static const unsigned int DEFAULT_BYTES_PER_SIGOP
Default for -bytespersigop.
bool AppInitParameterInteraction(const ArgsManager &args)
Initialization: parameter interaction.
static const char * DEFAULT_ASMAP_FILENAME
uint256 defaultAssumeValid
By default assume that the signatures in ancestors of this block are valid.
static const size_t DEFAULT_MAXSENDBUFFER
virtual bool ParameterInteraction() const =0
Check wallet parameter interaction.
static void new_handler_terminate()
fs::path GetConfigFile(const std::string &confPath)
static const uint64_t DEFAULT_MAX_UPLOAD_TARGET
The default for -maxuploadtarget.
The block chain is a tree shaped structure starting with the genesis block at the root...
const CBlock & GenesisBlock() const
const CChainParams & Params()
Return the currently selected parameters.
static bool TryParse(const std::string str, NetWhitebindPermissions &output, bilingual_str &error)
void FlushBackgroundCallbacks()
Call any remaining callbacks on the calling thread.
static const char * FEE_ESTIMATES_FILENAME
static const signed int DEFAULT_CHECKBLOCKS
void RpcInterruptionPoint()
Throw JSONRPCError if RPC is not running.
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
static const int64_t nMaxCoinsDBCache
Max memory allocated to coin DB specific cache (MiB)
void InitScriptExecutionCache()
Initializes the script-execution cache.
bool(* handler)(const util::Ref &context, HTTPRequest *req, const std::string &strReq)
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...
static const unsigned int DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN
Default number of orphan+recently-replaced txn to keep around for block reconstruction.
static const unsigned int DUST_RELAY_TX_FEE
Min feerate for defining dust.
bool Read(CAutoFile &filein)
Read estimation data from a file.
ServiceFlags nLocalServices
void InterruptREST()
Interrupt RPC REST subsystem.
int64_t GetAdjustedTime()
uint64_t nMaxOutboundLimit
std::vector< std::string > m_added_nodes
static const int DEFAULT_CONNECT_TIMEOUT
-timeout default
bool AppInitBasicSetup(ArgsManager &args)
Initialize bitcoin core: Basic context setup.
static const int64_t nMaxDbCache
max. -dbcache (MiB)
std::string FormatSubVersion(const std::string &name, int nClientVersion, const std::vector< std::string > &comments)
Format the subversion field according to BIP 14 spec (https://github.com/bitcoin/bips/blob/master/bip...
CChainState &InitializeChainstate(CTxMemPool &mempool, const uint256 &snapshot_blockhash=uint256()) EXCLUSIVE_LOCKS_REQUIRED(std::vector< CChainState * > GetAll()
Instantiate a new chainstate and assign it based upon whether it is from a snapshot.
FILE * OpenBlockFile(const FlatFilePos &pos, bool fReadOnly)
Open a block file (blk?????.dat)
static Mutex g_genesis_wait_mutex
Fee rate in satoshis per kilobyte: CAmount / kB.
void SetupHelpOptions(ArgsManager &args)
Add help options to the args manager.
std::unique_ptr< CBlockTreeDB > pblocktree
Global variable that points to the active block tree (protected by cs_main)
std::string ToString() const
bool RequireStandard() const
Policy: Filter transactions that do not match well-defined patterns.
CService DefaultOnionServiceTarget()
static const unsigned int MAX_SUBVERSION_LENGTH
Maximum length of the user agent string in version message.
static const bool DEFAULT_UPNP
-upnp default
static const int64_t DEFAULT_PEER_CONNECT_TIMEOUT
-peertimeout default
static const bool DEFAULT_BLOCKSONLY
Default for blocks only.
static const std::string TESTNET
void RegisterValidationInterface(CValidationInterface *callbacks)
Register subscriber.
static std::vector< bool > DecodeAsmap(fs::path path)
unsigned int nSendBufferMaxSize
void StartHTTPServer()
Start HTTP server.
static std::thread g_load_block
std::string GetChainName() const
Returns the appropriate chain name from the program arguments.
void InterruptTorControl()
int SegwitHeight
Block height at which Segwit (BIP141, BIP143 and BIP147) becomes active.
bool DefaultConsistencyChecks() const
Default value for -checkmempool and -checkblockindex argument.
void OnStarted(std::function< void()> slot)
bool AppInitInterfaces(NodeContext &node)
Initialize node and wallet interface pointers.
static const bool DEFAULT_WHITELISTRELAY
Default for -whitelistrelay.
bool AppInitLockDataDirectory()
Lock bitcoin core data directory.
void UnloadBlockIndex(CTxMemPool *mempool, ChainstateManager &chainman)
Unload database information.
static bool InitSanityCheck()
Sanity checks Ensure that Bitcoin is running in a usable environment with all necessary library suppo...
bool AppInitMain(const util::Ref &context, NodeContext &node, interfaces::BlockAndHeaderTipInfo *tip_info)
Bitcoin core main initialization.
static const int MAX_OUTBOUND_FULL_RELAY_CONNECTIONS
Maximum number of automatic outgoing nodes over which we'll relay everything (blocks, tx, addrs, etc)
void ScheduleBatchPriority()
On platforms that support it, tell the kernel the calling thread is CPU-intensive and non-interactive...
std::string strSubVersion
Subversion as sent to the P2P network in version messages.
static const bool DEFAULT_LOGIPS
CClientUIInterface uiInterface
int nHeight
height of the entry in the chain. The genesis block has height 0
bool ECC_InitSanityCheck()
Check that required EC support is available at runtime.
static const char * BITCOIN_PID_FILENAME
The PID file facilities.
int64_t m_total_coinsdb_cache
The total number of bytes available for us to use across all leveldb coins databases.
static const bool DEFAULT_PRINTPRIORITY
void SetReachable(enum Network net, bool reachable)
Mark a network as reachable or unreachable (no automatic connects to it)
void LogArgs() const
Log the config file options and the command line arguments, useful for troubleshooting.
static void registerSignalHandler(int signal, void(*handler)(int))
static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES
int64_t GetBlockTime() const
static const unsigned int DEFAULT_BLOCK_MAX_WEIGHT
Default for -blockmaxweight, which controls the range of block weights the mining code will create...
#define MIN_CORE_FILEDESCRIPTORS
int64_t GetTime()
Return system time (or mocked time, if set)
static const unsigned int DEFAULT_MAX_ORPHAN_TRANSACTIONS
Default for -maxorphantx, maximum number of orphan transactions kept in memory.
const char *const DEFAULT_DEBUGLOGFILE
static const int CLIENT_VERSION
bitcoind-res.rc includes this file, but it cannot cope with real c++ code.
static const bool DEFAULT_LISTEN_ONION
bool AddLocal(const CService &addr, int nScore=LOCAL_NONE)
bool m_use_addrman_outgoing
std::vector< NetWhitebindPermissions > vWhiteBinds
bool Random_SanityCheck()
Check that OS randomness is available and returning the requested number of bytes.
static const bool DEFAULT_LOGTIMESTAMPS
static const std::string SIGNET
static const bool DEFAULT_TXINDEX
static const int DEFAULT_HTTP_THREADS
static const bool DEFAULT_REST_ENABLE
static bool TryParse(const std::string str, NetWhitelistPermissions &output, bilingual_str &error)
unsigned nMaxDatacarrierBytes
Maximum size of TxoutType::NULL_DATA scripts that this node considers standard.
bool IsArgNegated(const std::string &strArg) const
Return true if the argument was originally passed as a negated option, i.e.
void InitParameterInteraction(ArgsManager &args)
Parameter interaction: change current parameters depending on various rules.
static const int64_t DEFAULT_MAX_TIME_ADJUSTMENT
static const unsigned int DEFAULT_CHECKLEVEL
Non-refcounted RAII wrapper for FILE*.
static const int MAX_SCRIPTCHECK_THREADS
Maximum number of dedicated script-checking threads allowed.
#define Assert(val)
Identity function.
uint256 GetBlockHash() const
CZMQNotificationInterface * g_zmq_notification_interface
static bool LockDataDirectory(bool probeOnly)
const std::string & BlockFilterTypeName(BlockFilterType filter_type)
Get the human-readable name for a filter type.
std::unique_ptr< CScheduler > scheduler
CChain & ActiveChain() const
int64_t m_peer_connect_timeout
std::unique_ptr< const CChainParams > CreateChainParams(const ArgsManager &args, const std::string &chain)
Creates and returns a std::unique_ptr of the chosen chain.
BlockMap & BlockIndex() EXCLUSIVE_LOCKS_REQUIRED(
Addresses from these networks are not publicly routable on the global Internet.