6 #if defined(HAVE_CONFIG_H) 57 #include <boost/algorithm/string/classification.hpp> 58 #include <boost/algorithm/string/replace.hpp> 59 #include <boost/algorithm/string/split.hpp> 60 #include <boost/bind.hpp> 61 #include <boost/interprocess/sync/file_lock.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 91 static const char* FEE_ESTIMATES_FILENAME=
"fee_estimates.dat";
143 }
catch(
const std::runtime_error&
e) {
145 LogPrintf(
"Error reading from database: %s\n", e.what());
157 static std::unique_ptr<ECCVerifyHandle> globalVerifyHandle;
168 threadGroup.interrupt_all();
173 LogPrintf(
"%s: In progress...\n", __func__);
175 TRY_LOCK(cs_Shutdown, lockShutdown);
192 pwallet->Flush(
false);
214 fs::path est_path =
GetDataDir() / FEE_ESTIMATES_FILENAME;
216 if (!est_fileout.
IsNull())
219 LogPrintf(
"%s: Failed to write fee estimates to %s\n", __func__, est_path.string());
245 delete pcoinscatcher;
246 pcoinscatcher =
nullptr;
258 pwallet->Flush(
true);
263 if (pzmqNotificationInterface) {
265 delete pzmqNotificationInterface;
266 pzmqNotificationInterface =
nullptr;
273 }
catch (
const fs::filesystem_error&
e) {
274 LogPrintf(
"%s: Unable to remove pidfile: %s\n", __func__, e.what());
285 globalVerifyHandle.reset();
295 static void HandleSIGTERM(
int)
300 static void HandleSIGHUP(
int)
306 static void registerSignalHandler(
int signal,
void(*
handler)(
int))
310 sigemptyset(&sa.sa_mask);
312 sigaction(signal, &sa,
nullptr);
333 if (strWarning !=
"" && !
gArgs.
GetBoolArg(
"-disablesafemode", DEFAULT_DISABLE_SAFEMODE) &&
349 strUsage +=
HelpMessageOpt(
"-?",
_(
"Print this help message and exit"));
351 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)"));
352 strUsage +=
HelpMessageOpt(
"-blocknotify=<cmd>",
_(
"Execute command when the best block changes (%s in cmd is replaced by block hash)"));
354 strUsage +=
HelpMessageOpt(
"-blocksonly",
strprintf(
_(
"Whether to operate in a blocks only mode (default: %u)"), DEFAULT_BLOCKSONLY));
355 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()));
360 strUsage +=
HelpMessageOpt(
"-daemon",
_(
"Run in the background as a daemon and accept commands"));
363 strUsage +=
HelpMessageOpt(
"-datadir=<dir>",
_(
"Specify data directory"));
365 strUsage +=
HelpMessageOpt(
"-dbbatchsize",
strprintf(
"Maximum database write batch size in bytes (default: %u)", nDefaultDbBatchSize));
367 strUsage +=
HelpMessageOpt(
"-dbcache=<n>",
strprintf(
_(
"Set database cache size in megabytes (%d to %d, default: %d)"), nMinDbCache, nMaxDbCache, nDefaultDbCache));
369 strUsage +=
HelpMessageOpt(
"-feefilter",
strprintf(
"Tell other nodes to filter invs to us by our mempool min fee (default: %u)", DEFAULT_FEEFILTER));
370 strUsage +=
HelpMessageOpt(
"-loadblock=<file>",
_(
"Imports blocks from external blk000??.dat file on startup"));
371 strUsage +=
HelpMessageOpt(
"-maxorphantx=<n>",
strprintf(
_(
"Keep at most <n> unconnectable transactions in memory (default: %u)"), DEFAULT_MAX_ORPHAN_TRANSACTIONS));
372 strUsage +=
HelpMessageOpt(
"-maxmempool=<n>",
strprintf(
_(
"Keep the transaction memory pool below <n> megabytes (default: %u)"), DEFAULT_MAX_MEMPOOL_SIZE));
373 strUsage +=
HelpMessageOpt(
"-mempoolexpiry=<n>",
strprintf(
_(
"Do not keep transactions in the mempool longer than <n> hours (default: %u)"), DEFAULT_MEMPOOL_EXPIRY));
375 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()));
377 strUsage +=
HelpMessageOpt(
"-persistmempool",
strprintf(
_(
"Whether to save the mempool on shutdown and load on restart (default: %u)"), DEFAULT_PERSIST_MEMPOOL));
378 strUsage +=
HelpMessageOpt(
"-blockreconstructionextratxn=<n>",
strprintf(
_(
"Extra transactions to keep in memory for compact block reconstructions (default: %u)"), DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN));
379 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)"),
380 -
GetNumCores(), MAX_SCRIPTCHECK_THREADS, DEFAULT_SCRIPTCHECK_THREADS));
384 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. " 385 "Warning: Reverting this setting requires re-downloading the entire blockchain. " 386 "(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));
387 strUsage +=
HelpMessageOpt(
"-record-log-opcodes",
strprintf(
_(
"Logs all EVM LOG opcode operations to the file vmExecLogs.json")));
388 strUsage +=
HelpMessageOpt(
"-reindex-chainstate",
_(
"Rebuild chain state from the currently indexed blocks"));
389 strUsage +=
HelpMessageOpt(
"-reindex",
_(
"Rebuild chain state and block index from the blk*.dat files on disk"));
391 strUsage +=
HelpMessageOpt(
"-sysperms",
_(
"Create new files with system default permissions, instead of umask 077 (only effective with disabled wallet functionality)"));
393 strUsage +=
HelpMessageOpt(
"-txindex",
strprintf(
_(
"Maintain a full transaction index, used by the getrawtransaction rpc call (default: %u)"), DEFAULT_TXINDEX));
394 strUsage +=
HelpMessageOpt(
"-logevents",
strprintf(
_(
"Maintain a full EVM log index, used by searchlogs and gettransactionreceipt rpc calls (default: %u)"), DEFAULT_LOGEVENTS));
397 strUsage +=
HelpMessageOpt(
"-addnode=<ip>",
_(
"Add a node to connect to and attempt to keep the connection open"));
398 strUsage +=
HelpMessageOpt(
"-banscore=<n>",
strprintf(
_(
"Threshold for disconnecting misbehaving peers (default: %u)"), DEFAULT_BANSCORE_THRESHOLD));
399 strUsage +=
HelpMessageOpt(
"-bantime=<n>",
strprintf(
_(
"Number of seconds to keep misbehaving peers from reconnecting (default: %u)"), DEFAULT_MISBEHAVING_BANTIME));
400 strUsage +=
HelpMessageOpt(
"-bind=<addr>",
_(
"Bind to given address and always listen on it. Use [host]:port notation for IPv6"));
401 strUsage +=
HelpMessageOpt(
"-connect=<ip>",
_(
"Connect only to the specified node(s); -connect=0 disables automatic connections"));
402 strUsage +=
HelpMessageOpt(
"-discover",
_(
"Discover own IP addresses (default: 1 when listening and no -externalip or -proxy)"));
403 strUsage +=
HelpMessageOpt(
"-dns",
_(
"Allow DNS lookups for -addnode, -seednode and -connect") +
" " +
strprintf(
_(
"(default: %u)"), DEFAULT_NAME_LOOKUP));
404 strUsage +=
HelpMessageOpt(
"-dnsseed",
_(
"Query for peer addresses via DNS lookup, if low on addresses (default: 1 unless -connect used)"));
405 strUsage +=
HelpMessageOpt(
"-externalip=<ip>",
_(
"Specify your own public address"));
406 strUsage +=
HelpMessageOpt(
"-forcednsseed",
strprintf(
_(
"Always query for peer addresses via DNS lookup (default: %u)"), DEFAULT_FORCEDNSSEED));
407 strUsage +=
HelpMessageOpt(
"-listen",
_(
"Accept connections from outside (default: 1 if no -proxy or -connect)"));
408 strUsage +=
HelpMessageOpt(
"-listenonion",
strprintf(
_(
"Automatically create Tor hidden service (default: %d)"), DEFAULT_LISTEN_ONION));
409 strUsage +=
HelpMessageOpt(
"-maxconnections=<n>",
strprintf(
_(
"Maintain at most <n> connections to peers (default: %u)"), DEFAULT_MAX_PEER_CONNECTIONS));
410 strUsage +=
HelpMessageOpt(
"-maxreceivebuffer=<n>",
strprintf(
_(
"Maximum per-connection receive buffer, <n>*1000 bytes (default: %u)"), DEFAULT_MAXRECEIVEBUFFER));
411 strUsage +=
HelpMessageOpt(
"-maxsendbuffer=<n>",
strprintf(
_(
"Maximum per-connection send buffer, <n>*1000 bytes (default: %u)"), DEFAULT_MAXSENDBUFFER));
412 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));
413 strUsage +=
HelpMessageOpt(
"-onion=<ip:port>",
strprintf(
_(
"Use separate SOCKS5 proxy to reach peers via Tor hidden services (default: %s)"),
"-proxy"));
414 strUsage +=
HelpMessageOpt(
"-onlynet=<net>",
_(
"Only connect to nodes in network <net> (ipv4, ipv6 or onion)"));
415 strUsage +=
HelpMessageOpt(
"-permitbaremultisig",
strprintf(
_(
"Relay non-P2SH multisig (default: %u)"), DEFAULT_PERMIT_BAREMULTISIG));
416 strUsage +=
HelpMessageOpt(
"-peerbloomfilters",
strprintf(
_(
"Support filtering of blocks and transaction with bloom filters (default: %u)"), DEFAULT_PEERBLOOMFILTERS));
417 strUsage +=
HelpMessageOpt(
"-port=<port>",
strprintf(
_(
"Listen for connections on <port> (default: %u or testnet: %u)"), defaultChainParams->GetDefaultPort(), testnetChainParams->GetDefaultPort()));
418 strUsage +=
HelpMessageOpt(
"-proxy=<ip:port>",
_(
"Connect through SOCKS5 proxy"));
419 strUsage +=
HelpMessageOpt(
"-proxyrandomize",
strprintf(
_(
"Randomize credentials for every proxy connection. This enables Tor stream isolation (default: %u)"), DEFAULT_PROXYRANDOMIZE));
420 strUsage +=
HelpMessageOpt(
"-seednode=<ip>",
_(
"Connect to a node to retrieve peer addresses, and disconnect"));
421 strUsage +=
HelpMessageOpt(
"-timeout=<n>",
strprintf(
_(
"Specify connection timeout in milliseconds (minimum: 1, default: %d)"), DEFAULT_CONNECT_TIMEOUT));
423 strUsage +=
HelpMessageOpt(
"-torpassword=<pass>",
_(
"Tor control port password (default: empty)"));
424 strUsage +=
HelpMessageOpt(
"-dgpstorage",
_(
"Receiving data from DGP via storage (default: -dgpevm)"));
425 strUsage +=
HelpMessageOpt(
"-dgpevm",
_(
"Receiving data from DGP via a contract call (default: -dgpevm)"));
428 strUsage +=
HelpMessageOpt(
"-upnp",
_(
"Use UPnP to map the listening port (default: 1 when listening and no -proxy)"));
433 strUsage +=
HelpMessageOpt(
"-whitebind=<addr>",
_(
"Bind to given address and whitelist peers connecting to it. Use [host]:port notation for IPv6"));
434 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.") +
435 " " +
_(
"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"));
436 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));
444 strUsage +=
HelpMessageOpt(
"-zmqpubhashblock=<address>",
_(
"Enable publish hash block in <address>"));
445 strUsage +=
HelpMessageOpt(
"-zmqpubhashtx=<address>",
_(
"Enable publish hash transaction in <address>"));
446 strUsage +=
HelpMessageOpt(
"-zmqpubrawblock=<address>",
_(
"Enable publish raw block in <address>"));
447 strUsage +=
HelpMessageOpt(
"-zmqpubrawtx=<address>",
_(
"Enable publish raw transaction in <address>"));
451 strUsage +=
HelpMessageOpt(
"-uacomment=<cmt>",
_(
"Append comment to the user agent string"));
454 strUsage +=
HelpMessageOpt(
"-checkblocks=<n>",
strprintf(
_(
"How many blocks to check at startup (default: %u, 0 = all)"), DEFAULT_CHECKBLOCKS));
455 strUsage +=
HelpMessageOpt(
"-checklevel=<n>",
strprintf(
_(
"How thorough the block verification of -checkblocks is (0-4, default: %u)"), DEFAULT_CHECKLEVEL));
456 strUsage +=
HelpMessageOpt(
"-checkblockindex",
strprintf(
"Do a full consistency check for mapBlockIndex, setBlockIndexCandidates, chainActive and mapBlocksUnlinked occasionally. Also sets -checkmempool (default: %u)", defaultChainParams->DefaultConsistencyChecks()));
457 strUsage +=
HelpMessageOpt(
"-checkmempool=<n>",
strprintf(
"Run checks every <n> transactions (default: %u)", defaultChainParams->DefaultConsistencyChecks()));
458 strUsage +=
HelpMessageOpt(
"-checkpoints",
strprintf(
"Disable expensive verification for known chain history (default: %u)", DEFAULT_CHECKPOINTS_ENABLED));
459 strUsage +=
HelpMessageOpt(
"-disablesafemode",
strprintf(
"Disable safemode, override a real safe mode event (default: %u)", DEFAULT_DISABLE_SAFEMODE));
461 strUsage +=
HelpMessageOpt(
"-dropmessagestest=<n>",
"Randomly drop 1 of every <n> network messages");
462 strUsage +=
HelpMessageOpt(
"-fuzzmessagestest=<n>",
"Randomly fuzz 1 of every <n> network messages");
463 strUsage +=
HelpMessageOpt(
"-stopafterblockimport",
strprintf(
"Stop running after importing blocks from disk (default: %u)", DEFAULT_STOPAFTERBLOCKIMPORT));
464 strUsage +=
HelpMessageOpt(
"-stopatheight",
strprintf(
"Stop running after reaching the given height in the main chain (default: %u)", DEFAULT_STOPATHEIGHT));
466 strUsage +=
HelpMessageOpt(
"-limitancestorcount=<n>",
strprintf(
"Do not accept transactions if number of in-mempool ancestors is <n> or more (default: %u)", DEFAULT_ANCESTOR_LIMIT));
467 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));
468 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));
469 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));
470 strUsage +=
HelpMessageOpt(
"-vbparams=deployment:start:end",
"Use given start/end times for specified version bits deployment (regtest-only)");
472 strUsage +=
HelpMessageOpt(
"-debug=<category>",
strprintf(
_(
"Output debugging information (default: %u, supplying <category> is optional)"), 0) +
". " +
473 _(
"If <category> is not supplied or if <category> = 1, output all debugging information.") +
" " +
_(
"<category> can be:") +
" " +
ListLogCategories() +
".");
474 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.")));
478 strUsage +=
HelpMessageOpt(
"-genproclimit=<n>",
strprintf(
_(
"Set the number of threads for coin generation if enabled (-1 = all cores, default: %d)"), 1));
481 strUsage +=
HelpMessageOpt(
"-G",
_(
"Enable GPU mining (default: false)"));
482 strUsage +=
HelpMessageOpt(
"-platform=<id>",
_(
"If -G is enabled this specifies the GPU platform number to use (default: 0)"));
483 strUsage +=
HelpMessageOpt(
"-device=<id>",
_(
"If -G is enabled this specifies the GPU device number to use (default: 0)"));
484 strUsage +=
HelpMessageOpt(
"-allgpu",
_(
"If -G is enabled this will mine on all available GPU platforms and devices (default: false)"));
485 strUsage +=
HelpMessageOpt(
"-forcenolimit",
_(
"Do not limit thread count per GPU by memory limits. (default: false)"));
488 strUsage +=
HelpMessageOpt(
"-CUDA",
_(
"Enable NVIDIA CUDA mining (default: false)"));
492 strUsage +=
HelpMessageOpt(
"-help-debug",
_(
"Show all debugging options (usage: --help -help-debug)"));
493 strUsage +=
HelpMessageOpt(
"-logips",
strprintf(
_(
"Include IP addresses in debug output (default: %u)"), DEFAULT_LOGIPS));
494 strUsage +=
HelpMessageOpt(
"-logtimestamps",
strprintf(
_(
"Prepend debug output with timestamp (default: %u)"), DEFAULT_LOGTIMESTAMPS));
497 strUsage +=
HelpMessageOpt(
"-logtimemicros",
strprintf(
"Add microsecond precision to debug timestamps (default: %u)", DEFAULT_LOGTIMEMICROS));
498 strUsage +=
HelpMessageOpt(
"-mocktime=<n>",
"Replace actual time with <n> seconds since epoch (default: 0)");
499 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));
500 strUsage +=
HelpMessageOpt(
"-maxtipage=<n>",
strprintf(
"Maximum tip age in seconds to consider node in initial block download (default: %u)", DEFAULT_MAX_TIP_AGE));
502 strUsage +=
HelpMessageOpt(
"-minmempoolgaslimit=<limit>",
strprintf(
"The minimum transaction gas limit we are willing to accept into the mempool (default: %s)",MEMPOOL_MIN_GAS_LIMIT));
503 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)"),
505 strUsage +=
HelpMessageOpt(
"-printtoconsole",
_(
"Send trace/debug info to console instead of debug.log file"));
508 strUsage +=
HelpMessageOpt(
"-printpriority",
strprintf(
"Log transaction fee per kB when mining blocks (default: %u)", DEFAULT_PRINTPRIORITY));
510 strUsage +=
HelpMessageOpt(
"-shrinkdebugfile",
_(
"Shrink debug.log file on client startup (default: 1 when no -debug)"));
516 strUsage +=
HelpMessageOpt(
"-acceptnonstdtxn",
strprintf(
"Relay and mine \"non-standard\" transactions (%sdefault: %u)",
"testnet/regtest only; ", defaultChainParams->RequireStandard()));
517 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)));
518 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)));
520 strUsage +=
HelpMessageOpt(
"-bytespersigop",
strprintf(
_(
"Equivalent bytes per sigop in transactions for relay and mining (default: %u)"), DEFAULT_BYTES_PER_SIGOP));
521 strUsage +=
HelpMessageOpt(
"-datacarrier",
strprintf(
_(
"Relay and mine data carrier transactions (default: %u)"), DEFAULT_ACCEPT_DATACARRIER));
522 strUsage +=
HelpMessageOpt(
"-datacarriersize",
strprintf(
_(
"Maximum size of data in data carrier transactions we relay and mine (default: %u)"), MAX_OP_RETURN_RELAY));
523 strUsage +=
HelpMessageOpt(
"-mempoolreplacement",
strprintf(
_(
"Enable transaction replacement in the memory pool (default: %u)"), DEFAULT_ENABLE_REPLACEMENT));
524 strUsage +=
HelpMessageOpt(
"-minrelaytxfee=<amt>",
strprintf(
_(
"Fees (in %s/kB) smaller than this are considered zero fee for relaying, mining and transaction creation (default: %s)"),
526 strUsage +=
HelpMessageOpt(
"-whitelistrelay",
strprintf(
_(
"Accept relayed transactions received from whitelisted peers even when not relaying transactions (default: %d)"), DEFAULT_WHITELISTRELAY));
527 strUsage +=
HelpMessageOpt(
"-whitelistforcerelay",
strprintf(
_(
"Force relay of transactions from whitelisted peers even if they violate local relay policy (default: %d)"), DEFAULT_WHITELISTFORCERELAY));
530 strUsage +=
HelpMessageOpt(
"-blockmaxweight=<n>",
strprintf(
_(
"Set maximum BIP141 block weight (default: %d)"), DEFAULT_BLOCK_MAX_WEIGHT));
531 strUsage +=
HelpMessageOpt(
"-blockmaxsize=<n>",
_(
"Set maximum BIP141 block weight to this * 4. Deprecated, use blockmaxweight"));
534 strUsage +=
HelpMessageOpt(
"-blockversion=<n>",
"Override block version to test forking scenarios");
536 strUsage +=
HelpMessageOpt(
"-blockmaxconflict=<n>",
strprintf(
_(
"Set max conflicted blocks can be overwrited, default: %d )"), DEFAULT_BLOCK_MAX_CONFLICT ));
539 strUsage +=
HelpMessageOpt(
"-server",
_(
"Accept command line and JSON-RPC commands"));
540 strUsage +=
HelpMessageOpt(
"-rest",
strprintf(
_(
"Accept public REST requests (default: %u)"), DEFAULT_REST_ENABLE));
541 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)"));
542 strUsage +=
HelpMessageOpt(
"-rpccookiefile=<loc>",
_(
"Location of the auth cookie (default: data dir)"));
543 strUsage +=
HelpMessageOpt(
"-rpcuser=<user>",
_(
"Username for JSON-RPC connections"));
544 strUsage +=
HelpMessageOpt(
"-rpcpassword=<pw>",
_(
"Password for JSON-RPC connections"));
545 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"));
546 strUsage +=
HelpMessageOpt(
"-rpcport=<port>",
strprintf(
_(
"Listen for JSON-RPC connections on <port> (default: %u or testnet: %u)"), defaultBaseParams->RPCPort(), testnetBaseParams->RPCPort()));
547 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"));
548 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));
549 strUsage +=
HelpMessageOpt(
"-rpcthreads=<n>",
strprintf(
_(
"Set the number of threads to service RPC calls (default: %d)"), DEFAULT_HTTP_THREADS));
551 strUsage +=
HelpMessageOpt(
"-rpcworkqueue=<n>",
strprintf(
"Set the depth of the work queue to service RPC calls (default: %d)", DEFAULT_HTTP_WORKQUEUE));
552 strUsage +=
HelpMessageOpt(
"-rpcservertimeout=<n>",
strprintf(
"Timeout during HTTP requests (default: %d)", DEFAULT_HTTP_SERVER_TIMEOUT));
560 const std::string URL_SOURCE_CODE =
"<https://github.com/blockchaingate/fabcoin>";
561 const std::string URL_WEBSITE =
"<https://fabcoin.pro>";
565 strprintf(
_(
"Please contribute if you find %s useful. " 566 "Visit %s for further information about the software."),
569 strprintf(
_(
"The source code is available from %s."),
573 _(
"This is experimental software.") +
"\n" +
574 strprintf(
_(
"Distributed under the MIT software license, see the accompanying file %s or %s"),
"COPYING",
"<https://opensource.org/licenses/MIT>") +
"\n" +
576 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>") +
580 static void BlockNotifyCallback(
bool initialSync,
const CBlockIndex *pBlockIndex)
582 if (initialSync || !pBlockIndex)
585 std::string strCmd =
gArgs.
GetArg(
"-blocknotify",
"");
591 static bool fHaveGenesis =
false;
592 static boost::mutex cs_GenesisWait;
595 static void BlockNotifyGenesisWait(
bool,
const CBlockIndex *pBlockIndex)
597 if (pBlockIndex !=
nullptr) {
599 boost::unique_lock<boost::mutex> lock_GenesisWait(cs_GenesisWait);
602 condvar_GenesisWait.notify_all();
628 std::map<std::string, fs::path> mapBlockFiles;
633 LogPrintf(
"Removing unusable blk?????.dat and rev?????.dat files for -reindex with -prune\n");
635 for (fs::directory_iterator it(blocksdir); it != fs::directory_iterator(); it++) {
636 if (is_regular_file(*it) &&
637 it->path().filename().string().length() == 12 &&
638 it->path().filename().string().substr(8,4) ==
".dat")
640 if (it->path().filename().string().substr(0,3) ==
"blk")
641 mapBlockFiles[it->path().filename().string().substr(3,5)] = it->path();
642 else if (it->path().filename().string().substr(0,3) ==
"rev")
651 int nContigCounter = 0;
652 for (
const std::pair<std::string, fs::path>& item : mapBlockFiles) {
653 if (
atoi(item.first) == nContigCounter) {
679 LogPrintf(
"Reindexing block file blk%05u.dat...\n", (
unsigned int)nFile);
691 fs::path pathBootstrap =
GetDataDir() /
"bootstrap.dat";
692 if (fs::exists(pathBootstrap)) {
695 fs::path pathBootstrapOld =
GetDataDir() /
"bootstrap.dat.old";
696 LogPrintf(
"Importing bootstrap.dat...\n");
700 LogPrintf(
"Warning: Could not open bootstrap file %s\n", pathBootstrap.string());
705 for (
const fs::path& path : vImportFiles) {
708 LogPrintf(
"Importing blocks file %s...\n", path.string());
711 LogPrintf(
"Warning: Could not open blocks file %s\n", path.string());
718 LogPrintf(
"Failed to connect best block");
722 if (
gArgs.
GetBoolArg(
"-stopafterblockimport", DEFAULT_STOPAFTERBLOCKIMPORT)) {
723 LogPrintf(
"Stopping after block import\n");
727 if (
gArgs.
GetArg(
"-persistmempool", DEFAULT_PERSIST_MEMPOOL)) {
740 InitError(
"Elliptic curve cryptography sanity check failure. Aborting.");
748 InitError(
"OS cryptographic RNG sanity check failure. Aborting.");
780 LogPrintf(
"%s: parameter interaction: -bind set -> setting -listen=1\n", __func__);
784 LogPrintf(
"%s: parameter interaction: -whitebind set -> setting -listen=1\n", __func__);
790 LogPrintf(
"%s: parameter interaction: -connect set -> setting -dnsseed=0\n", __func__);
792 LogPrintf(
"%s: parameter interaction: -connect set -> setting -listen=0\n", __func__);
798 LogPrintf(
"%s: parameter interaction: -proxy set -> setting -listen=0\n", __func__);
802 LogPrintf(
"%s: parameter interaction: -proxy set -> setting -upnp=0\n", __func__);
805 LogPrintf(
"%s: parameter interaction: -proxy set -> setting -discover=0\n", __func__);
811 LogPrintf(
"%s: parameter interaction: -listen=0 -> setting -upnp=0\n", __func__);
813 LogPrintf(
"%s: parameter interaction: -listen=0 -> setting -discover=0\n", __func__);
815 LogPrintf(
"%s: parameter interaction: -listen=0 -> setting -listenonion=0\n", __func__);
821 LogPrintf(
"%s: parameter interaction: -externalip set -> setting -discover=0\n", __func__);
827 LogPrintf(
"%s: parameter interaction: -blocksonly=1 -> setting -whitelistrelay=0\n", __func__);
831 if (
gArgs.
GetBoolArg(
"-whitelistforcerelay", DEFAULT_WHITELISTFORCERELAY)) {
833 LogPrintf(
"%s: parameter interaction: -whitelistforcerelay=1 -> setting -whitelistrelay=1\n", __func__);
837 unsigned int max_size =
gArgs.
GetArg(
"-blockmaxsize", 0);
839 LogPrintf(
"%s: parameter interaction: -blockmaxsize=%d -> setting -blockmaxweight=%d (-blockmaxsize is deprecated!)\n", __func__, max_size, max_size * WITNESS_SCALE_FACTOR);
841 LogPrintf(
"%s: Ignoring blockmaxsize setting which is overridden by blockmaxweight", __func__);
846 static std::string ResolveErrMsg(
const char *
const optname,
const std::string& strBind)
848 return strprintf(
_(
"Cannot resolve -%s address: '%s'"), optname, strBind);
858 LogPrintf(
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
866 int nUserMaxConnections;
872 [[noreturn]]
static void new_handler_terminate()
878 std::set_new_handler(std::terminate);
879 LogPrintf(
"Error: Out of memory. Terminating.\n");
890 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
891 _CrtSetReportFile(_CRT_WARN, CreateFileA(
"NUL", GENERIC_WRITE, 0,
nullptr, OPEN_EXISTING, 0, 0));
893 _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
899 #ifndef PROCESS_DEP_ENABLE 902 #define PROCESS_DEP_ENABLE 0x00000001 904 typedef BOOL (WINAPI *PSETPROCDEPPOL)(DWORD);
905 PSETPROCDEPPOL setProcDEPPol = (PSETPROCDEPPOL)GetProcAddress(GetModuleHandleA(
"Kernel32.dll"),
"SetProcessDEPPolicy");
906 if (setProcDEPPol !=
nullptr) setProcDEPPol(PROCESS_DEP_ENABLE);
910 return InitError(
"Initializing networking failed");
918 registerSignalHandler(SIGTERM, HandleSIGTERM);
919 registerSignalHandler(SIGINT, HandleSIGTERM);
922 registerSignalHandler(SIGHUP, HandleSIGHUP);
925 signal(SIGPIPE, SIG_IGN);
928 std::set_new_handler(new_handler_terminate);
943 return InitError(
_(
"Prune mode is incompatible with -txindex."));
949 return InitError(
"Cannot set -bind or -whitebind together with -listen=0");
953 int nBind =
std::max(nUserBind,
size_t(1));
954 nUserMaxConnections =
gArgs.
GetArg(
"-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS);
955 nMaxConnections =
std::max(nUserMaxConnections, 0);
961 return InitError(
_(
"Not enough file descriptors available."));
964 if (nMaxConnections < nUserMaxConnections)
965 InitWarning(
strprintf(
_(
"Reducing -maxconnections from %d to %d, because of system limitations."), nUserMaxConnections, nMaxConnections));
970 const std::vector<std::string> categories =
gArgs.
GetArgs(
"-debug");
972 if (find(categories.begin(), categories.end(), std::string(
"0")) == categories.end()) {
973 for (
const auto& cat : categories) {
985 for (
const std::string& cat :
gArgs.
GetArgs(
"-debugexclude")) {
996 InitWarning(
_(
"Unsupported argument -debugnet ignored, use -debug=net."));
999 return InitError(
_(
"Unsupported argument -socks found. Setting SOCKS version isn't possible anymore, only SOCKS5 proxies are supported."));
1002 return InitError(
_(
"Unsupported argument -tor found, use -onion."));
1005 InitWarning(
_(
"Unsupported argument -benchmark ignored, use -debug=bench."));
1008 InitWarning(
_(
"Unsupported argument -whitelistalwaysrelay ignored, use -whitelistrelay and/or -whitelistforcerelay."));
1011 InitWarning(
"Unsupported argument -blockminsize ignored.");
1025 LogPrintf(
"Validating signatures for all blocks.\n");
1028 const std::string minChainWorkStr =
gArgs.
GetArg(
"-minimumchainwork",
"");
1030 return InitError(
strprintf(
"Invalid non-hex (%s) minimum chain work value specified", minChainWorkStr));
1042 int64_t nMempoolSizeMax =
gArgs.
GetArg(
"-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000;
1043 int64_t nMempoolSizeMin =
gArgs.
GetArg(
"-limitdescendantsize", DEFAULT_DESCENDANT_SIZE_LIMIT) * 1000 * 40;
1044 if (nMempoolSizeMax < 0 || nMempoolSizeMax < nMempoolSizeMin)
1045 return InitError(
strprintf(
_(
"-maxmempool must be at least %d MB"), std::ceil(nMempoolSizeMin / 1000000.0)));
1067 if (nPruneArg < 0) {
1068 return InitError(
_(
"Prune cannot be configured with a negative value."));
1071 if (nPruneArg == 1) {
1072 LogPrintf(
"Block pruning enabled. Use RPC call pruneblockchain(height) to manually prune block and undo files.\n");
1077 return InitError(
strprintf(
_(
"Prune configured below the minimum of %d MiB. Please use a higher number."), MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024));
1079 LogPrintf(
"Prune configured to target %uMiB on disk for block and undo files.\n",
nPruneTarget / 1024 / 1024);
1083 RegisterAllCoreRPCCommands(
tableRPC);
1084 #ifdef ENABLE_WALLET 1129 #ifdef ENABLE_WALLET 1144 if (
gArgs.
GetArg(
"-rpcserialversion", DEFAULT_RPC_SERIALIZE_VERSION) < 0)
1145 return InitError(
"rpcserialversion must be non-negative.");
1147 if (
gArgs.
GetArg(
"-rpcserialversion", DEFAULT_RPC_SERIALIZE_VERSION) > 1)
1148 return InitError(
"unknown rpcserialversion requested.");
1155 std::string strReplacementModeList =
gArgs.
GetArg(
"-mempoolreplacement",
"");
1156 std::vector<std::string> vstrReplacementModes;
1157 boost::split(vstrReplacementModes, strReplacementModeList, boost::is_any_of(
","));
1158 fEnableReplacement = (std::find(vstrReplacementModes.begin(), vstrReplacementModes.end(),
"fee") != vstrReplacementModes.end());
1164 return InitError(
"Version bits parameters may only be overridden on regtest.");
1166 for (
const std::string& strDeployment :
gArgs.
GetArgs(
"-vbparams")) {
1167 std::vector<std::string> vDeploymentParams;
1168 boost::split(vDeploymentParams, strDeployment, boost::is_any_of(
":"));
1169 if (vDeploymentParams.size() != 3) {
1170 return InitError(
"Version bits parameters malformed, expecting deployment:start:end");
1172 int64_t nStartTime, nTimeout;
1173 if (!
ParseInt64(vDeploymentParams[1], &nStartTime)) {
1176 if (!
ParseInt64(vDeploymentParams[2], &nTimeout)) {
1185 LogPrintf(
"Setting version bits activation parameters for %s to start=%ld, timeout=%ld\n", vDeploymentParams[0], nStartTime, nTimeout);
1197 static bool LockDataDirectory(
bool probeOnly,
bool try_lock=
true)
1199 std::string strDataDir =
GetDataDir().string();
1202 fs::path pathLockFile =
GetDataDir() /
".lock";
1204 if (file) fclose(file);
1207 static boost::interprocess::file_lock lock(pathLockFile.string().c_str());
1208 if (try_lock && !lock.try_lock()) {
1214 }
catch(
const boost::interprocess::interprocess_exception&
e) {
1215 return InitError(
strprintf(
_(
"Cannot obtain a lock on data directory %s. %s is probably already running.") +
" %s.", strDataDir,
_(
PACKAGE_NAME), e.what()));
1226 LogPrintf(
"Using the '%s' SHA256 implementation\n", sha256_algo);
1238 return LockDataDirectory(
true);
1246 if (!LockDataDirectory(
false)) {
1280 LogPrintf(
"Using at most %i automatic connections (%i file descriptors available)\n", nMaxConnections, nFD);
1293 threadGroup.create_thread(boost::bind(&TraceThread<CScheduler::Function>,
"scheduler", serviceLoop));
1306 return InitError(
_(
"Unable to start HTTP server. See debug log for details."));
1312 #ifdef ENABLE_WALLET 1330 std::vector<std::string> uacomments;
1331 for (
const std::string& cmt :
gArgs.
GetArgs(
"-uacomment")) {
1333 return InitError(
strprintf(
_(
"User Agent comment (%s) contains unsafe characters."), cmt));
1334 uacomments.push_back(cmt);
1338 return InitError(
strprintf(
_(
"Total length of network version string (%i) exceeds maximum length (%i). Reduce the number or size of uacomments."),
1343 std::set<enum Network> nets;
1344 for (
const std::string& snet :
gArgs.
GetArgs(
"-onlynet")) {
1350 for (
int n = 0; n <
NET_MAX; n++) {
1352 if (!nets.count(net))
1360 bool proxyRandomize =
gArgs.
GetBoolArg(
"-proxyrandomize", DEFAULT_PROXYRANDOMIZE);
1363 std::string proxyArg =
gArgs.
GetArg(
"-proxy",
"");
1365 if (proxyArg !=
"" && proxyArg !=
"0") {
1385 std::string onionArg =
gArgs.
GetArg(
"-onion",
"");
1386 if (onionArg !=
"") {
1387 if (onionArg ==
"0") {
1407 for (
const std::string& strAddr :
gArgs.
GetArgs(
"-externalip")) {
1412 return InitError(ResolveErrMsg(
"externalip", strAddr));
1418 if (pzmqNotificationInterface) {
1422 uint64_t nMaxOutboundLimit = 0;
1423 uint64_t nMaxOutboundTimeframe = MAX_UPLOAD_TIMEFRAME;
1426 nMaxOutboundLimit =
gArgs.
GetArg(
"-maxuploadtarget", DEFAULT_MAX_UPLOAD_TARGET)*1024*1024;
1432 bool fReindexChainState =
gArgs.
GetBoolArg(
"-reindex-chainstate",
false);
1435 int64_t nTotalCache = (
gArgs.
GetArg(
"-dbcache", nDefaultDbCache) << 20);
1436 nTotalCache =
std::max(nTotalCache, nMinDbCache << 20);
1437 nTotalCache =
std::min(nTotalCache, nMaxDbCache << 20);
1438 int64_t nBlockTreeDBCache = nTotalCache / 8;
1439 nBlockTreeDBCache =
std::min(nBlockTreeDBCache, (
gArgs.
GetBoolArg(
"-txindex", DEFAULT_TXINDEX) ? nMaxBlockDBAndTxIndexCache : nMaxBlockDBCache) << 20);
1440 nTotalCache -= nBlockTreeDBCache;
1441 int64_t nCoinDBCache =
std::min(nTotalCache / 2, (nTotalCache / 4) + (1 << 23));
1442 nCoinDBCache =
std::min(nCoinDBCache, nMaxCoinsDBCache << 20);
1443 nTotalCache -= nCoinDBCache;
1445 int64_t nMempoolSizeMax =
gArgs.
GetArg(
"-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000;
1447 LogPrintf(
"* Using %.1fMiB for block index database\n", nBlockTreeDBCache * (1.0 / 1024 / 1024));
1448 LogPrintf(
"* Using %.1fMiB for chain state database\n", nCoinDBCache * (1.0 / 1024 / 1024));
1449 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));
1451 bool fLoaded =
false;
1454 std::string strLoadError;
1464 delete pcoinscatcher;
1491 strLoadError =
_(
"Error loading block database");
1498 return InitError(
_(
"Incorrect or no genesis block found. Wrong datadir for network?"));
1502 strLoadError =
_(
"You need to rebuild the database using -reindex to change -txindex");
1509 strLoadError =
_(
"You need to rebuild the database using -reindex to go back to unpruned mode. This will redownload the entire blockchain");
1518 strLoadError =
_(
"Error initializing block database");
1524 strLoadError =
_(
"Unable to replay blocks. You will need to rebuild the database using -reindex-chainstate.");
1532 if (!is_coinsview_empty) {
1535 strLoadError =
_(
"Error initializing block database");
1550 fs::path fascStateDir =
GetDataDir() /
"stateFasc";
1551 bool fStatus = fs::exists(fascStateDir);
1552 const std::string dirFasc(fascStateDir.string());
1557 globalSealEngine = std::unique_ptr<dev::eth::SealEngineFace>(cp.createSealEngine());
1581 strLoadError =
_(
"You need to rebuild the database using -reindex-chainstate to enable -logevents");
1587 pstorageresult->wipeResults();
1599 strLoadError =
_(
"Unable to rewind the database to a pre-fork state. You will need to redownload the blockchain");
1604 if (!is_coinsview_empty) {
1607 LogPrintf(
"Prune: pruned datadir may not have more than %d blocks; only checking available blocks",
1608 MIN_BLOCKS_TO_KEEP);
1616 strLoadError =
_(
"The block database contains a block which appears to be from the future. " 1617 "This may be due to your computer's date and time being set incorrectly. " 1618 "Only rebuild the block database if you are sure that your computer's date and time are correct");
1624 gArgs.
GetArg(
"-checkblocks", DEFAULT_CHECKBLOCKS))) {
1625 strLoadError =
_(
"Corrupted block database detected");
1629 }
catch (
const std::exception&
e) {
1631 strLoadError =
_(
"Error opening block database");
1642 strLoadError +
".\n\n" +
_(
"Do you want to rebuild the block database now?"),
1643 strLoadError +
".\nPlease restart with -reindex or -reindex-chainstate to recover.",
1649 LogPrintf(
"Aborted block database rebuild. Exiting.\n");
1663 LogPrintf(
"Shutdown requested. Exiting.\n");
1670 fs::path est_path =
GetDataDir() / FEE_ESTIMATES_FILENAME;
1673 if (!est_filein.
IsNull())
1678 #ifdef ENABLE_WALLET 1687 LogPrintf(
"No wallet support compiled in!\n");
1695 LogPrintf(
"Unsetting NODE_NETWORK on prune mode\n");
1725 fHaveGenesis =
true;
1731 std::vector<fs::path> vImportFiles;
1732 for (
const std::string& strFile :
gArgs.
GetArgs(
"-loadblock")) {
1733 vImportFiles.push_back(strFile);
1736 threadGroup.create_thread(boost::bind(&
ThreadImport, vImportFiles));
1740 boost::unique_lock<boost::mutex> lock(cs_GenesisWait);
1741 while (!fHaveGenesis) {
1742 condvar_GenesisWait.wait(lock);
1762 connOptions.nRelevantServices = nRelevantServices;
1763 connOptions.nMaxConnections = nMaxConnections;
1764 connOptions.nMaxOutbound =
std::min(MAX_OUTBOUND_CONNECTIONS, connOptions.nMaxConnections);
1765 connOptions.nMaxAddnode = MAX_ADDNODE_CONNECTIONS;
1766 connOptions.nMaxFeeler = 1;
1769 connOptions.m_msgproc =
peerLogic.get();
1770 connOptions.nSendBufferMaxSize = 1000*
gArgs.
GetArg(
"-maxsendbuffer", DEFAULT_MAXSENDBUFFER);
1771 connOptions.nReceiveFloodSize = 1000*
gArgs.
GetArg(
"-maxreceivebuffer", DEFAULT_MAXRECEIVEBUFFER);
1773 connOptions.nMaxOutboundTimeframe = nMaxOutboundTimeframe;
1774 connOptions.nMaxOutboundLimit = nMaxOutboundLimit;
1776 for (
const std::string& strBind :
gArgs.
GetArgs(
"-bind")) {
1779 return InitError(ResolveErrMsg(
"bind", strBind));
1781 connOptions.vBinds.push_back(addrBind);
1783 for (
const std::string& strBind :
gArgs.
GetArgs(
"-whitebind")) {
1785 if (!
Lookup(strBind.c_str(), addrBind, 0,
false)) {
1786 return InitError(ResolveErrMsg(
"whitebind", strBind));
1788 if (addrBind.
GetPort() == 0) {
1791 connOptions.vWhiteBinds.push_back(addrBind);
1799 connOptions.vWhitelistedRange.push_back(subnet);
1806 if (!connman.Start(scheduler, connOptions)) {
1810 #ifdef ENABLE_WALLET 1831 #ifdef ENABLE_WALLET 1833 pwallet->postInitProcess(scheduler);
1843 LockDataDirectory(
true,
false);
bool GetCoin(const COutPoint &outpoint, Coin &coin) const override
Retrieve the Coin (unspent transaction output) for a given outpoint.
void CleanupBlockRevFiles()
void UnlockDataDirectory()
Unlock the data directory.
const std::string CURRENCY_UNIT
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.
bool(* handler)(HTTPRequest *req, const std::string &strReq)
void ECC_Start()
Initialize the elliptic curve support.
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".
static std::string GetWalletHelpString(bool showDebug)
bool fPruneMode
True if we're running in -prune mode.
std::vector< CWalletRef > vpwallets
bool MineBlocksOnDemand() const
Make miner stop after a block is found.
void OnRPCPreCommand(const CRPCCommand &cmd)
unsigned short GetPort() const
FASC Homestead + EIP150 + EIP158 Rules active from block 0 to enum class Network. ...
boost::condition_variable CConditionVariable
Just a typedef for boost::condition_variable, can be wrapped later if desired.
ServiceFlags
nServices flags
bool StartHTTPServer()
Start HTTP server.
void UnloadBlockIndex()
Unload database information.
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 IsArgSet(const std::string &strArg)
Return true if the given argument has been manually set.
static bool InitLoadWallet()
bool SoftSetBoolArg(const std::string &strArg, bool fValue)
Set a boolean argument if it doesn't already have a value.
void SetRPCWarmupStatus(const std::string &newStatus)
Set the RPC warmup status.
bytes rlp(_T _t)
Export a single item in RLP format, returning a byte array.
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.
std::atomic< bool > fRequestShutdown(false)
static OverlayDB openDB(std::string const &_path, h256 const &_genesisHash, WithExisting _we=WithExisting::Trust)
Open a DB - useful for passing into the constructor & keeping for other states that are necessary...
std::string DateTimeStrFormat(const char *pszFormat, int64_t nTime)
std::string GetHex() const
bool FlushStateToDisk()
Flush all state, indexes and buffers to disk.
const Consensus::Params & GetConsensus() const
void SetMockTime(int64_t nMockTimeIn)
bool StartHTTPRPC()
Start HTTP RPC subsystem.
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...
void GenerateFabcoins(bool fGenerate, int nThreads, const CChainParams &chainparams)
Run the miner threads.
bool GetBoolArg(const std::string &strArg, bool fDefault)
Return boolean argument or default value.
arith_uint256 nMinimumChainWork
Minimum work we will assume exists on some valid chain.
static bool ParameterInteraction()
std::vector< std::string > GetArgs(const std::string &strArg)
assert(len-trim+(2 *lenIndices)<=WIDTH)
CChainParams defines various tweakable parameters of a given instance of the Fabcoin system...
void UnregisterAllValidationInterfaces()
Unregister all wallets from core.
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 fabcoin core: Basic context setup.
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 RenameThread(const char *name)
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 StartREST()
Start HTTP REST subsystem.
arith_uint256 UintToArith256(const uint256 &a)
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 lius (Can be negative)
void InitParameterInteraction()
Parameter interaction: change current parameters depending on various rules.
void SetRPCWarmupFinished()
boost::signals2::signal< void(bool, const CBlockIndex *)> NotifyBlockTip
New block has been accepted.
CBlockPolicyEstimator feeEstimator
std::string NetworkIDString() const
Return the BIP70 network string (main, test or regtest)
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.
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or nullptr if none.
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.
int Height() const
Return the maximal height in the chain.
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.
const char *const FABCOIN_PID_FILENAME
enum Network ParseNetwork(std::string net)
dev::h256 uintToh256(const uint256 &in)
FILE * OpenBlockFile(const CDiskBlockPos &pos, bool fReadOnly)
Open a block file (blk?????.dat)
static CZMQNotificationInterface * Create()
const std::string DEFAULT_TOR_CONTROL
Default control port.
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) ...
const char *const FABCOIN_CONF_FILENAME
std::unique_ptr< CChainParams > CreateChainParams(const std::string &chain)
Creates and returns a std::unique_ptr<CChainParams> of the chosen chain.
void Interrupt(boost::thread_group &threadGroup)
Interrupt threads.
void ECC_Stop()
Deinitialize the elliptic curve support.
std::function< void(std::string const &, char const *)> g_logPost
The current method that the logging system uses to output the log messages. Defaults to simpleDebugOu...
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.
uint256 uint256S(const char *str)
RAII wrapper for VerifyDB: Verify consistency of the block and coin databases.
std::function< void(void)> Function
void InitSignatureCache()
CMainSignals & GetMainSignals()
bool ParseMoney(const std::string &str, CAmount &nRet)
std::string GetWarnings(const std::string &strFor)
Format a string that describes several potential problems detected by the core.
CChain chainActive
The currently-connected chain of blocks (protected by cs_main).
std::atomic_bool fImporting
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void >> u256
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)
std::string GetHex() const
bool RenameOver(fs::path src, fs::path dest)
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()
uint256 hashAssumeValid
Block hash whose ancestors we will assume to have valid scripts without checking them.
bool LookupSubNet(const char *pszName, CSubNet &ret)
bool IsNull() const
Return true if the wrapped FILE* is nullptr, false otherwise.
bool SetProxy(enum Network net, const proxyType &addrProxy)
void RegisterWalletRPCCommands(CRPCTable &t)
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.
void DumpMempool(void)
Dump the mempool to disk.
std::string ToString() const
bool Write(CAutoFile &fileout) const
Write estimation data to a file.
#define LogPrint(category,...)
void RegisterBackgroundSignalScheduler(CScheduler &scheduler)
Register a CScheduler to give callbacks which should run in the background (may only be called once) ...
Capture information about block/transaction validation.
int64_t nTimeout
Timeout/expiry MedianTime for the deployment attempt.
bool glibcxx_sanity_test()
bool LoadExternalBlockFile(const CChainParams &chainparams, FILE *fileIn, CDiskBlockPos *dbp)
Import blocks from an external file.
static bool Verify()
Responsible for reading and validating the -wallet arguments and verifying the wallet database...
bool fFeeEstimatesInitialized
uint256 nMinimumChainWork
std::string const & genesisInfo(Network _n)
bool InitError(const std::string &str)
Show error message.
std::atomic< bool > fReopenDebugLog
uint256 defaultAssumeValid
The block chain is a tree shaped structure starting with the genesis block at the root...
const CBlock & GenesisBlock() const
const CChainParams & Params()
Return the currently selected parameters.
fs::path GetConfigFile(const std::string &confPath)
std::string GetArg(const std::string &strArg, const std::string &strDefault)
Return string argument or default value.
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.
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)
bool sha3(bytesConstRef _input, bytesRef o_output)
Calculate SHA3-256 hash of the given input and load it into the given output.
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/fabcoin/bips/blob/master/bip...
bool AppInitServers(boost::thread_group &threadGroup)
Server is in safe mode, and command is not allowed in safe mode.
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
Fee rate in liu per kilobyte: CAmount / kB.
std::unique_ptr< CConnman > g_connman
int LogPrintStr(const std::string &str, bool useVMLog)
Send a string to the log output.
bool RequireStandard() const
Policy: Filter transactions that do not match well-defined patterns.
void Discover(boost::thread_group &threadGroup)
bool InitSanityCheck(void)
Sanity checks Ensure that Fabcoin is running in a usable environment with all necessary library suppo...
bool WriteReindexing(bool fReindex)
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
bool WriteFlag(const std::string &name, bool fValue)
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)
void InterruptTorControl()
UniValue JSONRPCError(int code, const std::string &message)
bool DefaultConsistencyChecks() const
Default value for -checkmempool and -checkblockindex argument.
void OnStarted(std::function< void()> slot)
dev::WithExisting max(dev::WithExisting _a, dev::WithExisting _b)
bool AppInitLockDataDirectory()
Lock fabcoin core data directory.
int64_t GetTime()
GetTimeMicros() and GetTimeMillis() both return the system time, but in different units...
void InitWarning(const std::string &str)
Show warning message.
CClientUIInterface uiInterface
bool AppInitMain(boost::thread_group &threadGroup, CScheduler &scheduler)
Fabcoin core main initialization.
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.
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.
#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::string HelpMessageGroup(const std::string &message)
Format a string to be used as group of options in help messages.
unsigned nMaxDatacarrierBytes
std::unique_ptr< FascState > globalState
Global state.
StorageResults * pstorageresult
bool LoadChainTip(const CChainParams &chainparams)
Update the chain tip based on database information.
Non-refcounted RAII wrapper for FILE*.
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 ...
BIP9Deployment vDeployments[MAX_VERSION_BITS_DEPLOYMENTS]
int atoi(const std::string &str)
boost::signals2::signal< void(const std::string &message)> InitMessage
Progress message during initialization.
std::shared_ptr< dev::eth::SealEngineFace > globalSealEngine
uint256 GetBlockHash() const
uint64_t GetRand(uint64_t nMax)
CConditionVariable cvBlockChange
void OnPreCommand(std::function< void(const CRPCCommand &)> slot)