6#if defined(HAVE_CONFIG_H)
7#include <config/bitcoin-config.h>
89#include <boost/signals2/signal.hpp>
92#include <chronik-cpp/chronik.h>
107#include <condition_variable>
142#define MIN_CORE_FILEDESCRIPTORS 0
144#define MIN_CORE_FILEDESCRIPTORS 150
208 if (
node.avalanche) {
211 node.avalanche->stopEventLoop();
214 node.connman->Interrupt();
240 node.mempool->AddTransactionsUpdated(1);
247 for (
const auto &
client :
node.chain_clients) {
258 if (
node.avalanche) {
259 node.avalanche->stopEventLoop();
268 node.connman->Stop();
275 if (
node.scheduler) {
276 node.scheduler->stop();
278 if (
node.chainman &&
node.chainman->m_load_block.joinable()) {
279 node.chainman->m_load_block.join();
285 node.peerman.reset();
288 node.avalanche.reset();
289 node.connman.reset();
291 node.addrman.reset();
293 if (
node.mempool &&
node.mempool->GetLoadTried() &&
294 ShouldPersistMempool(*
node.args)) {
295 DumpMempool(*
node.mempool, MempoolPath(*
node.args));
346 node.chainman->DumpRecentHeadersTime(
node.chainman->m_options.datadir /
349 for (
const auto &
client :
node.chain_clients) {
360 node.chain_clients.clear();
364 node.mempool.reset();
365 node.chainman.reset();
366 node.scheduler.reset();
370 LogPrintf(
"%s: Unable to remove PID file: File does not exist\n",
373 }
catch (
const fs::filesystem_error &
e) {
434 "Print help message with debugging options and exit",
false,
458 "-automaticunparking",
459 "-replayprotectionactivationtime",
461 "-chronikallowpause",
464 "-allowselfsignedrootcertificates",
469 "-rootcertificates=<file>",
473 "-augustoactivationtime",
483#if defined(HAVE_SYSTEM)
485 "-alertnotify=<cmd>",
486 "Execute command when a relevant alert is received or we see "
487 "a really long fork (%s in cmd is replaced by message)",
491 "-assumevalid=<hex>",
493 "If this block is in the chain assume that it and its ancestors "
494 "are valid and potentially skip their script verification (0 to "
495 "verify all, default: %s, testnet: %s)",
499 argsman.AddArg(
"-blocksdir=<dir>",
500 "Specify directory to hold blocks subdirectory for *.dat "
501 "files (default: <datadir>)",
504 "Use smaller block files and lower minimum prune height for "
508#if defined(HAVE_SYSTEM)
509 argsman.AddArg(
"-blocknotify=<cmd>",
510 "Execute command when the best block changes (%s in cmd is "
511 "replaced by block hash)",
514 argsman.AddArg(
"-blockreconstructionextratxn=<n>",
515 strprintf(
"Extra transactions to keep in memory for compact "
516 "block reconstructions (default: %u)",
521 strprintf(
"Whether to reject transactions from network peers. "
522 "Automatic broadcast and rebroadcast of any transactions "
523 "from inbound peers is disabled, unless the peer has the "
524 "'forcerelay' permission. RPC transactions are"
525 " not affected. (default: %u)",
528 argsman.AddArg(
"-coinstatsindex",
529 strprintf(
"Maintain coinstats index used by the "
530 "gettxoutsetinfo RPC (default: %u)",
535 strprintf(
"Specify path to read-only configuration file. Relative "
536 "paths will be prefixed by datadir location. (default: %s)",
539 argsman.AddArg(
"-datadir=<dir>",
"Specify data directory",
543 strprintf(
"Maximum database write batch size in bytes (default: %u)",
549 strprintf(
"Set database cache size in MiB (%d to %d, default: %d)",
553 "-includeconf=<file>",
554 "Specify additional configuration file, relative to the -datadir path "
555 "(only useable from configuration file, not command line)",
557 argsman.AddArg(
"-loadblock=<file>",
558 "Imports blocks from external file on startup",
560 argsman.AddArg(
"-maxmempool=<n>",
561 strprintf(
"Keep the transaction memory pool below <n> "
562 "megabytes (default: %u)",
565 argsman.AddArg(
"-maxorphantx=<n>",
566 strprintf(
"Keep at most <n> unconnectable transactions in "
567 "memory (default: %u)",
570 argsman.AddArg(
"-mempoolexpiry=<n>",
571 strprintf(
"Do not keep transactions in the mempool longer "
572 "than <n> hours (default: %u)",
576 "-minimumchainwork=<hex>",
578 "Minimum work assumed to exist on a valid chain in hex "
579 "(default: %s, testnet: %s)",
586 strprintf(
"Set the number of script verification threads (%u to %d, 0 "
587 "= auto, <0 = leave that many cores free, default: %d)",
591 argsman.AddArg(
"-persistmempool",
592 strprintf(
"Whether to save the mempool on shutdown and load "
593 "on restart (default: %u)",
594 DEFAULT_PERSIST_MEMPOOL),
597 "-persistrecentheaderstime",
599 "Whether the node stores the recent headers reception time to a "
600 "file and load it upon startup. This is intended for mining nodes "
601 "to overestimate the real time target upon restart (default: %u)",
606 strprintf(
"Specify pid file. Relative paths will be prefixed "
607 "by a net-specific datadir location. (default: %s)",
612 strprintf(
"Reduce storage requirements by enabling pruning (deleting) "
613 "of old blocks. This allows the pruneblockchain RPC to be "
614 "called to delete specific blocks, and enables automatic "
615 "pruning of old blocks if a target size in MiB is provided. "
616 "This mode is incompatible with -txindex, -coinstatsindex "
617 "and -rescan. Warning: Reverting this setting requires "
618 "re-downloading the entire blockchain. (default: 0 = disable "
619 "pruning blocks, 1 = allow manual pruning via RPC, >=%u = "
620 "automatically prune block files to stay under the specified "
621 "target size in MiB)",
625 "-reindex-chainstate",
626 "Rebuild chain state from the currently indexed blocks. When "
627 "in pruning mode or if blocks on disk might be corrupted, use "
628 "full -reindex instead.",
632 "Rebuild chain state and block index from the blk*.dat files on disk",
637 "Specify path to dynamic settings data file. Can be disabled with "
638 "-nosettings. File is written at runtime and not meant to be "
639 "edited by users (use %s instead for custom settings). Relative "
640 "paths will be prefixed by datadir location. (default: %s)",
644 argsman.AddArg(
"-startupnotify=<cmd>",
"Execute command on startup.",
650 "Create new files with system default permissions, instead of umask "
651 "077 (only effective with disabled wallet functionality)",
657 strprintf(
"Maintain a full transaction index, used by the "
658 "getrawtransaction rpc call (default: %d)",
664 strprintf(
"Enable the Chronik indexer, which can be read via a "
665 "dedicated HTTP/Protobuf interface (default: %d)",
669 "-chronikbind=<addr>[:port]",
671 "Bind the Chronik indexer to the given address to listen for "
672 "HTTP/Protobuf connections to access the index. Unlike the "
673 "JSON-RPC, it's ok to have this publicly exposed on the internet. "
674 "This option can be specified multiple times (default: %s; default "
675 "port: %u, testnet: %u, regtest: %u)",
676 Join(chronik::DEFAULT_BINDS,
", "),
681 argsman.AddArg(
"-chroniktokenindex",
682 "Enable token indexing in Chronik (default: 1)",
684 argsman.AddArg(
"-chroniklokadidindex",
685 "Enable LOKAD ID indexing in Chronik (default: 1)",
687 argsman.AddArg(
"-chronikreindex",
688 "Reindex the Chronik indexer from genesis, but leave the "
689 "other indexes untouched",
692 "-chroniktxnumcachebuckets",
694 "Tuning param of the TxNumCache, specifies how many buckets "
695 "to use on the belt. Caution against setting this too high, "
696 "it may slow down indexing. Set to 0 to disable. (default: %d)",
697 chronik::DEFAULT_TX_NUM_CACHE_BUCKETS),
700 "-chroniktxnumcachebucketsize",
702 "Tuning param of the TxNumCache, specifies the size of each bucket "
703 "on the belt. Unlike the number of buckets, this may be increased "
704 "without much danger of slowing the indexer down. The total cache "
705 "size will be `num_buckets * bucket_size * 40B`, so by default the "
706 "cache will require %dkB of memory. (default: %d)",
707 chronik::DEFAULT_TX_NUM_CACHE_BUCKETS *
708 chronik::DEFAULT_TX_NUM_CACHE_BUCKET_SIZE * 40 / 1000,
709 chronik::DEFAULT_TX_NUM_CACHE_BUCKET_SIZE),
711 argsman.AddArg(
"-chronikperfstats",
712 "Output some performance statistics (e.g. num cache hits, "
713 "seconds spent) into a <datadir>/perf folder. (default: 0)",
716 "-chronikscripthashindex",
717 "Enable the scripthash index for the Chronik indexer (default: 0) ",
721 "-blockfilterindex=<type>",
722 strprintf(
"Maintain an index of compact filters by block "
723 "(default: %s, values: %s).",
725 " If <type> is not supplied or if <type> = 1, indexes for "
726 "all known types are enabled.",
730 "Use Cash Address for destination encoding instead of base58 "
731 "(activate by default on Jan, 14)",
736 "Add a node to connect to and attempt to keep the connection "
737 "open (see the `addnode` RPC command help for more info)",
740 argsman.AddArg(
"-asmap=<file>",
741 strprintf(
"Specify asn mapping used for bucketing of the "
742 "peers (default: %s). Relative paths will be "
743 "prefixed by the net-specific datadir location.",
747 strprintf(
"Default duration (in seconds) of manually "
748 "configured bans (default: %u)",
752 "-bind=<addr>[:<port>][=onion]",
753 strprintf(
"Bind to given address and always listen on it (default: "
754 "0.0.0.0). Use [host]:port notation for IPv6. Append =onion "
755 "to tag any incoming connections to that address and port as "
756 "incoming Tor connections (default: 127.0.0.1:%u=onion, "
757 "testnet: 127.0.0.1:%u=onion, regtest: 127.0.0.1:%u=onion)",
765 "Connect only to the specified node(s); -connect=0 disables automatic "
766 "connections (the rules for this peer are the same as for -addnode)",
771 "Discover own IP addresses (default: 1 when listening and no "
772 "-externalip or -proxy)",
775 strprintf(
"Allow DNS lookups for -addnode, -seednode and "
776 "-connect (default: %d)",
782 "Query for peer addresses via DNS lookup, if low on addresses "
783 "(default: %u unless -connect used)",
786 argsman.AddArg(
"-externalip=<ip>",
"Specify your own public address",
791 "Allow fixed seeds if DNS seeds don't provide peers (default: %u)",
797 "Always query for peer addresses via DNS lookup (default: %d)",
800 argsman.AddArg(
"-overridednsseed",
801 "If set, only use the specified DNS seed when "
802 "querying for peer addresses via DNS lookup.",
806 "Accept connections from outside (default: 1 if no -proxy or -connect)",
810 strprintf(
"Automatically create Tor onion service (default: %d)",
814 "-maxconnections=<n>",
815 strprintf(
"Maintain at most <n> connections to peers. The effective "
816 "limit depends on system limitations and might be lower than "
817 "the specified value (default: %u)",
820 argsman.AddArg(
"-maxreceivebuffer=<n>",
821 strprintf(
"Maximum per-connection receive buffer, <n>*1000 "
822 "bytes (default: %u)",
826 "-maxsendbuffer=<n>",
828 "Maximum per-connection send buffer, <n>*1000 bytes (default: %u)",
832 "-maxtimeadjustment",
833 strprintf(
"Maximum allowed median peer time offset adjustment. Local "
834 "perspective of time may be influenced by peers forward or "
835 "backward by this amount. (default: %u seconds)",
838 argsman.AddArg(
"-onion=<ip:port>",
839 strprintf(
"Use separate SOCKS5 proxy to reach peers via Tor "
840 "onion services (default: %s)",
843 argsman.AddArg(
"-i2psam=<ip:port>",
844 "I2P SAM proxy to reach I2P peers and accept I2P "
845 "connections (default: none)",
848 "-i2pacceptincoming",
849 "If set and -i2psam is also set then incoming I2P connections are "
850 "accepted via the SAM proxy. If this is not set but -i2psam is set "
851 "then only outgoing connections will be made to the I2P network. "
852 "Ignored if -i2psam is not set. Listening for incoming I2P connections "
853 "is done through the SAM proxy, not by binding to a local address and "
859 "Make outgoing connections only through network <net> (" +
861 "). Incoming connections are not affected by this option. This "
862 "option can be specified multiple times to allow multiple "
863 "networks. Warning: if it is used with non-onion networks "
864 "and the -onion or -proxy option is set, then outbound onion "
865 "connections will still be made; use -noonion or -onion=0 to "
866 "disable outbound onion connections in this case",
868 argsman.AddArg(
"-peerbloomfilters",
869 strprintf(
"Support filtering of blocks and transaction with "
870 "bloom filters (default: %d)",
876 "Serve compact block filters to peers per BIP 157 (default: %u)",
879 argsman.AddArg(
"-permitbaremultisig",
880 strprintf(
"Relay non-P2SH multisig (default: %d)",
887 strprintf(
"Listen for connections on <port>. Nodes not "
888 "using the default ports (default: %u, "
889 "testnet: %u, regtest: %u) are unlikely to get "
890 "incoming connections. Not relevant for I2P (see "
897 argsman.AddArg(
"-proxy=<ip:port>",
"Connect through SOCKS5 proxy",
901 strprintf(
"Randomize credentials for every proxy connection. "
902 "This enables Tor stream isolation (default: %d)",
907 "Connect to a node to retrieve peer addresses, and disconnect",
911 "Enable all P2P network activity (default: 1). Can be changed "
912 "by the setnetworkactive RPC command",
915 strprintf(
"Specify connection timeout in milliseconds "
916 "(minimum: 1, default: %d)",
921 strprintf(
"Specify p2p connection timeout in seconds. This option "
922 "determines the amount of time a peer may be inactive before "
923 "the connection to it is dropped. (minimum: 1, default: %d)",
927 "-torcontrol=<ip>:<port>",
929 "Tor control port to use if onion listening enabled (default: %s)",
932 argsman.AddArg(
"-torpassword=<pass>",
933 "Tor control port password (default: empty)",
939 "Use UPnP to map the listening port (default: 1 when "
940 "listening and no -proxy)",
945 strprintf(
"Use UPnP to map the listening port (default: %u)", 0),
954 strprintf(
"Use NAT-PMP to map the listening port (default: %s)",
961 "-whitebind=<[permissions@]addr>",
962 "Bind to the given address and add permission flags to the peers "
964 "Use [host]:port notation for IPv6. Allowed permissions: " +
967 "Specify multiple permissions separated by commas (default: "
968 "download,noban,mempool,relay). Can be specified multiple times.",
971 argsman.AddArg(
"-whitelist=<[permissions@]IP address or network>",
972 "Add permission flags to the peers connecting from the "
973 "given IP address (e.g. 1.2.3.4) or CIDR-notated network "
974 "(e.g. 1.2.3.0/24). "
975 "Uses the same permissions as -whitebind. Can be specified "
979 "-maxuploadtarget=<n>",
980 strprintf(
"Tries to keep outbound traffic under the given target (in "
981 "MiB per 24h). Limit does not apply to peers with 'download' "
982 "permission. 0 = no limit (default: %d)",
989 argsman.AddArg(
"-zmqpubhashblock=<address>",
990 "Enable publish hash block in <address>",
992 argsman.AddArg(
"-zmqpubhashtx=<address>",
993 "Enable publish hash transaction in <address>",
995 argsman.AddArg(
"-zmqpubrawblock=<address>",
996 "Enable publish raw block in <address>",
998 argsman.AddArg(
"-zmqpubrawtx=<address>",
999 "Enable publish raw transaction in <address>",
1001 argsman.AddArg(
"-zmqpubsequence=<address>",
1002 "Enable publish hash block and tx sequence in <address>",
1005 "-zmqpubhashblockhwm=<n>",
1006 strprintf(
"Set publish hash block outbound message high water "
1007 "mark (default: %d)",
1011 "-zmqpubhashtxhwm=<n>",
1012 strprintf(
"Set publish hash transaction outbound message high "
1013 "water mark (default: %d)",
1017 "-zmqpubrawblockhwm=<n>",
1018 strprintf(
"Set publish raw block outbound message high water "
1019 "mark (default: %d)",
1023 "-zmqpubrawtxhwm=<n>",
1024 strprintf(
"Set publish raw transaction outbound message high "
1025 "water mark (default: %d)",
1028 argsman.AddArg(
"-zmqpubsequencehwm=<n>",
1029 strprintf(
"Set publish hash sequence message high water mark"
1034 hidden_args.emplace_back(
"-zmqpubhashblock=<address>");
1035 hidden_args.emplace_back(
"-zmqpubhashtx=<address>");
1036 hidden_args.emplace_back(
"-zmqpubrawblock=<address>");
1037 hidden_args.emplace_back(
"-zmqpubrawtx=<address>");
1039 hidden_args.emplace_back(
"-zmqpubhashblockhwm=<n>");
1041 hidden_args.emplace_back(
"-zmqpubrawblockhwm=<n>");
1043 hidden_args.emplace_back(
"-zmqpubsequencehwm=<n>");
1048 strprintf(
"How many blocks to check at startup (default: %u, 0 = all)",
1052 argsman.AddArg(
"-checklevel=<n>",
1053 strprintf(
"How thorough the block verification of "
1054 "-checkblocks is: %s (0-4, default: %u)",
1058 argsman.AddArg(
"-checkblockindex",
1059 strprintf(
"Do a consistency check for the block tree, "
1060 "chainstate, and other validation data structures "
1061 "occasionally. (default: %u, regtest: %u)",
1066 argsman.AddArg(
"-checkaddrman=<n>",
1067 strprintf(
"Run addrman consistency checks every <n> "
1068 "operations. Use 0 to disable. (default: %u)",
1073 "-checkmempool=<n>",
1074 strprintf(
"Run mempool consistency checks every <n> transactions. Use "
1075 "0 to disable. (default: %u, regtest: %u)",
1080 argsman.AddArg(
"-checkpoints",
1081 strprintf(
"Only accept block chain matching built-in "
1082 "checkpoints (default: %d)",
1086 argsman.AddArg(
"-deprecatedrpc=<method>",
1087 "Allows deprecated RPC method(s) to be used",
1091 "-stopafterblockimport",
1092 strprintf(
"Stop running after importing blocks from disk (default: %d)",
1093 DEFAULT_STOPAFTERBLOCKIMPORT),
1096 argsman.AddArg(
"-stopatheight",
1097 strprintf(
"Stop running after reaching the given height in "
1098 "the main chain (default: %u)",
1102 argsman.AddArg(
"-addrmantest",
"Allows to test address relay on localhost",
1105 argsman.AddArg(
"-capturemessages",
"Capture all P2P messages to disk",
1108 argsman.AddArg(
"-mocktime=<n>",
1114 "-maxsigcachesize=<n>",
1115 strprintf(
"Limit size of signature cache to <n> MiB (default: %u)",
1120 "-maxscriptcachesize=<n>",
1121 strprintf(
"Limit size of script cache to <n> MiB (default: %u)",
1125 argsman.AddArg(
"-maxtipage=<n>",
1126 strprintf(
"Maximum tip age in seconds to consider node in "
1127 "initial block download (default: %u)",
1132 argsman.AddArg(
"-uacomment=<cmt>",
1133 "Append comment to the user agent string",
1135 argsman.AddArg(
"-uaclientname=<clientname>",
"Set user agent client name",
1137 argsman.AddArg(
"-uaclientversion=<clientversion>",
1146 "Relay and mine \"non-standard\" transactions (%sdefault: %u)",
1150 argsman.AddArg(
"-excessiveblocksize=<n>",
1151 strprintf(
"Do not accept blocks larger than this limit, in "
1152 "bytes (default: %d)",
1158 "-dustrelayfee=<amt>",
1159 strprintf(
"Fee rate (in %s/kB) used to define dust, the value of an "
1160 "output such that it will cost about 1/3 of its value in "
1161 "fees at this fee rate to spend it. (default: %s)",
1167 "-bytespersigcheck",
1168 strprintf(
"Equivalent bytes per sigCheck in transactions for relay and "
1169 "mining (default: %u).",
1174 strprintf(
"DEPRECATED: Equivalent bytes per sigCheck in transactions "
1175 "for relay and mining (default: %u). This has been "
1176 "deprecated since v0.26.8 and will be removed in the future, "
1177 "please use -bytespersigcheck instead.",
1182 strprintf(
"Relay and mine data carrier transactions (default: %d)",
1187 strprintf(
"Maximum size of data in data carrier transactions "
1188 "we relay and mine (default: %u)",
1192 "-minrelaytxfee=<amt>",
1193 strprintf(
"Fees (in %s/kB) smaller than this are rejected for "
1194 "relaying, mining and transaction creation (default: %s)",
1199 strprintf(
"Add 'relay' permission to whitelisted inbound peers "
1200 "with default permissions. This will accept relayed "
1201 "transactions even when not relaying transactions "
1206 "-whitelistforcerelay",
1207 strprintf(
"Add 'forcerelay' permission to whitelisted inbound peers"
1208 " with default permissions. This will relay transactions "
1209 "even if the transactions were already in the mempool "
1214 argsman.AddArg(
"-blockmaxsize=<n>",
1215 strprintf(
"Set maximum block size in bytes (default: %d)",
1219 "-blockmintxfee=<amt>",
1220 strprintf(
"Set lowest fee rate (in %s/kB) for transactions to "
1221 "be included in block creation. (default: %s)",
1225 argsman.AddArg(
"-blockversion=<n>",
1226 "Override block version to test forking scenarios",
1230 argsman.AddArg(
"-server",
"Accept command line and JSON-RPC commands",
1233 strprintf(
"Accept public REST requests (default: %d)",
1237 "-rpcbind=<addr>[:port]",
1238 "Bind to given address to listen for JSON-RPC connections. Do not "
1239 "expose the RPC server to untrusted networks such as the public "
1240 "internet! This option is ignored unless -rpcallowip is also passed. "
1241 "Port is optional and overrides -rpcport. Use [host]:port notation "
1242 "for IPv6. This option can be specified multiple times (default: "
1243 "127.0.0.1 and ::1 i.e., localhost)",
1249 strprintf(
"Throw a non-fatal error at runtime if the documentation for "
1250 "an RPC is incorrect (default: %u)",
1254 "-rpccookiefile=<loc>",
1255 "Location of the auth cookie. Relative paths will be prefixed "
1256 "by a net-specific datadir location. (default: data dir)",
1258 argsman.AddArg(
"-rpcuser=<user>",
"Username for JSON-RPC connections",
1261 argsman.AddArg(
"-rpcpassword=<pw>",
"Password for JSON-RPC connections",
1265 "-rpcwhitelist=<whitelist>",
1266 "Set a whitelist to filter incoming RPC calls for a specific user. The "
1267 "field <whitelist> comes in the format: <USERNAME>:<rpc 1>,<rpc "
1268 "2>,...,<rpc n>. If multiple whitelists are set for a given user, they "
1269 "are set-intersected. See -rpcwhitelistdefault documentation for "
1270 "information on default whitelist behavior.",
1273 "-rpcwhitelistdefault",
1274 "Sets default behavior for rpc whitelisting. Unless "
1275 "rpcwhitelistdefault is set to 0, if any -rpcwhitelist is set, the rpc "
1276 "server acts as if all rpc users are subject to "
1277 "empty-unless-otherwise-specified whitelists. If rpcwhitelistdefault "
1278 "is set to 1 and no -rpcwhitelist is set, rpc server acts as if all "
1279 "rpc users are subject to empty whitelists.",
1282 "-rpcauth=<userpw>",
1283 "Username and HMAC-SHA-256 hashed password for JSON-RPC connections. "
1284 "The field <userpw> comes in the format: <USERNAME>:<SALT>$<HASH>. A "
1285 "canonical python script is included in share/rpcauth. The client then "
1286 "connects normally using the rpcuser=<USERNAME>/rpcpassword=<PASSWORD> "
1287 "pair of arguments. This option can be specified multiple times",
1289 argsman.AddArg(
"-rpcport=<port>",
1290 strprintf(
"Listen for JSON-RPC connections on <port> "
1291 "(default: %u, testnet: %u, regtest: %u)",
1299 "Allow JSON-RPC connections from specified source. Valid for "
1300 "<ip> are a single IP (e.g. 1.2.3.4), a network/netmask (e.g. "
1301 "1.2.3.4/255.255.255.0) or a network/CIDR (e.g. 1.2.3.4/24). "
1302 "This option can be specified multiple times",
1307 "Set the number of threads to service RPC calls (default: %d)",
1311 "-rpccorsdomain=value",
1312 "Domain from which to accept cross origin requests (browser enforced)",
1315 argsman.AddArg(
"-rpcworkqueue=<n>",
1316 strprintf(
"Set the depth of the work queue to service RPC "
1317 "calls (default: %d)",
1321 argsman.AddArg(
"-rpcservertimeout=<n>",
1322 strprintf(
"Timeout during HTTP requests (default: %d)",
1329 strprintf(
"Run in the background as a daemon and accept "
1330 "commands (default: %d)",
1334 strprintf(
"Wait for initialization to be finished before "
1335 "exiting. This implies -daemon (default: %d)",
1345 strprintf(
"Enable the avalanche feature (default: %u)",
1349 "-avalanchestakingrewards",
1350 strprintf(
"Enable the avalanche staking rewards feature (default: %u, "
1351 "testnet: %u, regtest: %u)",
1356 argsman.AddArg(
"-avalancheconflictingproofcooldown",
1357 strprintf(
"Mandatory cooldown before a proof conflicting "
1358 "with an already registered one can be considered "
1359 "in seconds (default: %u)",
1362 argsman.AddArg(
"-avalanchepeerreplacementcooldown",
1363 strprintf(
"Mandatory cooldown before a peer can be replaced "
1364 "in seconds (default: %u)",
1368 "-avaminquorumstake",
1370 "Minimum amount of known stake for a usable quorum (default: %s)",
1374 "-avaminquorumconnectedstakeratio",
1375 strprintf(
"Minimum proportion of known stake we"
1376 " need nodes for to have a usable quorum (default: %s)",
1380 "-avaminavaproofsnodecount",
1381 strprintf(
"Minimum number of node that needs to send us an avaproofs"
1382 " message before we consider we have a usable quorum"
1387 "-avastalevotethreshold",
1388 strprintf(
"Number of avalanche votes before a voted item goes stale "
1389 "when voting confidence is low (default: %u)",
1393 "-avastalevotefactor",
1395 "Factor affecting the number of avalanche votes before a voted "
1396 "item goes stale when voting confidence is high (default: %u)",
1399 argsman.AddArg(
"-avacooldown",
1400 strprintf(
"Mandatory cooldown between two avapoll in "
1401 "milliseconds (default: %u)",
1406 strprintf(
"Avalanche query timeout in milliseconds (default: %u)",
1411 "Avalanche proof delegation to the master key used by this node "
1412 "(default: none). Should be used in conjunction with -avaproof and "
1416 "Avalanche proof to be used by this node (default: none)",
1419 "-avaproofstakeutxoconfirmations",
1421 "Minimum number of confirmations before a stake utxo is mature"
1422 " enough to be included into a proof. Utxos in the mempool are not "
1423 "accepted (i.e this value must be greater than 0) (default: %s)",
1426 argsman.AddArg(
"-avaproofstakeutxodustthreshold",
1427 strprintf(
"Minimum value each stake utxo must have to be "
1428 "considered valid (default: %s)",
1431 argsman.AddArg(
"-avamasterkey",
1432 "Master key associated with the proof. If a proof is "
1433 "required, this is mandatory.",
1436 argsman.AddArg(
"-avasessionkey",
"Avalanche session key (default: random)",
1440 strprintf(
"Whether to enforce Real Time Targeting via "
1441 "Avalanche, default (%u)",
1445 "-maxavalancheoutbound",
1447 "Set the maximum number of avalanche outbound peers to connect to. "
1448 "Note that this option takes precedence over the -maxconnections "
1449 "option (default: %u).",
1454 strprintf(
"Whether to save the avalanche peers upon shutdown and load "
1455 "them upon startup (default: %u).",
1459 hidden_args.emplace_back(
"-avalanchepreconsensus");
1460 hidden_args.emplace_back(
"-avalanchestakingpreconsensus");
1482 std::string
cmd = args.
GetArg(
"-startupnotify",
"");
1522 "%s: parameter interaction: -bind set -> setting -listen=1\n",
1528 LogPrintf(
"%s: parameter interaction: -whitebind set -> setting "
1538 LogPrintf(
"%s: parameter interaction: -connect set -> setting "
1543 LogPrintf(
"%s: parameter interaction: -connect set -> setting "
1554 "%s: parameter interaction: -proxy set -> setting -listen=0\n",
1562 "%s: parameter interaction: -proxy set -> setting -upnp=0\n",
1567 "%s: parameter interaction: -proxy set -> setting -natpmp=0\n",
1572 LogPrintf(
"%s: parameter interaction: -proxy set -> setting "
1583 "%s: parameter interaction: -listen=0 -> setting -upnp=0\n",
1588 "%s: parameter interaction: -listen=0 -> setting -natpmp=0\n",
1593 "%s: parameter interaction: -listen=0 -> setting -discover=0\n",
1597 LogPrintf(
"%s: parameter interaction: -listen=0 -> setting "
1602 LogPrintf(
"%s: parameter interaction: -listen=0 -> setting "
1603 "-i2pacceptincoming=0\n",
1608 if (args.
IsArgSet(
"-externalip")) {
1611 LogPrintf(
"%s: parameter interaction: -externalip set -> setting "
1620 LogPrintf(
"%s: parameter interaction: -blocksonly=1 -> setting "
1621 "-whitelistrelay=0\n",
1630 LogPrintf(
"%s: parameter interaction: -whitelistforcerelay=1 -> "
1631 "setting -whitelistrelay=1\n",
1670 std::set_new_handler(std::terminate);
1671 LogPrintf(
"Error: Out of memory. Terminating.\n");
1693 Untranslated(
"Initializing wait-for-shutdown state failed."));
1737 "network when in [%s] section.") +
1739 arg, network, network);
1750 _(
"Section [%s] is not recognized.") +
1761 strprintf(
_(
"Specified blocks directory \"%s\" does not exist."),
1762 args.
GetArg(
"-blocksdir",
"")));
1771 const std::vector<std::string>
names =
1772 args.
GetArgs(
"-blockfilterindex");
1788 _(
"Cannot set -peerblockfilters without -blockfilterindex."));
1797 return InitError(
_(
"Prune mode is incompatible with -txindex."));
1801 _(
"Prune mode is incompatible with -coinstatsindex."));
1804 return InitError(
_(
"Prune mode is incompatible with -chronik."));
1810 args.
GetArgs(
"-bind").size() + args.
GetArgs(
"-whitebind").size();
1813 "Cannot set -bind or -whitebind together with -listen=0"));
1830 LogPrintf(
"Increasing -maxconnections from %d to %d to comply with "
1831 "-maxavalancheoutbound\n",
1846 nMaxConnections = std::max(
1847 std::min<int>(nMaxConnections,
1852 return InitError(
_(
"Not enough file descriptors available."));
1862 LogPrintf(
"Reducing -maxconnections from %d to %d, because of system "
1876 _(
"Excessive block size must be > 1,000,000 bytes (1MB)"));
1883 return InitError(
_(
"Max generated block size must be greater than 0"));
1886 return InitError(
_(
"Max generated block size (blockmaxsize) cannot "
1887 "exceed the excessive block size "
1888 "(excessiveblocksize)"));
1900 "peertimeout cannot be configured with a negative value."));
1906 if (args.
IsArgSet(
"-blockmintxfee")) {
1910 args.
GetArg(
"-blockmintxfee",
"")));
1930 if (args.
IsArgSet(
"-proxy") && args.
GetArg(
"-proxy",
"").empty()) {
1932 "No proxy server specified. Use -proxy=<ip> or -proxy=<ip:port>."));
1937 args.
GetIntArg(
"-avaproofstakeutxoconfirmations",
1943 return InitError(
_(
"Avalanche stake UTXO minimum confirmations can "
1944 "only be set on test chains."));
1948 return InitError(
_(
"Avalanche stake UTXO minimum confirmations must be "
1949 "a positive integer."));
1952 if (args.
IsArgSet(
"-avaproofstakeutxodustthreshold")) {
1955 args.
GetArg(
"-avaproofstakeutxodustthreshold",
""), amount);
1958 "avaproofstakeutxodustthreshold",
1959 args.
GetArg(
"-avaproofstakeutxodustthreshold",
"")));
1964 return InitError(
_(
"Avalanche stake UTXO dust threshold can "
1965 "only be set on test chains."));
1972 return InitError(
_(
"Running a staking node requires accepting "
1973 "inbound connections. Please enable -listen."));
1976 return InitError(
_(
"Running a staking node behind a proxy is not "
1977 "supported. Please disable -proxy."));
1980 return InitError(
_(
"Running a staking node behind I2P is not "
1981 "supported. Please disable -i2psam."));
1985 _(
"Restricting the outbound network is not supported when "
1986 "running a staking node. Please disable -onlynet."));
1996 .notifications = notifications,
2018 _(
"Cannot write to data directory '%s'; check permissions."),
2023 "%s. %s is probably already running."),
2037 _(
"Initialization sanity check failed. %s is shutting down."),
2086 LogPrintf(
"Using at most %i automatic connections (%i file descriptors "
2088 nMaxConnections,
nFD);
2092 !args.
GetPathArg(
"-datadir").is_absolute()) {
2093 LogPrintf(
"Warning: relative datadir option '%s' specified, which will "
2094 "be interpreted relative to the current working directory "
2095 "'%s'. This is fragile, because if bitcoin is started in the "
2096 "future from a different location, it will be unable to "
2097 "locate the current data files. There could also be data "
2098 "loss if bitcoin is started while in a temporary "
2100 args.
GetArg(
"-datadir",
""),
2109 _(
"Unable to allocate memory for -maxsigcachesize: '%s' MiB"),
2116 _(
"Unable to allocate memory for -maxscriptcachesize: '%s' MiB"),
2135 LogPrintf(
"Script verification uses %d additional threads\n",
2142 node.scheduler = std::make_unique<CScheduler>();
2145 node.scheduler->m_service_thread =
2147 [&] {
node.scheduler->serviceQueue(); });
2150 node.scheduler->scheduleEvery(
2155 std::chrono::minutes{1});
2164 for (
const auto &
client :
node.chain_clients) {
2181 _(
"Unable to start HTTP server. See debug log for details."));
2186 for (
const auto &
client :
node.chain_clients) {
2207 std::vector<bool>
asmap;
2220 if (
asmap.size() == 0) {
2226 LogPrintf(
"Using asmap version %s for IP bucketing\n",
2229 LogPrintf(
"Using /16 prefix for IP bucketing\n");
2232 uiInterface.InitMessage(
_(
"Loading P2P addresses...").translated);
2237 node.addrman = std::move(*addrman);
2241 node.banman = std::make_unique<BanMan>(
2245 node.connman = std::make_unique<CConnman>(
2251 for (
const std::string &
cmt : args.
GetArgs(
"-uacomment")) {
2254 _(
"User Agent comment (%s) contains unsafe characters."),
cmt));
2263 _(
"-uaclientname (%s) contains invalid characters."),
client_name));
2268 strprintf(
_(
"-uaclientversion (%s) contains invalid characters."),
2275 _(
"Total length of network version string (%i) exceeds maximum "
2276 "length (%i). Reduce the number or size of uacomments."),
2281 std::set<enum Network>
nets;
2282 for (
const std::string &
snet : args.
GetArgs(
"-onlynet")) {
2286 _(
"Unknown network specified in -onlynet: '%s'"),
snet));
2290 for (
int n = 0; n <
NET_MAX; n++) {
2313 _(
"Invalid -proxy address or hostname: '%s'"),
proxyArg));
2319 _(
"Invalid -proxy address or hostname: '%s'"),
proxyArg));
2344 _(
"Invalid -onion address or hostname: '%s'"),
onionArg));
2349 _(
"Invalid -onion address or hostname: '%s'"),
onionArg));
2370 return chainman->m_blockman.ReadBlockFromDisk(block, index);
2380 node.notifications = std::make_unique<KernelNotifications>();
2381 fReindex = args.
GetBoolArg(
"-reindex",
false);
2388 .notifications = *
node.notifications,
2394 LogPrintf(
"Checkpoints will be verified.\n");
2396 LogPrintf(
"Skipping checkpoint verification.\n");
2411 LogPrintf(
"* Using %.1f MiB for block index database\n",
2414 LogPrintf(
"* Using %.1f MiB for transaction index database\n",
2418 LogPrintf(
"* Using %.1f MiB for %s block filter index database\n",
2422 LogPrintf(
"* Using %.1f MiB for chain state database\n",
2435 std::clamp<int>(
mempool_opts.check_ratio, 0, 1'000'000);
2448 LogPrintf(
"* Using %.1f MiB for in-memory UTXO set (plus up to %.1f MiB of "
2449 "unused mempool space)\n",
2473 _(
"Error reading from database, shutting down."),
"",
2477 uiInterface.InitMessage(
_(
"Loading block index...").translated);
2483 }
catch (
const std::exception &
e) {
2486 _(
"Error opening block database"));
2490 [&] {
return LoadChainstate(chainman,
cache_sizes, options); });
2495 LogPrintf(
"Prune: pruned datadir may not have more than %d "
2496 "blocks; only checking available blocks\n",
2500 [&] {
return VerifyLoadedChainstate(chainman, options); });
2503 node.chainman->m_options.datadir /
2523 _(
"Do you want to rebuild the block database now?"),
2525 "-reindex-chainstate to recover.",
2533 LogPrintf(
"Aborted block database rebuild. Exiting.\n");
2547 LogPrintf(
"Shutdown requested. Exiting.\n");
2557 args, *
node.chain,
node.connman.get(), chainman,
node.mempool.get(),
2559 if (!
node.avalanche) {
2564 if (
node.avalanche->isAvalancheServiceAvailable()) {
2574 node.banman.get(), chainman, *
node.mempool,
2592 std::make_unique<TxIndex>(
cache_sizes.tx_index,
false, fReindex);
2609 0,
false, fReindex);
2618 fReindex || args.
GetBoolArg(
"-chronikreindex",
false);
2626 for (
const auto &
client :
node.chain_clients) {
2637 LogPrintf(
"Unsetting NODE_NETWORK on prune mode\n");
2651 strprintf(
_(
"Error: Disk space is low for %s"),
2657 strprintf(
_(
"Error: Disk space is low for %s"),
2675#if defined(HAVE_SYSTEM)
2694 for (
const std::string &strFile : args.
GetArgs(
"-loadblock")) {
2702 ShouldPersistMempool(args) ? MempoolPath(args)
2740 if (
tip_info && chainman.m_best_header) {
2741 tip_info->header_height = chainman.m_best_header->nHeight;
2742 tip_info->header_time = chainman.m_best_header->GetBlockTime();
2759 ? args.
GetIntArg(
"-maxavalancheoutbound",
2765 connOptions.m_max_outbound_block_relay = std::min(
2774 if (
node.avalanche) {
2793 return strprintf(
_(
"%s request to listen on port %u. This port is "
2794 "considered \"bad\" and "
2795 "thus it is unlikely that any Bitcoin ABC peers "
2796 "connect to it. See "
2797 "doc/p2p-bad-ports.md for details and a full list."),
2803 const size_t index =
bind_arg.rfind(
'=');
2804 if (index == std::string::npos) {
2819 BaseParams().OnionServiceTargetPort(),
false)) {
2840 args.
GetArgs(
"-bind").empty() && args.
GetArgs(
"-whitebind").empty();
2862 _(
"More than one onion bind address is provided. Using %s "
2863 "for the automatically created Tor onion service."),
2875 for (
const auto &
net : args.
GetArgs(
"-whitelist")) {
2900 _(
"Invalid -i2psam address or hostname: '%s'"),
i2psam_arg));
2931 for (
const auto &
client :
node.chain_clients) {
2936 node.scheduler->scheduleEvery(
2944 if (
node.avalanche) {
2945 node.avalanche->startEventLoop(*
node.scheduler);
2949 node.peerman->StartScheduledTasks(*
node.scheduler);
util::Result< std::unique_ptr< AddrMan > > LoadAddrman(const CChainParams &chainparams, const std::vector< bool > &asmap, const ArgsManager &args)
Returns an error string on failure.
static constexpr int32_t DEFAULT_ADDRMAN_CONSISTENCY_CHECKS
Default for -checkaddrman.
void SetupHelpOptions(ArgsManager &args)
Add help options to the args manager.
const char *const BITCOIN_SETTINGS_FILENAME
const char *const BITCOIN_CONF_FILENAME
fs::path AbsPathForConfigVal(const ArgsManager &args, const fs::path &path, bool net_specific=true)
Most paths passed as configuration arguments are treated as relative to the datadir if they are not a...
std::vector< bool > DecodeAsmap(fs::path path)
Read asmap from provided binary file.
static constexpr bool DEFAULT_PERSIST_AVAPEERS
Default for -persistavapeers.
static constexpr double AVALANCHE_DEFAULT_MIN_QUORUM_CONNECTED_STAKE_RATIO
Default minimum percentage of stake-weighted peers we must have a node for to constitute a usable quo...
static constexpr size_t AVALANCHE_DEFAULT_PEER_REPLACEMENT_COOLDOWN
Peer replacement cooldown time default value in seconds.
static constexpr double AVALANCHE_DEFAULT_MIN_AVAPROOFS_NODE_COUNT
Default minimum number of nodes that sent us an avaproofs message before we can consider our quorum s...
static constexpr Amount AVALANCHE_DEFAULT_MIN_QUORUM_STAKE
Default minimum cumulative stake of all known peers that constitutes a usable quorum.
static constexpr size_t AVALANCHE_DEFAULT_CONFLICTING_PROOF_COOLDOWN
Conflicting proofs cooldown time default value in seconds.
static constexpr bool AVALANCHE_DEFAULT_ENABLED
Is avalanche enabled by default.
static constexpr size_t AVALANCHE_DEFAULT_COOLDOWN
Avalanche default cooldown in milliseconds.
static constexpr unsigned int DEFAULT_MISBEHAVING_BANTIME
static constexpr std::chrono::minutes DUMP_BANS_INTERVAL
void RPCNotifyBlockChange(const CBlockIndex *pindex)
Callback for when block tip changed.
const std::string & BlockFilterTypeName(BlockFilterType filter_type)
Get the human-readable name for a filter type.
const std::set< BlockFilterType > & AllBlockFilterTypes()
Get a list of known filter types.
const std::string & ListBlockFilterTypes()
Get a comma-separated list of known filter type names.
bool BlockFilterTypeByName(const std::string &name, BlockFilterType &filter_type)
Find a filter type by its human-readable name.
void DestroyAllBlockFilterIndexes()
Destroy all open block filter indexes.
BlockFilterIndex * GetBlockFilterIndex(BlockFilterType filter_type)
Get a block filter index by type.
void ForEachBlockFilterIndex(std::function< void(BlockFilterIndex &)> fn)
Iterate over all running block filter indexes, invoking fn on each.
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 char *const DEFAULT_BLOCKFILTERINDEX
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.
const CChainParams & Params()
Return the currently selected parameters.
std::unique_ptr< CBaseChainParams > CreateBaseChainParams(const std::string &chain)
Port numbers for incoming Tor connections (8334, 18334, 38334, 18445) have been chosen arbitrarily to...
const CBaseChainParams & BaseParams()
Return the currently selected parameters.
void SetupChainParamsBaseOptions(ArgsManager &argsman)
Set the arguments for chainparams.
static constexpr bool DEFAULT_CHECKPOINTS_ENABLED
static constexpr auto DEFAULT_MAX_TIP_AGE
static constexpr bool DEFAULT_STORE_RECENT_HEADERS_TIME
#define Assert(val)
Identity function.
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...
std::vector< std::string > GetArgs(const std::string &strArg) const
Return a vector of strings of the given argument.
fs::path GetDataDirNet() const
Get data directory path with appended network identifier.
bool IsArgSet(const std::string &strArg) const
Return true if the given argument has been manually set.
int64_t GetIntArg(const std::string &strArg, int64_t nDefault) const
Return integer argument or default value.
fs::path GetBlocksDirPath() const
Get blocks directory path.
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
bool SoftSetBoolArg(const std::string &strArg, bool fValue)
Set a boolean argument if it doesn't already have a value.
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
fs::path GetPathArg(std::string arg, const fs::path &default_value={}) const
Return path argument or default value.
const std::list< SectionInfo > GetUnrecognizedSections() const
Log warnings for unrecognized section names in the config file.
std::string GetChainName() const
Looks for -regtest, -testnet and returns the appropriate BIP70 chain name.
std::atomic< bool > m_reopen_file
void Stop()
Stops the instance from staying in sync with blockchain updates.
bool BlockUntilSyncedToCurrentChain() const LOCKS_EXCLUDED(void Interrupt()
Blocks the current thread until the index is caught up to the current state of the block chain.
BlockFilterIndex is used to store and retrieve block filters, hashes, and headers for a range of bloc...
static const std::string REGTEST
static const std::string TESTNET
static const std::string MAIN
BIP70 chain name strings (main, test or regtest)
The block chain is a tree shaped structure starting with the genesis block at the root,...
int64_t GetBlockTime() const
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or nullptr if none.
int Height() const
Return the maximal height in the chain.
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
const CBlock & GenesisBlock() const
bool DefaultConsistencyChecks() const
Default value for -checkmempool and -checkblockindex argument.
const ChainTxData & TxData() const
bool IsTestChain() const
If this chain is exclusively used for testing.
uint16_t GetDefaultPort() const
void UnregisterBackgroundSignalScheduler()
Unregister a CScheduler to give callbacks which should run in the background - these callbacks will n...
void RegisterBackgroundSignalScheduler(CScheduler &scheduler)
Register a CScheduler to give callbacks which should run in the background (may only be called once)
void FlushBackgroundCallbacks()
Call any remaining callbacks on the calling thread.
A combination of a network address (CNetAddr) and a (TCP) port.
static const int DEFAULT_ZMQ_SNDHWM
static std::unique_ptr< CZMQNotificationInterface > Create(std::function< bool(CBlock &, const CBlockIndex &)> get_block_by_index)
Chainstate stores and provides an API to update our local knowledge of the current best chain.
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
node::BlockMap & BlockIndex() EXCLUSIVE_LOCKS_REQUIRED(
RecursiveMutex & GetMutex() const LOCK_RETURNED(
Alias for cs_main.
CBlockIndex * ActiveTip() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex())
SnapshotCompletionResult MaybeCompleteSnapshotValidation(std::function< void(bilingual_str)> shutdown_fnc=[](bilingual_str msg) { AbortNode(msg.original, msg);}) EXCLUSIVE_LOCKS_REQUIRED(Chainstate & ActiveChainstate() const
Once the background validation chainstate has reached the height which is the base of the UTXO snapsh...
const CChainParams & GetParams() const
CChain & ActiveChain() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex())
Chainstate &InitializeChainstate(CTxMemPool *mempool) EXCLUSIVE_LOCKS_REQUIRED(std::vector< Chainstate * GetAll)()
Instantiate a new chainstate.
node::BlockManager m_blockman
A single BlockManager instance is shared across each constructed chainstate to avoid duplicating bloc...
virtual uint64_t GetMaxBlockSize() const =0
virtual const CChainParams & GetChainParams() const =0
virtual bool SetMaxBlockSize(uint64_t maxBlockSize)=0
virtual void SetCashAddrEncoding(bool)=0
Different type to mark Mutex at global scope.
A writer stream (for serialization) that computes a 256-bit hash.
static bool TryParse(const std::string &str, NetWhitebindPermissions &output, bilingual_str &error)
static bool TryParse(const std::string &str, NetWhitelistPermissions &output, bilingual_str &error)
static std::unique_ptr< PeerManager > make(CConnman &connman, AddrMan &addrman, BanMan *banman, ChainstateManager &chainman, CTxMemPool &pool, avalanche::Processor *const avalanche, Options opts)
Class for registering and managing all RPC calls.
virtual void AddWalletOptions(ArgsManager &argsman) const =0
Get wallet help string.
virtual void Construct(node::NodeContext &node) const =0
Add wallets that should be opened to list of chain clients.
virtual bool ParameterInteraction() const =0
Check wallet parameter interaction.
static std::unique_ptr< Processor > MakeProcessor(const ArgsManager &argsman, interfaces::Chain &chain, CConnman *connman, ChainstateManager &chainman, CTxMemPool *mempoolIn, CScheduler &scheduler, bilingual_str &error)
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
Maintains a tree of blocks (stored in m_block_index) which is consulted to determine where the most-w...
const CBlockIndex *GetFirstStoredBlock(const CBlockIndex &start_block) EXCLUSIVE_LOCKS_REQUIRED(bool m_have_pruned
Find the first block that is not pruned.
bool IsPruneMode() const
Whether running in -prune mode.
kernel::BlockManagerOpts Options
std::string FormatVersion(int nVersion)
std::string FormatUserAgent(const std::string &name, const std::string &version, const std::vector< std::string > &comments)
Format the subversion field according to BIP 14 spec.
static constexpr int CLIENT_VERSION
bitcoind-res.rc includes this file, but it cannot cope with real c++ code.
const std::string CLIENT_NAME
std::unique_ptr< CoinStatsIndex > g_coin_stats_index
The global UTXO set hash object.
static constexpr bool DEFAULT_COINSTATSINDEX
static const uint64_t DEFAULT_MAX_BLOCK_SIZE
Default setting for maximum allowed size for a block, in bytes.
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
void SetupCurrencyUnitOptions(ArgsManager &argsman)
const WalletInitInterface & g_wallet_init_interface
bilingual_str AmountErrMsg(const std::string &optname, const std::string &strValue)
bilingual_str ResolveErrMsg(const std::string &optname, const std::string &strBind)
bool LockDirectory(const fs::path &directory, const std::string lockfile_name, bool probe_only)
bool DirIsWritable(const fs::path &directory)
int RaiseFileDescriptorLimit(int nMinFD)
This function tries to raise the file descriptor limit to the requested number.
bool CheckDiskSpace(const fs::path &dir, uint64_t additional_bytes)
void InterruptHTTPRPC()
Interrupt HTTP RPC subsystem.
void StopHTTPRPC()
Stop HTTP RPC subsystem.
bool StartHTTPRPC(HTTPRPCRequestProcessor &httpRPCRequestProcessor)
Start HTTP RPC subsystem.
void StartREST(const std::any &context)
Start HTTP REST subsystem.
void StopREST()
Stop HTTP REST subsystem.
void InterruptREST()
Interrupt RPC REST subsystem.
void InterruptHTTPServer()
Interrupt HTTP server threads.
void StartHTTPServer()
Start HTTP server.
void StopHTTPServer()
Stop HTTP server.
bool InitHTTPServer(Config &config)
Initialize HTTP server.
static const int DEFAULT_HTTP_SERVER_TIMEOUT
static const int DEFAULT_HTTP_WORKQUEUE
static const int DEFAULT_HTTP_THREADS
Common init functions shared by bitcoin-node, bitcoin-wallet, etc.
static const char * BITCOIN_PID_FILENAME
The PID file facilities.
static bool CreatePidFile(const ArgsManager &args)
static const bool DEFAULT_PROXYRANDOMIZE
void Interrupt(NodeContext &node)
Interrupt threads.
void InitLogging(const ArgsManager &args)
Initialize global loggers.
bool AppInitLockDataDirectory()
Lock bitcoin data directory.
void SetupServerArgs(NodeContext &node)
Register all arguments with the ArgsManager.
static bool AppInitServers(Config &config, HTTPRPCRequestProcessor &httpRPCRequestProcessor, NodeContext &node)
#define MIN_CORE_FILEDESCRIPTORS
void Shutdown(NodeContext &node)
static void HandleSIGTERM(int)
Signal handlers are very limited in what they are allowed to do.
static GlobalMutex g_genesis_wait_mutex
static void OnRPCStarted()
static void HandleSIGHUP(int)
static fs::path GetPidFile(const ArgsManager &args)
static std::condition_variable g_genesis_wait_cv
bool AppInitMain(Config &config, RPCServer &rpcServer, HTTPRPCRequestProcessor &httpRPCRequestProcessor, NodeContext &node, interfaces::BlockAndHeaderTipInfo *tip_info)
Bitcoin main initialization.
static constexpr bool DEFAULT_CHRONIK
bool AppInitBasicSetup(const ArgsManager &args)
Initialize bitcoin: Basic context setup.
bool AppInitSanityChecks()
Initialization sanity checks: ecc init, sanity checks, dir lock.
bool AppInitInterfaces(NodeContext &node)
Initialize node and wallet interface pointers.
static const char * DEFAULT_ASMAP_FILENAME
void InitParameterInteraction(ArgsManager &args)
Parameter interaction: change current parameters depending on various rules.
static void BlockNotifyGenesisWait(const CBlockIndex *pBlockIndex)
static void OnRPCStopped()
static bool LockDataDirectory(bool probeOnly)
static void registerSignalHandler(int signal, void(*handler)(int))
bool AppInitParameterInteraction(Config &config, const ArgsManager &args)
Initialization: parameter interaction.
static const bool DEFAULT_REST_ENABLE
static boost::signals2::connection rpc_notify_block_change_connection
static void new_handler_terminate()
static const std::string HEADERS_TIME_FILE_NAME
static constexpr bool DEFAULT_DAEMON
Default value for -daemon option.
static constexpr bool DEFAULT_DAEMONWAIT
Default value for -daemonwait option.
BCLog::Logger & LogInstance()
bool error(const char *fmt, const Args &...args)
#define LogPrint(category,...)
void StartMapPort(bool use_upnp, bool use_natpmp)
static constexpr bool DEFAULT_NATPMP
static constexpr bool DEFAULT_UPNP
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 constexpr unsigned int DEFAULT_MAX_MEMPOOL_SIZE_MB
Default for -maxmempool, maximum megabytes of mempool memory usage.
static constexpr unsigned int DEFAULT_MEMPOOL_EXPIRY_HOURS
Default for -mempoolexpiry, expiration time for mempool transactions in hours.
std::string FormatMoney(const Amount amt)
Do not use these functions to represent or parse monetary amounts to or from JSON but use AmountFromV...
bool ParseMoney(const std::string &money_string, Amount &nRet)
Parse an amount denoted in full coins.
void OnStarted(std::function< void()> slot)
void OnStopped(std::function< void()> slot)
static constexpr Amount PROOF_DUST_THRESHOLD
Minimum amount per utxo.
static auto quoted(const std::string &s)
static bool exists(const path &p)
static std::string PathToString(const path &path)
Convert path object to byte string.
static path PathFromString(const std::string &string)
Convert byte string to path object.
std::string get_filesystem_error_message(const fs::filesystem_error &e)
void AddLoggingArgs(ArgsManager &argsman)
void SetLoggingCategories(const ArgsManager &args)
bool SanityChecks()
Ensure a usable environment with all necessary library support.
bool StartLogging(const ArgsManager &args)
void SetLoggingOptions(const ArgsManager &args)
std::unique_ptr< Chain > MakeChain(node::NodeContext &node, const CChainParams ¶ms)
Return implementation of Chain interface.
static constexpr bool DEFAULT_STOPAFTERBLOCKIMPORT
bool DumpMempool(const CTxMemPool &pool, const fs::path &dump_path, FopenFn mockable_fopen_function, bool skip_file_commit)
@ FAILURE_INCOMPATIBLE_DB
@ FAILURE_FATAL
Fatal error which should not prompt to reindex.
@ FAILURE
Generic failure which reindexing may fix.
@ FAILURE_INSUFFICIENT_DBCACHE
CacheSizes CalculateCacheSizes(const ArgsManager &args, size_t n_indexes)
fs::path MempoolPath(const ArgsManager &argsman)
bool ShouldPersistMempool(const ArgsManager &argsman)
void ThreadImport(ChainstateManager &chainman, avalanche::Processor *const avalanche, std::vector< fs::path > vImportFiles, const fs::path &mempool_path)
std::optional< bilingual_str > ApplyArgsManOptions(const ArgsManager &args, BlockManager::Options &opts)
ChainstateLoadResult LoadChainstate(ChainstateManager &chainman, const CacheSizes &cache_sizes, const ChainstateLoadOptions &options)
This sequence can have 4 types of outcomes:
ChainstateLoadResult VerifyLoadedChainstate(ChainstateManager &chainman, const ChainstateLoadOptions &options)
static constexpr bool DEFAULT_PERSIST_MEMPOOL
Default for -persistmempool, indicating whether the node should attempt to automatically load the mem...
std::atomic_bool fReindex
bilingual_str ErrorString(const Result< T > &result)
void TraceThread(const char *thread_name, std::function< void()> thread_func)
A wrapper for do-something-once thread functions.
void ThreadRename(std::string &&)
Rename a thread both in terms of an internal (in-memory) name as well as its system thread name.
void SetReachable(enum Network net, bool reachable)
Mark a network as reachable or unreachable (no automatic connects to it)
bool AddLocal(const CService &addr, int nScore)
void Discover()
Look up IP addresses from all interfaces on the machine and add them to the list of local addresses t...
static const unsigned int DEFAULT_MAX_PEER_CONNECTIONS
The maximum number of peer connections to maintain.
static const unsigned int MAX_SUBVERSION_LENGTH
Maximum length of the user agent string in version message.
static const int MAX_ADDNODE_CONNECTIONS
Maximum number of addnode outgoing nodes.
static const size_t DEFAULT_MAXSENDBUFFER
static const int NUM_FDS_MESSAGE_CAPTURE
Number of file descriptors required for message capture.
static const bool DEFAULT_BLOCKSONLY
Default for blocks only.
static const bool DEFAULT_WHITELISTFORCERELAY
Default for -whitelistforcerelay.
static const bool DEFAULT_FORCEDNSSEED
static const bool DEFAULT_WHITELISTRELAY
Default for -whitelistrelay.
static constexpr uint64_t DEFAULT_MAX_UPLOAD_TARGET
The default for -maxuploadtarget.
static const size_t DEFAULT_MAXRECEIVEBUFFER
static const int DEFAULT_MAX_AVALANCHE_OUTBOUND_CONNECTIONS
Maximum number of avalanche enabled outgoing connections by default.
static const bool DEFAULT_FIXEDSEEDS
static const int MAX_FEELER_CONNECTIONS
Maximum number of feeler connections.
static const bool DEFAULT_LISTEN
-listen default
static const int64_t DEFAULT_PEER_CONNECT_TIMEOUT
-peertimeout default
static const bool DEFAULT_DNSSEED
static const int MAX_OUTBOUND_FULL_RELAY_CONNECTIONS
Maximum number of automatic outgoing nodes over which we'll relay everything (blocks,...
static const int MAX_BLOCK_RELAY_ONLY_CONNECTIONS
Maximum number of block-relay-only outgoing connections.
const std::vector< std::string > NET_PERMISSIONS_DOC
static const uint32_t DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN
Default number of non-mempool transactions to keep around for block reconstruction.
static const uint32_t DEFAULT_MAX_ORPHAN_TRANSACTIONS
Default for -maxorphantx, maximum number of orphan transactions kept in memory.
static const bool DEFAULT_PEERBLOCKFILTERS
@ NET_MAX
Dummy value to indicate the number of NET_* constants.
@ NET_ONION
TOR (v2 or v3)
@ NET_UNROUTABLE
Addresses from these networks are not publicly routable on the global Internet.
enum Network ParseNetwork(const std::string &net_in)
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.
bool SetNameProxy(const proxyType &addrProxy)
Set the name proxy to use for all connections to nodes specified by a hostname.
bool IsBadPort(uint16_t port)
Determine if a port is "bad" from the perspective of attempting to connect to a node on that port.
bool SetProxy(enum Network net, const proxyType &addrProxy)
std::vector< std::string > GetNetworkNames(bool append_unroutable)
Return a vector of publicly routable Network names; optionally append NET_UNROUTABLE.
static const int DEFAULT_NAME_LOOKUP
-dns default
static const int DEFAULT_CONNECT_TIMEOUT
-timeout default
uint32_t nBytesPerSigCheck
static constexpr uint64_t DEFAULT_MAX_GENERATED_BLOCK_SIZE
Default for -blockmaxsize, which controls the maximum size of block the mining code will create.
static constexpr Amount DUST_RELAY_TX_FEE(1000 *SATOSHI)
Min feerate for defining dust.
static constexpr bool DEFAULT_PERMIT_BAREMULTISIG
Default for -permitbaremultisig.
static constexpr Amount DEFAULT_MIN_RELAY_TX_FEE_PER_KB(1000 *SATOSHI)
Default for -minrelaytxfee, minimum relay fee for transactions.
static constexpr unsigned int DEFAULT_BYTES_PER_SIGCHECK
Default for -bytespersigcheck .
static constexpr Amount DEFAULT_BLOCK_MIN_TX_FEE_PER_KB(1000 *SATOSHI)
Default for -blockmintxfee, which sets the minimum feerate for a transaction in blocks created by min...
static constexpr std::chrono::milliseconds AVALANCHE_DEFAULT_QUERY_TIMEOUT
How long before we consider that a query timed out.
static constexpr int AVALANCHE_DEFAULT_STAKE_UTXO_CONFIRMATIONS
Minimum number of confirmations before a stake utxo is mature enough to be included into a proof.
ServiceFlags
nServices flags.
void RandAddPeriodic() noexcept
Gather entropy from various expensive sources, and feed them to the PRNG state.
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
static void RegisterAllRPCCommands(const Config &config, RPCServer &rpcServer, CRPCTable &rpcTable)
Register all context-sensitive RPC commands.
bool(* handler)(Config &config, const std::any &context, HTTPRequest *req, const std::string &strReq)
const std::string UNIX_EPOCH_TIME
String used to describe UNIX epoch time in documentation, factored out to a constant for consistency.
static constexpr bool DEFAULT_RPC_DOC_CHECK
static constexpr bool DEFAULT_ENABLE_RTT
Default for -enablertt.
bool InitScriptExecutionCache(size_t max_size_bytes)
Initializes the script-execution cache.
static constexpr size_t DEFAULT_MAX_SCRIPT_CACHE_BYTES
void SetRPCWarmupFinished()
Mark warmup as done.
void SetRPCWarmupStatus(const std::string &newStatus)
Set the RPC warmup status.
void RpcInterruptionPoint()
Throw JSONRPCError if RPC is not running.
bool ShutdownRequested()
Returns true if a shutdown is requested, false otherwise.
bool InitShutdownState()
Initialize shutdown state.
void StartShutdown()
Request shutdown of the application.
void AbortShutdown()
Clear shutdown flag.
bool InitSignatureCache(size_t max_size_bytes)
static constexpr size_t DEFAULT_MAX_SIG_CACHE_BYTES
static const unsigned int MAX_OP_RETURN_RELAY
Default setting for nMaxDatacarrierBytes.
static const bool DEFAULT_ACCEPT_DATACARRIER
std::string SanitizeString(const std::string &str, int rule)
Remove unsafe chars.
@ SAFE_CHARS_UA_COMMENT
BIP-0014 subset.
void ReplaceAll(std::string &in_out, const std::string &search, const std::string &substitute)
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 constexpr Amount zero() noexcept
ServiceFlags nLocalServices
static const Currency & get()
Block and header tip information.
const CChainParams & chainparams
An options struct for ChainstateManager, more ergonomically referred to as ChainstateManager::Options...
Options struct containing options for constructing a CTxMemPool.
int check_ratio
The ratio used to determine how often sanity checks will run.
bool require_full_verification
std::function< void()> coins_error_cb
std::function< bool()> check_interrupt
NodeContext struct containing references to chain state and connection state.
#define WAIT_LOCK(cs, name)
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
#define TRY_LOCK(cs, name)
std::string SysErrorString(int err)
Return system error string from errno value.
int GetNumCores()
Return the number of cores available on the current system.
int64_t GetTimeMillis()
Returns the system time (not mockable)
void SetMockTime(int64_t nMockTimeIn)
DEPRECATED Use SetMockTime with chrono type.
NodeClock::time_point GetAdjustedTime()
static const int64_t DEFAULT_MAX_TIME_ADJUSTMENT
CService DefaultOnionServiceTarget()
const std::string DEFAULT_TOR_CONTROL
Default control port.
void InterruptTorControl()
void StartTorControl(CService onion_service_target)
static const bool DEFAULT_LISTEN_ONION
bilingual_str _(const char *psz)
Translation function.
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
util::Result< void > CheckLegacyTxindex(CBlockTreeDB &block_tree_db)
static constexpr int64_t MAX_DB_CACHE_MB
max. -dbcache (MiB)
static constexpr int64_t MIN_DB_CACHE_MB
min. -dbcache (MiB)
static constexpr int64_t DEFAULT_DB_BATCH_SIZE
-dbbatchsize default (bytes)
static constexpr int64_t DEFAULT_DB_CACHE_MB
-dbcache default (MiB)
std::unique_ptr< TxIndex > g_txindex
The global transaction index, used in GetTransaction. May be null.
static constexpr bool DEFAULT_TXINDEX
CClientUIInterface uiInterface
void InitWarning(const bilingual_str &str)
Show warning message.
bool InitError(const bilingual_str &str)
Show error message.
void StartScriptCheckWorkerThreads(int threads_num)
Run instances of script checking worker threads.
std::condition_variable g_best_block_cv
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...
void StopScriptCheckWorkerThreads()
Stop all of the script checking worker threads.
const std::vector< std::string > CHECKLEVEL_DOC
Documentation for argument 'checklevel'.
static constexpr int DEFAULT_CHECKLEVEL
static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES
Require that user allocate at least 550 MiB for block & undo files (blk???.dat and rev?...
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...
static const int MAX_SCRIPTCHECK_THREADS
Maximum number of dedicated script-checking threads allowed.
SynchronizationState
Current sync state passed to tip changed callbacks.
static const int DEFAULT_SCRIPTCHECK_THREADS
-par default (number of script-checking threads, 0 = auto)
static const signed int DEFAULT_CHECKBLOCKS
static const bool DEFAULT_PEERBLOOMFILTERS
static const int DEFAULT_STOPATHEIGHT
Default for -stopatheight.
CMainSignals & GetMainSignals()
void UnregisterAllValidationInterfaces()
Unregister all subscribers.
void UnregisterValidationInterface(CValidationInterface *callbacks)
Unregister subscriber.
void RegisterValidationInterface(CValidationInterface *callbacks)
Register subscriber.
static constexpr uint32_t AVALANCHE_VOTE_STALE_FACTOR
Scaling factor applied to confidence to determine staleness threshold.
static constexpr uint32_t AVALANCHE_VOTE_STALE_THRESHOLD
Number of votes before a record may be considered as stale.
std::unique_ptr< CZMQNotificationInterface > g_zmq_notification_interface
void RegisterZMQRPCCommands(CRPCTable &t)