6 #if defined(HAVE_CONFIG_H) 84 #include <boost/algorithm/string/replace.hpp> 85 #include <boost/signals2/signal.hpp> 100 #define MIN_CORE_FILEDESCRIPTORS 0 102 #define MIN_CORE_FILEDESCRIPTORS 150 166 node.connman->Interrupt();
178 static Mutex g_shutdown_mutex;
179 TRY_LOCK(g_shutdown_mutex, lock_shutdown);
180 if (!lock_shutdown)
return;
181 LogPrintf(
"%s: In progress...\n", __func__);
189 if (
node.mempool)
node.mempool->AddTransactionsUpdated(1);
195 for (
const auto& client :
node.chain_clients) {
203 if (
node.connman)
node.connman->Stop();
209 if (
node.scheduler)
node.scheduler->stop();
210 if (
node.chainman &&
node.chainman->m_load_block.joinable())
node.chainman->m_load_block.join();
215 node.peerman.reset();
216 node.connman.reset();
218 node.addrman.reset();
225 if (
node.fee_estimator)
node.fee_estimator->Flush();
231 if (chainstate->CanFlushToDisk()) {
232 chainstate->ForceFlushStateToDisk();
262 if (chainstate->CanFlushToDisk()) {
263 chainstate->ForceFlushStateToDisk();
264 chainstate->ResetCoinsViews();
269 for (
const auto& client :
node.chain_clients) {
281 node.chain_clients.clear();
285 node.mempool.reset();
286 node.fee_estimator.reset();
287 node.chainman.reset();
288 node.scheduler.reset();
292 LogPrintf(
"%s: Unable to remove PID file: File does not exist\n", __func__);
294 }
catch (
const fs::filesystem_error& e) {
318 static BOOL WINAPI consoleCtrlHandler(DWORD dwCtrlType)
331 sigemptyset(&sa.sa_mask);
333 sigaction(signal, &sa,
nullptr);
368 std::vector<std::string> hidden_args = {
369 "-dbcrashratio",
"-forcecompactdb",
371 "-choosedatadir",
"-lang=<lang>",
"-min",
"-resetguisettings",
"-splash",
"-uiplatform"};
377 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);
396 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)",
400 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, -coinstatsindex and -rescan. " 401 "Warning: Reverting this setting requires re-downloading the entire blockchain. " 412 hidden_args.emplace_back(
"-sysperms");
415 argsman.
AddArg(
"-blockfilterindex=<type>",
417 " If <type> is not supplied or if <type> = 1, indexes for all known types are enabled.",
423 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);
440 argsman.
AddArg(
"-i2pacceptincoming",
"If set and -i2psam is also set then incoming I2P connections are accepted via the SAM proxy. If this is not set but -i2psam is set then only outgoing connections will be made to the I2P network. Ignored if -i2psam is not set. Listening for incoming I2P connections is done through the SAM proxy, not by binding to a local address and port (default: 1)",
ArgsManager::ALLOW_BOOL,
OptionsCategory::CONNECTION);
441 argsman.
AddArg(
"-onlynet=<net>",
"Make outgoing connections only through network <net> (" +
Join(
GetNetworkNames(),
", ") +
"). Incoming connections are not affected by this option. This option can be specified multiple times to allow multiple networks. Warning: if it is used with non-onion networks and the -onion or -proxy option is set, then outbound onion connections will still be made; use -noonion or -onion=0 to disable outbound onion connections in this case.",
ArgsManager::ALLOW_ANY,
OptionsCategory::CONNECTION);
445 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. Not relevant for I2P (see doc/i2p.md).", defaultChainParams->GetDefaultPort(), testnetChainParams->GetDefaultPort(), signetChainParams->GetDefaultPort(), regtestChainParams->GetDefaultPort()),
ArgsManager::ALLOW_ANY |
ArgsManager::NETWORK_ONLY,
OptionsCategory::CONNECTION);
461 hidden_args.emplace_back(
"-upnp");
466 hidden_args.emplace_back(
"-natpmp");
468 argsman.
AddArg(
"-whitebind=<[permissions@]addr>",
"Bind to the given address and add permission flags to the peers connecting to it. " 472 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 " 473 "CIDR-notated network (e.g. 1.2.3.0/24). Uses the same permissions as " 490 hidden_args.emplace_back(
"-zmqpubhashblock=<address>");
491 hidden_args.emplace_back(
"-zmqpubhashtx=<address>");
492 hidden_args.emplace_back(
"-zmqpubrawblock=<address>");
493 hidden_args.emplace_back(
"-zmqpubrawtx=<address>");
494 hidden_args.emplace_back(
"-zmqpubsequence=<n>");
495 hidden_args.emplace_back(
"-zmqpubhashblockhwm=<n>");
496 hidden_args.emplace_back(
"-zmqpubhashtxhwm=<n>");
497 hidden_args.emplace_back(
"-zmqpubrawblockhwm=<n>");
498 hidden_args.emplace_back(
"-zmqpubrawtxhwm=<n>");
499 hidden_args.emplace_back(
"-zmqpubsequencehwm=<n>");
530 argsman.
AddArg(
"-minrelaytxfee=<amt>",
strprintf(
"Fees (in %s/kvB) smaller than this are considered zero fee for relaying, mining and transaction creation (default: %s)",
541 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);
542 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);
543 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);
546 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);
551 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);
552 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);
560 hidden_args.emplace_back(
"-daemon");
561 hidden_args.emplace_back(
"-daemonwait");
570 const std::string URL_SOURCE_CODE =
"<https://github.com/bitcoin/bitcoin>";
574 strprintf(
_(
"Please contribute if you find %s useful. " 575 "Visit %s for further information about the software.").translated,
578 strprintf(
_(
"The source code is available from %s.").translated,
582 _(
"This is experimental software.").
translated +
"\n" +
583 strprintf(
_(
"Distributed under the MIT software license, see the accompanying file %s or %s").translated,
"COPYING",
"<https://opensource.org/licenses/MIT>") +
593 if (pBlockIndex !=
nullptr) {
605 std::string cmd = args.
GetArg(
"-startupnotify",
"");
607 std::thread t(runCommand, cmd);
636 LogPrintf(
"%s: parameter interaction: -bind set -> setting -listen=1\n", __func__);
640 LogPrintf(
"%s: parameter interaction: -whitebind set -> setting -listen=1\n", __func__);
646 LogPrintf(
"%s: parameter interaction: -connect set -> setting -dnsseed=0\n", __func__);
648 LogPrintf(
"%s: parameter interaction: -connect set -> setting -listen=0\n", __func__);
654 LogPrintf(
"%s: parameter interaction: -proxy set -> setting -listen=0\n", __func__);
658 LogPrintf(
"%s: parameter interaction: -proxy set -> setting -upnp=0\n", __func__);
660 LogPrintf(
"%s: parameter interaction: -proxy set -> setting -natpmp=0\n", __func__);
664 LogPrintf(
"%s: parameter interaction: -proxy set -> setting -discover=0\n", __func__);
670 LogPrintf(
"%s: parameter interaction: -listen=0 -> setting -upnp=0\n", __func__);
672 LogPrintf(
"%s: parameter interaction: -listen=0 -> setting -natpmp=0\n", __func__);
675 LogPrintf(
"%s: parameter interaction: -listen=0 -> setting -discover=0\n", __func__);
677 LogPrintf(
"%s: parameter interaction: -listen=0 -> setting -listenonion=0\n", __func__);
679 LogPrintf(
"%s: parameter interaction: -listen=0 -> setting -i2pacceptincoming=0\n", __func__);
686 LogPrintf(
"%s: parameter interaction: -externalip set -> setting -discover=0\n", __func__);
692 LogPrintf(
"%s: parameter interaction: -blocksonly=1 -> setting -whitelistrelay=0\n", __func__);
698 LogPrintf(
"%s: parameter interaction: -whitelistforcerelay=1 -> setting -whitelistrelay=1\n", __func__);
717 int nUserMaxConnections;
720 int64_t peer_connect_timeout;
721 std::set<BlockFilterType> g_enabled_filter_types;
731 std::set_new_handler(std::terminate);
732 LogPrintf(
"Error: Out of memory. Terminating.\n");
743 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
744 _CrtSetReportFile(_CRT_WARN, CreateFileA(
"NUL", GENERIC_WRITE, 0,
nullptr, OPEN_EXISTING, 0, 0));
746 _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
750 HeapSetInformation(
nullptr, HeapEnableTerminationOnCorruption,
nullptr, 0);
773 signal(SIGPIPE, SIG_IGN);
775 SetConsoleCtrlHandler(consoleCtrlHandler,
true);
799 errors +=
strprintf(
_(
"Config setting for %s only applied on %s network when in [%s] section.") +
Untranslated(
"\n"), arg, network, network);
802 if (!errors.
empty()) {
812 if (!warnings.
empty()) {
822 if (blockfilterindex_value ==
"" || blockfilterindex_value ==
"1") {
824 }
else if (blockfilterindex_value !=
"0") {
825 const std::vector<std::string> names = args.
GetArgs(
"-blockfilterindex");
826 for (
const auto&
name : names) {
831 g_enabled_filter_types.insert(filter_type);
838 return InitError(
_(
"Cannot set -peerblockfilters without -blockfilterindex."));
845 if (args.
GetArg(
"-prune", 0)) {
847 return InitError(
_(
"Prune mode is incompatible with -txindex."));
849 return InitError(
_(
"Prune mode is incompatible with -coinstatsindex."));
853 size_t nUserBind = args.
GetArgs(
"-bind").size() + args.
GetArgs(
"-whitebind").size();
859 int nBind = std::max(nUserBind,
size_t(1));
861 nMaxConnections = std::max(nUserMaxConnections, 0);
870 int fd_max = FD_SETSIZE;
874 return InitError(
_(
"Not enough file descriptors available."));
877 if (nMaxConnections < nUserMaxConnections)
878 InitWarning(
strprintf(
_(
"Reducing -maxconnections from %d to %d, because of system limitations."), nUserMaxConnections, nMaxConnections));
890 LogPrintf(
"Validating signatures for all blocks.\n");
892 if (args.
IsArgSet(
"-minimumchainwork")) {
893 const std::string minChainWorkStr = args.
GetArg(
"-minimumchainwork",
"");
909 if (nMempoolSizeMax < 0 || nMempoolSizeMax < nMempoolSizeMin)
910 return InitError(
strprintf(
_(
"-maxmempool must be at least %d MB"), std::ceil(nMempoolSizeMin / 1000000.0)));
913 if (args.
IsArgSet(
"-incrementalrelayfee")) {
921 int64_t nPruneArg = args.
GetArg(
"-prune", 0);
923 return InitError(
_(
"Prune cannot be configured with a negative value."));
926 if (nPruneArg == 1) {
927 LogPrintf(
"Block pruning enabled. Use RPC call pruneblockchain(height) to manually prune block and undo files.\n");
934 LogPrintf(
"Prune configured to target %u MiB on disk for block and undo files.\n",
nPruneTarget / 1024 / 1024);
944 if (peer_connect_timeout <= 0) {
948 if (args.
IsArgSet(
"-minrelaytxfee")) {
963 if (args.
IsArgSet(
"-blockmintxfee")) {
971 if (args.
IsArgSet(
"-dustrelayfee")) {
1004 if (args.
IsArgSet(
"-proxy") && args.
GetArg(
"-proxy",
"").empty()) {
1005 return InitError(
_(
"No proxy server specified. Use -proxy=<ip> or -proxy=<ip:port>."));
1016 return InitError(
strprintf(
_(
"Cannot write to data directory '%s'; check permissions."), datadir.string()));
1077 LogPrintf(
"Using at most %i automatic connections (%i file descriptors available)\n", nMaxConnections, nFD);
1080 if (args.
IsArgSet(
"-datadir") && !fs::path(args.
GetArg(
"-datadir",
"")).is_absolute()) {
1081 LogPrintf(
"Warning: relative datadir option '%s' specified, which will be interpreted relative to the " 1082 "current working directory '%s'. This is fragile, because if bitcoin is started in the future " 1083 "from a different location, it will be unable to locate the current data files. There could " 1084 "also be data loss if bitcoin is started while in a temporary directory.\n",
1085 args.
GetArg(
"-datadir",
""), fs::current_path().string());
1092 if (script_threads <= 0) {
1099 script_threads = std::max(script_threads - 1, 0);
1104 LogPrintf(
"Script verification uses %d additional threads\n", script_threads);
1105 if (script_threads >= 1) {
1111 node.scheduler = std::make_unique<CScheduler>();
1114 node.scheduler->m_service_thread = std::thread(
util::TraceThread,
"scheduler", [&] {
node.scheduler->serviceQueue(); });
1117 node.scheduler->scheduleEvery([]{
1119 }, std::chrono::minutes{1});
1127 for (
const auto& client :
node.chain_clients) {
1128 client->registerRpcs();
1142 return InitError(
_(
"Unable to start HTTP server. See debug log for details."));
1146 for (
const auto& client :
node.chain_clients) {
1147 if (!client->verify()) {
1163 node.addrman = std::make_unique<CAddrMan>();
1167 node.connman = std::make_unique<CConnman>(
GetRand(std::numeric_limits<uint64_t>::max()),
GetRand(std::numeric_limits<uint64_t>::max()), *
node.addrman, args.
GetBoolArg(
"-networkactive",
true));
1172 if (!ignores_incoming_txs)
node.fee_estimator = std::make_unique<CBlockPolicyEstimator>();
1176 node.mempool = std::make_unique<CTxMemPool>(
node.fee_estimator.get(), check_ratio);
1179 node.chainman = std::make_unique<ChainstateManager>();
1184 *
node.scheduler, chainman, *
node.mempool, ignores_incoming_txs);
1188 std::vector<std::string> uacomments;
1189 for (
const std::string& cmt : args.
GetArgs(
"-uacomment")) {
1191 return InitError(
strprintf(
_(
"User Agent comment (%s) contains unsafe characters."), cmt));
1192 uacomments.push_back(cmt);
1196 return InitError(
strprintf(
_(
"Total length of network version string (%i) exceeds maximum length (%i). Reduce the number or size of uacomments."),
1201 std::set<enum Network> nets;
1202 for (
const std::string& snet : args.
GetArgs(
"-onlynet")) {
1208 for (
int n = 0; n <
NET_MAX; n++) {
1210 if (!nets.count(net))
1221 std::string proxyArg = args.
GetArg(
"-proxy",
"");
1223 if (proxyArg !=
"" && proxyArg !=
"0") {
1243 std::string onionArg = args.
GetArg(
"-onion",
"");
1244 if (onionArg !=
"") {
1245 if (onionArg ==
"0") {
1260 for (
const std::string& strAddr : args.
GetArgs(
"-externalip")) {
1270 fs::path asmap_path = fs::path(args.
GetArg(
"-asmap",
""));
1271 if (asmap_path.empty()) {
1274 if (!asmap_path.is_absolute()) {
1277 if (!fs::exists(asmap_path)) {
1282 if (asmap.size() == 0) {
1287 node.connman->SetAsmap(std::move(asmap));
1288 LogPrintf(
"Using asmap version %s for IP bucketing\n", asmap_version.
ToString());
1290 LogPrintf(
"Using /16 prefix for IP bucketing\n");
1304 bool fReindexChainState = args.
GetBoolArg(
"-reindex-chainstate",
false);
1308 nTotalCache = std::max(nTotalCache,
nMinDbCache << 20);
1309 nTotalCache = std::min(nTotalCache,
nMaxDbCache << 20);
1310 int64_t nBlockTreeDBCache = std::min(nTotalCache / 8,
nMaxBlockDBCache << 20);
1311 nTotalCache -= nBlockTreeDBCache;
1313 nTotalCache -= nTxIndexCache;
1314 int64_t filter_index_cache = 0;
1315 if (!g_enabled_filter_types.empty()) {
1316 size_t n_indexes = g_enabled_filter_types.size();
1318 filter_index_cache = max_cache / n_indexes;
1319 nTotalCache -= filter_index_cache * n_indexes;
1321 int64_t nCoinDBCache = std::min(nTotalCache / 2, (nTotalCache / 4) + (1 << 23));
1323 nTotalCache -= nCoinDBCache;
1324 int64_t nCoinCacheUsage = nTotalCache;
1327 LogPrintf(
"* Using %.1f MiB for block index database\n", nBlockTreeDBCache * (1.0 / 1024 / 1024));
1329 LogPrintf(
"* Using %.1f MiB for transaction index database\n", nTxIndexCache * (1.0 / 1024 / 1024));
1332 LogPrintf(
"* Using %.1f MiB for %s block filter index database\n",
1335 LogPrintf(
"* Using %.1f MiB for chain state database\n", nCoinDBCache * (1.0 / 1024 / 1024));
1336 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));
1338 bool fLoaded =
false;
1342 return fReset || fReindexChainState || chainstate->CoinsTip().GetBestBlock().IsNull();
1346 uiInterface.InitMessage(
_(
"Loading block index…").translated);
1349 const int64_t load_block_index_start_time =
GetTimeMillis();
1352 chainman.InitializeChainstate(
Assert(
node.mempool.get()));
1353 chainman.m_total_coinstip_cache = nCoinCacheUsage;
1354 chainman.m_total_coinsdb_cache = nCoinDBCache;
1376 if (!chainman.LoadBlockIndex()) {
1378 strLoadError =
_(
"Error loading block database");
1384 if (!chainman.BlockIndex().empty() &&
1386 return InitError(
_(
"Incorrect or no genesis block found. Wrong datadir for network?"));
1392 strLoadError =
_(
"You need to rebuild the database using -reindex to go back to unpruned mode. This will redownload the entire blockchain");
1400 if (!
fReindex && !chainman.ActiveChainstate().LoadGenesisBlock()) {
1401 strLoadError =
_(
"Error initializing block database");
1408 bool failed_chainstate_init =
false;
1410 for (
CChainState* chainstate : chainman.GetAll()) {
1411 chainstate->InitCoinsDB(
1414 fReset || fReindexChainState);
1416 chainstate->CoinsErrorCatcher().AddReadErrCallback([]() {
1418 _(
"Error reading from database, shutting down."),
1424 if (!chainstate->CoinsDB().Upgrade()) {
1425 strLoadError =
_(
"Error upgrading chainstate database");
1426 failed_chainstate_init =
true;
1431 if (!chainstate->ReplayBlocks()) {
1432 strLoadError =
_(
"Unable to replay blocks. You will need to rebuild the database using -reindex-chainstate.");
1433 failed_chainstate_init =
true;
1438 chainstate->InitCoinsCache(nCoinCacheUsage);
1439 assert(chainstate->CanFlushToDisk());
1441 if (!is_coinsview_empty(chainstate)) {
1443 if (!chainstate->LoadChainTip()) {
1444 strLoadError =
_(
"Error initializing block database");
1445 failed_chainstate_init =
true;
1448 assert(chainstate->m_chain.Tip() !=
nullptr);
1452 if (failed_chainstate_init) {
1455 }
catch (
const std::exception& e) {
1457 strLoadError =
_(
"Error opening block database");
1463 auto chainstates{chainman.GetAll()};
1464 if (std::any_of(chainstates.begin(), chainstates.end(),
1466 strLoadError =
strprintf(
_(
"Witness data for blocks after height %d requires validation. Please restart with -reindex."),
1472 bool failed_verification =
false;
1477 for (
CChainState* chainstate : chainman.GetAll()) {
1478 if (!is_coinsview_empty(chainstate)) {
1479 uiInterface.InitMessage(
_(
"Verifying blocks…").translated);
1481 LogPrintf(
"Prune: pruned datadir may not have more than %d blocks; only checking available blocks\n",
1485 const CBlockIndex* tip = chainstate->m_chain.Tip();
1488 strLoadError =
_(
"The block database contains a block which appears to be from the future. " 1489 "This may be due to your computer's date and time being set incorrectly. " 1490 "Only rebuild the block database if you are sure that your computer's date and time are correct");
1491 failed_verification =
true;
1496 *chainstate, chainparams, chainstate->CoinsDB(),
1499 strLoadError =
_(
"Corrupted block database detected");
1500 failed_verification =
true;
1505 }
catch (
const std::exception& e) {
1507 strLoadError =
_(
"Error opening block database");
1508 failed_verification =
true;
1512 if (!failed_verification) {
1522 strLoadError +
Untranslated(
".\n\n") +
_(
"Do you want to rebuild the block database now?"),
1523 strLoadError.
original +
".\nPlease restart with -reindex or -reindex-chainstate to recover.",
1529 LogPrintf(
"Aborted block database rebuild. Exiting.\n");
1542 LogPrintf(
"Shutdown requested. Exiting.\n");
1549 if (!
g_txindex->Start(chainman.ActiveChainstate())) {
1554 for (
const auto& filter_type : g_enabled_filter_types) {
1569 for (
const auto& client :
node.chain_clients) {
1570 if (!client->load()) {
1580 LogPrintf(
"Unsetting NODE_NETWORK on prune mode\n");
1584 for (
CChainState* chainstate : chainman.GetAll()) {
1585 uiInterface.InitMessage(
_(
"Pruning blockstore…").translated);
1586 chainstate->PruneAndFlush();
1610 boost::signals2::connection block_notify_genesis_wait_connection;
1611 if (chainman.ActiveChain().Tip() ==
nullptr) {
1618 const std::string block_notify = args.
GetArg(
"-blocknotify",
"");
1619 if (!block_notify.empty()) {
1622 std::string command = block_notify;
1624 std::thread t(runCommand, command);
1630 std::vector<fs::path> vImportFiles;
1631 for (
const std::string& strFile : args.
GetArgs(
"-loadblock")) {
1632 vImportFiles.push_back(strFile);
1635 chainman.m_load_block = std::thread(&
util::TraceThread,
"loadblk", [=, &chainman, &args] {
1648 block_notify_genesis_wait_connection.disconnect();
1657 int chain_active_height;
1662 LogPrintf(
"block tree size = %u\n", chainman.BlockIndex().size());
1663 chain_active_height = chainman.ActiveChain().Height();
1674 LogPrintf(
"nBestHeight = %d\n", chain_active_height);
1675 if (
node.peerman)
node.peerman->SetBestHeight(chain_active_height);
1684 connOptions.nMaxConnections = nMaxConnections;
1690 connOptions.m_banman =
node.banman.get();
1691 connOptions.m_msgproc =
node.peerman.get();
1694 connOptions.m_added_nodes = args.
GetArgs(
"-addnode");
1697 connOptions.m_peer_connect_timeout = peer_connect_timeout;
1699 for (
const std::string& bind_arg : args.
GetArgs(
"-bind")) {
1701 const size_t index = bind_arg.rfind(
'=');
1702 if (index == std::string::npos) {
1704 connOptions.vBinds.push_back(bind_addr);
1708 const std::string network_type = bind_arg.substr(index + 1);
1709 if (network_type ==
"onion") {
1710 const std::string truncated_bind_arg = bind_arg.substr(0, index);
1711 if (
Lookup(truncated_bind_arg, bind_addr,
BaseParams().OnionServiceTargetPort(),
false)) {
1712 connOptions.onion_binds.push_back(bind_addr);
1720 for (
const std::string& strBind : args.
GetArgs(
"-whitebind")) {
1724 connOptions.vWhiteBinds.push_back(whitebind);
1729 connOptions.bind_on_any = args.
GetArgs(
"-bind").empty() && args.
GetArgs(
"-whitebind").empty();
1732 if (!connOptions.onion_binds.empty()) {
1733 onion_service_target = connOptions.onion_binds.front();
1736 connOptions.onion_binds.push_back(onion_service_target);
1740 if (connOptions.onion_binds.size() > 1) {
1742 "for the automatically created Tor onion service."),
1748 for (
const auto& net : args.
GetArgs(
"-whitelist")) {
1752 connOptions.vWhitelistedRange.push_back(subnet);
1755 connOptions.vSeedNodes = args.
GetArgs(
"-seednode");
1758 connOptions.m_use_addrman_outgoing = !args.
IsArgSet(
"-connect");
1759 if (!connOptions.m_use_addrman_outgoing) {
1760 const auto connect = args.
GetArgs(
"-connect");
1761 if (connect.size() != 1 || connect[0] !=
"0") {
1762 connOptions.m_specified_outgoing = connect;
1766 const std::string& i2psam_arg = args.
GetArg(
"-i2psam",
"");
1767 if (!i2psam_arg.empty()) {
1778 connOptions.m_i2p_accept_incoming = args.
GetBoolArg(
"-i2pacceptincoming",
true);
1780 if (!
node.connman->Start(*
node.scheduler, connOptions)) {
1789 for (
const auto& client :
node.chain_clients) {
1790 client->start(*
node.scheduler);
1794 node.scheduler->scheduleEvery([banman]{
std::string SanitizeString(const std::string &str, int rule)
Remove unsafe chars.
static const int MAX_BLOCK_RELAY_ONLY_CONNECTIONS
Maximum number of block-relay-only outgoing connections.
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)
std::string NetworkIDString() const
Return the network string.
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'.
bool IsArgSet(const std::string &strArg) const
Return true if the given argument has been manually set.
bool ShutdownRequested()
Returns true if a shutdown is requested, false otherwise.
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.
void SetupChainParamsBaseOptions(ArgsManager &argsman)
Set the arguments for chainparams.
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
bilingual_str AmountErrMsg(const std::string &optname, const std::string &strValue)
#define LogPrint(category,...)
int64_t GetBlockTime() const
bool DirIsWritable(const fs::path &directory)
bool AddLocal(const CService &addr, int nScore)
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)
void SetupServerArgs(ArgsManager &argsman)
Register all arguments with the ArgsManager.
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.
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)
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
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.
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
static const int DEFAULT_HTTP_WORKQUEUE
static void RegisterAllCoreRPCCommands(CRPCTable &t)
static void OnRPCStarted()
static const int64_t DEFAULT_MAX_TIP_AGE
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 pruned.
static const unsigned int DEFAULT_ANCESTOR_LIMIT
Default for -limitancestorcount, max number of in-mempool ancestors.
void StartREST(const std::any &context)
Start HTTP REST subsystem.
const std::string UNIX_EPOCH_TIME
String used to describe UNIX epoch time in documentation, factored out to a constant for consistency...
void AddHiddenArgs(const std::vector< std::string > &args)
Add many hidden arguments.
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...
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
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.
const std::set< BlockFilterType > & AllBlockFilterTypes()
Get a list of known filter types.
bool DefaultConsistencyChecks() const
Default value for -checkmempool and -checkblockindex argument.
const CBlock & GenesisBlock() const
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.
bool InitShutdownState()
Initialize shutdown state.
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
void StartMapPort(bool use_upnp, bool use_natpmp)
static const int64_t nMinDbCache
min. -dbcache (MiB)
bool StartHTTPRPC(const std::any &context)
Start HTTP RPC subsystem.
void RandAddPeriodic() noexcept
Gather entropy from various expensive sources, and feed them to the PRNG state.
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.
bool CheckDiskSpace(const fs::path &dir, uint64_t additional_bytes)
void SetLoggingCategories(const ArgsManager &args)
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.
bool SetNameProxy(const proxyType &addrProxy)
Set the name proxy to use for all connections to nodes specified by a hostname.
bool(* handler)(const std::any &context, HTTPRequest *req, const std::string &strReq)
bool Lookup(const std::string &name, std::vector< CService > &vAddr, uint16_t portDefault, bool fAllowLookup, unsigned int nMaxSolutions, DNSLookupFn dns_lookup_function)
Resolve a service string to its corresponding service.
static constexpr bool DEFAULT_DAEMON
Default value for -daemon option.
void SetReachable(enum Network net, bool reachable)
Mark a network as reachable or unreachable (no automatic connects to it)
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.
void StartScriptCheckWorkerThreads(int threads_num)
Run instances of script checking worker threads.
arith_uint256 UintToArith256(const uint256 &a)
bool AppInitBasicSetup(const ArgsManager &args)
Initialize bitcoin core: Basic context setup.
static const std::string MAIN
Chain name strings.
static const bool DEFAULT_PEERBLOCKFILTERS
bool DeploymentEnabled(const Consensus::Params ¶ms, Consensus::BuriedDeployment dep)
Determine if a deployment is enabled (can ever be active)
int64_t CAmount
Amount in satoshis (Can be negative)
static constexpr bool DEFAULT_UPNP
Common init functions shared by bitcoin-node, bitcoin-wallet, etc.
uint256 GetBlockHash() const
void SetMockTime(int64_t nMockTimeIn)
DEPRECATED Use SetMockTime with chrono type.
bool SanityChecks()
Ensure a usable environment with all necessary library support.
void SetRPCWarmupFinished()
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
bool LockDirectory(const fs::path &directory, const std::string lockfile_name, bool probe_only)
static const bool DEFAULT_PERSIST_MEMPOOL
Default for -persistmempool.
bool InitHTTPServer()
Initialize HTTP server.
bool AppInitSanityChecks()
Initialization sanity checks: ecc init, sanity checks, dir lock.
void TraceThread(const char *thread_name, std::function< void()> thread_func)
A wrapper for do-something-once thread functions.
uint64_t nPruneTarget
Number of MiB of block files that we're trying to stay below.
const std::string & ListBlockFilterTypes()
Get a comma-separated list of known filter type names.
static CZMQNotificationInterface * Create()
NodeContext struct containing references to chain state and connection state.
bool fPruneMode
True if we're running in -prune mode.
const std::string DEFAULT_TOR_CONTROL
Default control port.
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).
std::unique_ptr< TxIndex > g_txindex
The global transaction index, used in GetTransaction. May be null.
static bool TryParse(const std::string &str, NetWhitelistPermissions &output, bilingual_str &error)
bilingual_str _(const char *psz)
Translation function.
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...
A combination of a network address (CNetAddr) and a (TCP) port.
uint256 uint256S(const char *str)
void DestroyAllBlockFilterIndexes()
Destroy all open block filter indexes.
std::string ToString(const FeeEstimateMode &fee_estimate_mode=FeeEstimateMode::BTC_KVB) const
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.
static const unsigned int DEFAULT_MIN_RELAY_TX_FEE
Default for -minrelaytxfee, minimum relay fee for transactions.
bool StartLogging(const ArgsManager &args)
static const int NUM_FDS_MESSAGE_CAPTURE
Number of file descriptors required for message capture.
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.
bool AppInitMain(NodeContext &node, interfaces::BlockAndHeaderTipInfo *tip_info)
Bitcoin core main initialization.
static constexpr bool DEFAULT_COINSTATSINDEX
static const int DEFAULT_STOPATHEIGHT
Default for -stopatheight.
void InitSignatureCache()
static constexpr std::chrono::minutes DUMP_BANS_INTERVAL
How often to dump banned addresses/subnets to disk.
const std::string CURRENCY_UNIT
CMainSignals & GetMainSignals()
static const int64_t nDefaultDbCache
-dbcache default (MiB)
Block and header tip information.
const CMessageHeader::MessageStartChars & MessageStart() const
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.
#define WAIT_LOCK(cs, name)
static const int64_t nDefaultDbBatchSize
-dbbatchsize default (bytes)
std::string ToString() const
static fs::path GetPidFile(const ArgsManager &args)
void StopScriptCheckWorkerThreads()
Stop all of the script checking worker threads.
const std::string CLIENT_NAME
std::string strSubVersion
Subversion as sent to the P2P network in version messages.
static const int DEFAULT_NAME_LOOKUP
-dns default
void SetLoggingOptions(const ArgsManager &args)
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...
static const char *const DEFAULT_BLOCKFILTERINDEX
static const int DEFAULT_ZMQ_SNDHWM
static const bool DEFAULT_PROXYRANDOMIZE
bool IsHexNumber(const std::string &str)
Return true if the string is a hex number, optionally prefixed with "0x".
void AddLoggingArgs(ArgsManager &argsman)
int64_t nMaxTipAge
If the tip is older than this (in seconds), the node is considered to be in initial block download...
CFeeRate incrementalRelayFee
virtual void AddWalletOptions(ArgsManager &argsman) const =0
Get wallet help string.
std::vector< std::string > GetNetworkNames(bool append_unroutable)
Return a vector of publicly routable Network names; optionally append NET_UNROUTABLE.
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)
bool SetProxy(enum Network net, const proxyType &addrProxy)
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate...
void StopHTTPRPC()
Stop HTTP RPC subsystem.
enum Network ParseNetwork(const std::string &net_in)
static const bool DEFAULT_DNSSEED
static constexpr uint64_t DEFAULT_MAX_UPLOAD_TARGET
The default for -maxuploadtarget.
std::string FormatMoney(const CAmount n)
Money parsing/formatting utilities.
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.
double verification_progress
static constexpr bool DEFAULT_NATPMP
std::atomic_bool fReindex
static const bool DEFAULT_PEERBLOOMFILTERS
void RegisterZMQRPCCommands(CRPCTable &t)
uint256 nMinimumChainWork
The best chain should have at least this much work.
bool RequireStandard() const
Policy: Filter transactions that do not match well-defined patterns.
bool g_parallel_script_checks
Whether there are dedicated script-checking threads running.
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.
bool IsTestChain() const
If this chain is exclusively used for testing.
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()
The block chain is a tree shaped structure starting with the genesis block at the root...
const CChainParams & Params()
Return the currently selected parameters.
void FlushBackgroundCallbacks()
Call any remaining callbacks on the calling thread.
static const signed int DEFAULT_CHECKBLOCKS
void RpcInterruptionPoint()
Throw JSONRPCError if RPC is not running.
static const int64_t nMaxCoinsDBCache
Max memory allocated to coin DB specific cache (MiB)
void InitScriptExecutionCache()
Initializes the script-execution cache.
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.
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
ServiceFlags nLocalServices
void InterruptREST()
Interrupt RPC REST subsystem.
int64_t GetAdjustedTime()
std::string ToStringIPPort() const
static const int DEFAULT_CONNECT_TIMEOUT
-timeout default
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...
std::string GetHex() const
void AbortShutdown()
Clear shutdown flag.
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)
CService DefaultOnionServiceTarget()
static constexpr bool DEFAULT_DAEMONWAIT
Default value for -daemonwait option.
static const unsigned int MAX_SUBVERSION_LENGTH
Maximum length of the user agent string in version message.
static const int64_t DEFAULT_PEER_CONNECT_TIMEOUT
-peertimeout default
void StartShutdown()
Request shutdown of the application.
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)
void StartHTTPServer()
Start HTTP server.
std::string GetChainName() const
Returns the appropriate chain name from the program arguments.
std::unique_ptr< CoinStatsIndex > g_coin_stats_index
The global UTXO set hash object.
const std::list< SectionInfo > GetUnrecognizedSections() const
Log warnings for unrecognized section names in the config file.
const fs::path & GetBlocksDirPath() const
Get blocks directory path.
void CleanupBlockRevFiles()
void InterruptTorControl()
int SegwitHeight
Block height at which Segwit (BIP141, BIP143 and BIP147) becomes active.
void OnStarted(std::function< void()> slot)
bool AppInitInterfaces(NodeContext &node)
Initialize node and wallet interface pointers.
static const bool DEFAULT_WHITELISTRELAY
Default for -whitelistrelay.
std::string GetHex() const
bool AppInitLockDataDirectory()
Lock bitcoin core data directory.
void UnloadBlockIndex(CTxMemPool *mempool, ChainstateManager &chainman)
Unload database information.
static const int MAX_OUTBOUND_FULL_RELAY_CONNECTIONS
Maximum number of automatic outgoing nodes over which we'll relay everything (blocks, tx, addrs, etc)
CClientUIInterface uiInterface
static bool TryParse(const std::string &str, NetWhitebindPermissions &output, bilingual_str &error)
int nHeight
height of the entry in the chain. The genesis block has height 0
static std::unique_ptr< PeerManager > make(const CChainParams &chainparams, CConnman &connman, CAddrMan &addrman, BanMan *banman, CScheduler &scheduler, ChainstateManager &chainman, CTxMemPool &pool, bool ignore_incoming_txs)
static const char * BITCOIN_PID_FILENAME
The PID file facilities.
const Consensus::Params & GetConsensus() const
static const bool DEFAULT_PRINTPRIORITY
static void registerSignalHandler(int signal, void(*handler)(int))
static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES
bool fHavePruned
Pruning-related variables and constants.
std::vector< std::string > GetArgs(const std::string &strArg) const
Return a vector of strings of the given argument.
void ThreadImport(ChainstateManager &chainman, std::vector< fs::path > vImportFiles, const ArgsManager &args)
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
static constexpr bool DEFAULT_STOPAFTERBLOCKIMPORT
static const unsigned int DEFAULT_MAX_ORPHAN_TRANSACTIONS
Default for -maxorphantx, maximum number of orphan transactions kept in memory.
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
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...
bool error(const char *fmt, const Args &... args)
static bool CreatePidFile(const ArgsManager &args)
static const std::string SIGNET
static const bool DEFAULT_TXINDEX
static const int DEFAULT_HTTP_THREADS
static const bool DEFAULT_REST_ENABLE
static bool AppInitServers(NodeContext &node)
unsigned nMaxDatacarrierBytes
Maximum size of TxoutType::NULL_DATA scripts that this node considers standard.
bool DumpMempool(const CTxMemPool &pool, FopenFn mockable_fopen_function, bool skip_file_commit)
Dump the mempool to disk.
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
static const int MAX_SCRIPTCHECK_THREADS
Maximum number of dedicated script-checking threads allowed.
#define Assert(val)
Identity function.
const fs::path & GetDataDirNet() const
Get data directory path with appended network identifier.
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< const CChainParams > CreateChainParams(const ArgsManager &args, const std::string &chain)
Creates and returns a std::unique_ptr<CChainParams> of the chosen chain.
Addresses from these networks are not publicly routable on the global Internet.
static const bool DEFAULT_FIXEDSEEDS