7 #if defined(HAVE_CONFIG_H) 64 #include <boost/algorithm/string/classification.hpp> 65 #include <boost/algorithm/string/replace.hpp> 66 #include <boost/algorithm/string/split.hpp> 67 #include <boost/bind.hpp> 68 #include <boost/interprocess/sync/file_lock.hpp> 69 #include <boost/thread.hpp> 70 #include <openssl/crypto.h> 77 static const bool DEFAULT_PROXYRANDOMIZE =
true;
78 static const bool DEFAULT_REST_ENABLE =
false;
79 static const bool DEFAULT_STOPAFTERBLOCKIMPORT =
false;
92 #define MIN_CORE_FILEDESCRIPTORS 0 94 #define MIN_CORE_FILEDESCRIPTORS 150 97 static const char* FEE_ESTIMATES_FILENAME=
"fee_estimates.dat";
153 }
catch(
const std::runtime_error& e) {
155 LogPrintf(
"Error reading from database: %s\n", e.what());
167 static std::unique_ptr<ECCVerifyHandle> globalVerifyHandle;
178 threadGroup.interrupt_all();
184 LogPrintf(
"%s: In progress...\n", __func__);
186 TRY_LOCK(cs_Shutdown, lockShutdown);
222 fs::path est_path =
GetDataDir() / FEE_ESTIMATES_FILENAME;
224 if (!est_fileout.
IsNull())
227 LogPrintf(
"%s: Failed to write fee estimates to %s\n", __func__, est_path.string());
254 delete pcoinscatcher;
255 pcoinscatcher =
nullptr;
309 if (pzmqNotificationInterface) {
311 delete pzmqNotificationInterface;
312 pzmqNotificationInterface =
nullptr;
319 }
catch (
const fs::filesystem_error& e) {
320 LogPrintf(
"%s: Unable to remove pidfile: %s\n", __func__, e.what());
347 globalVerifyHandle.reset();
357 static void HandleSIGTERM(
int)
362 static void HandleSIGHUP(
int)
368 static void registerSignalHandler(
int signal,
void(*
handler)(
int))
372 sigemptyset(&sa.sa_mask);
374 sigaction(signal, &sa,
nullptr);
402 strUsage +=
HelpMessageOpt(
"-?",
_(
"Print this help message and exit"));
404 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)"));
405 strUsage +=
HelpMessageOpt(
"-blocknotify=<cmd>",
_(
"Execute command when the best block changes (%s in cmd is replaced by block hash)"));
407 strUsage +=
HelpMessageOpt(
"-blocksonly",
strprintf(
_(
"Whether to operate in a blocks only mode (default: %u)"), DEFAULT_BLOCKSONLY));
408 strUsage +=
HelpMessageOpt(
"-assumevalid=<hex>",
strprintf(
_(
"If this block is in the chain assume that it and its ancestors are valid and potentially skip their script verification (0 to verify all, default: %s, testnet: %s)"), defaultChainParams->GetConsensus().defaultAssumeValid.GetHex(), testnetChainParams->GetConsensus().defaultAssumeValid.GetHex()));
413 strUsage +=
HelpMessageOpt(
"-daemon",
_(
"Run in the background as a daemon and accept commands"));
416 strUsage +=
HelpMessageOpt(
"-datadir=<dir>",
_(
"Specify data directory"));
418 strUsage +=
HelpMessageOpt(
"-dbbatchsize",
strprintf(
"Maximum database write batch size in bytes (default: %u)", nDefaultDbBatchSize));
420 strUsage +=
HelpMessageOpt(
"-dbcache=<n>",
strprintf(
_(
"Set database cache size in megabytes (%d to %d, default: %d)"), nMinDbCache, nMaxDbCache, nDefaultDbCache));
421 strUsage +=
HelpMessageOpt(
"-disablemessaging",
strprintf(
_(
"Turn off the databasing the messages sent with assets (default: %u)"),
false));
423 strUsage +=
HelpMessageOpt(
"-feefilter",
strprintf(
"Tell other nodes to filter invs to us by our mempool min fee (default: %u)", DEFAULT_FEEFILTER));
424 strUsage +=
HelpMessageOpt(
"-loadblock=<file>",
_(
"Imports blocks from external blk000??.dat file on startup"));
425 strUsage +=
HelpMessageOpt(
"-maxreorg=<n>",
strprintf(
_(
"Set the Maximum reorg depth (default: %u)"), defaultChainParams->MaxReorganizationDepth()));
426 strUsage +=
HelpMessageOpt(
"-minreorgpeers=<n>",
strprintf(
_(
"Set the Minimum amount of peers required to disallow reorg of chains of depth >= maxreorg. Peers must be greater than. (default: %u)"), defaultChainParams->MinReorganizationPeers()));
427 strUsage +=
HelpMessageOpt(
"-minreorgage=<n>",
strprintf(
_(
"Set the Minimum tip age (in seconds) required to allow reorg of a chain of depth >= maxreorg on a node with more than minreorgpeers peers. (default: %u)"), defaultChainParams->MinReorganizationAge()));
428 strUsage +=
HelpMessageOpt(
"-maxorphantx=<n>",
strprintf(
_(
"Keep at most <n> unconnectable transactions in memory (default: %u)"), DEFAULT_MAX_ORPHAN_TRANSACTIONS));
429 strUsage +=
HelpMessageOpt(
"-maxmempool=<n>",
strprintf(
_(
"Keep the transaction memory pool below <n> megabytes (default: %u)"), DEFAULT_MAX_MEMPOOL_SIZE));
430 strUsage +=
HelpMessageOpt(
"-mempoolexpiry=<n>",
strprintf(
_(
"Do not keep transactions in the mempool longer than <n> hours (default: %u)"), DEFAULT_MEMPOOL_EXPIRY));
432 strUsage +=
HelpMessageOpt(
"-minimumchainwork=<hex>",
strprintf(
"Minimum work assumed to exist on a valid chain in hex (default: %s, testnet: %s)", defaultChainParams->GetConsensus().nMinimumChainWork.GetHex(), testnetChainParams->GetConsensus().nMinimumChainWork.GetHex()));
434 strUsage +=
HelpMessageOpt(
"-persistmempool",
strprintf(
_(
"Whether to save the mempool on shutdown and load on restart (default: %u)"), DEFAULT_PERSIST_MEMPOOL));
435 strUsage +=
HelpMessageOpt(
"-blockreconstructionextratxn=<n>",
strprintf(
_(
"Extra transactions to keep in memory for compact block reconstructions (default: %u)"), DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN));
436 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)"),
437 -
GetNumCores(), MAX_SCRIPTCHECK_THREADS, DEFAULT_SCRIPTCHECK_THREADS));
441 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. " 442 "Warning: Reverting this setting requires re-downloading the entire blockchain. " 443 "(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));
444 strUsage +=
HelpMessageOpt(
"-reindex-chainstate",
_(
"Rebuild chain state from the currently indexed blocks"));
445 strUsage +=
HelpMessageOpt(
"-reindex",
_(
"Rebuild chain state and block index from the blk*.dat files on disk"));
447 strUsage +=
HelpMessageOpt(
"-sysperms",
_(
"Create new files with system default permissions, instead of umask 077 (only effective with disabled wallet functionality)"));
449 strUsage +=
HelpMessageOpt(
"-txindex",
strprintf(
_(
"Maintain a full transaction index, used by the getrawtransaction rpc call (default: %u)"), DEFAULT_TXINDEX));
451 strUsage +=
HelpMessageOpt(
"-addressindex",
strprintf(
_(
"Maintain a full address index, used to query for the balance, txids and unspent outputs for addresses (default: %u)"), DEFAULT_ADDRESSINDEX));
452 strUsage +=
HelpMessageOpt(
"-timestampindex",
strprintf(
_(
"Maintain a timestamp index for block hashes, used to query blocks hashes by a range of timestamps (default: %u)"), DEFAULT_TIMESTAMPINDEX));
453 strUsage +=
HelpMessageOpt(
"-spentindex",
strprintf(
_(
"Maintain a full spent index, used to query the spending txid and input index for an outpoint (default: %u)"), DEFAULT_SPENTINDEX));
456 strUsage +=
HelpMessageOpt(
"-addnode=<ip>",
_(
"Add a node to connect to and attempt to keep the connection open (see the `addnode` RPC command help for more info)"));
457 strUsage +=
HelpMessageOpt(
"-banscore=<n>",
strprintf(
_(
"Threshold for disconnecting misbehaving peers (default: %u)"), DEFAULT_BANSCORE_THRESHOLD));
458 strUsage +=
HelpMessageOpt(
"-bantime=<n>",
strprintf(
_(
"Number of seconds to keep misbehaving peers from reconnecting (default: %u)"), DEFAULT_MISBEHAVING_BANTIME));
459 strUsage +=
HelpMessageOpt(
"-bind=<addr>",
_(
"Bind to given address and always listen on it. Use [host]:port notation for IPv6"));
460 strUsage +=
HelpMessageOpt(
"-connect=<ip>",
_(
"Connect only to the specified node(s); -connect=0 disables automatic connections (the rules for this peer are the same as for -addnode)"));
461 strUsage +=
HelpMessageOpt(
"-discover",
_(
"Discover own IP addresses (default: 1 when listening and no -externalip or -proxy)"));
462 strUsage +=
HelpMessageOpt(
"-dns",
_(
"Allow DNS lookups for -addnode, -seednode and -connect") +
" " +
strprintf(
_(
"(default: %u)"), DEFAULT_NAME_LOOKUP));
463 strUsage +=
HelpMessageOpt(
"-dnsseed",
_(
"Query for peer addresses via DNS lookup, if low on addresses (default: 1 unless -connect used)"));
464 strUsage +=
HelpMessageOpt(
"-externalip=<ip>",
_(
"Specify your own public address"));
465 strUsage +=
HelpMessageOpt(
"-forcednsseed",
strprintf(
_(
"Always query for peer addresses via DNS lookup (default: %u)"), DEFAULT_FORCEDNSSEED));
466 strUsage +=
HelpMessageOpt(
"-listen",
_(
"Accept connections from outside (default: 1 if no -proxy or -connect)"));
467 strUsage +=
HelpMessageOpt(
"-listenonion",
strprintf(
_(
"Automatically create Tor hidden service (default: %d)"), DEFAULT_LISTEN_ONION));
468 strUsage +=
HelpMessageOpt(
"-maxconnections=<n>",
strprintf(
_(
"Maintain at most <n> connections to peers (default: %u)"), DEFAULT_MAX_PEER_CONNECTIONS));
469 strUsage +=
HelpMessageOpt(
"-maxreceivebuffer=<n>",
strprintf(
_(
"Maximum per-connection receive buffer, <n>*1000 bytes (default: %u)"), DEFAULT_MAXRECEIVEBUFFER));
470 strUsage +=
HelpMessageOpt(
"-maxsendbuffer=<n>",
strprintf(
_(
"Maximum per-connection send buffer, <n>*1000 bytes (default: %u)"), DEFAULT_MAXSENDBUFFER));
471 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));
472 strUsage +=
HelpMessageOpt(
"-onion=<ip:port>",
strprintf(
_(
"Use separate SOCKS5 proxy to reach peers via Tor hidden services (default: %s)"),
"-proxy"));
473 strUsage +=
HelpMessageOpt(
"-onlynet=<net>",
_(
"Only connect to nodes in network <net> (ipv4, ipv6 or onion)"));
474 strUsage +=
HelpMessageOpt(
"-permitbaremultisig",
strprintf(
_(
"Relay non-P2SH multisig (default: %u)"), DEFAULT_PERMIT_BAREMULTISIG));
475 strUsage +=
HelpMessageOpt(
"-peerbloomfilters",
strprintf(
_(
"Support filtering of blocks and transaction with bloom filters (default: %u)"), DEFAULT_PEERBLOOMFILTERS));
476 strUsage +=
HelpMessageOpt(
"-port=<port>",
strprintf(
_(
"Listen for connections on <port> (default: %u or testnet: %u)"), defaultChainParams->GetDefaultPort(), testnetChainParams->GetDefaultPort()));
477 strUsage +=
HelpMessageOpt(
"-proxy=<ip:port>",
_(
"Connect through SOCKS5 proxy"));
478 strUsage +=
HelpMessageOpt(
"-proxyrandomize",
strprintf(
_(
"Randomize credentials for every proxy connection. This enables Tor stream isolation (default: %u)"), DEFAULT_PROXYRANDOMIZE));
479 strUsage +=
HelpMessageOpt(
"-seednode=<ip>",
_(
"Connect to a node to retrieve peer addresses, and disconnect"));
480 strUsage +=
HelpMessageOpt(
"-timeout=<n>",
strprintf(
_(
"Specify connection timeout in milliseconds (minimum: 1, default: %d)"), DEFAULT_CONNECT_TIMEOUT));
482 strUsage +=
HelpMessageOpt(
"-torpassword=<pass>",
_(
"Tor control port password (default: empty)"));
485 strUsage +=
HelpMessageOpt(
"-upnp",
_(
"Use UPnP to map the listening port (default: 1 when listening and no -proxy)"));
490 strUsage +=
HelpMessageOpt(
"-whitebind=<addr>",
_(
"Bind to given address and whitelist peers connecting to it. Use [host]:port notation for IPv6"));
491 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.") +
492 " " +
_(
"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"));
493 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));
501 strUsage +=
HelpMessageOpt(
"-zmqpubhashblock=<address>",
_(
"Enable publish hash block in <address>"));
502 strUsage +=
HelpMessageOpt(
"-zmqpubhashtx=<address>",
_(
"Enable publish hash transaction in <address>"));
503 strUsage +=
HelpMessageOpt(
"-zmqpubrawblock=<address>",
_(
"Enable publish raw block in <address>"));
504 strUsage +=
HelpMessageOpt(
"-zmqpubrawtx=<address>",
_(
"Enable publish raw transaction in <address>"));
505 strUsage +=
HelpMessageOpt(
"-zmqpubrawmessage=<address>",
_(
"Enable publish raw asset messages in <address>"));
509 strUsage +=
HelpMessageOpt(
"-uacomment=<cmt>",
_(
"Append comment to the user agent string"));
512 strUsage +=
HelpMessageOpt(
"-checkblocks=<n>",
strprintf(
_(
"How many blocks to check at startup (default: %u, 0 = all)"), DEFAULT_CHECKBLOCKS));
513 strUsage +=
HelpMessageOpt(
"-checklevel=<n>",
strprintf(
_(
"How thorough the block verification of -checkblocks is (0-4, default: %u)"), DEFAULT_CHECKLEVEL));
514 strUsage +=
HelpMessageOpt(
"-checkblockindex",
strprintf(
"Do a full consistency check for mapBlockIndex, setBlockIndexCandidates, chainActive and mapBlocksUnlinked occasionally. Also sets -checkmempool (default: %u)", defaultChainParams->DefaultConsistencyChecks()));
515 strUsage +=
HelpMessageOpt(
"-checkmempool=<n>",
strprintf(
"Run checks every <n> transactions (default: %u)", defaultChainParams->DefaultConsistencyChecks()));
516 strUsage +=
HelpMessageOpt(
"-checkpoints",
strprintf(
"Disable expensive verification for known chain history (default: %u)", DEFAULT_CHECKPOINTS_ENABLED));
517 strUsage +=
HelpMessageOpt(
"-disablesafemode",
strprintf(
"Disable safemode, override a real safe mode event (default: %u)", DEFAULT_DISABLE_SAFEMODE));
518 strUsage +=
HelpMessageOpt(
"-deprecatedrpc=<method>",
"Allows deprecated RPC method(s) to be used");
520 strUsage +=
HelpMessageOpt(
"-dropmessagestest=<n>",
"Randomly drop 1 of every <n> network messages");
521 strUsage +=
HelpMessageOpt(
"-fuzzmessagestest=<n>",
"Randomly fuzz 1 of every <n> network messages");
522 strUsage +=
HelpMessageOpt(
"-stopafterblockimport",
strprintf(
"Stop running after importing blocks from disk (default: %u)", DEFAULT_STOPAFTERBLOCKIMPORT));
523 strUsage +=
HelpMessageOpt(
"-stopatheight",
strprintf(
"Stop running after reaching the given height in the main chain (default: %u)", DEFAULT_STOPATHEIGHT));
525 strUsage +=
HelpMessageOpt(
"-limitancestorcount=<n>",
strprintf(
"Do not accept transactions if number of in-mempool ancestors is <n> or more (default: %u)", DEFAULT_ANCESTOR_LIMIT));
526 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));
527 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));
528 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));
529 strUsage +=
HelpMessageOpt(
"-vbparams=deployment:start:end",
"Use given start/end times for specified version bits deployment (regtest-only)");
531 strUsage +=
HelpMessageOpt(
"-debug=<category>",
strprintf(
_(
"Output debugging information (default: %u, supplying <category> is optional)"), 0) +
". " +
532 _(
"If <category> is not supplied or if <category> = 1, output all debugging information.") +
" " +
_(
"<category> can be:") +
" " +
ListLogCategories() +
".");
533 strUsage +=
HelpMessageOpt(
"-debugexclude=<category>",
strprintf(
_(
"Exclude debugging information for a category. Can be used in conjunction with -debug=1 to output debug logs for all categories except one or more specified categories.")));
534 strUsage +=
HelpMessageOpt(
"-help-debug",
_(
"Show all debugging options (usage: --help -help-debug)"));
535 strUsage +=
HelpMessageOpt(
"-logips",
strprintf(
_(
"Include IP addresses in debug output (default: %u)"), DEFAULT_LOGIPS));
536 strUsage +=
HelpMessageOpt(
"-logtimestamps",
strprintf(
_(
"Prepend debug output with timestamp (default: %u)"), DEFAULT_LOGTIMESTAMPS));
539 strUsage +=
HelpMessageOpt(
"-logtimemicros",
strprintf(
"Add microsecond precision to debug timestamps (default: %u)", DEFAULT_LOGTIMEMICROS));
540 strUsage +=
HelpMessageOpt(
"-mocktime=<n>",
"Replace actual time with <n> seconds since epoch (default: 0)");
541 strUsage +=
HelpMessageOpt(
"-maxsigcachesize=<n>",
strprintf(
"Limit sum of signature cache and script execution cache sizes to <n> MiB (default: %u)", DEFAULT_MAX_SIG_CACHE_SIZE));
542 strUsage +=
HelpMessageOpt(
"-maxtipage=<n>",
strprintf(
"Maximum tip age in seconds to consider node in initial block download (default: %u)", DEFAULT_MAX_TIP_AGE));
544 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)"),
546 strUsage +=
HelpMessageOpt(
"-printtoconsole",
_(
"Send trace/debug info to console instead of debug.log file"));
549 strUsage +=
HelpMessageOpt(
"-printpriority",
strprintf(
"Log transaction fee per kB when mining blocks (default: %u)", DEFAULT_PRINTPRIORITY));
551 strUsage +=
HelpMessageOpt(
"-shrinkdebugfile",
_(
"Shrink debug.log file on client startup (default: 1 when no -debug)"));
557 strUsage +=
HelpMessageOpt(
"-acceptnonstdtxn",
strprintf(
"Relay and mine \"non-standard\" transactions (%sdefault: %u)",
"testnet/regtest only; ", !testnetChainParams->RequireStandard()));
558 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)));
559 strUsage +=
HelpMessageOpt(
"-dustrelayfee=<amt>",
strprintf(
"Fee rate (in %s/kB) used to defined dust, the value of an output such that it will cost more than its value in fees at this fee rate to spend it. (default: %s)",
CURRENCY_UNIT,
FormatMoney(DUST_RELAY_TX_FEE)));
561 strUsage +=
HelpMessageOpt(
"-bytespersigop",
strprintf(
_(
"Equivalent bytes per sigop in transactions for relay and mining (default: %u)"), DEFAULT_BYTES_PER_SIGOP));
562 strUsage +=
HelpMessageOpt(
"-datacarrier",
strprintf(
_(
"Relay and mine data carrier transactions (default: %u)"), DEFAULT_ACCEPT_DATACARRIER));
563 strUsage +=
HelpMessageOpt(
"-datacarriersize",
strprintf(
_(
"Maximum size of data in data carrier transactions we relay and mine (default: %u)"), MAX_OP_RETURN_RELAY));
564 strUsage +=
HelpMessageOpt(
"-mempoolreplacement",
strprintf(
_(
"Enable transaction replacement in the memory pool (default: %u)"), DEFAULT_ENABLE_REPLACEMENT));
565 strUsage +=
HelpMessageOpt(
"-minrelaytxfee=<amt>",
strprintf(
_(
"Fees (in %s/kB) smaller than this are considered zero fee for relaying, mining and transaction creation (default: %s)"),
567 strUsage +=
HelpMessageOpt(
"-whitelistrelay",
strprintf(
_(
"Accept relayed transactions received from whitelisted peers even when not relaying transactions (default: %d)"), DEFAULT_WHITELISTRELAY));
568 strUsage +=
HelpMessageOpt(
"-whitelistforcerelay",
strprintf(
_(
"Force relay of transactions from whitelisted peers even if they violate local relay policy (default: %d)"), DEFAULT_WHITELISTFORCERELAY));
571 strUsage +=
HelpMessageOpt(
"-blockmaxweight=<n>",
strprintf(
_(
"Set maximum BIP141 block weight (default: %d)"), MAX_BLOCK_WEIGHT - 4000));
572 strUsage +=
HelpMessageOpt(
"-blockmaxsize=<n>",
_(
"Set maximum BIP141 block weight to this * 4. Deprecated, use blockmaxweight"));
575 strUsage +=
HelpMessageOpt(
"-blockversion=<n>",
"Override block version to test forking scenarios");
578 strUsage +=
HelpMessageOpt(
"-server",
_(
"Accept command line and JSON-RPC commands"));
579 strUsage +=
HelpMessageOpt(
"-rest",
strprintf(
_(
"Accept public REST requests (default: %u)"), DEFAULT_REST_ENABLE));
580 strUsage +=
HelpMessageOpt(
"-rpcbind=<addr>[:port]",
_(
"Bind to given address to listen for JSON-RPC connections. This option is ignored unless -rpcallowip is also passed. Port is optional and overrides -rpcport. Use [host]:port notation for IPv6. This option can be specified multiple times (default: 127.0.0.1 and ::1 i.e., localhost, or if -rpcallowip has been specified, 0.0.0.0 and :: i.e., all addresses)"));
581 strUsage +=
HelpMessageOpt(
"-rpccookiefile=<loc>",
_(
"Location of the auth cookie (default: data dir)"));
582 strUsage +=
HelpMessageOpt(
"-rpcuser=<user>",
_(
"Username for JSON-RPC connections"));
583 strUsage +=
HelpMessageOpt(
"-rpcpassword=<pw>",
_(
"Password for JSON-RPC connections"));
584 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"));
585 strUsage +=
HelpMessageOpt(
"-rpcport=<port>",
strprintf(
_(
"Listen for JSON-RPC connections on <port> (default: %u or testnet: %u)"), defaultBaseParams->RPCPort(), testnetBaseParams->RPCPort()));
586 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"));
587 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));
588 strUsage +=
HelpMessageOpt(
"-rpcthreads=<n>",
strprintf(
_(
"Set the number of threads to service RPC calls (default: %d)"), DEFAULT_HTTP_THREADS));
590 strUsage +=
HelpMessageOpt(
"-rpcworkqueue=<n>",
strprintf(
"Set the depth of the work queue to service RPC calls (default: %d)", DEFAULT_HTTP_WORKQUEUE));
591 strUsage +=
HelpMessageOpt(
"-rpcservertimeout=<n>",
strprintf(
"Timeout during HTTP requests (default: %d)", DEFAULT_HTTP_SERVER_TIMEOUT));
599 const std::string URL_SOURCE_CODE =
"<https://github.com/RavenProject/Ravencoin>";
600 const std::string URL_WEBSITE =
"<https://ravencoin.org>";
604 strprintf(
_(
"Please contribute if you find %s useful. " 605 "Visit %s for further information about the software."),
608 strprintf(
_(
"The source code is available from %s."),
612 _(
"This is experimental software.") +
"\n" +
613 strprintf(
_(
"Distributed under the MIT software license, see the accompanying file %s or %s"),
"COPYING",
"<https://opensource.org/licenses/MIT>") +
"\n" +
615 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."),
"<https://www.openssl.org>") +
619 static void BlockNotifyCallback(
bool initialSync,
const CBlockIndex *pBlockIndex)
621 if (initialSync || !pBlockIndex)
624 std::string strCmd =
gArgs.
GetArg(
"-blocknotify",
"");
625 if (!strCmd.empty()) {
631 static bool fHaveGenesis =
false;
632 static boost::mutex cs_GenesisWait;
635 static void BlockNotifyGenesisWait(
bool,
const CBlockIndex *pBlockIndex)
637 if (pBlockIndex !=
nullptr) {
639 boost::unique_lock<boost::mutex> lock_GenesisWait(cs_GenesisWait);
642 condvar_GenesisWait.notify_all();
668 std::map<std::string, fs::path> mapBlockFiles;
673 LogPrintf(
"Removing unusable blk?????.dat and rev?????.dat files for -reindex with -prune\n");
675 for (fs::directory_iterator it(blocksdir); it != fs::directory_iterator(); it++) {
676 if (fs::is_regular_file(*it) &&
677 it->path().filename().string().length() == 12 &&
678 it->path().filename().string().substr(8,4) ==
".dat")
680 if (it->path().filename().string().substr(0,3) ==
"blk")
681 mapBlockFiles[it->path().filename().string().substr(3,5)] = it->path();
682 else if (it->path().filename().string().substr(0,3) ==
"rev")
691 int nContigCounter = 0;
692 for (
const std::pair<std::string, fs::path>& item : mapBlockFiles) {
693 if (
atoi(item.first) == nContigCounter) {
719 LogPrintf(
"Reindexing block file blk%05u.dat...\n", (
unsigned int)nFile);
731 fs::path pathBootstrap =
GetDataDir() /
"bootstrap.dat";
732 if (fs::exists(pathBootstrap)) {
735 fs::path pathBootstrapOld =
GetDataDir() /
"bootstrap.dat.old";
736 LogPrintf(
"Importing bootstrap.dat...\n");
740 LogPrintf(
"Warning: Could not open bootstrap file %s\n", pathBootstrap.string());
745 for (
const fs::path& path : vImportFiles) {
748 LogPrintf(
"Importing blocks file %s...\n", path.string());
751 LogPrintf(
"Warning: Could not open blocks file %s\n", path.string());
758 LogPrintf(
"Failed to connect best block");
762 if (
gArgs.
GetBoolArg(
"-stopafterblockimport", DEFAULT_STOPAFTERBLOCKIMPORT)) {
763 LogPrintf(
"Stopping after block import\n");
767 if (
gArgs.
GetArg(
"-persistmempool", DEFAULT_PERSIST_MEMPOOL)) {
780 InitError(
"Elliptic curve cryptography sanity check failure. Aborting.");
788 InitError(
"OS cryptographic RNG sanity check failure. Aborting.");
819 LogPrintf(
"%s: parameter interaction: -bind set -> setting -listen=1\n", __func__);
823 LogPrintf(
"%s: parameter interaction: -whitebind set -> setting -listen=1\n", __func__);
829 LogPrintf(
"%s: parameter interaction: -connect set -> setting -dnsseed=0\n", __func__);
831 LogPrintf(
"%s: parameter interaction: -connect set -> setting -listen=0\n", __func__);
837 LogPrintf(
"%s: parameter interaction: -proxy set -> setting -listen=0\n", __func__);
841 LogPrintf(
"%s: parameter interaction: -proxy set -> setting -upnp=0\n", __func__);
844 LogPrintf(
"%s: parameter interaction: -proxy set -> setting -discover=0\n", __func__);
850 LogPrintf(
"%s: parameter interaction: -listen=0 -> setting -upnp=0\n", __func__);
852 LogPrintf(
"%s: parameter interaction: -listen=0 -> setting -discover=0\n", __func__);
854 LogPrintf(
"%s: parameter interaction: -listen=0 -> setting -listenonion=0\n", __func__);
860 LogPrintf(
"%s: parameter interaction: -externalip set -> setting -discover=0\n", __func__);
866 LogPrintf(
"%s: parameter interaction: -blocksonly=1 -> setting -whitelistrelay=0\n", __func__);
870 if (
gArgs.
GetBoolArg(
"-whitelistforcerelay", DEFAULT_WHITELISTFORCERELAY)) {
872 LogPrintf(
"%s: parameter interaction: -whitelistforcerelay=1 -> setting -whitelistrelay=1\n", __func__);
876 unsigned int max_size =
gArgs.
GetArg(
"-blockmaxsize", 0);
878 LogPrintf(
"%s: parameter interaction: -blockmaxsize=%d -> setting -blockmaxweight=%d (-blockmaxsize is deprecated!)\n", __func__, max_size, max_size * WITNESS_SCALE_FACTOR);
880 LogPrintf(
"%s: Ignoring blockmaxsize setting which is overridden by blockmaxweight", __func__);
885 static std::string ResolveErrMsg(
const char *
const optname,
const std::string& strBind)
887 return strprintf(
_(
"Cannot resolve -%s address: '%s'"), optname, strBind);
897 LogPrintf(
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
904 int nUserMaxConnections;
910 [[noreturn]]
static void new_handler_terminate()
916 std::set_new_handler(std::terminate);
917 LogPrintf(
"Error: Out of memory. Terminating.\n");
928 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
929 _CrtSetReportFile(_CRT_WARN, CreateFileA(
"NUL", GENERIC_WRITE, 0,
nullptr, OPEN_EXISTING, 0, 0));
931 _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
937 #ifndef PROCESS_DEP_ENABLE 940 #define PROCESS_DEP_ENABLE 0x00000001 942 typedef BOOL (WINAPI *PSETPROCDEPPOL)(DWORD);
943 PSETPROCDEPPOL setProcDEPPol = (PSETPROCDEPPOL)GetProcAddress(GetModuleHandleA(
"Kernel32.dll"),
"SetProcessDEPPolicy");
944 if (setProcDEPPol !=
nullptr) setProcDEPPol(PROCESS_DEP_ENABLE);
948 return InitError(
"Initializing networking failed");
956 registerSignalHandler(SIGTERM, HandleSIGTERM);
957 registerSignalHandler(SIGINT, HandleSIGTERM);
960 registerSignalHandler(SIGHUP, HandleSIGHUP);
963 signal(SIGPIPE, SIG_IGN);
966 std::set_new_handler(new_handler_terminate);
981 return InitError(
_(
"Prune mode is incompatible with -txindex."));
987 return InitError(
"Cannot set -bind or -whitebind together with -listen=0");
991 int nBind = std::max(nUserBind,
size_t(1));
992 nUserMaxConnections =
gArgs.
GetArg(
"-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS);
993 nMaxConnections = std::max(nUserMaxConnections, 0);
996 nMaxConnections = std::max(std::min(nMaxConnections, (
int)(FD_SETSIZE - nBind -
MIN_CORE_FILEDESCRIPTORS - MAX_ADDNODE_CONNECTIONS)), 0);
999 return InitError(
_(
"Not enough file descriptors available."));
1002 if (nMaxConnections < nUserMaxConnections)
1003 InitWarning(
strprintf(
_(
"Reducing -maxconnections from %d to %d, because of system limitations."), nUserMaxConnections, nMaxConnections));
1008 const std::vector<std::string> categories =
gArgs.
GetArgs(
"-debug");
1010 if (find(categories.begin(), categories.end(), std::string(
"0")) == categories.end()) {
1011 for (
const auto& cat : categories) {
1023 for (
const std::string& cat :
gArgs.
GetArgs(
"-debugexclude")) {
1034 InitWarning(
_(
"Unsupported argument -debugnet ignored, use -debug=net."));
1037 return InitError(
_(
"Unsupported argument -socks found. Setting SOCKS version isn't possible anymore, only SOCKS5 proxies are supported."));
1040 return InitError(
_(
"Unsupported argument -tor found, use -onion."));
1043 InitWarning(
_(
"Unsupported argument -benchmark ignored, use -debug=bench."));
1046 InitWarning(
_(
"Unsupported argument -whitelistalwaysrelay ignored, use -whitelistrelay and/or -whitelistforcerelay."));
1049 InitWarning(
"Unsupported argument -blockminsize ignored.");
1063 LogPrintf(
"Validating signatures for all blocks.\n");
1066 const std::string minChainWorkStr =
gArgs.
GetArg(
"-minimumchainwork",
"");
1068 return InitError(
strprintf(
"Invalid non-hex (%s) minimum chain work value specified", minChainWorkStr));
1080 int64_t nMempoolSizeMax =
gArgs.
GetArg(
"-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000;
1081 int64_t nMempoolSizeMin =
gArgs.
GetArg(
"-limitdescendantsize", DEFAULT_DESCENDANT_SIZE_LIMIT) * 1000 * 40;
1082 if (nMempoolSizeMax < 0 || nMempoolSizeMax < nMempoolSizeMin)
1083 return InitError(
strprintf(
_(
"-maxmempool must be at least %d MB"), std::ceil(nMempoolSizeMin / 1000000.0)));
1105 if (nPruneArg < 0) {
1106 return InitError(
_(
"Prune cannot be configured with a negative value."));
1109 if (nPruneArg == 1) {
1110 LogPrintf(
"Block pruning enabled. Use RPC call pruneblockchain(height) to manually prune block and undo files.\n");
1115 return InitError(
strprintf(
_(
"Prune configured below the minimum of %d MiB. Please use a higher number."), MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024));
1117 LogPrintf(
"Prune configured to target %uMiB on disk for block and undo files.\n",
nPruneTarget / 1024 / 1024);
1121 RegisterAllCoreRPCCommands(
tableRPC);
1122 #ifdef ENABLE_WALLET 1167 #ifdef ENABLE_WALLET 1182 if (
gArgs.
GetArg(
"-rpcserialversion", DEFAULT_RPC_SERIALIZE_VERSION) < 0)
1183 return InitError(
"rpcserialversion must be non-negative.");
1185 if (
gArgs.
GetArg(
"-rpcserialversion", DEFAULT_RPC_SERIALIZE_VERSION) > 1)
1186 return InitError(
"unknown rpcserialversion requested.");
1193 std::string strReplacementModeList =
gArgs.
GetArg(
"-mempoolreplacement",
"");
1194 std::vector<std::string> vstrReplacementModes;
1195 boost::split(vstrReplacementModes, strReplacementModeList, boost::is_any_of(
","));
1196 fEnableReplacement = (std::find(vstrReplacementModes.begin(), vstrReplacementModes.end(),
"fee") != vstrReplacementModes.end());
1202 return InitError(
"Version bits parameters may only be overridden on regtest.");
1204 for (
const std::string& strDeployment :
gArgs.
GetArgs(
"-vbparams")) {
1205 std::vector<std::string> vDeploymentParams;
1206 boost::split(vDeploymentParams, strDeployment, boost::is_any_of(
":"));
1207 if (vDeploymentParams.size() != 3) {
1208 return InitError(
"Version bits parameters malformed, expecting deployment:start:end");
1210 int64_t nStartTime, nTimeout;
1211 if (!
ParseInt64(vDeploymentParams[1], &nStartTime)) {
1214 if (!
ParseInt64(vDeploymentParams[2], &nTimeout)) {
1223 LogPrintf(
"Setting version bits activation parameters for %s to start=%ld, timeout=%ld\n", vDeploymentParams[0], nStartTime, nTimeout);
1235 static bool LockDataDirectory(
bool probeOnly)
1237 std::string strDataDir =
GetDataDir().string();
1240 fs::path pathLockFile =
GetDataDir() /
".lock";
1242 if (file) fclose(file);
1245 static boost::interprocess::file_lock lock(pathLockFile.string().c_str());
1246 if (!lock.try_lock()) {
1252 }
catch(
const boost::interprocess::interprocess_exception& e) {
1253 return InitError(
strprintf(
_(
"Cannot obtain a lock on data directory %s. %s is probably already running.") +
" %s.", strDataDir,
_(
PACKAGE_NAME), e.what()));
1264 LogPrintf(
"Using the '%s' SHA256 implementation\n", sha256_algo);
1276 return LockDataDirectory(
true);
1284 if (!LockDataDirectory(
false)) {
1312 LogPrintf(
"Using at most %i automatic connections (%i file descriptors available)\n", nMaxConnections, nFD);
1325 threadGroup.create_thread(boost::bind(&TraceThread<CScheduler::Function>,
"scheduler", serviceLoop));
1338 return InitError(
_(
"Unable to start HTTP server. See debug log for details."));
1344 #ifdef ENABLE_WALLET 1349 bool fGenerate =
gArgs.
GetBoolArg(
"-regtest",
false) ? false : DEFAULT_GENERATE;
1367 std::vector<std::string> uacomments;
1368 for (
const std::string& cmt :
gArgs.
GetArgs(
"-uacomment")) {
1370 return InitError(
strprintf(
_(
"User Agent comment (%s) contains unsafe characters."), cmt));
1371 uacomments.push_back(cmt);
1375 return InitError(
strprintf(
_(
"Total length of network version string (%i) exceeds maximum length (%i). Reduce the number or size of uacomments."),
1380 std::set<enum Network> nets;
1381 for (
const std::string& snet :
gArgs.
GetArgs(
"-onlynet")) {
1387 for (
int n = 0; n <
NET_MAX; n++) {
1389 if (!nets.count(net))
1397 bool proxyRandomize =
gArgs.
GetBoolArg(
"-proxyrandomize", DEFAULT_PROXYRANDOMIZE);
1400 std::string proxyArg =
gArgs.
GetArg(
"-proxy",
"");
1402 if (proxyArg !=
"" && proxyArg !=
"0") {
1422 std::string onionArg =
gArgs.
GetArg(
"-onion",
"");
1423 if (onionArg !=
"") {
1424 if (onionArg ==
"0") {
1444 for (
const std::string& strAddr :
gArgs.
GetArgs(
"-externalip")) {
1449 return InitError(ResolveErrMsg(
"externalip", strAddr));
1455 if (pzmqNotificationInterface) {
1459 uint64_t nMaxOutboundLimit = 0;
1460 uint64_t nMaxOutboundTimeframe = MAX_UPLOAD_TIMEFRAME;
1463 nMaxOutboundLimit =
gArgs.
GetArg(
"-maxuploadtarget", DEFAULT_MAX_UPLOAD_TARGET)*1024*1024;
1469 bool fReindexChainState =
gArgs.
GetBoolArg(
"-reindex-chainstate",
false);
1472 size_t dbMaxFileSize =
gArgs.
GetArg(
"-dbmaxfilesize", DEFAULT_DB_MAX_FILE_SIZE) << 20;
1474 LogPrintf(
"Block index database configuration:\n");
1475 LogPrintf(
"* Using %d MB files\n", (dbMaxFileSize / 1024 / 1024));
1478 int64_t nTotalCache = (
gArgs.
GetArg(
"-dbcache", nDefaultDbCache) << 20);
1479 nTotalCache = std::max(nTotalCache, nMinDbCache << 20);
1480 nTotalCache = std::min(nTotalCache, nMaxDbCache << 20);
1481 int64_t nBlockTreeDBCache = nTotalCache / 8;
1482 nBlockTreeDBCache = std::min(nBlockTreeDBCache, (
gArgs.
GetBoolArg(
"-txindex", DEFAULT_TXINDEX) ? nMaxBlockDBAndTxIndexCache : nMaxBlockDBCache) << 20);
1483 nTotalCache -= nBlockTreeDBCache;
1484 int64_t nCoinDBCache = std::min(nTotalCache / 2, (nTotalCache / 4) + (1 << 23));
1485 nCoinDBCache = std::min(nCoinDBCache, nMaxCoinsDBCache << 20);
1486 nTotalCache -= nCoinDBCache;
1488 int64_t nMempoolSizeMax =
gArgs.
GetArg(
"-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000;
1490 LogPrintf(
"* Using %.1fMiB for block index database\n", nBlockTreeDBCache * (1.0 / 1024 / 1024));
1491 LogPrintf(
"* Using %.1fMiB for chain state database\n", nCoinDBCache * (1.0 / 1024 / 1024));
1492 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));
1494 bool fLoaded =
false;
1497 std::string strLoadError;
1507 delete pcoinscatcher;
1557 strLoadError =
_(
"Failed to load Assets Database");
1563 "Database failed to load last Reissued Mempool State. Will have to start from empty state");
1565 LogPrintf(
"Loaded Assets from database without error\nCache of assets size: %d\n",
1593 strLoadError =
_(
"Error loading block database");
1600 return InitError(
_(
"Incorrect or no genesis block found. Wrong datadir for network?"));
1604 strLoadError =
_(
"You need to rebuild the database using -reindex to change -txindex");
1610 strLoadError =
_(
"You need to rebuild the database using -reindex to change -assetIndex");
1616 strLoadError =
_(
"You need to rebuild the database using -reindex-chainstate to change -addressindex");
1622 strLoadError =
_(
"You need to rebuild the database using -reindex-chainstate to change -spentindex");
1628 strLoadError =
_(
"You need to rebuild the database using -reindex-chainstate to change -timestampindex");
1635 strLoadError =
_(
"You need to rebuild the database using -reindex to go back to unpruned mode. This will redownload the entire blockchain");
1644 strLoadError =
_(
"Error initializing block database");
1657 strLoadError =
_(
"Error upgrading chainstate database");
1663 strLoadError =
_(
"Unable to replay blocks. You will need to rebuild the database using -reindex-chainstate.");
1671 if (!is_coinsview_empty) {
1674 strLoadError =
_(
"Error initializing block database");
1686 strLoadError =
_(
"Unable to rewind the database to a pre-fork state. You will need to redownload the blockchain");
1691 if (!is_coinsview_empty) {
1694 LogPrintf(
"Prune: pruned datadir may not have more than %d blocks; only checking available blocks",
1695 MIN_BLOCKS_TO_KEEP);
1703 strLoadError =
_(
"The block database contains a block which appears to be from the future. " 1704 "This may be due to your computer's date and time being set incorrectly. " 1705 "Only rebuild the block database if you are sure that your computer's date and time are correct");
1711 gArgs.
GetArg(
"-checkblocks", DEFAULT_CHECKBLOCKS))) {
1712 strLoadError =
_(
"Corrupted block database detected");
1716 }
catch (
const std::exception& e) {
1718 strLoadError =
_(
"Error opening block database");
1729 strLoadError +
".\n\n" +
_(
"Do you want to rebuild the block database now?"),
1730 strLoadError +
".\nPlease restart with -reindex or -reindex-chainstate to recover.",
1736 LogPrintf(
"Aborted block database rebuild. Exiting.\n");
1750 LogPrintf(
"Shutdown requested. Exiting.\n");
1757 fs::path est_path =
GetDataDir() / FEE_ESTIMATES_FILENAME;
1760 if (!est_filein.
IsNull())
1765 #ifdef ENABLE_WALLET 1769 LogPrintf(
"No wallet support compiled in!\n");
1777 LogPrintf(
"Unsetting NODE_NETWORK on prune mode\n");
1798 fHaveGenesis =
true;
1804 std::vector<fs::path> vImportFiles;
1805 for (
const std::string& strFile :
gArgs.
GetArgs(
"-loadblock")) {
1806 vImportFiles.push_back(strFile);
1809 threadGroup.create_thread(boost::bind(&
ThreadImport, vImportFiles));
1813 boost::unique_lock<boost::mutex> lock(cs_GenesisWait);
1814 while (!fHaveGenesis) {
1815 condvar_GenesisWait.wait(lock);
1822 int chain_active_height;
1830 LogPrintf(
"nBestHeight = %d\n", chain_active_height);
1842 connOptions.nMaxConnections = nMaxConnections;
1843 connOptions.nMaxOutbound = std::min(MAX_OUTBOUND_CONNECTIONS, connOptions.nMaxConnections);
1844 connOptions.nMaxAddnode = MAX_ADDNODE_CONNECTIONS;
1845 connOptions.nMaxFeeler = 1;
1846 connOptions.nBestHeight = chain_active_height;
1848 connOptions.m_msgproc =
peerLogic.get();
1849 connOptions.nSendBufferMaxSize = 1000*
gArgs.
GetArg(
"-maxsendbuffer", DEFAULT_MAXSENDBUFFER);
1850 connOptions.nReceiveFloodSize = 1000*
gArgs.
GetArg(
"-maxreceivebuffer", DEFAULT_MAXRECEIVEBUFFER);
1853 connOptions.nMaxOutboundTimeframe = nMaxOutboundTimeframe;
1854 connOptions.nMaxOutboundLimit = nMaxOutboundLimit;
1856 for (
const std::string& strBind :
gArgs.
GetArgs(
"-bind")) {
1859 return InitError(ResolveErrMsg(
"bind", strBind));
1861 connOptions.vBinds.push_back(addrBind);
1863 for (
const std::string& strBind :
gArgs.
GetArgs(
"-whitebind")) {
1865 if (!
Lookup(strBind.c_str(), addrBind, 0,
false)) {
1866 return InitError(ResolveErrMsg(
"whitebind", strBind));
1868 if (addrBind.
GetPort() == 0) {
1871 connOptions.vWhiteBinds.push_back(addrBind);
1879 connOptions.vWhitelistedRange.push_back(subnet);
1885 connOptions.m_use_addrman_outgoing = !
gArgs.
IsArgSet(
"-connect");
1886 if (!connOptions.m_use_addrman_outgoing) {
1888 if (connect.size() != 1 || connect[0] !=
"0") {
1889 connOptions.m_specified_outgoing = connect;
1892 if (!connman.Start(scheduler, connOptions)) {
1903 #ifdef ENABLE_WALLET 1912 std::string strLoadError;
bool GetCoin(const COutPoint &outpoint, Coin &coin) const override
Retrieve the Coin (unspent transaction output) for a given outpoint.
void CleanupBlockRevFiles()
void RandomInit()
Initialize the RNG.
std::string HelpMessageOpt(const std::string &option, const std::string &message)
Format a string to be used as option description in help messages.
std::string NetworkIDString() const
Return the BIP70 network string (main, test or regtest)
bool(* handler)(HTTPRequest *req, const std::string &strReq)
void ECC_Start()
Initialize the elliptic curve support.
unsigned short GetPort() const
std::unique_ptr< CBaseChainParams > CreateBaseChainParams(const std::string &chain)
Creates and returns a std::unique_ptr<CBaseChainParams> of the chosen chain.
void AppendParamsHelpMessages(std::string &strUsage, bool debugHelp)
Append the help messages for the chainparams options to the parameter string.
std::string ListLogCategories()
Returns a string with the log categories.
bool IsHexNumber(const std::string &str)
Return true if the string is a hex number, optionally prefixed with "0x".
bool IsArgSet(const std::string &strArg) const
Return true if the given argument has been manually set.
const char *const RAVEN_CONF_FILENAME
bool fPruneMode
True if we're running in -prune mode.
boost::condition_variable CConditionVariable
Just a typedef for boost::condition_variable, can be wrapped later if desired.
bool DumpMempool(void)
Dump the mempool to disk.
ServiceFlags
nServices flags
bool StartHTTPServer()
Start HTTP server.
void UnloadBlockIndex()
Unload database information.
bool Upgrade()
Attempt to update from an older database format. Returns whether an error occurred.
void InitLogging()
Initialize the logging infrastructure.
bool AddLocal(const CService &addr, int nScore)
FILE * fopen(const fs::path &p, const char *mode)
#define TRY_LOCK(cs, name)
bool SoftSetBoolArg(const std::string &strArg, bool fValue)
Set a boolean argument if it doesn't already have a value.
CLRUCache< std::string, int8_t > * passetsQualifierCache
Global variable that points to the asset address qualifier LRU Cache (protected by cs_main) ...
void SetRPCWarmupStatus(const std::string &newStatus)
Set the RPC warmup status.
HelpMessageMode
The help message mode determines what help message to show.
bool LoadGenesisBlock(const CChainParams &chainparams)
Ensures we have a genesis block in the block tree, possibly writing one to disk.
bool fHavePruned
Pruning-related variables and constants.
CRestrictedDB * prestricteddb
Global variable that points to the active restricted asset database (protected by cs_main) ...
std::atomic< bool > fRequestShutdown(false)
std::string DateTimeStrFormat(const char *pszFormat, int64_t nTime)
bool Write(CAutoFile &fileout) const
Write estimation data to a file.
bool ReadFlag(const std::string &name, bool &fValue)
int Height() const
Return the maximal height in the chain.
void SetMockTime(int64_t nMockTimeIn)
CMessageChannelDB * pmessagechanneldb
Global variable that points to the message channel database (protected by cs_main) ...
bool StartHTTPRPC()
Start HTTP RPC subsystem.
CCriticalSection cs_main
Global state.
bool OpenWallets()
Load wallet databases.
bool fAcceptDatacarrier
A data carrying output is an unspendable output containing data.
void CloseWallets()
Close all wallets.
void StopREST()
Stop HTTP REST subsystem.
const struct VBDeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION_BITS_DEPLOYMENTS]
void OnStopped(std::function< void()> slot)
void SetLimited(enum Network net, bool fLimited)
Make a particular network entirely off-limits (no automatic connects to it)
void UnregisterBackgroundSignalScheduler()
Unregister a CScheduler to give callbacks which should run in the background - these callbacks will n...
arith_uint256 nMinimumChainWork
Minimum work we will assume exists on some valid chain.
bool DefaultConsistencyChecks() const
Default value for -checkmempool and -checkblockindex argument.
const std::string CURRENCY_UNIT
CChainParams defines various tweakable parameters of a given instance of the Raven system...
void UnregisterAllValidationInterfaces()
Unregister all wallets from core.
std::string GetWalletHelpString(bool showDebug)
Return the wallets help message.
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
unsigned short GetListenPort()
void UnregisterValidationInterface(CValidationInterface *pwalletIn)
Unregister a wallet from core.
std::string SHA256AutoDetect()
Autodetect the best available SHA256 implementation.
std::atomic< uint32_t > logCategories
void InterruptHTTPRPC()
Interrupt HTTP RPC subsystem.
bool AppInitBasicSetup()
Initialize raven core: Basic context setup.
void StopWallets()
Stop all wallets. Wallets will be flushed first.
CAssetsDB * passetsdb
RVN START.
void ThreadImport(std::vector< fs::path > vImportFiles)
unsigned int nBytesPerSigOp
std::string LicenseInfo()
Returns licensing information (for -version)
void InterruptHTTPServer()
Interrupt HTTP server threads.
uint64_t nPruneTarget
Number of MiB of block files that we're trying to stay below.
bool SetNameProxy(const proxyType &addrProxy)
bool SoftSetArg(const std::string &strArg, const std::string &strValue)
Set an argument if it doesn't already have a value.
void PrepareShutdown()
Preparing steps before shutting down or restarting the wallet.
void RenameThread(const char *name)
CLRUCache< std::string, int > * pMessageSubscribedChannelsCache
Global variable that points to the subscribed channel LRU Cache (protected by cs_main) ...
bool WriteReindexing(bool fReindexing)
bool ActivateBestChain(CValidationState &state, const CChainParams &chainparams, std::shared_ptr< const CBlock > pblock)
Make the best chain active, in multiple steps.
std::string HelpMessage(HelpMessageMode mode)
Help for options shared between UI and daemon (for -help)
bool IsNull() const
Return true if the wrapped FILE* is nullptr, false otherwise.
bool StartREST()
Start HTTP REST subsystem.
int GenerateRavens(bool fGenerate, int nThreads, const CChainParams &chainparams)
arith_uint256 UintToArith256(const uint256 &a)
CLRUCache< std::string, int8_t > * passetsRestrictionCache
Global variable that points to the asset address restriction LRU Cache (protected by cs_main) ...
CCoinsViewErrorCatcher(CCoinsView *view)
static const std::string MAIN
BIP70 chain name strings (main, test or regtest)
int RaiseFileDescriptorLimit(int nMinFD)
this function tries to raise the file descriptor limit to the requested number.
int64_t CAmount
Amount in corbies (Can be negative)
void InitParameterInteraction()
Parameter interaction: change current parameters depending on various rules.
uint256 GetBlockHash() const
void SetRPCWarmupFinished()
boost::signals2::signal< void(bool, const CBlockIndex *)> NotifyBlockTip
New block has been accepted.
CLRUCache< std::string, CMessage > * pMessagesCache
Global variable that points to the subscribed channel LRU Cache (protected by cs_main) ...
CBlockPolicyEstimator feeEstimator
bool CheckDiskSpace(uint64_t nAdditionalBytes)
Check whether enough disk space is available for an incoming block.
bool ParseInt64(const std::string &str, int64_t *out)
Convert string to signed 64-bit integer with strict parse error feedback.
CCoinsViewCache * pcoinsTip
Global variable that points to the active CCoinsView (protected by cs_main)
void setSanityCheck(double dFrequency=1.0)
bool InitHTTPServer()
Initialize HTTP server.
Users of this module must hold an ECCVerifyHandle.
bool AppInitSanityChecks()
Initialization sanity checks: ecc init, sanity checks, dir lock.
bool ReplayBlocks(const CChainParams ¶ms, CCoinsView *view)
Replay blocks that aren't fully applied to the database.
enum Network ParseNetwork(std::string net)
FILE * OpenBlockFile(const CDiskBlockPos &pos, bool fReadOnly)
Open a block file (blk?????.dat)
static CZMQNotificationInterface * Create()
CLRUCache< std::string, CNullAssetTxVerifierString > * passetsVerifierCache
Global variable that points to the asset verifier LRU Cache (protected by cs_main) ...
const std::string DEFAULT_TOR_CONTROL
Default control port.
bool MineBlocksOnDemand() const
Make miner stop after a block is found.
Access to the block database (blocks/index/)
void StopHTTPServer()
Stop HTTP server.
Abstract view on the open txout dataset.
CFeeRate minRelayTxFee
A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation) ...
std::unique_ptr< CChainParams > CreateChainParams(const std::string &chain)
Creates and returns a std::unique_ptr<CChainParams> of the chosen chain.
void RegisterWalletRPC(CRPCTable &t)
Register wallet RPCs.
void Interrupt(boost::thread_group &threadGroup)
Interrupt threads.
void ECC_Stop()
Deinitialize the elliptic curve support.
CMessageDB * pmessagedb
Global variable that points to the messages database (protected by cs_main)
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.
void FlushUnconfirmed(CTxMemPool &pool)
Empty mempool transactions on shutdown to record failure to confirm for txs still in mempool...
A combination of a network address (CNetAddr) and a (TCP) port.
bool WriteFlag(const std::string &name, bool fValue)
uint256 uint256S(const char *str)
RAII wrapper for VerifyDB: Verify consistency of the block and coin databases.
std::function< void(void)> Function
void InitSignatureCache()
void Shutdown()
Shutdown is split into 2 parts: Part 1: shut down everything but the main wallet instance (done in Pr...
CMainSignals & GetMainSignals()
bool ParseMoney(const std::string &str, CAmount &nRet)
CChain chainActive
The currently-connected chain of blocks (protected by cs_main).
std::atomic_bool fImporting
bool WalletParameterInteraction()
Wallets parameter interaction.
void ThreadScriptCheck()
Run an instance of the script checking thread.
An outpoint - a combination of a transaction hash and an index n into its vout.
const std::string CLIENT_NAME
std::string strSubVersion
Subversion as sent to the P2P network in version messages.
void AddTransactionsUpdated(unsigned int n)
bool RenameOver(fs::path src, fs::path dest)
CLRUCache< std::string, int8_t > * passetsGlobalRestrictionCache
Global variable that points to the global asset restriction LRU Cache (protected by cs_main) ...
std::string FormatMoney(const CAmount &n)
Money parsing/formatting utilities.
int64_t nMaxTipAge
If the tip is older than this (in seconds), the node is considered to be in initial block download...
std::string FormatFullVersion()
std::string CopyrightHolders(const std::string &strPrefix)
fs::path GetDefaultDataDir()
void FlushStateToDisk()
Flush all state, indexes and buffers to disk.
bool ReadFlag(const std::string &name, bool &fValue)
uint256 hashAssumeValid
Block hash whose ancestors we will assume to have valid scripts without checking them.
bool LookupSubNet(const char *pszName, CSubNet &ret)
bool SetProxy(enum Network net, const proxyType &addrProxy)
std::atomic< bool > fDumpMempoolLater(false)
void RegisterValidationInterface(CValidationInterface *pwalletIn)
Register a wallet to receive updates from core.
bool LoadBlockIndex(const CChainParams &chainparams)
Load the block tree and coins database from disk, initializing state if we're running with -reindex...
void StopHTTPRPC()
Stop HTTP RPC subsystem.
bool AppInitParameterInteraction()
Initialization: parameter interaction.
uint256 GetBestBlock() const override
Retrieve the block hash whose state this CCoinsView currently represents.
#define MAX_CACHE_ASSETS_SIZE
#define LogPrint(category,...)
std::atomic_bool fReindex
void RegisterBackgroundSignalScheduler(CScheduler &scheduler)
Register a CScheduler to give callbacks which should run in the background (may only be called once) ...
bool glibcxx_sanity_test()
bool LoadExternalBlockFile(const CChainParams &chainparams, FILE *fileIn, CDiskBlockPos *dbp)
Import blocks from an external file.
CAssetsCache * passets
Global variable that point to the active assets (protected by cs_main)
bool fFeeEstimatesInitialized
uint256 nMinimumChainWork
bool RequireStandard() const
Policy: Filter transactions that do not match well-defined patterns.
bool InitError(const std::string &str)
Show error message.
std::atomic< bool > fReopenDebugLog
uint256 defaultAssumeValid
bool ScanForMessageChannels(std::string &strError)
The block chain is a tree shaped structure starting with the genesis block at the root...
const CChainParams & Params()
Return the currently selected parameters.
fs::path GetConfigFile(const std::string &confPath)
void FlushBackgroundCallbacks()
Call any remaining callbacks on the calling thread.
CCoinsView backed by the coin database (chainstate/)
void UpdateVersionBitsParameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout)
Allows modifying the Version Bits regtest parameters.
void InitScriptExecutionCache()
Initializes the script-execution cache.
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
bool Read(CAutoFile &filein)
Read estimation data from a file.
ServiceFlags nLocalServices
void InterruptREST()
Interrupt RPC REST subsystem.
int64_t GetAdjustedTime()
void runCommand(const std::string &strCommand)
bool LoadMempool(void)
Load the mempool from disk.
bool Lookup(const char *pszName, std::vector< CService > &vAddr, int portDefault, bool fAllowLookup, unsigned int nMaxSolutions)
bool GetCoin(const COutPoint &outpoint, Coin &coin) const override
Retrieve the Coin (unspent transaction output) for a given outpoint.
void StartTorControl(boost::thread_group &threadGroup, CScheduler &scheduler)
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or nullptr if none.
std::string FormatSubVersion(const std::string &name, int nClientVersion, const std::vector< std::string > &comments)
Format the subversion field according to BIP 14 spec (https://github.com/raven/bips/blob/master/bip-0...
bool AppInitServers(boost::thread_group &threadGroup)
std::string GetHex() const
bool ReadReissuedMempoolState()
Fee rate in satoshis per kilobyte: CAmount / kB.
std::unique_ptr< CConnman > g_connman
void FlushWallets()
Flush all wallets in preparation for shutdown.
void Discover(boost::thread_group &threadGroup)
bool InitSanityCheck(void)
Sanity checks Ensure that Raven is running in a usable environment with all necessary library support...
std::unique_ptr< PeerLogicValidation > peerLogic
CBlockTreeDB * pblocktree
Global variable that points to the active block tree (protected by cs_main)
boost::signals2::signal< bool(const std::string &message, const std::string &caption, unsigned int style), boost::signals2::last_value< bool > > ThreadSafeMessageBox
Show message box.
static const std::string TESTNET
void RPCNotifyBlockChange(bool ibd, const CBlockIndex *pindex)
Callback for when block tip changed.
const fs::path & GetDataDir(bool fNetSpecific)
void CreatePidFile(const fs::path &path, pid_t pid)
const char *const RAVEN_PID_FILENAME
void InterruptTorControl()
void OnStarted(std::function< void()> slot)
void StartWallets(CScheduler &scheduler)
Complete startup of wallets.
std::string GetHex() const
bool AppInitLockDataDirectory()
Lock raven core data directory.
int64_t GetTime()
GetTimeMicros() and GetTimeMillis() both return the system time, but in different units...
std::string ToString() const
void InitWarning(const std::string &str)
Show warning message.
CClientUIInterface uiInterface
bool AppInitMain(boost::thread_group &threadGroup, CScheduler &scheduler)
Raven core main initialization.
CLRUCache< std::string, CDatabasedAssetData > * passetsCache
Global variable that point to the assets metadata LRU Cache (protected by cs_main) ...
CCoinsView backed by another CCoinsView.
int GetNumCores()
Return the number of physical cores available on the current system.
bool ECC_InitSanityCheck()
Check that required EC support is available at runtime.
const Consensus::Params & GetConsensus() const
bool VerifyWallets()
Responsible for reading and validating the -wallet arguments and verifying the wallet database...
CCoinsViewDB * pcoinsdbview
Global variable that points to the coins database (protected by cs_main)
CCoinsView that adds a memory cache for transactions to another CCoinsView.
void PruneAndFlush()
Prune block files and flush state to disk.
std::vector< std::string > GetArgs(const std::string &strArg) const
Return a vector of strings of the given argument.
#define MIN_CORE_FILEDESCRIPTORS
bool GetLogCategory(uint32_t *f, const std::string *str)
Return true if str parses as a log category and set the flags in f.
std::string AmountErrMsg(const char *const optname, const std::string &strValue)
std::string SanitizeString(const std::string &str, int rule)
Remove unsafe chars.
fs::path GetBlockPosFilename(const CDiskBlockPos &pos, const char *prefix)
Translation to a filesystem path.
This is a minimally invasive approach to shutdown on LevelDB read errors from the chainstate...
bool RewindBlockIndex(const CChainParams ¶ms)
When there are blocks in the active chain with missing data, rewind the chainstate and remove them fr...
bool Random_SanityCheck()
Check that OS randomness is available and returning the requested number of bytes.
CFeeRate incrementalRelayFee
std::atomic< bool > fRequestRestart(false)
std::string HelpMessageGroup(const std::string &message)
Format a string to be used as group of options in help messages.
Access to the block database (blocks/index/)
unsigned nMaxDatacarrierBytes
Maximum size of TX_NULL_DATA scripts that this node considers standard.
bool LoadChainTip(const CChainParams &chainparams)
Update the chain tip based on database information.
Non-refcounted RAII wrapper for FILE*.
CLRUCache< std::string, int > * pMessagesSeenAddressCache
Global variable that points to the address seen LRU Cache (protected by cs_main)
std::string _(const char *psz)
Translation function: Call Translate signal on UI interface, which returns a boost::optional result...
Wrapped boost mutex: supports recursive locking, but no waiting TODO: We should move away from using ...
int atoi(const std::string &str)
boost::signals2::signal< void(const std::string &message)> InitMessage
Progress message during initialization.
uint64_t GetRand(uint64_t nMax)
CConditionVariable cvBlockChange