6 #if defined(HAVE_CONFIG_H) 85 #include <condition_variable> 101 #include <boost/signals2/signal.hpp> 135 #define MIN_CORE_FILEDESCRIPTORS 0 137 #define MIN_CORE_FILEDESCRIPTORS 150 201 node.connman->Interrupt();
213 static Mutex g_shutdown_mutex;
214 TRY_LOCK(g_shutdown_mutex, lock_shutdown);
215 if (!lock_shutdown)
return;
216 LogPrintf(
"%s: In progress...\n", __func__);
224 if (
node.mempool)
node.mempool->AddTransactionsUpdated(1);
230 for (
const auto& client :
node.chain_clients) {
238 if (
node.connman)
node.connman->Stop();
244 if (
node.scheduler)
node.scheduler->stop();
245 if (
node.chainman &&
node.chainman->m_load_block.joinable())
node.chainman->m_load_block.join();
250 node.peerman.reset();
251 node.connman.reset();
253 node.addrman.reset();
254 node.netgroupman.reset();
261 if (
node.fee_estimator)
node.fee_estimator->Flush();
267 if (chainstate->CanFlushToDisk()) {
268 chainstate->ForceFlushStateToDisk();
298 if (chainstate->CanFlushToDisk()) {
299 chainstate->ForceFlushStateToDisk();
300 chainstate->ResetCoinsViews();
304 for (
const auto& client :
node.chain_clients) {
316 node.chain_clients.clear();
320 node.mempool.reset();
321 node.fee_estimator.reset();
322 node.chainman.reset();
323 node.scheduler.reset();
327 LogPrintf(
"%s: Unable to remove PID file: File does not exist\n", __func__);
329 }
catch (
const fs::filesystem_error& e) {
352 static BOOL WINAPI consoleCtrlHandler(DWORD dwCtrlType)
365 sigemptyset(&sa.sa_mask);
367 sigaction(signal, &sa,
nullptr);
402 std::vector<std::string> hidden_args = {
403 "-dbcrashratio",
"-forcecompactdb",
405 "-choosedatadir",
"-lang=<lang>",
"-min",
"-resetguisettings",
"-splash",
"-uiplatform"};
411 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);
430 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)",
434 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. " 435 "Warning: Reverting this setting requires re-downloading the entire blockchain. " 438 argsman.
AddArg(
"-reindex-chainstate",
"Rebuild chain state from the currently indexed blocks. When in pruning mode or if blocks on disk might be corrupted, use full -reindex instead. Deactivate all optional indexes before running this.",
ArgsManager::ALLOW_ANY,
OptionsCategory::OPTIONS);
446 hidden_args.emplace_back(
"-sysperms");
449 argsman.
AddArg(
"-blockfilterindex=<type>",
451 " If <type> is not supplied or if <type> = 1, indexes for all known types are enabled.",
457 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);
475 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_ANY,
OptionsCategory::CONNECTION);
481 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);
497 hidden_args.emplace_back(
"-upnp");
502 hidden_args.emplace_back(
"-natpmp");
504 argsman.
AddArg(
"-whitebind=<[permissions@]addr>",
"Bind to the given address and add permission flags to the peers connecting to it. " 508 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 " 509 "CIDR-notated network (e.g. 1.2.3.0/24). Uses the same permissions as " 526 hidden_args.emplace_back(
"-zmqpubhashblock=<address>");
527 hidden_args.emplace_back(
"-zmqpubhashtx=<address>");
528 hidden_args.emplace_back(
"-zmqpubrawblock=<address>");
529 hidden_args.emplace_back(
"-zmqpubrawtx=<address>");
530 hidden_args.emplace_back(
"-zmqpubsequence=<n>");
531 hidden_args.emplace_back(
"-zmqpubhashblockhwm=<n>");
532 hidden_args.emplace_back(
"-zmqpubhashtxhwm=<n>");
533 hidden_args.emplace_back(
"-zmqpubrawblockhwm=<n>");
534 hidden_args.emplace_back(
"-zmqpubrawtxhwm=<n>");
535 hidden_args.emplace_back(
"-zmqpubsequencehwm=<n>");
570 argsman.
AddArg(
"-minrelaytxfee=<amt>",
strprintf(
"Fees (in %s/kvB) smaller than this are considered zero fee for relaying, mining and transaction creation (default: %s)",
581 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);
582 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);
583 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);
587 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);
592 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);
593 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_ANY,
OptionsCategory::RPC);
601 hidden_args.emplace_back(
"-daemon");
602 hidden_args.emplace_back(
"-daemonwait");
605 #if defined(USE_SYSCALL_SANDBOX) 606 argsman.
AddArg(
"-sandbox=<mode>",
"Use the experimental syscall sandbox in the specified mode (-sandbox=log-and-abort or -sandbox=abort). Allow only expected syscalls to be used by bitcoind. Note that this is an experimental new feature that may cause bitcoind to exit or crash unexpectedly: use with caution. In the \"log-and-abort\" mode the invocation of an unexpected syscall results in a debug handler being invoked which will log the incident and terminate the program (without executing the unexpected syscall). In the \"abort\" mode the invocation of an unexpected syscall results in the entire process being killed immediately by the kernel without executing the unexpected syscall.",
ArgsManager::ALLOW_ANY,
OptionsCategory::OPTIONS);
607 #endif // USE_SYSCALL_SANDBOX 619 if (pBlockIndex !=
nullptr) {
633 std::thread
t(runCommand,
cmd);
662 LogPrintf(
"%s: parameter interaction: -bind set -> setting -listen=1\n", __func__);
666 LogPrintf(
"%s: parameter interaction: -whitebind set -> setting -listen=1\n", __func__);
672 LogPrintf(
"%s: parameter interaction: -connect set -> setting -dnsseed=0\n", __func__);
674 LogPrintf(
"%s: parameter interaction: -connect set -> setting -listen=0\n", __func__);
677 std::string proxy_arg =
args.
GetArg(
"-proxy",
"");
678 if (proxy_arg !=
"" && proxy_arg !=
"0") {
681 LogPrintf(
"%s: parameter interaction: -proxy set -> setting -listen=0\n", __func__);
685 LogPrintf(
"%s: parameter interaction: -proxy set -> setting -upnp=0\n", __func__);
687 LogPrintf(
"%s: parameter interaction: -proxy set -> setting -natpmp=0\n", __func__);
691 LogPrintf(
"%s: parameter interaction: -proxy set -> setting -discover=0\n", __func__);
697 LogPrintf(
"%s: parameter interaction: -listen=0 -> setting -upnp=0\n", __func__);
699 LogPrintf(
"%s: parameter interaction: -listen=0 -> setting -natpmp=0\n", __func__);
702 LogPrintf(
"%s: parameter interaction: -listen=0 -> setting -discover=0\n", __func__);
704 LogPrintf(
"%s: parameter interaction: -listen=0 -> setting -listenonion=0\n", __func__);
706 LogPrintf(
"%s: parameter interaction: -listen=0 -> setting -i2pacceptincoming=0\n", __func__);
713 LogPrintf(
"%s: parameter interaction: -externalip set -> setting -discover=0\n", __func__);
719 LogPrintf(
"%s: parameter interaction: -blocksonly=1 -> setting -whitelistrelay=0\n", __func__);
725 LogPrintf(
"%s: parameter interaction: -whitelistforcerelay=1 -> setting -whitelistrelay=1\n", __func__);
729 bool clearnet_reachable = std::any_of(onlynets.begin(), onlynets.end(), [](
const auto& net) {
734 LogPrintf(
"%s: parameter interaction: -onlynet excludes IPv4 and IPv6 -> setting -dnsseed=0\n", __func__);
754 int nUserMaxConnections;
757 int64_t peer_connect_timeout;
758 std::set<BlockFilterType> g_enabled_filter_types;
768 std::set_new_handler(std::terminate);
769 LogPrintf(
"Error: Out of memory. Terminating.\n");
780 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
781 _CrtSetReportFile(_CRT_WARN, CreateFileA(
"NUL", GENERIC_WRITE, 0,
nullptr, OPEN_EXISTING, 0, 0));
783 _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
787 HeapSetInformation(
nullptr, HeapEnableTerminationOnCorruption,
nullptr, 0);
810 signal(SIGPIPE, SIG_IGN);
812 SetConsoleCtrlHandler(consoleCtrlHandler,
true);
836 errors +=
strprintf(
_(
"Config setting for %s only applied on %s network when in [%s] section.") +
Untranslated(
"\n"), arg, network, network);
839 if (!errors.
empty()) {
849 if (!warnings.
empty()) {
859 if (blockfilterindex_value ==
"" || blockfilterindex_value ==
"1") {
861 }
else if (blockfilterindex_value !=
"0") {
862 const std::vector<std::string> names =
args.
GetArgs(
"-blockfilterindex");
863 for (
const auto&
name : names) {
868 g_enabled_filter_types.insert(filter_type);
875 return InitError(
_(
"Cannot set -peerblockfilters without -blockfilterindex."));
883 return InitError(
_(
"Prune mode is incompatible with -txindex."));
885 return InitError(
_(
"Prune mode is incompatible with -reindex-chainstate. Use full -reindex instead."));
891 return InitError(
_(
"Cannot set -forcednsseed to true when setting -dnsseed to false."));
906 int nBind = std::max(nUserBind,
size_t(1));
908 nMaxConnections = std::max(nUserMaxConnections, 0);
915 int fd_max = FD_SETSIZE;
921 return InitError(
_(
"Not enough file descriptors available."));
924 if (nMaxConnections < nUserMaxConnections)
925 InitWarning(
strprintf(
_(
"Reducing -maxconnections from %d to %d, because of system limitations."), nUserMaxConnections, nMaxConnections));
937 const std::string minChainWorkStr =
args.
GetArg(
"-minimumchainwork",
"");
949 return InitError(
_(
"Prune cannot be configured with a negative value."));
952 if (nPruneArg == 1) {
968 if (peer_connect_timeout <= 0) {
1001 return InitError(
_(
"-reindex-chainstate option is not compatible with -coinstatsindex. Please temporarily disable coinstatsindex while using -reindex-chainstate, or replace -reindex-chainstate with -reindex to fully rebuild all indexes."));
1004 return InitError(
_(
"-reindex-chainstate option is not compatible with -blockfilterindex. Please temporarily disable blockfilterindex while using -reindex-chainstate, or replace -reindex-chainstate with -reindex to fully rebuild all indexes."));
1007 return InitError(
_(
"-reindex-chainstate option is not compatible with -txindex. Please temporarily disable txindex while using -reindex-chainstate, or replace -reindex-chainstate with -reindex to fully rebuild all indexes."));
1011 #if defined(USE_SYSCALL_SANDBOX) 1013 const std::string sandbox_arg{
args.
GetArg(
"-sandbox",
"")};
1014 bool log_syscall_violation_before_terminating{
false};
1015 if (sandbox_arg ==
"log-and-abort") {
1016 log_syscall_violation_before_terminating =
true;
1017 }
else if (sandbox_arg ==
"abort") {
1020 return InitError(
Untranslated(
"Unknown syscall sandbox mode (-sandbox=<mode>). Available modes are \"log-and-abort\" and \"abort\"."));
1023 const std::vector<std::string> features_using_execve{
1030 for (
const std::string& feature_using_execve : features_using_execve) {
1031 if (!
args.
GetArg(feature_using_execve,
"").empty()) {
1032 return InitError(
Untranslated(
strprintf(
"The experimental syscall sandbox feature (-sandbox=<mode>) is incompatible with %s (which uses execve).", feature_using_execve)));
1035 if (!SetupSyscallSandbox(log_syscall_violation_before_terminating)) {
1038 if (use_syscall_sandbox) {
1041 LogPrintf(
"Experimental syscall sandbox enabled (-sandbox=%s): bitcoind will terminate if an unexpected (not allowlisted) syscall is invoked.\n", sandbox_arg);
1043 #endif // USE_SYSCALL_SANDBOX 1089 node.chain =
node.init->makeChain();
1099 if (!opt_max_upload) {
1113 LogPrintf(
"Using at most %i automatic connections (%i file descriptors available)\n", nMaxConnections, nFD);
1117 LogPrintf(
"Warning: relative datadir option '%s' specified, which will be interpreted relative to the " 1118 "current working directory '%s'. This is fragile, because if bitcoin is started in the future " 1119 "from a different location, it will be unable to locate the current data files. There could " 1120 "also be data loss if bitcoin is started while in a temporary directory.\n",
1133 if (script_threads <= 0) {
1140 script_threads = std::max(script_threads - 1, 0);
1145 LogPrintf(
"Script verification uses %d additional threads\n", script_threads);
1146 if (script_threads >= 1) {
1152 node.scheduler = std::make_unique<CScheduler>();
1155 node.scheduler->m_service_thread = std::thread(
util::TraceThread,
"scheduler", [&] {
node.scheduler->serviceQueue(); });
1158 node.scheduler->scheduleEvery([]{
1160 }, std::chrono::minutes{1});
1175 for (
const auto& client :
node.chain_clients) {
1176 client->registerRpcs();
1190 return InitError(
_(
"Unable to start HTTP server. See debug log for details."));
1194 for (
const auto& client :
node.chain_clients) {
1195 if (!client->verify()) {
1213 std::vector<bool> asmap;
1216 if (!asmap_path.is_absolute()) {
1224 if (asmap.size() == 0) {
1229 LogPrintf(
"Using asmap version %s for IP bucketing\n", asmap_version.
ToString());
1231 LogPrintf(
"Using /16 prefix for IP bucketing\n");
1236 node.netgroupman = std::make_unique<NetGroupManager>(std::move(asmap));
1240 uiInterface.InitMessage(
_(
"Loading P2P addresses…").translated);
1249 node.connman = std::make_unique<CConnman>(GetRand<uint64_t>(),
1250 GetRand<uint64_t>(),
1256 if (!ignores_incoming_txs)
node.fee_estimator = std::make_unique<CBlockPolicyEstimator>(
FeeestPath(
args));
1259 std::vector<std::string> uacomments;
1260 for (
const std::string& cmt :
args.
GetArgs(
"-uacomment")) {
1262 return InitError(
strprintf(
_(
"User Agent comment (%s) contains unsafe characters."), cmt));
1263 uacomments.push_back(cmt);
1267 return InitError(
strprintf(
_(
"Total length of network version string (%i) exceeds maximum length (%i). Reduce the number or size of uacomments."),
1272 std::set<enum Network> nets;
1273 for (
const std::string& snet :
args.
GetArgs(
"-onlynet")) {
1279 for (
int n = 0; n <
NET_MAX; n++) {
1282 if (!nets.count(net))
1290 _(
"Outbound connections restricted to CJDNS (-onlynet=cjdns) but " 1291 "-cjdnsreachable is not provided"));
1304 return InitError(
strprintf(
_(
"Incompatible options: -dnsseed=1 was explicitly specified, but -onlynet forbids connections to IPv4/IPv6")));
1315 std::string proxyArg =
args.
GetArg(
"-proxy",
"");
1316 if (proxyArg !=
"" && proxyArg !=
"0") {
1322 Proxy addrProxy =
Proxy(proxyAddr, proxyRandomize);
1330 onion_proxy = addrProxy;
1338 std::string onionArg =
args.
GetArg(
"-onion",
"");
1339 if (onionArg !=
"") {
1340 if (onionArg ==
"0") {
1341 onion_proxy =
Proxy{};
1342 if (onlynet_used_with_onion) {
1344 _(
"Outbound connections restricted to Tor (-onlynet=onion) but the proxy for " 1345 "reaching the Tor network is explicitly forbidden: -onion=0"));
1352 onion_proxy =
Proxy{addr, proxyRandomize};
1362 if (onlynet_used_with_onion && listenonion_disabled) {
1364 _(
"Outbound connections restricted to Tor (-onlynet=onion) but the proxy for " 1365 "reaching the Tor network is not provided: none of -proxy, -onion or " 1366 "-listenonion is given"));
1371 for (
const std::string& strAddr :
args.
GetArgs(
"-externalip")) {
1390 bool fReindexChainState =
args.
GetBoolArg(
"-reindex-chainstate",
false);
1396 LogPrintf(
"* Using %.1f MiB for block index database\n", cache_sizes.
block_tree_db * (1.0 / 1024 / 1024));
1398 LogPrintf(
"* Using %.1f MiB for transaction index database\n", cache_sizes.
tx_index * (1.0 / 1024 / 1024));
1401 LogPrintf(
"* Using %.1f MiB for %s block filter index database\n",
1404 LogPrintf(
"* Using %.1f MiB for chain state database\n", cache_sizes.
coins_db * (1.0 / 1024 / 1024));
1416 mempool_opts.check_ratio = std::clamp<int>(mempool_opts.check_ratio, 0, 1
'000'000);
1418 int64_t descendant_limit_bytes = mempool_opts.limits.descendant_size_vbytes * 40;
1419 if (mempool_opts.max_size_bytes < 0 || mempool_opts.max_size_bytes < descendant_limit_bytes) {
1420 return InitError(
strprintf(
_(
"-maxmempool must be at least %d MB"), std::ceil(descendant_limit_bytes / 1
'000'000.0)));
1422 LogPrintf(
"* Using %.1f MiB for in-memory UTXO set (plus up to %.1f MiB of unused mempool space)\n", cache_sizes.
coins * (1.0 / 1024 / 1024), mempool_opts.max_size_bytes * (1.0 / 1024 / 1024));
1425 node.mempool = std::make_unique<CTxMemPool>(mempool_opts);
1431 node.chainman = std::make_unique<ChainstateManager>(chainman_opts);
1444 _(
"Error reading from database, shutting down."),
1448 uiInterface.InitMessage(
_(
"Loading block index…").translated);
1449 const auto load_block_index_start_time{SteadyClock::now()};
1450 auto catch_exceptions = [](
auto&& f) {
1453 }
catch (
const std::exception& e) {
1458 auto [status,
error] = catch_exceptions([&]{
return LoadChainstate(chainman, cache_sizes, options); });
1460 uiInterface.InitMessage(
_(
"Verifying blocks…").translated);
1468 LogPrintf(
" block index %15dms\n", Ticks<std::chrono::milliseconds>(SteadyClock::now() - load_block_index_start_time));
1481 error.original +
".\nPlease restart with -reindex or -reindex-chainstate to recover.",
1487 LogPrintf(
"Aborted block database rebuild. Exiting.\n");
1500 LogPrintf(
"Shutdown requested. Exiting.\n");
1508 chainman, *
node.mempool, ignores_incoming_txs);
1523 for (
const auto& filter_type : g_enabled_filter_types) {
1538 for (
const auto& client :
node.chain_clients) {
1539 if (!client->load()) {
1552 uiInterface.InitMessage(
_(
"Pruning blockstore…").translated);
1553 chainstate->PruneAndFlush();
1557 LogPrintf(
"Setting NODE_NETWORK on non-prune mode\n");
1574 boost::signals2::connection block_notify_genesis_wait_connection;
1582 const std::string block_notify =
args.
GetArg(
"-blocknotify",
"");
1583 if (!block_notify.empty()) {
1586 std::string
command = block_notify;
1588 std::thread
t(runCommand,
command);
1594 std::vector<fs::path> vImportFiles;
1595 for (
const std::string& strFile :
args.
GetArgs(
"-loadblock")) {
1612 block_notify_genesis_wait_connection.disconnect();
1621 int chain_active_height;
1638 LogPrintf(
"nBestHeight = %d\n", chain_active_height);
1639 if (
node.peerman)
node.peerman->SetBestHeight(chain_active_height);
1646 connOptions.nMaxConnections = nMaxConnections;
1652 connOptions.m_banman =
node.banman.get();
1653 connOptions.m_msgproc =
node.peerman.get();
1656 connOptions.m_added_nodes =
args.
GetArgs(
"-addnode");
1657 connOptions.nMaxOutboundLimit = *opt_max_upload;
1658 connOptions.m_peer_connect_timeout = peer_connect_timeout;
1661 const uint16_t default_bind_port =
1664 const auto BadPortWarning = [](
const char*
prefix, uint16_t port) {
1665 return strprintf(
_(
"%s request to listen on port %u. This port is considered \"bad\" and " 1666 "thus it is unlikely that any Bitcoin Core peers connect to it. See " 1667 "doc/p2p-bad-ports.md for details and a full list."),
1672 for (
const std::string& bind_arg :
args.
GetArgs(
"-bind")) {
1674 const size_t index = bind_arg.rfind(
'=');
1675 if (index == std::string::npos) {
1676 if (
Lookup(bind_arg, bind_addr, default_bind_port,
false)) {
1677 connOptions.vBinds.push_back(bind_addr);
1684 const std::string network_type = bind_arg.substr(index + 1);
1685 if (network_type ==
"onion") {
1686 const std::string truncated_bind_arg = bind_arg.substr(0, index);
1687 if (
Lookup(truncated_bind_arg, bind_addr,
BaseParams().OnionServiceTargetPort(),
false)) {
1688 connOptions.onion_binds.push_back(bind_addr);
1696 for (
const std::string& strBind :
args.
GetArgs(
"-whitebind")) {
1700 connOptions.vWhiteBinds.push_back(whitebind);
1709 if (connOptions.bind_on_any &&
args.
IsArgSet(
"-port")) {
1717 if (!connOptions.onion_binds.empty()) {
1718 onion_service_target = connOptions.onion_binds.front();
1721 connOptions.onion_binds.push_back(onion_service_target);
1725 if (connOptions.onion_binds.size() > 1) {
1727 "for the automatically created Tor onion service."),
1733 if (connOptions.bind_on_any) {
1739 for (
const auto& net :
args.
GetArgs(
"-whitelist")) {
1743 connOptions.vWhitelistedRange.push_back(subnet);
1746 connOptions.vSeedNodes =
args.
GetArgs(
"-seednode");
1749 connOptions.m_use_addrman_outgoing = !
args.
IsArgSet(
"-connect");
1750 if (!connOptions.m_use_addrman_outgoing) {
1752 if (connect.size() != 1 || connect[0] !=
"0") {
1753 connOptions.m_specified_outgoing = connect;
1757 const std::string& i2psam_arg =
args.
GetArg(
"-i2psam",
"");
1758 if (!i2psam_arg.empty()) {
1767 _(
"Outbound connections restricted to i2p (-onlynet=i2p) but " 1768 "-i2psam is not provided"));
1773 connOptions.m_i2p_accept_incoming =
args.
GetBoolArg(
"-i2pacceptincoming",
true);
1775 if (!
node.connman->Start(*
node.scheduler, connOptions)) {
1794 for (
const auto& client :
node.chain_clients) {
1795 client->start(*
node.scheduler);
1799 node.scheduler->scheduleEvery([banman]{
1803 if (
node.peerman)
node.peerman->StartScheduledTasks(*
node.scheduler);
1806 StartupNotify(
args);
static const int MAX_BLOCK_RELAY_ONLY_CONNECTIONS
Maximum number of block-relay-only outgoing connections.
static void BlockNotifyGenesisWait(const CBlockIndex *pBlockIndex)
bool Start()
Start initializes the sync state and registers the instance as a ValidationInterface so that it stays...
static const int DEFAULT_SCRIPTCHECK_THREADS
-par default (number of script-checking threads, 0 = auto)
node::BlockManager m_blockman
A single BlockManager instance is shared across each constructed chainstate to avoid duplicating bloc...
static path PathFromString(const std::string &string)
Convert byte string to path object.
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...
fs::path GetPathArg(std::string arg, const fs::path &default_value={}) const
Return path argument or default value.
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.
fs::path FeeestPath(const ArgsManager &argsman)
bool ShutdownRequested()
Returns true if a shutdown is requested, false otherwise.
bool ShouldPersistMempool(const ArgsManager &argsman)
bilingual_str ResolveErrMsg(const std::string &optname, const std::string &strBind)
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 SetupChainParamsBaseOptions(ArgsManager &argsman)
Set the arguments for chainparams.
static constexpr unsigned int DEFAULT_INCREMENTAL_RELAY_FEE
Default for -incrementalrelayfee, which sets the minimum feerate increase for mempool limiting or rep...
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
bool InitBlockFilterIndex(std::function< std::unique_ptr< interfaces::Chain >()> make_chain, 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. ...
bilingual_str AmountErrMsg(const std::string &optname, const std::string &strValue)
CClientUIInterface uiInterface
CBlockIndex * m_best_header
Best header we've seen so far (used for getheaders queries' starting points).
#define LogPrint(category,...)
int64_t GetBlockTime() const
static const int DEFAULT_HTTP_SERVER_TIMEOUT
static constexpr unsigned int DEFAULT_DESCENDANT_SIZE_LIMIT_KVB
Default for -limitdescendantsize, maximum kilobytes of in-mempool descendants.
static constexpr unsigned int DEFAULT_MEMPOOL_EXPIRY_HOURS
Default for -mempoolexpiry, expiration time for mempool transactions in hours.
#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 -datacarriersize.
std::atomic_bool fReindex
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
bool IsHexNumber(std::string_view str)
Return true if the string is a hex number, optionally prefixed with "0x".
void SetRPCWarmupStatus(const std::string &newStatus)
Set the RPC warmup status.
static const unsigned int DEFAULT_RPC_SERIALIZE_VERSION
ChainstateLoadResult VerifyLoadedChainstate(ChainstateManager &chainman, const ChainstateLoadOptions &options)
bool BlockFilterTypeByName(const std::string &name, BlockFilterType &filter_type)
Find a filter type by its human-readable name.
static boost::signals2::connection rpc_notify_block_change_connection
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
static constexpr bool DEFAULT_STOPAFTERBLOCKIMPORT
static const int DEFAULT_HTTP_WORKQUEUE
static void RegisterAllCoreRPCCommands(CRPCTable &t)
std::vector< bool > DecodeAsmap(fs::path path)
Read asmap from provided binary file.
static void OnRPCStarted()
static const int64_t DEFAULT_MAX_TIP_AGE
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 ActiveChain().Tip() will not be pr...
void StartREST(const std::any &context)
Start HTTP REST subsystem.
static constexpr bool DEFAULT_RPC_DOC_CHECK
CChain & ActiveChain() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex())
void AddHiddenArgs(const std::vector< std::string > &args)
Add many hidden arguments.
static constexpr int DEFAULT_CHECKLEVEL
int Height() const
Return the maximal height in the chain.
void ForEachBlockFilterIndex(std::function< void(BlockFilterIndex &)> fn)
Iterate over all running block filter indexes, invoking fn on each.
void ThreadRename(std::string &&)
Rename a thread both in terms of an internal (in-memory) name as well as its system thread name...
const CChainParams & chainparams
void StopREST()
Stop HTTP REST subsystem.
void OnStopped(std::function< void()> slot)
static constexpr unsigned int DEFAULT_MIN_RELAY_TX_FEE
Default for -minrelaytxfee, minimum relay fee for transactions.
static const bool DEFAULT_LISTEN
-listen default
std::atomic< bool > m_reopen_file
std::optional< bilingual_str > ApplyArgsManOptions(const ArgsManager &argsman, const CChainParams &chainparams, MemPoolOptions &mempool_opts)
Overlay the options set in argsman on top of corresponding members in mempool_opts.
static const int MAX_ADDNODE_CONNECTIONS
Maximum number of addnode outgoing nodes.
An options struct for ChainstateManager, more ergonomically referred to as ChainstateManager::Options...
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.
void Discover()
Look up IP addresses from all interfaces on the machine and add them to the list of local addresses t...
const CBlock & GenesisBlock() const
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system...
void UnregisterAllValidationInterfaces()
Unregister all subscribers.
bool InitShutdownState()
Initialize shutdown state.
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
std::function< bool()> check_interrupt
void StartMapPort(bool use_upnp, bool use_natpmp)
const char *const BITCOIN_SETTINGS_FILENAME
bool DumpMempool(const CTxMemPool &pool, const fs::path &dump_path, FopenFn mockable_fopen_function, bool skip_file_commit)
bool SetProxy(enum Network net, const Proxy &addrProxy)
static const int64_t nMinDbCache
min. -dbcache (MiB)
std::optional< bilingual_str > SanityChecks(const Context &)
Ensure a usable environment with all necessary library support.
bool StartHTTPRPC(const std::any &context)
Start HTTP RPC subsystem.
static constexpr bool DEFAULT_PERMIT_BAREMULTISIG
Default for -permitbaremultisig.
void RandAddPeriodic() noexcept
Gather entropy from various expensive sources, and feed them to the PRNG state.
void InterruptHTTPRPC()
Interrupt HTTP RPC subsystem.
static constexpr unsigned int DEFAULT_BYTES_PER_SIGOP
Default for -bytespersigop.
static void HandleSIGHUP(int)
void InitWarning(const bilingual_str &str)
Show warning message.
void SetLoggingCategories(const ArgsManager &args)
void StartTorControl(CService onion_service_target)
void InterruptHTTPServer()
Interrupt HTTP server threads.
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.
virtual void Construct(node::NodeContext &node) const =0
Add wallets that should be opened to list of chain clients.
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.
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.
NodeClock::time_point GetAdjustedTime()
static constexpr unsigned int DEFAULT_ANCESTOR_SIZE_LIMIT_KVB
Default for -limitancestorsize, maximum kilobytes of tx + all in-mempool ancestors.
static const std::string MAIN
Chain name strings.
static const bool DEFAULT_PEERBLOCKFILTERS
std::string SysErrorString(int err)
Return system error string from errno value.
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 InitSignatureCache(size_t max_size_bytes)
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.
std::string SanitizeString(std::string_view str, int rule)
Remove unsafe chars.
static const size_t DEFAULT_MAXRECEIVEBUFFER
NodeContext struct containing references to chain state and connection state.
disallow -foo syntax that doesn't assign any value
bool IsBadPort(uint16_t port)
Determine if a port is "bad" from the perspective of attempting to connect to a node on that port...
void SetLoggingLevel(const ArgsManager &args)
bool InitHTTPServer()
Initialize HTTP server.
static std::unique_ptr< PeerManager > make(CConnman &connman, AddrMan &addrman, BanMan *banman, ChainstateManager &chainman, CTxMemPool &pool, bool ignore_incoming_txs)
bool IsArgNegated(const std::string &strArg) const
Return true if the argument was originally passed as a negated option, i.e.
const std::string & ListBlockFilterTypes()
Get a comma-separated list of known filter type names.
void SetupHelpOptions(ArgsManager &args)
Add help options to the args manager.
static CZMQNotificationInterface * Create()
static constexpr unsigned int DEFAULT_DESCENDANT_LIMIT
Default for -limitdescendantcount, max number of in-mempool descendants.
static std::string PathToString(const path &path)
Convert path object to a byte string.
uint64_t nPruneTarget
Number of bytes of block files that we're trying to stay below.
const std::string DEFAULT_TOR_CONTROL
Default control port.
Chainstate stores and provides an API to update our local knowledge of the current best chain...
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
static constexpr bool DEFAULT_PERSIST_MEMPOOL
Default for -persistmempool, indicating whether the node should attempt to automatically load the mem...
void StopHTTPServer()
Stop HTTP server.
static std::condition_variable g_genesis_wait_cv
std::optional< bilingual_str > CheckLegacyTxindex(CBlockTreeDB &block_tree_db)
void Interrupt(NodeContext &node)
Interrupt threads.
static constexpr unsigned int DEFAULT_MAX_MEMPOOL_SIZE_MB
Default for -maxmempool, maximum megabytes of mempool memory usage.
bool InitError(const bilingual_str &str)
Show error message.
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.
bool AddLocal(const CService &addr_, int nScore)
A combination of a network address (CNetAddr) and a (TCP) port.
bool SetNameProxy(const Proxy &addrProxy)
Set the name proxy to use for all connections to nodes specified by a hostname.
uint256 uint256S(const char *str)
void DestroyAllBlockFilterIndexes()
Destroy all open block filter indexes.
static constexpr unsigned int DEFAULT_ANCESTOR_LIMIT
Default for -limitancestorcount, max number of in-mempool ancestors.
void AddArg(const std::string &name, const std::string &help, unsigned int flags, const OptionsCategory &cat)
Add argument.
bool StartLogging(const ArgsManager &args)
std::optional< uint64_t > ParseByteUnits(std::string_view str, ByteUnit default_multiplier)
Parse a string with suffix unit [k|K|m|M|g|G|t|T].
static const int NUM_FDS_MESSAGE_CAPTURE
Number of file descriptors required for message capture.
int GetNumCores()
Return the number of cores available on the current system.
std::optional< CAmount > ParseMoney(const std::string &money_string)
Parse an amount denoted in full coins.
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.
static constexpr std::chrono::minutes DUMP_BANS_INTERVAL
How often to dump banned addresses/subnets to disk.
bool DirIsWritable(const fs::path &directory)
const std::string CURRENCY_UNIT
static constexpr bool DEFAULT_FIXEDSEEDS
CMainSignals & GetMainSignals()
CBlockIndex * ActiveTip() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex())
static const int64_t nDefaultDbCache
-dbcache default (MiB)
bool InitScriptExecutionCache(size_t max_size_bytes)
Initializes the script-execution cache.
#define LogPrintfCategory(category,...)
Block and header tip information.
const CMessageHeader::MessageStartChars & MessageStart() const
static const unsigned int DEFAULT_MAX_PEER_CONNECTIONS
The maximum number of peer connections to maintain.
#define WAIT_LOCK(cs, name)
static constexpr bool DEFAULT_DNSSEED
void ReplaceAll(std::string &in_out, const std::string &search, const std::string &substitute)
static const int64_t nDefaultDbBatchSize
-dbbatchsize default (bytes)
std::string ToString() const
void SetSyscallSandboxPolicy(SyscallSandboxPolicy syscall_policy)
Force the current thread (and threads created from the current thread) into a restricted-service oper...
static fs::path GetPidFile(const ArgsManager &args)
static GlobalMutex g_genesis_wait_mutex
RecursiveMutex & GetMutex() const LOCK_RETURNED(
Alias for cs_main.
void StopScriptCheckWorkerThreads()
Stop all of the script checking worker threads.
void ApplyArgsManOptions(const ArgsManager &argsman, ValidationCacheSizes &cache_sizes)
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
bool LockDirectory(const fs::path &directory, const fs::path &lockfile_name, bool probe_only)
int RaiseFileDescriptorLimit(int nMinFD)
this function tries to raise the file descriptor limit to the requested number.
void SetLoggingOptions(const ArgsManager &args)
static const char *const DEFAULT_BLOCKFILTERINDEX
static const int DEFAULT_ZMQ_SNDHWM
Chainstate &InitializeChainstate(CTxMemPool *mempool, const std::optional< uint256 > &snapshot_blockhash=std::nullopt) LIFETIMEBOUND EXCLUSIVE_LOCKS_REQUIRED(std::vector< Chainstate * GetAll)()
Instantiate a new chainstate and assign it based upon whether it is from a snapshot.
static const bool DEFAULT_PROXYRANDOMIZE
void AddLoggingArgs(ArgsManager &argsman)
#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...
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.
uint256 hashAssumeValid
Block hash whose ancestors we will assume to have valid scripts without checking them.
node::BlockMap & BlockIndex() EXCLUSIVE_LOCKS_REQUIRED(
bool CheckDiskSpace(const fs::path &dir, uint64_t additional_bytes)
void StopHTTPRPC()
Stop HTTP RPC subsystem.
std::function< void()> coins_error_cb
enum Network ParseNetwork(const std::string &net_in)
bool fPruneMode
Pruning-related variables and constants.
const char *const BITCOIN_CONF_FILENAME
static constexpr unsigned int DUST_RELAY_TX_FEE
Min feerate for defining dust.
CBlockPolicyEstimator * estimator
const CChainParams & GetParams() const
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
bool IsReachable(enum Network net)
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.
static const bool DEFAULT_CHECKPOINTS_ENABLED
const WalletInitInterface & g_wallet_init_interface
std::unique_ptr< Chain > MakeChain(node::NodeContext &node)
Return implementation of Chain interface.
static constexpr unsigned int DEFAULT_MISBEHAVING_BANTIME
static const bool DEFAULT_WHITELISTFORCERELAY
Default for -whitelistforcerelay.
const ChainTxData & TxData() const
unsigned int nBytesPerSigOp
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
auto Join(const C &container, const S &separator, UnaryOp unary_op)
Join all container items.
static constexpr bool DEFAULT_MEMPOOL_FULL_RBF
Default for -mempoolfullrbf, if the transaction replaceability signaling is ignored.
void RpcInterruptionPoint()
Throw JSONRPCError if RPC is not running.
fs::path MempoolPath(const ArgsManager &argsman)
int64_t GetIntArg(const std::string &strArg, int64_t nDefault) const
Return integer argument or default value.
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.
std::optional< bilingual_str > LoadAddrman(const NetGroupManager &netgroupman, const ArgsManager &args, std::unique_ptr< AddrMan > &addrman)
Returns an error string on failure.
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.
std::string ToStringIPPort() const
static const int DEFAULT_CONNECT_TIMEOUT
-timeout default
Context struct holding the kernel library's logically global state, and passed to external libbitcoin...
static constexpr int32_t DEFAULT_ADDRMAN_CONSISTENCY_CHECKS
Default for -checkaddrman.
static const int64_t nMaxDbCache
max. -dbcache (MiB)
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate...
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or nullptr if none.
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
bool AppInitParameterInteraction(const ArgsManager &args, bool use_syscall_sandbox)
Initialization: parameter interaction.
void AbortShutdown()
Clear shutdown flag.
bool AppInitSanityChecks(const kernel::Context &kernel)
Initialization sanity checks.
static constexpr unsigned int DEFAULT_BLOCK_MAX_WEIGHT
Default for -blockmaxweight, which controls the range of block weights the mining code will create...
void ThreadImport(ChainstateManager &chainman, std::vector< fs::path > vImportFiles, const ArgsManager &args, const fs::path &mempool_path)
static constexpr bool DEFAULT_FORCEDNSSEED
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
static constexpr unsigned int DEFAULT_BLOCK_MIN_TX_FEE
Default for -blockmintxfee, which sets the minimum feerate for a transaction in blocks created by min...
void RegisterValidationInterface(CValidationInterface *callbacks)
Register subscriber.
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.
static constexpr size_t DEFAULT_MAX_SIG_CACHE_BYTES
static auto quoted(const std::string &s)
void InterruptTorControl()
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.
static const int MAX_OUTBOUND_FULL_RELAY_CONNECTIONS
Maximum number of automatic outgoing nodes over which we'll relay everything (blocks, tx, addrs, etc)
Options struct containing options for constructing a CTxMemPool.
static bool TryParse(const std::string &str, NetWhitebindPermissions &output, bilingual_str &error)
Different type to mark Mutex at global scope.
int nHeight
height of the entry in the chain. The genesis block has height 0
static const char * BITCOIN_PID_FILENAME
The PID file facilities.
const Consensus::Params & GetConsensus() const
ChainstateLoadResult LoadChainstate(ChainstateManager &chainman, const CacheSizes &cache_sizes, const ChainstateLoadOptions &options)
This sequence can have 4 types of outcomes:
static void registerSignalHandler(int signal, void(*handler)(int))
static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES
std::vector< std::string > GetArgs(const std::string &strArg) const
Return a vector of strings of the given argument.
static bool exists(const path &p)
#define MIN_CORE_FILEDESCRIPTORS
static const unsigned int DEFAULT_MAX_ORPHAN_TRANSACTIONS
Default for -maxorphantx, maximum number of orphan transactions kept in memory.
static const bool DEFAULT_PRINTPRIORITY
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
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)
CacheSizes CalculateCacheSizes(const ArgsManager &args, size_t n_indexes)
void InitParameterInteraction(ArgsManager &args)
Parameter interaction: change current parameters depending on various rules.
static const int64_t DEFAULT_MAX_TIME_ADJUSTMENT
static const int MAX_SCRIPTCHECK_THREADS
Maximum number of dedicated script-checking threads allowed.
#define Assert(val)
Identity function.
const std::string UNIX_EPOCH_TIME
String used to describe UNIX epoch time in documentation, factored out to a constant for consistency...
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.
void TraceThread(std::string_view thread_name, std::function< void()> thread_func)
A wrapper for do-something-once thread functions.
static const std::string DEFAULT_MAX_UPLOAD_TARGET
The default for -maxuploadtarget.
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.