6 #if defined(HAVE_CONFIG_H)
7 #include "config/bitcoin-config.h"
53 #include <boost/algorithm/string/classification.hpp>
54 #include <boost/algorithm/string/predicate.hpp>
55 #include <boost/algorithm/string/replace.hpp>
56 #include <boost/algorithm/string/split.hpp>
57 #include <boost/bind/bind.hpp>
58 #include <boost/filesystem.hpp>
59 #include <boost/function.hpp>
60 #include <boost/interprocess/sync/file_lock.hpp>
61 #include <boost/lexical_cast.hpp>
62 #include <boost/thread.hpp>
63 #include <openssl/crypto.h>
70 static const bool DEFAULT_PROXYRANDOMIZE =
true;
71 static const bool DEFAULT_REST_ENABLE =
false;
72 static const bool DEFAULT_DISABLE_SAFEMODE =
false;
73 static const bool DEFAULT_STOPAFTERBLOCKIMPORT =
false;
86 #define MIN_CORE_FILEDESCRIPTORS 0
88 #define MIN_CORE_FILEDESCRIPTORS 150
99 static const char* FEE_ESTIMATES_FILENAME=
"fee_estimates.dat";
155 }
catch(
const std::runtime_error& e) {
157 LogPrintf(
"Error reading from database: %s\n", e.what());
170 static std::unique_ptr<ECCVerifyHandle> globalVerifyHandle;
181 threadGroup.interrupt_all();
186 LogPrintf(
"%s: In progress...\n", __func__);
188 TRY_LOCK(cs_Shutdown, lockShutdown);
220 boost::filesystem::path est_path =
GetDataDir() / FEE_ESTIMATES_FILENAME;
221 CAutoFile est_fileout(fopen(est_path.string().c_str(),
"wb"),
SER_DISK, CLIENT_VERSION);
222 if (!est_fileout.
IsNull())
225 LogPrintf(
"%s: Failed to write fee estimates to %s\n", __func__, est_path.string());
236 delete pcoinscatcher;
237 pcoinscatcher = NULL;
249 if (pzmqNotificationInterface) {
251 delete pzmqNotificationInterface;
252 pzmqNotificationInterface = NULL;
259 }
catch (
const boost::filesystem::filesystem_error& e) {
260 LogPrintf(
"%s: Unable to remove pidfile: %s\n", __func__, e.what());
268 globalVerifyHandle.reset();
289 std::string strError;
314 if (strWarning !=
"" && !
GetBoolArg(
"-disablesafemode", DEFAULT_DISABLE_SAFEMODE) &&
321 const bool showDebug =
GetBoolArg(
"-help-debug",
false);
326 strUsage +=
HelpMessageOpt(
"-?",
_(
"Print this help message and exit"));
328 strUsage +=
HelpMessageOpt(
"-alerts",
strprintf(
_(
"Receive and display P2P network alerts (default: %u)"), DEFAULT_ALERTS));
329 strUsage +=
HelpMessageOpt(
"-alertnotify=<cmd>",
_(
"Execute command when a relevant alert is received or we see a really long fork (%s in cmd is replaced by message)"));
330 strUsage +=
HelpMessageOpt(
"-blocknotify=<cmd>",
_(
"Execute command when the best block changes (%s in cmd is replaced by block hash, %i is replaced by block number)"));
332 strUsage +=
HelpMessageOpt(
"-blocksonly",
strprintf(
_(
"Whether to operate in a blocks only mode (default: %u)"), DEFAULT_BLOCKSONLY));
338 strUsage +=
HelpMessageOpt(
"-daemon",
_(
"Run in the background as a daemon and accept commands"));
341 strUsage +=
HelpMessageOpt(
"-datadir=<dir>",
_(
"Specify data directory"));
342 strUsage +=
HelpMessageOpt(
"-dbcache=<n>",
strprintf(
_(
"Set database cache size in megabytes (%d to %d, default: %d)"), nMinDbCache, nMaxDbCache, nDefaultDbCache));
344 strUsage +=
HelpMessageOpt(
"-feefilter",
strprintf(
"Tell other nodes to filter invs to us by our mempool min fee (default: %u)", DEFAULT_FEEFILTER));
345 strUsage +=
HelpMessageOpt(
"-loadblock=<file>",
_(
"Imports blocks from external blk000??.dat file on startup"));
346 strUsage +=
HelpMessageOpt(
"-maxorphantx=<n>",
strprintf(
_(
"Keep at most <n> unconnectable transactions in memory (default: %u)"), DEFAULT_MAX_ORPHAN_TRANSACTIONS));
347 strUsage +=
HelpMessageOpt(
"-maxmempool=<n>",
strprintf(
_(
"Keep the transaction memory pool below <n> megabytes (default: %u)"), DEFAULT_MAX_MEMPOOL_SIZE));
348 strUsage +=
HelpMessageOpt(
"-mempoolexpiry=<n>",
strprintf(
_(
"Do not keep transactions in the mempool longer than <n> hours (default: %u)"), DEFAULT_MEMPOOL_EXPIRY));
349 strUsage +=
HelpMessageOpt(
"-blockreconstructionextratxn=<n>",
strprintf(
_(
"Extra transactions to keep in memory for compact block reconstructions (default: %u)"), DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN));
350 strUsage +=
HelpMessageOpt(
"-par=<n>",
strprintf(
_(
"Set the number of script verification threads (%u to %d, 0 = auto, <0 = leave that many cores free, default: %d)"),
351 -
GetNumCores(), MAX_SCRIPTCHECK_THREADS, DEFAULT_SCRIPTCHECK_THREADS));
355 strUsage +=
HelpMessageOpt(
"-prune=<n>",
strprintf(
_(
"Reduce storage requirements by enabling pruning (deleting) of old blocks. This allows the pruneblockchain RPC to be called to delete specific blocks, and enables automatic pruning of old blocks if a target size in MiB is provided. This mode is incompatible with -txindex and -rescan. "
356 "Warning: Reverting this setting requires re-downloading the entire blockchain. "
357 "(default: 0 = disable pruning blocks, 1 = allow manual pruning via RPC, >%u = automatically prune block files to stay under the specified target size in MiB)"), MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024));
358 strUsage +=
HelpMessageOpt(
"-reindex-chainstate",
_(
"Rebuild chain state from the currently indexed blocks"));
359 strUsage +=
HelpMessageOpt(
"-reindex",
_(
"Rebuild chain state and block index from the blk*.dat files on disk"));
361 strUsage +=
HelpMessageOpt(
"-sysperms",
_(
"Create new files with system default permissions, instead of umask 077 (only effective with disabled wallet functionality)"));
363 strUsage +=
HelpMessageOpt(
"-txindex",
strprintf(
_(
"Maintain a full transaction index, used by the getrawtransaction rpc call (default: %u)"), DEFAULT_TXINDEX));
366 strUsage +=
HelpMessageOpt(
"-addnode=<ip>",
_(
"Add a node to connect to and attempt to keep the connection open"));
367 strUsage +=
HelpMessageOpt(
"-banscore=<n>",
strprintf(
_(
"Threshold for disconnecting misbehaving peers (default: %u)"), DEFAULT_BANSCORE_THRESHOLD));
368 strUsage +=
HelpMessageOpt(
"-bantime=<n>",
strprintf(
_(
"Number of seconds to keep misbehaving peers from reconnecting (default: %u)"), DEFAULT_MISBEHAVING_BANTIME));
369 strUsage +=
HelpMessageOpt(
"-bind=<addr>",
_(
"Bind to given address and always listen on it. Use [host]:port notation for IPv6"));
370 strUsage +=
HelpMessageOpt(
"-connect=<ip>",
_(
"Connect only to the specified node(s); -noconnect or -connect=0 alone to disable automatic connections"));
371 strUsage +=
HelpMessageOpt(
"-discover",
_(
"Discover own IP addresses (default: 1 when listening and no -externalip or -proxy)"));
372 strUsage +=
HelpMessageOpt(
"-dns",
_(
"Allow DNS lookups for -addnode, -seednode and -connect") +
" " +
strprintf(
_(
"(default: %u)"), DEFAULT_NAME_LOOKUP));
373 strUsage +=
HelpMessageOpt(
"-dnsseed",
_(
"Query for peer addresses via DNS lookup, if low on addresses (default: 1 unless -connect/-noconnect)"));
374 strUsage +=
HelpMessageOpt(
"-externalip=<ip>",
_(
"Specify your own public address"));
375 strUsage +=
HelpMessageOpt(
"-forcednsseed",
strprintf(
_(
"Always query for peer addresses via DNS lookup (default: %u)"), DEFAULT_FORCEDNSSEED));
376 strUsage +=
HelpMessageOpt(
"-listen",
_(
"Accept connections from outside (default: 1 if no -proxy or -connect/-noconnect)"));
377 strUsage +=
HelpMessageOpt(
"-listenonion",
strprintf(
_(
"Automatically create Tor hidden service (default: %d)"), DEFAULT_LISTEN_ONION));
378 strUsage +=
HelpMessageOpt(
"-maxconnections=<n>",
strprintf(
_(
"Maintain at most <n> connections to peers (default: %u)"), DEFAULT_MAX_PEER_CONNECTIONS));
379 strUsage +=
HelpMessageOpt(
"-maxreceivebuffer=<n>",
strprintf(
_(
"Maximum per-connection receive buffer, <n>*1000 bytes (default: %u)"), DEFAULT_MAXRECEIVEBUFFER));
380 strUsage +=
HelpMessageOpt(
"-maxsendbuffer=<n>",
strprintf(
_(
"Maximum per-connection send buffer, <n>*1000 bytes (default: %u)"), DEFAULT_MAXSENDBUFFER));
381 strUsage +=
HelpMessageOpt(
"-maxtimeadjustment",
strprintf(
_(
"Maximum allowed median peer time offset adjustment. Local perspective of time may be influenced by peers forward or backward by this amount. (default: %u seconds)"), DEFAULT_MAX_TIME_ADJUSTMENT));
382 strUsage +=
HelpMessageOpt(
"-onion=<ip:port>",
strprintf(
_(
"Use separate SOCKS5 proxy to reach peers via Tor hidden services (default: %s)"),
"-proxy"));
383 strUsage +=
HelpMessageOpt(
"-onlynet=<net>",
_(
"Only connect to nodes in network <net> (ipv4, ipv6 or onion)"));
384 strUsage +=
HelpMessageOpt(
"-permitbaremultisig",
strprintf(
_(
"Relay non-P2SH multisig (default: %u)"), DEFAULT_PERMIT_BAREMULTISIG));
385 strUsage +=
HelpMessageOpt(
"-peerbloomfilters",
strprintf(
_(
"Support filtering of blocks and transaction with bloom filters (default: %u)"), DEFAULT_PEERBLOOMFILTERS));
387 strUsage +=
HelpMessageOpt(
"-proxy=<ip:port>",
_(
"Connect through SOCKS5 proxy"));
388 strUsage +=
HelpMessageOpt(
"-proxyrandomize",
strprintf(
_(
"Randomize credentials for every proxy connection. This enables Tor stream isolation (default: %u)"), DEFAULT_PROXYRANDOMIZE));
389 strUsage +=
HelpMessageOpt(
"-rpcserialversion",
strprintf(
_(
"Sets the serialization of raw transaction or block hex returned in non-verbose mode, non-segwit(0) or segwit(1) (default: %d)"), DEFAULT_RPC_SERIALIZE_VERSION));
390 strUsage +=
HelpMessageOpt(
"-seednode=<ip>",
_(
"Connect to a node to retrieve peer addresses, and disconnect"));
391 strUsage +=
HelpMessageOpt(
"-timeout=<n>",
strprintf(
_(
"Specify connection timeout in milliseconds (minimum: 1, default: %d)"), DEFAULT_CONNECT_TIMEOUT));
393 strUsage +=
HelpMessageOpt(
"-torpassword=<pass>",
_(
"Tor control port password (default: empty)"));
396 strUsage +=
HelpMessageOpt(
"-upnp",
_(
"Use UPnP to map the listening port (default: 1 when listening and no -proxy)"));
401 strUsage +=
HelpMessageOpt(
"-whitebind=<addr>",
_(
"Bind to given address and whitelist peers connecting to it. Use [host]:port notation for IPv6"));
402 strUsage +=
HelpMessageOpt(
"-whitelist=<IP address or network>",
_(
"Whitelist peers connecting from the given IP address (e.g. 1.2.3.4) or CIDR notated network (e.g. 1.2.3.0/24). Can be specified multiple times.") +
403 " " +
_(
"Whitelisted peers cannot be DoS banned and their transactions are always relayed, even if they are already in the mempool, useful e.g. for a gateway"));
404 strUsage +=
HelpMessageOpt(
"-whitelistrelay",
strprintf(
_(
"Accept relayed transactions received from whitelisted peers even when not relaying transactions (default: %d)"), DEFAULT_WHITELISTRELAY));
405 strUsage +=
HelpMessageOpt(
"-whitelistforcerelay",
strprintf(
_(
"Force relay of transactions from whitelisted peers even if they violate local relay policy (default: %d)"), DEFAULT_WHITELISTFORCERELAY));
406 strUsage +=
HelpMessageOpt(
"-maxuploadtarget=<n>",
strprintf(
_(
"Tries to keep outbound traffic under the given target (in MiB per 24h), 0 = no limit (default: %d)"), DEFAULT_MAX_UPLOAD_TARGET));
414 strUsage +=
HelpMessageOpt(
"-zmqpubhashblock=<address>",
_(
"Enable publish hash block in <address>"));
415 strUsage +=
HelpMessageOpt(
"-zmqpubhashtx=<address>",
_(
"Enable publish hash transaction in <address>"));
416 strUsage +=
HelpMessageOpt(
"-zmqpubrawblock=<address>",
_(
"Enable publish raw block in <address>"));
417 strUsage +=
HelpMessageOpt(
"-zmqpubrawtx=<address>",
_(
"Enable publish raw transaction in <address>"));
421 strUsage +=
HelpMessageOpt(
"-uacomment=<cmt>",
_(
"Append comment to the user agent string"));
424 strUsage +=
HelpMessageOpt(
"-checkblocks=<n>",
strprintf(
_(
"How many blocks to check at startup (default: %u, 0 = all)"), DEFAULT_CHECKBLOCKS));
425 strUsage +=
HelpMessageOpt(
"-checklevel=<n>",
strprintf(
_(
"How thorough the block verification of -checkblocks is (0-4, default: %u)"), DEFAULT_CHECKLEVEL));
426 strUsage +=
HelpMessageOpt(
"-checkblockindex",
strprintf(
"Do a full consistency check for mapBlockIndex, setBlockIndexCandidates, chainActive and mapBlocksUnlinked occasionally. Also sets -checkmempool (default: %u)",
Params(
CBaseChainParams::MAIN).DefaultConsistencyChecks()));
428 strUsage +=
HelpMessageOpt(
"-checkpoints",
strprintf(
"Disable expensive verification for known chain history (default: %u)", DEFAULT_CHECKPOINTS_ENABLED));
429 strUsage +=
HelpMessageOpt(
"-disablesafemode",
strprintf(
"Disable safemode, override a real safe mode event (default: %u)", DEFAULT_DISABLE_SAFEMODE));
431 strUsage +=
HelpMessageOpt(
"-dropmessagestest=<n>",
"Randomly drop 1 of every <n> network messages");
432 strUsage +=
HelpMessageOpt(
"-fuzzmessagestest=<n>",
"Randomly fuzz 1 of every <n> network messages");
433 strUsage +=
HelpMessageOpt(
"-stopafterblockimport",
strprintf(
"Stop running after importing blocks from disk (default: %u)", DEFAULT_STOPAFTERBLOCKIMPORT));
434 strUsage +=
HelpMessageOpt(
"-limitancestorcount=<n>",
strprintf(
"Do not accept transactions if number of in-mempool ancestors is <n> or more (default: %u)", DEFAULT_ANCESTOR_LIMIT));
435 strUsage +=
HelpMessageOpt(
"-limitancestorsize=<n>",
strprintf(
"Do not accept transactions whose size with all in-mempool ancestors exceeds <n> kilobytes (default: %u)", DEFAULT_ANCESTOR_SIZE_LIMIT));
436 strUsage +=
HelpMessageOpt(
"-limitdescendantcount=<n>",
strprintf(
"Do not accept transactions if any ancestor would have <n> or more in-mempool descendants (default: %u)", DEFAULT_DESCENDANT_LIMIT));
437 strUsage +=
HelpMessageOpt(
"-limitdescendantsize=<n>",
strprintf(
"Do not accept transactions if any ancestor would have more than <n> kilobytes of in-mempool descendants (default: %u).", DEFAULT_DESCENDANT_SIZE_LIMIT));
438 strUsage +=
HelpMessageOpt(
"-bip9params=deployment:start:end",
"Use given start/end times for specified BIP9 deployment (regtest-only)");
440 std::string debugCategories =
"addrman, alert, bench, cmpctblock, coindb, db, http, libevent, lock, mempool, mempoolrej, net, proxy, prune, rand, reindex, rpc, selectcoins, tor, zmq";
442 debugCategories +=
", qt";
443 strUsage +=
HelpMessageOpt(
"-debug=<category>",
strprintf(
_(
"Output debugging information (default: %u, supplying <category> is optional)"), 0) +
". " +
444 _(
"If <category> is not supplied or if <category> = 1, output all debugging information.") +
_(
"<category> can be:") +
" " + debugCategories +
".");
446 strUsage +=
HelpMessageOpt(
"-nodebug",
"Turn off debugging messages, same as -debug=0");
447 strUsage +=
HelpMessageOpt(
"-help-debug",
_(
"Show all debugging options (usage: --help -help-debug)"));
448 strUsage +=
HelpMessageOpt(
"-logips",
strprintf(
_(
"Include IP addresses in debug output (default: %u)"), DEFAULT_LOGIPS));
449 strUsage +=
HelpMessageOpt(
"-logtimestamps",
strprintf(
_(
"Prepend debug output with timestamp (default: %u)"), DEFAULT_LOGTIMESTAMPS));
452 strUsage +=
HelpMessageOpt(
"-logtimemicros",
strprintf(
"Add microsecond precision to debug timestamps (default: %u)", DEFAULT_LOGTIMEMICROS));
453 strUsage +=
HelpMessageOpt(
"-mocktime=<n>",
"Replace actual time with <n> seconds since epoch (default: 0)");
454 strUsage +=
HelpMessageOpt(
"-limitfreerelay=<n>",
strprintf(
"Continuously rate-limit free transactions to <n>*1000 bytes per minute (default: %u)", DEFAULT_LIMITFREERELAY));
455 strUsage +=
HelpMessageOpt(
"-relaypriority",
strprintf(
"Require high priority for relaying free or low-fee transactions (default: %u)", DEFAULT_RELAYPRIORITY));
456 strUsage +=
HelpMessageOpt(
"-maxsigcachesize=<n>",
strprintf(
"Limit size of signature cache to <n> MiB (default: %u)", DEFAULT_MAX_SIG_CACHE_SIZE));
457 strUsage +=
HelpMessageOpt(
"-maxtipage=<n>",
strprintf(
"Maximum tip age in seconds to consider node in initial block download (default: %u)", DEFAULT_MAX_TIP_AGE));
459 strUsage +=
HelpMessageOpt(
"-minrelaytxfee=<amt>",
strprintf(
_(
"Fees (in %s/kB) smaller than this are considered zero fee for relaying, mining and transaction creation (default: %s)"),
461 strUsage +=
HelpMessageOpt(
"-maxtxfee=<amt>",
strprintf(
_(
"Maximum total fees (in %s) to use in a single wallet transaction or raw transaction; setting this too low may abort large transactions (default: %s)"),
463 strUsage +=
HelpMessageOpt(
"-printtoconsole",
_(
"Send trace/debug info to console instead of debug.log file"));
466 strUsage +=
HelpMessageOpt(
"-printpriority",
strprintf(
"Log transaction priority and fee per kB when mining blocks (default: %u)", DEFAULT_PRINTPRIORITY));
468 strUsage +=
HelpMessageOpt(
"-shrinkdebugfile",
_(
"Shrink debug.log file on client startup (default: 1 when no -debug)"));
475 strUsage +=
HelpMessageOpt(
"-incrementalrelayfee=<amt>",
strprintf(
"Fee rate (in %s/kB) used to define cost of relay, used for mempool limiting and BIP 125 replacement. (default: %s)",
CURRENCY_UNIT,
FormatMoney(DEFAULT_INCREMENTAL_RELAY_FEE)));
476 strUsage +=
HelpMessageOpt(
"-dustrelayfee=<amt>",
strprintf(
"Fee rate (in %s/kB) used to defined dust, the value of an output such that it will cost about 1/3 of its value in fees at this fee rate to spend it. (default: %s)",
CURRENCY_UNIT,
FormatMoney(DUST_RELAY_TX_FEE)));
478 strUsage +=
HelpMessageOpt(
"-bytespersigop",
strprintf(
_(
"Equivalent bytes per sigop in transactions for relay and mining (default: %u)"), DEFAULT_BYTES_PER_SIGOP));
479 strUsage +=
HelpMessageOpt(
"-datacarrier",
strprintf(
_(
"Relay and mine data carrier transactions (default: %u)"), DEFAULT_ACCEPT_DATACARRIER));
480 strUsage +=
HelpMessageOpt(
"-datacarriersize",
strprintf(
_(
"Maximum size of data in data carrier transactions we relay and mine (default: %u)"), MAX_OP_RETURN_RELAY));
481 strUsage +=
HelpMessageOpt(
"-mempoolreplacement",
strprintf(
_(
"Enable transaction replacement in the memory pool (default: %u)"), DEFAULT_ENABLE_REPLACEMENT));
484 strUsage +=
HelpMessageOpt(
"-blockmaxweight=<n>",
strprintf(
_(
"Set maximum BIP141 block weight (default: %d)"), DEFAULT_BLOCK_MAX_WEIGHT));
485 strUsage +=
HelpMessageOpt(
"-blockmaxsize=<n>",
strprintf(
_(
"Set maximum block size in bytes (default: %d)"), DEFAULT_BLOCK_MAX_SIZE));
486 strUsage +=
HelpMessageOpt(
"-blockprioritysize=<n>",
strprintf(
_(
"Set maximum size of high-priority/low-fee transactions in bytes (default: %d)"), DEFAULT_BLOCK_PRIORITY_SIZE));
489 strUsage +=
HelpMessageOpt(
"-blockversion=<n>",
"Override block version to test forking scenarios");
492 strUsage +=
HelpMessageOpt(
"-server",
_(
"Accept command line and JSON-RPC commands"));
493 strUsage +=
HelpMessageOpt(
"-rest",
strprintf(
_(
"Accept public REST requests (default: %u)"), DEFAULT_REST_ENABLE));
494 strUsage +=
HelpMessageOpt(
"-rpcbind=<addr>",
_(
"Bind to given address to listen for JSON-RPC connections. Use [host]:port notation for IPv6. This option can be specified multiple times (default: bind to all interfaces)"));
495 strUsage +=
HelpMessageOpt(
"-rpccookiefile=<loc>",
_(
"Location of the auth cookie (default: data dir)"));
496 strUsage +=
HelpMessageOpt(
"-rpcuser=<user>",
_(
"Username for JSON-RPC connections"));
497 strUsage +=
HelpMessageOpt(
"-rpcpassword=<pw>",
_(
"Password for JSON-RPC connections"));
498 strUsage +=
HelpMessageOpt(
"-rpcauth=<userpw>",
_(
"Username and hashed password for JSON-RPC connections. The field <userpw> comes in the format: <USERNAME>:<SALT>$<HASH>. A canonical python script is included in share/rpcuser. The client then connects normally using the rpcuser=<USERNAME>/rpcpassword=<PASSWORD> pair of arguments. This option can be specified multiple times"));
500 strUsage +=
HelpMessageOpt(
"-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"));
501 strUsage +=
HelpMessageOpt(
"-rpcthreads=<n>",
strprintf(
_(
"Set the number of threads to service RPC calls (default: %d)"), DEFAULT_HTTP_THREADS));
503 strUsage +=
HelpMessageOpt(
"-rpcworkqueue=<n>",
strprintf(
"Set the depth of the work queue to service RPC calls (default: %d)", DEFAULT_HTTP_WORKQUEUE));
504 strUsage +=
HelpMessageOpt(
"-rpcservertimeout=<n>",
strprintf(
"Timeout during HTTP requests (default: %d)", DEFAULT_HTTP_SERVER_TIMEOUT));
512 const std::string URL_SOURCE_CODE =
"<https://github.com/dogecoin/dogecoin>";
513 const std::string URL_WEBSITE =
"<https://dogecoin.com>";
517 strprintf(
_(
"Please contribute if you find %s useful. "
518 "Visit %s for further information about the software."),
519 PACKAGE_NAME, URL_WEBSITE) +
521 strprintf(
_(
"The source code is available from %s."),
525 _(
"This is experimental software.") +
"\n" +
526 strprintf(
_(
"Distributed under the MIT software license, see the accompanying file %s or %s"),
"COPYING",
"<https://opensource.org/licenses/MIT>") +
"\n" +
528 strprintf(
_(
"This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit %s and cryptographic software written by Eric Young and UPnP software written by Thomas Bernard. Paper wallet art provided by Anacoluthia."),
"<https://www.openssl.org>") +
532 static void BlockNotifyCallback(
bool initialSync,
const CBlockIndex *pBlockIndex)
534 if (initialSync || !pBlockIndex)
537 std::string strCmd =
GetArg(
"-blocknotify",
"");
540 boost::replace_all(strCmd,
"%i", boost::lexical_cast<std::string>(pBlockIndex->
nHeight));
544 static bool fHaveGenesis =
false;
545 static boost::mutex cs_GenesisWait;
548 static void BlockNotifyGenesisWait(
bool,
const CBlockIndex *pBlockIndex)
550 if (pBlockIndex != NULL) {
552 boost::unique_lock<boost::mutex> lock_GenesisWait(cs_GenesisWait);
555 condvar_GenesisWait.notify_all();
581 std::map<std::string, boost::filesystem::path> mapBlockFiles;
586 LogPrintf(
"Removing unusable blk?????.dat and rev?????.dat files for -reindex with -prune\n");
587 boost::filesystem::path blocksdir =
GetDataDir() /
"blocks";
588 for (boost::filesystem::directory_iterator it(blocksdir); it != boost::filesystem::directory_iterator(); it++) {
589 if (is_regular_file(*it) &&
590 it->path().filename().string().length() == 12 &&
591 it->path().filename().string().substr(8,4) ==
".dat")
593 if (it->path().filename().string().substr(0,3) ==
"blk")
594 mapBlockFiles[it->path().filename().string().substr(3,5)] = it->path();
595 else if (it->path().filename().string().substr(0,3) ==
"rev")
604 int nContigCounter = 0;
605 BOOST_FOREACH(
const PAIRTYPE(std::string, boost::filesystem::path)& item, mapBlockFiles) {
606 if (
atoi(item.first) == nContigCounter) {
632 LogPrintf(
"Reindexing block file blk%05u.dat...\n", (
unsigned int)nFile);
644 boost::filesystem::path pathBootstrap =
GetDataDir() /
"bootstrap.dat";
645 if (boost::filesystem::exists(pathBootstrap)) {
646 FILE *file = fopen(pathBootstrap.string().c_str(),
"rb");
648 boost::filesystem::path pathBootstrapOld =
GetDataDir() /
"bootstrap.dat.old";
649 LogPrintf(
"Importing bootstrap.dat...\n");
653 LogPrintf(
"Warning: Could not open bootstrap file %s\n", pathBootstrap.string());
658 BOOST_FOREACH(
const boost::filesystem::path& path, vImportFiles) {
659 FILE *file = fopen(path.string().c_str(),
"rb");
661 LogPrintf(
"Importing blocks file %s...\n", path.string());
664 LogPrintf(
"Warning: Could not open blocks file %s\n", path.string());
671 LogPrintf(
"Failed to connect best block");
675 if (
GetBoolArg(
"-stopafterblockimport", DEFAULT_STOPAFTERBLOCKIMPORT)) {
676 LogPrintf(
"Stopping after block import\n");
691 InitError(
"Elliptic curve cryptography sanity check failure. Aborting.");
725 LogPrintf(
"%s: parameter interaction: -bind set -> setting -listen=1\n", __func__);
729 LogPrintf(
"%s: parameter interaction: -whitebind set -> setting -listen=1\n", __func__);
735 LogPrintf(
"%s: parameter interaction: -connect set -> setting -dnsseed=0\n", __func__);
737 LogPrintf(
"%s: parameter interaction: -connect set -> setting -listen=0\n", __func__);
743 LogPrintf(
"%s: parameter interaction: -proxy set -> setting -listen=0\n", __func__);
747 LogPrintf(
"%s: parameter interaction: -proxy set -> setting -upnp=0\n", __func__);
750 LogPrintf(
"%s: parameter interaction: -proxy set -> setting -discover=0\n", __func__);
756 LogPrintf(
"%s: parameter interaction: -listen=0 -> setting -upnp=0\n", __func__);
758 LogPrintf(
"%s: parameter interaction: -listen=0 -> setting -discover=0\n", __func__);
760 LogPrintf(
"%s: parameter interaction: -listen=0 -> setting -listenonion=0\n", __func__);
766 LogPrintf(
"%s: parameter interaction: -externalip set -> setting -discover=0\n", __func__);
770 if (
GetBoolArg(
"-blocksonly", DEFAULT_BLOCKSONLY)) {
772 LogPrintf(
"%s: parameter interaction: -blocksonly=1 -> setting -whitelistrelay=0\n", __func__);
776 if (
GetBoolArg(
"-whitelistforcerelay", DEFAULT_WHITELISTFORCERELAY)) {
778 LogPrintf(
"%s: parameter interaction: -whitelistforcerelay=1 -> setting -whitelistrelay=1\n", __func__);
782 static std::string ResolveErrMsg(
const char *
const optname,
const std::string& strBind)
784 return strprintf(
_(
"Cannot resolve -%s address: '%s'"), optname, strBind);
794 LogPrintf(
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
802 int nUserMaxConnections;
808 [[noreturn]]
static void new_handler_terminate()
814 std::set_new_handler(std::terminate);
815 LogPrintf(
"Error: Out of memory. Terminating.\n");
826 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
827 _CrtSetReportFile(_CRT_WARN, CreateFileA(
"NUL", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0));
831 _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
837 #ifndef PROCESS_DEP_ENABLE
840 #define PROCESS_DEP_ENABLE 0x00000001
842 typedef BOOL (WINAPI *PSETPROCDEPPOL)(DWORD);
843 PSETPROCDEPPOL setProcDEPPol = (PSETPROCDEPPOL)GetProcAddress(GetModuleHandleA(
"Kernel32.dll"),
"SetProcessDEPPolicy");
844 if (setProcDEPPol != NULL) setProcDEPPol(PROCESS_DEP_ENABLE);
848 return InitError(
"Initializing networking failed");
858 sigemptyset(&sa.sa_mask);
860 sigaction(SIGTERM, &sa, NULL);
861 sigaction(SIGINT, &sa, NULL);
864 struct sigaction sa_hup;
866 sigemptyset(&sa_hup.sa_mask);
868 sigaction(SIGHUP, &sa_hup, NULL);
871 signal(SIGPIPE, SIG_IGN);
874 std::set_new_handler(new_handler_terminate);
887 if (
GetArg(
"-prune", 0)) {
889 return InitError(
_(
"Prune mode is incompatible with -txindex."));
893 int nBind = std::max(
896 nUserMaxConnections =
GetArg(
"-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS);
897 nMaxConnections = std::max(nUserMaxConnections, 0);
900 nMaxConnections = std::max(std::min(nMaxConnections, (
int)(FD_SETSIZE - nBind -
MIN_CORE_FILEDESCRIPTORS - MAX_ADDNODE_CONNECTIONS)), 0);
903 return InitError(
_(
"Not enough file descriptors available."));
906 if (nMaxConnections < nUserMaxConnections)
907 InitWarning(
strprintf(
_(
"Reducing -maxconnections from %d to %d, because of system limitations."), nUserMaxConnections, nMaxConnections));
914 const std::vector<std::string>& categories =
mapMultiArgs.at(
"-debug");
915 if (
GetBoolArg(
"-nodebug",
false) || find(categories.begin(), categories.end(), std::string(
"0")) != categories.end())
921 InitWarning(
_(
"Unsupported argument -debugnet ignored, use -debug=net."));
924 return InitError(
_(
"Unsupported argument -socks found. Setting SOCKS version isn't possible anymore, only SOCKS5 proxies are supported."));
927 return InitError(
_(
"Unsupported argument -tor found, use -onion."));
930 InitWarning(
_(
"Unsupported argument -benchmark ignored, use -debug=bench."));
932 if (
GetBoolArg(
"-whitelistalwaysrelay",
false))
933 InitWarning(
_(
"Unsupported argument -whitelistalwaysrelay ignored, use -whitelistrelay and/or -whitelistforcerelay."));
936 InitWarning(
"Unsupported argument -blockminsize ignored.");
950 LogPrintf(
"Validating signatures for all blocks.\n");
953 int64_t nMempoolSizeMax =
GetArg(
"-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000;
954 int64_t nMempoolSizeMin =
GetArg(
"-limitdescendantsize", DEFAULT_DESCENDANT_SIZE_LIMIT) * 1000 * 40;
955 if (nMempoolSizeMax < 0 || nMempoolSizeMax < nMempoolSizeMin)
956 return InitError(
strprintf(
_(
"-maxmempool must be at least %d MB"), std::ceil(nMempoolSizeMin / 1000000.0)));
959 if (
IsArgSet(
"-incrementalrelayfee"))
977 int64_t nPruneArg =
GetArg(
"-prune", 0);
979 return InitError(
_(
"Prune cannot be configured with a negative value."));
982 if (nPruneArg == 1) {
983 LogPrintf(
"Block pruning enabled. Use RPC call pruneblockchain(height) to manually prune block and undo files.\n");
988 return InitError(
strprintf(
_(
"Prune configured below the minimum of %d MiB. Please use a higher number."), MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024));
990 LogPrintf(
"Prune configured to target %uMiB on disk for block and undo files.\n",
nPruneTarget / 1024 / 1024);
994 RegisterAllCoreRPCCommands(
tableRPC);
1046 #ifdef ENABLE_WALLET
1060 if (
GetBoolArg(
"-peerbloomfilters", DEFAULT_PEERBLOOMFILTERS))
1063 if (
GetArg(
"-rpcserialversion", DEFAULT_RPC_SERIALIZE_VERSION) < 0)
1064 return InitError(
"rpcserialversion must be non-negative.");
1066 if (
GetArg(
"-rpcserialversion", DEFAULT_RPC_SERIALIZE_VERSION) > 1)
1067 return InitError(
"unknown rpcserialversion requested.");
1074 std::string strReplacementModeList =
GetArg(
"-mempoolreplacement",
"");
1075 std::vector<std::string> vstrReplacementModes;
1076 boost::split(vstrReplacementModes, strReplacementModeList, boost::is_any_of(
","));
1077 fEnableReplacement = (std::find(vstrReplacementModes.begin(), vstrReplacementModes.end(),
"fee") != vstrReplacementModes.end());
1083 return InitError(
"BIP9 parameters may only be overridden on regtest.");
1085 const std::vector<std::string>& deployments =
mapMultiArgs.at(
"-bip9params");
1086 for (
auto i : deployments) {
1087 std::vector<std::string> vDeploymentParams;
1088 boost::split(vDeploymentParams, i, boost::is_any_of(
":"));
1089 if (vDeploymentParams.size() != 3) {
1090 return InitError(
"BIP9 parameters malformed, expecting deployment:start:end");
1092 int64_t nStartTime, nTimeout;
1093 if (!
ParseInt64(vDeploymentParams[1], &nStartTime)) {
1096 if (!
ParseInt64(vDeploymentParams[2], &nTimeout)) {
1105 LogPrintf(
"Setting BIP9 activation parameters for %s to start=%ld, timeout=%ld\n", vDeploymentParams[0], nStartTime, nTimeout);
1117 static bool LockDataDirectory(
bool probeOnly)
1119 std::string strDataDir =
GetDataDir().string();
1122 boost::filesystem::path pathLockFile =
GetDataDir() /
".lock";
1123 FILE* file = fopen(pathLockFile.string().c_str(),
"a");
1124 if (file) fclose(file);
1127 static boost::interprocess::file_lock lock(pathLockFile.string().c_str());
1128 if (!lock.try_lock()) {
1129 return InitError(
strprintf(
_(
"Cannot obtain a lock on data directory %s. %s is probably already running."), strDataDir,
_(PACKAGE_NAME)));
1134 }
catch(
const boost::interprocess::interprocess_exception& e) {
1135 return InitError(
strprintf(
_(
"Cannot obtain a lock on data directory %s. %s is probably already running.") +
" %s.", strDataDir,
_(PACKAGE_NAME), e.what()));
1150 return InitError(
strprintf(
_(
"Initialization sanity check failed. %s is shutting down."),
_(PACKAGE_NAME)));
1153 return LockDataDirectory(
true);
1163 if (!LockDataDirectory(
false)) {
1185 LogPrintf(
"Using at most %i automatic connections (%i file descriptors available)\n", nMaxConnections, nFD);
1197 threadGroup.create_thread(boost::bind(&TraceThread<CScheduler::Function>,
"scheduler", serviceLoop));
1208 return InitError(
_(
"Unable to start HTTP server. See debug log for details."));
1213 #if defined(USE_SSE2)
1214 scrypt_detect_sse2();
1218 #ifdef ENABLE_WALLET
1237 std::vector<std::string> uacomments;
1239 BOOST_FOREACH(std::string cmt,
mapMultiArgs.at(
"-uacomment"))
1242 return InitError(
strprintf(
_(
"User Agent comment (%s) contains unsafe characters."), cmt));
1243 uacomments.push_back(cmt);
1248 return InitError(
strprintf(
_(
"Total length of network version string (%i) exceeds maximum length (%i). Reduce the number or size of uacomments."),
1253 std::set<enum Network> nets;
1254 BOOST_FOREACH(
const std::string& snet,
mapMultiArgs.at(
"-onlynet")) {
1260 for (
int n = 0; n <
NET_MAX; n++) {
1262 if (!nets.count(net))
1268 BOOST_FOREACH(
const std::string& net,
mapMultiArgs.at(
"-whitelist")) {
1277 bool proxyRandomize =
GetBoolArg(
"-proxyrandomize", DEFAULT_PROXYRANDOMIZE);
1280 std::string proxyArg =
GetArg(
"-proxy",
"");
1282 if (proxyArg !=
"" && proxyArg !=
"0") {
1298 std::string onionArg =
GetArg(
"-onion",
"");
1299 if (onionArg !=
"") {
1300 if (onionArg ==
"0") {
1319 bool fBound =
false;
1321 BOOST_FOREACH(
const std::string& strBind,
mapMultiArgs.at(
"-bind")) {
1324 return InitError(ResolveErrMsg(
"bind", strBind));
1329 BOOST_FOREACH(
const std::string& strBind,
mapMultiArgs.at(
"-whitebind")) {
1331 if (!
Lookup(strBind.c_str(), addrBind, 0,
false))
1332 return InitError(ResolveErrMsg(
"whitebind", strBind));
1339 struct in_addr inaddr_any;
1340 inaddr_any.s_addr = INADDR_ANY;
1345 return InitError(
_(
"Failed to listen on any port. Use -listen=0 if you want this."));
1349 BOOST_FOREACH(
const std::string& strAddr,
mapMultiArgs.at(
"-externalip")) {
1354 return InitError(ResolveErrMsg(
"externalip", strAddr));
1359 BOOST_FOREACH(
const std::string& strDest,
mapMultiArgs.at(
"-seednode"))
1366 if (pzmqNotificationInterface) {
1370 uint64_t nMaxOutboundLimit = 0;
1371 uint64_t nMaxOutboundTimeframe = MAX_UPLOAD_TIMEFRAME;
1373 if (
IsArgSet(
"-maxuploadtarget")) {
1374 nMaxOutboundLimit =
GetArg(
"-maxuploadtarget", DEFAULT_MAX_UPLOAD_TARGET)*1024*1024;
1380 bool fReindexChainState =
GetBoolArg(
"-reindex-chainstate",
false);
1383 boost::filesystem::path blocksDir =
GetDataDir() /
"blocks";
1384 if (!boost::filesystem::exists(blocksDir))
1386 boost::filesystem::create_directories(blocksDir);
1387 bool linked =
false;
1388 for (
unsigned int i = 1; i < 10000; i++) {
1390 if (!boost::filesystem::exists(
source))
break;
1391 boost::filesystem::path dest = blocksDir /
strprintf(
"blk%05u.dat", i-1);
1393 boost::filesystem::create_hard_link(
source, dest);
1396 }
catch (
const boost::filesystem::filesystem_error& e) {
1399 LogPrintf(
"Error hardlinking blk%04u.dat: %s\n", i, e.what());
1410 int64_t nTotalCache = (
GetArg(
"-dbcache", nDefaultDbCache) << 20);
1411 nTotalCache = std::max(nTotalCache, nMinDbCache << 20);
1412 nTotalCache = std::min(nTotalCache, nMaxDbCache << 20);
1413 int64_t nBlockTreeDBCache = nTotalCache / 8;
1414 nBlockTreeDBCache = std::min(nBlockTreeDBCache, (
GetBoolArg(
"-txindex", DEFAULT_TXINDEX) ? nMaxBlockDBAndTxIndexCache : nMaxBlockDBCache) << 20);
1415 nTotalCache -= nBlockTreeDBCache;
1416 int64_t nCoinDBCache = std::min(nTotalCache / 2, (nTotalCache / 4) + (1 << 23));
1417 nCoinDBCache = std::min(nCoinDBCache, nMaxCoinsDBCache << 20);
1418 nTotalCache -= nCoinDBCache;
1420 int64_t nMempoolSizeMax =
GetArg(
"-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000;
1422 LogPrintf(
"* Using %.1fMiB for block index database\n", nBlockTreeDBCache * (1.0 / 1024 / 1024));
1423 LogPrintf(
"* Using %.1fMiB for chain state database\n", nCoinDBCache * (1.0 / 1024 / 1024));
1424 LogPrintf(
"* Using %.1fMiB for in-memory UTXO set (plus up to %.1fMiB of unused mempool space)\n",
nCoinCacheUsage * (1.0 / 1024 / 1024), nMempoolSizeMax * (1.0 / 1024 / 1024));
1426 bool fLoaded =
false;
1429 std::string strLoadError;
1438 delete pcoinsdbview;
1439 delete pcoinscatcher;
1455 strLoadError =
_(
"Error loading block database");
1462 return InitError(
_(
"Incorrect or no genesis block found. Wrong datadir for network?"));
1466 strLoadError =
_(
"Error initializing block database");
1472 strLoadError =
_(
"You need to rebuild the database using -reindex-chainstate to change -txindex");
1479 strLoadError =
_(
"You need to rebuild the database using -reindex to go back to unpruned mode. This will redownload the entire blockchain");
1486 strLoadError =
_(
"Unable to rewind the database to a pre-fork state. You will need to redownload the blockchain");
1492 if (
fHavePruned &&
GetArg(
"-checkblocks", DEFAULT_CHECKBLOCKS) > MIN_BLOCKS_TO_KEEP) {
1493 LogPrintf(
"Prune: pruned datadir may not have more than %d blocks; only checking available blocks",
1494 MIN_BLOCKS_TO_KEEP);
1502 strLoadError =
_(
"The block database contains a block which appears to be from the future. "
1503 "This may be due to your computer's date and time being set incorrectly. "
1504 "Only rebuild the block database if you are sure that your computer's date and time are correct");
1509 if (!
CVerifyDB().VerifyDB(chainparams, pcoinsdbview,
GetArg(
"-checklevel", DEFAULT_CHECKLEVEL),
1510 GetArg(
"-checkblocks", DEFAULT_CHECKBLOCKS))) {
1511 strLoadError =
_(
"Corrupted block database detected");
1514 }
catch (
const std::exception& e) {
1516 strLoadError =
_(
"Error opening block database");
1527 strLoadError +
".\n\n" +
_(
"Do you want to rebuild the block database now?"),
1528 strLoadError +
".\nPlease restart with -reindex or -reindex-chainstate to recover.",
1534 LogPrintf(
"Aborted block database rebuild. Exiting.\n");
1548 LogPrintf(
"Shutdown requested. Exiting.\n");
1553 boost::filesystem::path est_path =
GetDataDir() / FEE_ESTIMATES_FILENAME;
1554 CAutoFile est_filein(fopen(est_path.string().c_str(),
"rb"),
SER_DISK, CLIENT_VERSION);
1556 if (!est_filein.
IsNull())
1561 #ifdef ENABLE_WALLET
1565 LogPrintf(
"No wallet support compiled in!\n");
1573 LogPrintf(
"Unsetting NODE_NETWORK on prune mode\n");
1603 fHaveGenesis =
true;
1609 std::vector<boost::filesystem::path> vImportFiles;
1612 BOOST_FOREACH(
const std::string& strFile,
mapMultiArgs.at(
"-loadblock"))
1613 vImportFiles.push_back(strFile);
1616 threadGroup.create_thread(boost::bind(&
ThreadImport, vImportFiles));
1620 boost::unique_lock<boost::mutex> lock(cs_GenesisWait);
1621 while (!fHaveGenesis) {
1622 condvar_GenesisWait.wait(lock);
1632 if (
GetBoolArg(
"-listenonion", DEFAULT_LISTEN_ONION))
1640 std::string strNodeError;
1646 connOptions.
nMaxAddnode = MAX_ADDNODE_CONNECTIONS;
1656 if (!connman.
Start(scheduler, strNodeError, connOptions))
1666 #ifdef ENABLE_WALLET
const std::string CURRENCY_UNIT
int64_t CAmount
Amount in satoshis (Can be negative)
void RPCNotifyBlockChange(bool ibd, const CBlockIndex *pindex)
const CChainParams & Params()
Return the currently selected parameters.
void UpdateRegtestBIP9Parameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout)
Allows modifying the BIP9 regtest parameters.
const CBaseChainParams & BaseParams()
Return the currently selected parameters.
void AppendParamsHelpMessages(std::string &strUsage, bool debugHelp)
Append the help messages for the chainparams options to the parameter string.
Non-refcounted RAII wrapper for FILE*.
bool IsNull() const
Return true if the wrapped FILE* is NULL, false otherwise.
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,...
uint256 GetBlockHash() const
int nHeight
height of the entry in the chain. The genesis block has height 0
Access to the block database (blocks/index/)
bool WriteReindexing(bool fReindex)
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or NULL 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.
bool DefaultConsistencyChecks() const
Default value for -checkmempool and -checkblockindex argument.
std::string NetworkIDString() const
Return the BIP70 network string (main, test or regtest)
bool RequireStandard() const
Policy: Filter transactions that do not match well-defined patterns.
bool MineBlocksOnDemand() const
Make miner stop after a block is found.
const Consensus::Params & GetConsensus(uint32_t nTargetHeight) const
boost::signals2::signal< void(bool, const CBlockIndex *)> NotifyBlockTip
New block has been accepted.
boost::signals2::signal< bool(const std::string &message, const std::string &caption, unsigned int style), boost::signals2::last_value< bool > > ThreadSafeMessageBox
Show message box.
boost::signals2::signal< bool(const std::string &message, const std::string &noninteractive_message, const std::string &caption, unsigned int style), boost::signals2::last_value< bool > > ThreadSafeQuestion
If possible, ask the user a question.
boost::signals2::signal< void(const std::string &message)> InitMessage
Progress message during initialization.
Pruned version of CTransaction: only retains metadata and unspent transaction outputs.
CCoinsView backed by another CCoinsView.
bool GetCoins(const uint256 &txid, CCoins &coins) const
Retrieve the CCoins (unspent transaction outputs) for a given txid.
CCoinsView that adds a memory cache for transactions to another CCoinsView.
CCoinsView backed by the coin database (chainstate/)
This is a minimally invasive approach to shutdown on LevelDB read errors from the chainstate,...
bool GetCoins(const uint256 &txid, CCoins &coins) const
Retrieve the CCoins (unspent transaction outputs) for a given txid.
CCoinsViewErrorCatcher(CCoinsView *view)
Abstract view on the open txout dataset.
void AddWhitelistedRange(const CSubNet &subnet)
bool Start(CScheduler &scheduler, std::string &strNodeError, Options options)
bool BindListenPort(const CService &bindAddr, std::string &strError, bool fWhitelisted=false)
void AddOneShot(const std::string &strDest)
Wrapped boost mutex: supports recursive locking, but no waiting TODO: We should move away from using ...
Fee rate in satoshis per kilobyte: CAmount / kB.
std::string ToString() const
boost::function< void(void)> Function
A combination of a network address (CNetAddr) and a (TCP) port.
unsigned short GetPort() const
bool ReadFeeEstimates(CAutoFile &filein)
bool WriteFeeEstimates(CAutoFile &fileout) const
Write/Read estimates to disk.
void AddTransactionsUpdated(unsigned int n)
void setSanityCheck(double dFrequency=1.0)
Capture information about block/transaction validation.
RAII wrapper for VerifyDB: Verify consistency of the block and coin databases.
void postInitProcess(boost::thread_group &threadGroup)
Wallet post-init setup Gives the wallet a chance to register repetitive tasks and complete post-init ...
static bool ParameterInteraction()
static bool InitLoadWallet()
static std::string GetWalletHelpString(bool showDebug)
static CZMQNotificationInterface * Create()
Users of this module must hold an ECCVerifyHandle.
std::string GetHex() const
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 FormatFullVersion()
#define COPYRIGHT_YEAR
Copyright year (2009-this) Todo: update this when changing our copyright comments in the source.
const std::string CLIENT_NAME
bool glibcxx_sanity_test()
void Flush(bool shutdown=false)
Flush wallet (bitdb flush)
static bool Verify()
Verify the wallet database and perform salvage if required.
void InterruptHTTPRPC()
Interrupt HTTP RPC subsystem.
void StopHTTPRPC()
Stop HTTP RPC subsystem.
bool StartHTTPRPC()
Start HTTP RPC subsystem.
void StopREST()
Stop HTTP REST subsystem.
bool StartREST()
Start HTTP REST subsystem.
void InterruptREST()
Interrupt RPC REST subsystem.
void InterruptHTTPServer()
Interrupt HTTP server threads.
bool InitHTTPServer()
Initialize HTTP server.
bool StartHTTPServer()
Start HTTP server.
void StopHTTPServer()
Stop HTTP server.
void ThreadImport(std::vector< boost::filesystem::path > vImportFiles)
std::unique_ptr< CConnman > g_connman
bool AppInitMain(boost::thread_group &threadGroup, CScheduler &scheduler)
Bitcoin core main initialization.
BindFlags
Used to pass flags to the Bind() function.
#define MIN_CORE_FILEDESCRIPTORS
void InitParameterInteraction()
Parameter interaction: change current parameters depending on various rules.
std::string HelpMessage(HelpMessageMode mode)
Help for options shared between UI and daemon (for -help)
std::atomic< bool > fDumpMempoolLater(false)
bool fFeeEstimatesInitialized
bool AppInitServers(boost::thread_group &threadGroup)
void CleanupBlockRevFiles()
bool InitSanityCheck(void)
Sanity checks Ensure that Bitcoin is running in a usable environment with all necessary library suppo...
void OnRPCPreCommand(const CRPCCommand &cmd)
bool AppInitParameterInteraction()
Initialization: parameter interaction.
bool AppInitBasicSetup()
Initialize bitcoin core: Basic context setup.
bool AppInitSanityChecks()
Initialization sanity checks: ecc init, sanity checks, dir lock.
void InitLogging()
Initialize the logging infrastructure.
std::string LicenseInfo()
Returns licensing information (for -version)
std::atomic< bool > fRequestShutdown(false)
void HandleSIGTERM(int)
Signal handlers are very limited in what they are allowed to do, so:
void Interrupt(boost::thread_group &threadGroup)
Interrupt threads.
std::unique_ptr< PeerLogicValidation > peerLogic
HelpMessageMode
The help message mode determines what help message to show.
bool ECC_InitSanityCheck()
Check that required EC support is available at runtime.
void ECC_Start()
Initialize the elliptic curve support.
void ECC_Stop()
Deinitialize the elliptic curve support.
@ MAX_VERSION_BITS_DEPLOYMENTS
void OnStopped(boost::function< void()> slot)
void OnPreCommand(boost::function< void(const CRPCCommand &)> slot)
void OnStarted(boost::function< void()> slot)
void SetLimited(enum Network net, bool fLimited)
Make a particular network entirely off-limits (no automatic connects to it)
CNodeSignals & GetNodeSignals()
std::string strSubVersion
Subversion as sent to the P2P network in version messages.
void Discover(boost::thread_group &threadGroup)
bool IsLimited(enum Network net)
bool AddLocal(const CService &addr, int nScore)
unsigned short GetListenPort()
void UnregisterNodeSignals(CNodeSignals &nodeSignals)
Unregister a network node.
void RegisterNodeSignals(CNodeSignals &nodeSignals)
Register with a network node to receive its signals.
enum Network ParseNetwork(std::string net)
bool LookupSubNet(const char *pszName, CSubNet &ret)
bool Lookup(const char *pszName, std::vector< CService > &vAddr, int portDefault, bool fAllowLookup, unsigned int nMaxSolutions)
CService LookupNumeric(const char *pszName, int portDefault)
bool SetNameProxy(const proxyType &addrProxy)
bool SetProxy(enum Network net, const proxyType &addrProxy)
CFeeRate incrementalRelayFee
unsigned int nBytesPerSigOp
ServiceFlags
nServices flags
uint64_t GetRand(uint64_t nMax)
UniValue JSONRPCError(int code, const string &message)
@ RPC_FORBIDDEN_BY_SAFE_MODE
Server is in safe mode, and command is not allowed in safe mode.
void RegisterWalletRPCCommands(CRPCTable &t)
void SetRPCWarmupFinished()
void SetRPCWarmupStatus(const std::string &newStatus)
Set the RPC warmup status.
void InitSignatureCache()
unsigned nMaxDatacarrierBytes
unsigned int nReceiveFloodSize
uint64_t nMaxOutboundLimit
CClientUIInterface * uiInterface
uint64_t nMaxOutboundTimeframe
ServiceFlags nLocalServices
ServiceFlags nRelevantServices
unsigned int nSendBufferMaxSize
int64_t nTimeout
Timeout/expiry MedianTime for the deployment attempt.
uint256 defaultAssumeValid
BIP9Deployment vDeployments[MAX_VERSION_BITS_DEPLOYMENTS]
#define TRY_LOCK(cs, name)
boost::condition_variable CConditionVariable
Just a typedef for boost::condition_variable, can be wrapped later if desired.
int64_t GetAdjustedTime()
const std::string DEFAULT_TOR_CONTROL
Default control port.
void InterruptTorControl()
void StartTorControl(boost::thread_group &threadGroup, CScheduler &scheduler)
std::string AmountErrMsg(const char *const optname, const std::string &strValue)
bool InitError(const std::string &str)
Show error message.
CClientUIInterface uiInterface
void InitWarning(const std::string &str)
Show warning message.
uint256 uint256S(const char *str)
void CreatePidFile(const boost::filesystem::path &path, pid_t pid)
boost::filesystem::path GetConfigFile(const std::string &confPath)
std::string GetArg(const std::string &strArg, const std::string &strDefault)
Return string argument or default value.
std::string CopyrightHolders(const std::string &strPrefix)
bool GetBoolArg(const std::string &strArg, bool fDefault)
Return boolean argument or default value.
int RaiseFileDescriptorLimit(int nMinFD)
this function tries to raise the file descriptor limit to the requested number.
void RenameThread(const char *name)
boost::filesystem::path GetPidFile()
const char *const BITCOIN_PID_FILENAME
const map< string, vector< string > > & mapMultiArgs
void runCommand(const std::string &strCommand)
std::string HelpMessageGroup(const std::string &message)
Format a string to be used as group of options in help messages.
boost::filesystem::path GetDefaultDataDir()
const boost::filesystem::path & GetDataDir(bool fNetSpecific)
const char *const BITCOIN_CONF_FILENAME
bool SoftSetBoolArg(const std::string &strArg, bool fValue)
Set a boolean argument if it doesn't already have a value.
bool IsArgSet(const std::string &strArg)
Return true if the given argument has been manually set.
bool RenameOver(boost::filesystem::path src, boost::filesystem::path dest)
int GetNumCores()
Return the number of physical cores available on the current system.
std::string HelpMessageOpt(const std::string &option, const std::string &message)
Format a string to be used as option description in help messages.
std::atomic< bool > fReopenDebugLog
#define LogPrint(category,...)
std::string _(const char *psz)
Translation function: Call Translate signal on UI interface, which returns a boost::optional result.
std::string FormatMoney(const CAmount &n)
Money parsing/formatting utilities.
bool ParseMoney(const string &str, CAmount &nRet)
string SanitizeString(const string &str, int rule)
int atoi(const std::string &str)
bool ParseInt64(const std::string &str, int64_t *out)
Convert string to signed 64-bit integer with strict parse error feedback.
#define PAIRTYPE(t1, t2)
This is needed because the foreach macro can't get over the comma in pair<t1, t2>
@ SAFE_CHARS_UA_COMMENT
BIP-0014 subset.
int64_t GetTime()
GetTimeMicros() and GetTimeMillis() both return the system time, but in different units.
std::string DateTimeStrFormat(const char *pszFormat, int64_t nTime)
void SetMockTime(int64_t nMockTimeIn)
CBlockTreeDB * pblocktree
Global variable that points to the active block tree (protected by cs_main)
uint256 hashAssumeValid
Block hash whose ancestors we will assume to have valid scripts without checking them.
void FlushStateToDisk()
Flush all state, indexes and buffers to disk.
FILE * OpenBlockFile(const CDiskBlockPos &pos, bool fReadOnly)
Open a block file (blk?????.dat)
uint64_t nPruneTarget
Number of MiB of block files that we're trying to stay below.
CCoinsViewCache * pcoinsTip
Global variable that points to the active CCoinsView (protected by cs_main)
CCriticalSection cs_main
Global state.
bool RewindBlockIndex(const CChainParams ¶ms)
When there are blocks in the active chain with missing data, rewind the chainstate and remove them fr...
boost::filesystem::path GetBlockPosFilename(const CDiskBlockPos &pos, const char *prefix)
Translation to a filesystem path.
bool fHavePruned
Pruning-related variables and constants.
CTxMemPool mempool(::minRelayTxFee)
CFeeRate minRelayTxFee
A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation)
void DumpMempool(void)
Dump the mempool to disk.
bool CheckDiskSpace(uint64_t nAdditionalBytes)
Check whether enough disk space is available for an incoming block.
void ThreadScriptCheck()
Run an instance of the script checking thread.
bool ActivateBestChain(CValidationState &state, const CChainParams &chainparams, std::shared_ptr< const CBlock > pblock)
Make the best chain active, in multiple steps.
bool InitBlockIndex(const CChainParams &chainparams)
Initialize a new block tree database + block data on disk.
bool fPruneMode
True if we're running in -prune mode.
bool LoadBlockIndex(const CChainParams &chainparams)
Load the block tree and coins database from disk.
void UnloadBlockIndex()
Unload database information.
CChain chainActive
The currently-connected chain of blocks (protected by cs_main).
CConditionVariable cvBlockChange
bool LoadMempool(void)
Load the mempool from disk.
bool LoadExternalBlockFile(const CChainParams &chainparams, FILE *fileIn, CDiskBlockPos *dbp)
Import blocks from an external file.
int64_t nMaxTipAge
If the tip is older than this (in seconds), the node is considered to be in initial block download.
void PruneAndFlush()
Prune block files and flush state to disk.
std::atomic_bool fImporting
std::string GetWarnings(const std::string &strFor)
Format a string that describes several potential problems detected by the core.
void UnregisterValidationInterface(CValidationInterface *pwalletIn)
Unregister a wallet from core.
void UnregisterAllValidationInterfaces()
Unregister all wallets from core.
void RegisterValidationInterface(CValidationInterface *pwalletIn)
Register a wallet to receive updates from core.
const struct BIP9DeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION_BITS_DEPLOYMENTS]