11 #if defined(HAVE_CONFIG_H)
74 #include <boost/algorithm/string.hpp>
75 #include <boost/algorithm/string/split.hpp>
76 #include <boost/algorithm/string/replace.hpp>
77 #include <boost/thread.hpp>
85 static const bool DEFAULT_PROXYRANDOMIZE =
true;
86 static const bool DEFAULT_REST_ENABLE =
false;
87 static const bool DEFAULT_DISABLE_SAFEMODE =
false;
88 static const bool DEFAULT_STOPAFTERBLOCKIMPORT =
false;
101 #define MIN_CORE_FILEDESCRIPTORS 0
103 #define MIN_CORE_FILEDESCRIPTORS 150
106 static const char* DEFAULT_ASMAP_FILENAME=
"ip_asn.map";
108 static const char* FEE_ESTIMATES_FILENAME =
"fee_estimates.dat";
126 fprintf(file,
"%d\n", getpid());
130 return UIError(
strprintf(
_(
"Unable to create the PID file '%s': %s"),
GetPidFile().
string(), std::strerror(errno)));
168 }
catch (
const std::runtime_error& e) {
170 LogPrintf(
"Error reading from database: %s\n", e.what());
181 static std::unique_ptr<CCoinsViewErrorCatcher> pcoinscatcher;
182 static std::unique_ptr<ECCVerifyHandle> globalVerifyHandle;
202 LogPrintf(
"%s: In progress...\n", __func__);
204 TRY_LOCK(cs_Shutdown, lockShutdown);
221 pwallet->Flush(
false);
223 GenerateBitcoins(
false,
nullptr, 0);
251 fs::path est_path =
GetDataDir() / FEE_ESTIMATES_FILENAME;
253 if (!est_fileout.
IsNull())
256 LogPrintf(
"%s: Failed to write fee estimates to %s\n", __func__, est_path.string());
284 pcoinscatcher.reset();
294 pwallet->Flush(
true);
302 if (pzmqNotificationInterface) {
304 delete pzmqNotificationInterface;
305 pzmqNotificationInterface =
nullptr;
316 LogPrintf(
"%s: Unable to remove PID file: File does not exist\n", __func__);
318 }
catch (
const fs::filesystem_error& e) {
319 LogPrintf(
"%s: Unable to remove PID file: %s\n", __func__, e.what());
329 globalVerifyHandle.reset();
331 LogPrintf(
"%s: done\n", __func__);
348 static void registerSignalHandler(
int signal,
void(*
handler)(
int))
350 struct sigaction sa{};
352 sigemptyset(&sa.sa_mask);
354 sigaction(signal, &sa,
nullptr);
376 if (!strWarning.empty() && !
gArgs.
GetBoolArg(
"-disablesafemode", DEFAULT_DISABLE_SAFEMODE) &&
393 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)");
394 strUsage +=
HelpMessageOpt(
"-blocksdir=<dir>",
"Specify directory to hold blocks subdirectory for *.dat files (default: <datadir>)");
395 strUsage +=
HelpMessageOpt(
"-blocknotify=<cmd>",
"Execute command when the best block changes (%s in cmd is replaced by block hash)");
396 strUsage +=
HelpMessageOpt(
"-checkblocks=<n>",
strprintf(
"How many blocks to check at startup (default: %u, 0 = all)", DEFAULT_CHECKBLOCKS));
397 strUsage +=
HelpMessageOpt(
"-checklevel=<n>",
strprintf(
"How thorough the block verification of -checkblocks is (0-4, default: %u)", DEFAULT_CHECKLEVEL));
402 strUsage +=
HelpMessageOpt(
"-daemon",
"Run in the background as a daemon and accept commands");
405 strUsage +=
HelpMessageOpt(
"-datadir=<dir>",
"Specify data directory");
407 strUsage +=
HelpMessageOpt(
"-dbbatchsize",
strprintf(
"Maximum database write batch size in bytes (default: %u)", nDefaultDbBatchSize));
411 strUsage +=
HelpMessageOpt(
"-disablesystemnotifications",
strprintf(
"Disable OS notifications for incoming transactions (default: %u)", 0));
412 strUsage +=
HelpMessageOpt(
"-dbcache=<n>",
strprintf(
"Set database cache size in megabytes (%d to %d, default: %d)", nMinDbCache, nMaxDbCache, nDefaultDbCache));
413 strUsage +=
HelpMessageOpt(
"-loadblock=<file>",
"Imports blocks from external blk000??.dat file on startup");
414 strUsage +=
HelpMessageOpt(
"-maxreorg=<n>",
strprintf(
"Set the Maximum reorg depth (default: %u)", DEFAULT_MAX_REORG_DEPTH));
415 strUsage +=
HelpMessageOpt(
"-maxorphantx=<n>",
strprintf(
"Keep at most <n> unconnectable transactions in memory (default: %u)", DEFAULT_MAX_ORPHAN_TRANSACTIONS));
416 strUsage +=
HelpMessageOpt(
"-maxmempool=<n>",
strprintf(
"Keep the transaction memory pool below <n> megabytes (default: %u)", DEFAULT_MAX_MEMPOOL_SIZE));
417 strUsage +=
HelpMessageOpt(
"-mempoolexpiry=<n>",
strprintf(
"Do not keep transactions in the mempool longer than <n> hours (default: %u)", DEFAULT_MEMPOOL_EXPIRY));
418 strUsage +=
HelpMessageOpt(
"-persistmempool",
strprintf(
"Whether to save the mempool on shutdown and load on restart (default: %u)", DEFAULT_PERSIST_MEMPOOL));
419 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)", -
GetNumCores(), MAX_SCRIPTCHECK_THREADS, DEFAULT_SCRIPTCHECK_THREADS));
423 strUsage +=
HelpMessageOpt(
"-reindex-chainstate",
"Rebuild chain state from the currently indexed blocks");
424 strUsage +=
HelpMessageOpt(
"-reindex",
"Rebuild block chain index from current blk000??.dat files on startup");
425 strUsage +=
HelpMessageOpt(
"-resync",
"Delete blockchain folders and resync from scratch on startup");
427 strUsage +=
HelpMessageOpt(
"-sysperms",
"Create new files with system default permissions, instead of umask 077 (only effective with disabled wallet functionality)");
429 strUsage +=
HelpMessageOpt(
"-txindex",
strprintf(
"Maintain a full transaction index, used by the getrawtransaction rpc call (default: %u)", DEFAULT_TXINDEX));
430 strUsage +=
HelpMessageOpt(
"-forcestart",
"Attempt to force blockchain corruption recovery on startup");
433 strUsage +=
HelpMessageOpt(
"-addnode=<ip>",
"Add a node to connect to and attempt to keep the connection open");
434 strUsage +=
HelpMessageOpt(
"-asmap=<file>",
strprintf(
"Specify asn mapping used for bucketing of the peers (default: %s). Relative paths will be prefixed by the net-specific datadir location.", DEFAULT_ASMAP_FILENAME));
435 strUsage +=
HelpMessageOpt(
"-banscore=<n>",
strprintf(
"Threshold for disconnecting misbehaving peers (default: %u)", DEFAULT_BANSCORE_THRESHOLD));
436 strUsage +=
HelpMessageOpt(
"-bantime=<n>",
strprintf(
"Number of seconds to keep misbehaving peers from reconnecting (default: %u)", DEFAULT_MISBEHAVING_BANTIME));
437 strUsage +=
HelpMessageOpt(
"-bind=<addr>",
"Bind to given address and always listen on it. Use [host]:port notation for IPv6");
438 strUsage +=
HelpMessageOpt(
"-connect=<ip>",
"Connect only to the specified node(s); -noconnect or -connect=0 alone to disable automatic connections");
439 strUsage +=
HelpMessageOpt(
"-discover",
"Discover own IP address (default: 1 when listening and no -externalip)");
440 strUsage +=
HelpMessageOpt(
"-dns",
strprintf(
"Allow DNS lookups for -addnode, -seednode and -connect (default: %u)", DEFAULT_NAME_LOOKUP));
441 strUsage +=
HelpMessageOpt(
"-dnsseed",
"Query for peer addresses via DNS lookup, if low on addresses (default: 1 unless -connect/-noconnect)");
442 strUsage +=
HelpMessageOpt(
"-externalip=<ip>",
"Specify your own public address");
443 strUsage +=
HelpMessageOpt(
"-forcednsseed",
strprintf(
"Always query for peer addresses via DNS lookup (default: %u)", DEFAULT_FORCEDNSSEED));
444 strUsage +=
HelpMessageOpt(
"-listen",
strprintf(
"Accept connections from outside (default: %u if no -proxy or -connect/-noconnect)", DEFAULT_LISTEN));
445 strUsage +=
HelpMessageOpt(
"-listenonion",
strprintf(
"Automatically create Tor hidden service (default: %d)", DEFAULT_LISTEN_ONION));
446 strUsage +=
HelpMessageOpt(
"-maxconnections=<n>",
strprintf(
"Maintain at most <n> connections to peers (default: %u)", DEFAULT_MAX_PEER_CONNECTIONS));
447 strUsage +=
HelpMessageOpt(
"-maxreceivebuffer=<n>",
strprintf(
"Maximum per-connection receive buffer, <n>*1000 bytes (default: %u)", DEFAULT_MAXRECEIVEBUFFER));
448 strUsage +=
HelpMessageOpt(
"-maxsendbuffer=<n>",
strprintf(
"Maximum per-connection send buffer, <n>*1000 bytes (default: %u)", DEFAULT_MAXSENDBUFFER));
449 strUsage +=
HelpMessageOpt(
"-onion=<ip:port>",
strprintf(
"Use separate SOCKS5 proxy to reach peers via Tor hidden services (default: %s)",
"-proxy"));
450 strUsage +=
HelpMessageOpt(
"-onlynet=<net>",
"Only connect to nodes in network <net> (ipv4, ipv6 or onion)");
451 strUsage +=
HelpMessageOpt(
"-permitbaremultisig",
strprintf(
"Relay non-P2SH multisig (default: %u)", DEFAULT_PERMIT_BAREMULTISIG));
452 strUsage +=
HelpMessageOpt(
"-peerbloomfilters",
strprintf(
"Support filtering of blocks and transaction with bloom filters (default: %u)", DEFAULT_PEERBLOOMFILTERS));
453 strUsage +=
HelpMessageOpt(
"-port=<port>",
strprintf(
"Listen for connections on <port> (default: %u or testnet: %u)", defaultChainParams->GetDefaultPort(), testnetChainParams->GetDefaultPort()));
454 strUsage +=
HelpMessageOpt(
"-proxy=<ip:port>",
"Connect through SOCKS5 proxy");
455 strUsage +=
HelpMessageOpt(
"-proxyrandomize",
strprintf(
"Randomize credentials for every proxy connection. This enables Tor stream isolation (default: %u)", DEFAULT_PROXYRANDOMIZE));
456 strUsage +=
HelpMessageOpt(
"-seednode=<ip>",
"Connect to a node to retrieve peer addresses, and disconnect");
457 strUsage +=
HelpMessageOpt(
"-timeout=<n>",
strprintf(
"Specify connection timeout in milliseconds (minimum: 1, default: %d)", DEFAULT_CONNECT_TIMEOUT));
459 strUsage +=
HelpMessageOpt(
"-torpassword=<pass>",
"Tor control port password (default: empty)");
460 strUsage +=
HelpMessageOpt(
"-upnp",
strprintf(
"Use UPnP to map the listening port (default: %u)", DEFAULT_UPNP));
462 strUsage +=
HelpMessageOpt(
"-natpmp",
strprintf(
"Use NAT-PMP to map the listening port (default: %s)", DEFAULT_NATPMP ?
"1 when listening and no -proxy" :
"0"));
464 strUsage +=
HelpMessageOpt(
"-whitebind=<addr>",
"Bind to given address and whitelist peers connecting to it. Use [host]:port notation for IPv6");
465 strUsage +=
HelpMessageOpt(
"-whitelist=<netmask>",
"Whitelist peers connecting from the given netmask or IP address. Can be specified multiple times."
466 " 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");
473 strUsage +=
HelpMessageOpt(
"-windowtitle=<name>",
"Wallet window title");
478 strUsage +=
HelpMessageOpt(
"-zmqpubhashblock=<address>",
"Enable publish hash block in <address>");
479 strUsage +=
HelpMessageOpt(
"-zmqpubhashtx=<address>",
"Enable publish hash transaction in <address>");
480 strUsage +=
HelpMessageOpt(
"-zmqpubrawblock=<address>",
"Enable publish raw block in <address>");
481 strUsage +=
HelpMessageOpt(
"-zmqpubrawtx=<address>",
"Enable publish raw transaction in <address>");
485 strUsage +=
HelpMessageOpt(
"-uacomment=<cmt>",
"Append comment to the user agent string");
487 strUsage +=
HelpMessageOpt(
"-checkblockindex",
strprintf(
"Do a full consistency check for mapBlockIndex, setBlockIndexCandidates, chainActive and mapBlocksUnlinked occasionally. Also sets -checkmempool (default: %u)", defaultChainParams->DefaultConsistencyChecks()));
488 strUsage +=
HelpMessageOpt(
"-checkmempool=<n>",
strprintf(
"Run checks every <n> transactions (default: %u)", defaultChainParams->DefaultConsistencyChecks()));
489 strUsage +=
HelpMessageOpt(
"-checkpoints",
strprintf(
"Only accept block chain matching built-in checkpoints (default: %u)", DEFAULT_CHECKPOINTS_ENABLED));
490 strUsage +=
HelpMessageOpt(
"-disablesafemode",
strprintf(
"Disable safemode, override a real safe mode event (default: %u)", DEFAULT_DISABLE_SAFEMODE));
492 strUsage +=
HelpMessageOpt(
"-deprecatedrpc=<method>",
"Allows deprecated RPC method(s) to be used");
493 strUsage +=
HelpMessageOpt(
"-dropmessagestest=<n>",
"Randomly drop 1 of every <n> network messages");
494 strUsage +=
HelpMessageOpt(
"-fuzzmessagestest=<n>",
"Randomly fuzz 1 of every <n> network messages");
495 strUsage +=
HelpMessageOpt(
"-stopafterblockimport",
strprintf(
"Stop running after importing blocks from disk (default: %u)", DEFAULT_STOPAFTERBLOCKIMPORT));
496 strUsage +=
HelpMessageOpt(
"-limitancestorcount=<n>",
strprintf(
"Do not accept transactions if number of in-mempool ancestors is <n> or more (default: %u)", DEFAULT_ANCESTOR_LIMIT));
497 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));
498 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));
499 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));
500 strUsage +=
HelpMessageOpt(
"-sporkkey=<privkey>",
"Enable spork administration functionality with the appropriate private key.");
501 strUsage +=
HelpMessageOpt(
"-nuparams=upgradeName:activationHeight",
"Use given activation height for specified network upgrade (regtest-only)");
503 strUsage +=
HelpMessageOpt(
"-debug=<category>",
strprintf(
"Output debugging information (default: %u, supplying <category> is optional)", 0) +
". " +
504 "If <category> is not supplied, output all debugging information. <category> can be: " +
ListLogCategories() +
".");
505 strUsage +=
HelpMessageOpt(
"-debugexclude=<category>",
"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.");
507 strUsage +=
HelpMessageOpt(
"-nodebug",
"Turn off debugging messages, same as -debug=0");
509 strUsage +=
HelpMessageOpt(
"-help-debug",
"Show all debugging options (usage: --help -help-debug)");
510 strUsage +=
HelpMessageOpt(
"-logips",
strprintf(
"Include IP addresses in debug output (default: %u)", DEFAULT_LOGIPS));
511 strUsage +=
HelpMessageOpt(
"-logtimestamps",
strprintf(
"Prepend debug output with timestamp (default: %u)", DEFAULT_LOGTIMESTAMPS));
512 strUsage +=
HelpMessageOpt(
"-logtimemicros",
strprintf(
"Add microsecond precision to debug timestamps (default: %u)", DEFAULT_LOGTIMEMICROS));
514 strUsage +=
HelpMessageOpt(
"-mocktime=<n>",
"Replace actual time with <n> seconds since epoch (default: 0)");
515 strUsage +=
HelpMessageOpt(
"-maxsigcachesize=<n>",
strprintf(
"Limit size of signature cache to <n> MiB (default: %u)", DEFAULT_MAX_SIG_CACHE_SIZE));
517 strUsage +=
HelpMessageOpt(
"-maxtipage=<n>",
strprintf(
"Maximum tip age in seconds to consider node in initial block download (default: %u)", DEFAULT_MAX_TIP_AGE));
519 strUsage +=
HelpMessageOpt(
"-printtoconsole",
strprintf(
"Send trace/debug info to console instead of debug.log file (default: %u)", 0));
521 strUsage +=
HelpMessageOpt(
"-dustrelayfee=<amt>",
strprintf(
"Fee rate (in %s/kB) used to define 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)));
522 strUsage +=
HelpMessageOpt(
"-printpriority",
strprintf(
"Log transaction fee per kB when mining blocks (default: %u)", DEFAULT_PRINTPRIORITY));
524 strUsage +=
HelpMessageOpt(
"-shrinkdebugfile",
"Shrink debug.log file on client startup (default: 1 when no -debug)");
532 strprintf(
"Relay and mine \"non-standard\" transactions (%sdefault: %u)",
533 "testnet/regtest only; ",
536 strUsage +=
HelpMessageOpt(
"-datacarrier",
strprintf(
"Relay and mine data carrier transactions (default: %u)", DEFAULT_ACCEPT_DATACARRIER));
537 strUsage +=
HelpMessageOpt(
"-datacarriersize",
strprintf(
"Maximum size of data in data carrier transactions we relay and mine (default: %u)", MAX_OP_RETURN_RELAY));
539 strUsage +=
HelpMessageOpt(
"-blockversion=<n>",
"Override block version to test forking scenarios");
543 strUsage +=
HelpMessageOpt(
"-blockmaxsize=<n>",
strprintf(
"Set maximum block size in bytes (default: %d)", DEFAULT_BLOCK_MAX_SIZE));
545 strUsage +=
HelpMessageOpt(
"-blockversion=<n>",
"Override block version to test forking scenarios");
548 strUsage +=
HelpMessageOpt(
"-server",
"Accept command line and JSON-RPC commands");
549 strUsage +=
HelpMessageOpt(
"-rest",
strprintf(
"Accept public REST requests (default: %u)", DEFAULT_REST_ENABLE));
550 strUsage +=
HelpMessageOpt(
"-rpcbind=<addr>",
"Bind to given address to listen for JSON-RPC connections. Do not expose the RPC server to untrusted networks such as the public internet! This option is ignored unless -rpcallowip is also passed. Port is optional and overrides -rpcport. Use [host]:port notation for IPv6. This option can be specified multiple times (default: 127.0.0.1 and ::1 i.e., localhost)");
551 strUsage +=
HelpMessageOpt(
"-rpccookiefile=<loc>",
"Location of the auth cookie (default: data dir)");
552 strUsage +=
HelpMessageOpt(
"-rpcuser=<user>",
"Username for JSON-RPC connections");
553 strUsage +=
HelpMessageOpt(
"-rpcpassword=<pw>",
"Password for JSON-RPC connections");
554 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");
555 strUsage +=
HelpMessageOpt(
"-rpcport=<port>",
strprintf(
"Listen for JSON-RPC connections on <port> (default: %u or testnet: %u)", defaultBaseParams->RPCPort(), testnetBaseParams->RPCPort()));
556 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");
557 strUsage +=
HelpMessageOpt(
"-rpcthreads=<n>",
strprintf(
"Set the number of threads to service RPC calls (default: %d)", DEFAULT_HTTP_THREADS));
559 strUsage +=
HelpMessageOpt(
"-rpcworkqueue=<n>",
strprintf(
"Set the depth of the work queue to service RPC calls (default: %d)", DEFAULT_HTTP_WORKQUEUE));
560 strUsage +=
HelpMessageOpt(
"-rpcservertimeout=<n>",
strprintf(
"Timeout during HTTP requests (default: %d)", DEFAULT_HTTP_SERVER_TIMEOUT));
563 strUsage +=
HelpMessageOpt(
"-blockspamfilter=<n>",
strprintf(
"Use block spam filter (default: %u)", DEFAULT_BLOCK_SPAM_FILTER));
564 strUsage +=
HelpMessageOpt(
"-blockspamfiltermaxsize=<n>",
strprintf(
"Maximum size of the list of indexes in the block spam filter (default: %u)", DEFAULT_BLOCK_SPAM_FILTER_MAX_SIZE));
565 strUsage +=
HelpMessageOpt(
"-blockspamfiltermaxavg=<n>",
strprintf(
"Maximum average size of an index occurrence in the block spam filter (default: %u)", DEFAULT_BLOCK_SPAM_FILTER_MAX_AVG));
580 FormatParagraph(
_(
"Distributed under the MIT software license, see the accompanying file COPYING or <http://www.opensource.org/licenses/mit-license.php>.")) +
"\n" +
582 FormatParagraph(
_(
"This product includes UPnP software written by Thomas Bernard.")) +
586 static void BlockNotifyCallback(
bool initialSync,
const CBlockIndex *pBlockIndex)
589 if (initialSync || !pBlockIndex)
592 std::string strCmd =
gArgs.
GetArg(
"-blocknotify",
"");
594 if (!strCmd.empty()) {
603 static bool fHaveGenesis =
false;
604 static std::mutex cs_GenesisWait;
605 static std::condition_variable condvar_GenesisWait;
607 static void BlockNotifyGenesisWait(
bool,
const CBlockIndex *pBlockIndex)
609 if (pBlockIndex !=
nullptr) {
611 std::unique_lock<std::mutex> lock_GenesisWait(cs_GenesisWait);
614 condvar_GenesisWait.notify_all();
651 LogPrintf(
"Reindexing block file blk%05u.dat...\n", (
unsigned int)nFile);
657 LogPrintf(
"Reindexing finished\n");
660 throw std::runtime_error(
"Error initializing block database");
665 fs::path pathBootstrap =
GetDataDir() /
"bootstrap.dat";
666 if (fs::exists(pathBootstrap)) {
669 fs::path pathBootstrapOld =
GetDataDir() /
"bootstrap.dat.old";
670 LogPrintf(
"Importing bootstrap.dat...\n");
674 LogPrintf(
"Warning: Could not open bootstrap file %s\n", pathBootstrap.string());
679 for (
const fs::path& path : vImportFiles) {
682 LogPrintf(
"Importing blocks file %s...\n", path.string());
685 LogPrintf(
"Warning: Could not open blocks file %s\n", path.string());
689 if (
gArgs.
GetBoolArg(
"-stopafterblockimport", DEFAULT_STOPAFTERBLOCKIMPORT)) {
690 LogPrintf(
"Stopping after block import\n");
697 LogPrintf(
"Failed to connect best block\n");
717 UIError(
_(
"Elliptic curve cryptography sanity check failure. Aborting."));
726 UIError(
_(
"OS cryptographic RNG sanity check failure. Aborting."));
737 static void LoadSaplingParams()
739 struct timeval tv_start{}, tv_end{};
741 gettimeofday(&tv_start,
nullptr);
745 }
catch (std::runtime_error &e) {
746 std::string strError =
strprintf(
_(
"Cannot find the Sapling parameters in the following directory:\n%s"),
ZC_GetParamsDir());
747 std::string strErrorPosix =
strprintf(
_(
"Please run the included %s script and then restart."),
"install-params.sh");
760 gettimeofday(&tv_end,
nullptr);
761 elapsed = float(tv_end.tv_sec-tv_start.tv_sec) + (tv_end.tv_usec-tv_start.tv_usec)/
float(1000000);
762 LogPrintf(
"Loaded Sapling parameters in %fs seconds.\n", elapsed);
783 [[noreturn]]
static void new_handler_terminate()
789 std::set_new_handler(std::terminate);
790 LogPrintf(
"Error: Out of memory. Terminating.\n");
800 int nUserMaxConnections;
810 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
811 _CrtSetReportFile(_CRT_WARN, CreateFileA(
"NUL", GENERIC_WRITE, 0,
nullptr, OPEN_EXISTING, 0, 0));
815 _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
821 #ifndef PROCESS_DEP_ENABLE
824 #define PROCESS_DEP_ENABLE 0x00000001
826 typedef BOOL(WINAPI * PSETPROCDEPPOL)(DWORD);
827 PSETPROCDEPPOL setProcDEPPol = (PSETPROCDEPPOL)GetProcAddress(GetModuleHandleA(
"Kernel32.dll"),
"SetProcessDEPPolicy");
828 if (setProcDEPPol !=
nullptr) setProcDEPPol(PROCESS_DEP_ENABLE);
832 return UIError(
_(
"Error: Initializing networking failed"));
847 signal(SIGPIPE, SIG_IGN);
850 std::set_new_handler(new_handler_terminate);
862 LogPrintf(
"%s : parameter interaction: -bind or -whitebind set -> setting -listen=1\n", __func__);
868 LogPrintf(
"%s : parameter interaction: -connect set -> setting -dnsseed=0\n", __func__);
870 LogPrintf(
"%s : parameter interaction: -connect set -> setting -listen=0\n", __func__);
876 LogPrintf(
"%s: parameter interaction: -proxy set -> setting -listen=0\n", __func__);
880 LogPrintf(
"%s: parameter interaction: -proxy set -> setting -upnp=0\n", __func__);
882 LogPrintf(
"%s: parameter interaction: -proxy set -> setting -natpmp=0\n", __func__);
886 LogPrintf(
"%s : parameter interaction: -proxy set -> setting -discover=0\n", __func__);
892 LogPrintf(
"%s : parameter interaction: -listen=0 -> setting -upnp=0\n", __func__);
894 LogPrintf(
"%s: parameter interaction: -listen=0 -> setting -natpmp=0\n", __func__);
897 LogPrintf(
"%s : parameter interaction: -listen=0 -> setting -discover=0\n", __func__);
899 LogPrintf(
"%s : parameter interaction: -listen=0 -> setting -listenonion=0\n", __func__);
905 LogPrintf(
"%s : parameter interaction: -externalip set -> setting -discover=0\n", __func__);
913 if (
Params().NetworkIDString() !=
"regtest") {
914 return UIError(
_(
"Network upgrade parameters may only be overridden on regtest."));
916 for (
const std::string& strDeployment :
gArgs.
GetArgs(
"-nuparams")) {
917 std::vector<std::string> vDeploymentParams;
918 boost::split(vDeploymentParams, strDeployment, boost::is_any_of(
":"));
919 if (vDeploymentParams.size() != 2) {
920 return UIError(
strprintf(
_(
"Network upgrade parameters malformed, expecting %s"),
"hexBranchId:activationHeight"));
922 int nActivationHeight;
923 if (!
ParseInt32(vDeploymentParams[1], &nActivationHeight)) {
924 return UIError(
strprintf(
_(
"Invalid activation height (%s)"), vDeploymentParams[1]));
932 LogPrintf(
"Setting network upgrade activation parameters for %s to height=%d\n", vDeploymentParams[0], nActivationHeight);
937 return UIError(
strprintf(
_(
"Invalid network upgrade (%s)"), vDeploymentParams[0]));
944 static std::string ResolveErrMsg(
const char *
const optname,
const std::string& strBind)
946 return strprintf(
_(
"Cannot resolve -%s address: '%s'"), optname, strBind);
957 LogPrintf(
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
967 version_string +=
" (debug build)";
969 version_string +=
" (release build)";
971 LogPrintf(
"PIVX version %s\n", version_string);
979 return UIError(
strprintf(
_(
"Specified blocks directory \"%s\" does not exist."),
gArgs.
GetArg(
"-blocksdir",
"").c_str()));
989 return UIError(
strprintf(
_(
"Cannot set %s or %s together with %s"),
"-bind",
"-whitebind",
"-listen=0"));
993 int nBind = std::max(nUserBind,
size_t(1));
994 nUserMaxConnections =
gArgs.
GetArg(
"-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS);
995 nMaxConnections = std::max(nUserMaxConnections, 0);
1002 int fd_max = FD_SETSIZE;
1004 nMaxConnections = std::max(std::min<int>(nMaxConnections, fd_max - nBind -
MIN_CORE_FILEDESCRIPTORS - MAX_ADDNODE_CONNECTIONS), 0);
1006 return UIError(
_(
"Not enough file descriptors available."));
1012 const std::vector<std::string>& categories =
gArgs.
GetArgs(
"-debug");
1015 find(categories.begin(), categories.end(), std::string(
"0")) != categories.end())) {
1016 for (
const auto& cat : categories) {
1018 UIWarning(
strprintf(
_(
"Unsupported logging category %s=%s."),
"-debug", cat));
1024 for (
const std::string& cat :
gArgs.
GetArgs(
"-debugexclude")) {
1026 UIWarning(
strprintf(
_(
"Unsupported logging category %s=%s."),
"-debugexclude", cat));
1032 UIWarning(
strprintf(
_(
"Warning: Unsupported argument %s ignored, use %s."),
"-debugnet",
"-debug=net"));
1036 strprintf(
_(
"Error: Unsupported argument %s found. Setting SOCKS version isn't possible anymore, only SOCKS5 proxies are supported."),
"-socks"));
1039 return UIError(
strprintf(
_(
"Error: Unsupported argument %s found, use %s."),
"-tor",
"-onion"));
1042 return UIError(
strprintf(
_(
"Error: Unsupported argument %s found. Checklevel must be level 4."),
"-checklevel"));
1045 return UIError(
strprintf(
_(
"Error: %s must be true if %s is set."),
"-listen",
"-masternode"));
1047 UIWarning(
strprintf(
_(
"Warning: Unsupported argument %s ignored, use %s"),
"-benchmark",
"-debug=bench."));
1050 int ratio = std::min<int>(
1051 std::max<int>(
gArgs.
GetArg(
"-checkmempool",
Params().DefaultConsistencyChecks() ? 1 : 0), 0), 1000000);
1059 int64_t nMempoolSizeLimit =
gArgs.
GetArg(
"-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000;
1060 int64_t nMempoolDescendantSizeLimit =
gArgs.
GetArg(
"-limitdescendantsize", DEFAULT_DESCENDANT_SIZE_LIMIT) * 1000;
1061 if (nMempoolSizeLimit < 0 || nMempoolSizeLimit < nMempoolDescendantSizeLimit * 40)
1062 return UIError(
strprintf(
_(
"Error: %s must be at least %d MB"),
"-maxmempool",
1063 gArgs.
GetArg(
"-limitdescendantsize", DEFAULT_DESCENDANT_SIZE_LIMIT) / 25));
1074 setvbuf(stdout,
nullptr, _IOLBF, 0);
1076 #ifndef ENABLE_WALLET
1078 LogPrintf(
"AppInit2 : parameter interaction: wallet functionality not enabled -> setting -staking=0\n");
1094 return UIError(AmountErrMsg(
"minrelaytxfee",
gArgs.
GetArg(
"-minrelaytxfee",
"")));
1103 return UIError(
strprintf(
"%s is not currently supported for %s chain",
"-acceptnonstdtxn", chainparams.
NetworkIDString()));
1110 return UIError(AmountErrMsg(
"dustrelayfee",
gArgs.
GetArg(
"-dustrelayfee",
"")));
1114 #ifdef ENABLE_WALLET
1123 if (
Params().IsRegTestNet()) {
1138 static bool LockDataDirectory(
bool probeOnly)
1143 return UIError(
strprintf(
_(
"Cannot write to data directory '%s'; check permissions."), datadir.string()));
1146 return UIError(
strprintf(
_(
"Cannot obtain a lock on data directory %s. %s is probably already running."), datadir.string(),
PACKAGE_NAME));
1165 return LockDataDirectory(
true);
1174 if (!LockDataDirectory(
false)) {
1180 if (!CreatePidFile()) {
1191 #ifdef ENABLE_WALLET
1192 LogPrintf(
"Using BerkeleyDB version %s\n", DbEnv::version(0, 0, 0));
1197 LogPrintf(
"Using data directory %s\n",
GetDataDir().
string());
1199 LogPrintf(
"Using at most %i automatic connections (%i file descriptors available)\n", nMaxConnections, nFD);
1200 std::ostringstream strErrors;
1204 LogPrintf(
"Warning: relative datadir option '%s' specified, which will be interpreted relative to the "
1205 "current working directory '%s'. This is fragile because if PIVX is started in the future "
1206 "from a different location. It will be unable to locate the current data files. There could "
1207 "also be data loss if PIVX is started while in a temporary directory.\n",
1208 gArgs.
GetArg(
"-datadir",
""), fs::current_path().string());
1222 return UIError(
_(
"Unable to sign spork message, wrong key?"));
1227 threadGroup.create_thread(std::bind(&TraceThread<CScheduler::Function>,
"scheduler", serviceLoop));
1237 LoadSaplingParams();
1242 RegisterAllCoreRPCCommands(
tableRPC);
1243 #ifdef ENABLE_WALLET
1255 return UIError(
_(
"Unable to start HTTP server. See debug log for details."));
1262 fs::path chainstateDir =
GetDataDir() /
"chainstate";
1263 fs::path sporksDir =
GetDataDir() /
"sporks";
1264 fs::path zerocoinDir =
GetDataDir() /
"zerocoin";
1267 LogPrintf(
"Deleting blockchain folders blocks, chainstate, sporks, zerocoin and evodb\n");
1268 std::vector<fs::path> removeDirs{blocksDir, chainstateDir, sporksDir, zerocoinDir, evoDir};
1271 for (
const auto& dir : removeDirs) {
1272 if (fs::exists(dir)) {
1273 fs::remove_all(dir);
1274 LogPrintf(
"-resync: folder deleted: %s\n", dir.string().c_str());
1277 }
catch (
const fs::filesystem_error&
error) {
1278 LogPrintf(
"Failed to delete blockchain folders %s\n",
error.what());
1283 #ifdef ENABLE_WALLET
1296 g_connman = std::make_unique<CConnman>(
GetRand(std::numeric_limits<uint64_t>::max()),
GetRand(std::numeric_limits<uint64_t>::max()));
1303 std::vector<std::string> uacomments;
1304 for (
const std::string& cmt :
gArgs.
GetArgs(
"-uacomment")) {
1306 return UIError(
strprintf(
_(
"User Agent comment (%s) contains unsafe characters."), cmt));
1307 uacomments.push_back(cmt);
1313 return UIError(
strprintf(
_(
"Total length of network version string (%i) exceeds maximum length (%i). Reduce the number or size of %s."),
1314 strSubVersion.size(), MAX_SUBVERSION_LENGTH,
"-uacomment"));
1318 std::set<enum Network> nets;
1319 for (
const std::string& snet :
gArgs.
GetArgs(
"-onlynet")) {
1322 return UIError(
strprintf(
_(
"Unknown network specified in %s: '%s'"),
"-onlynet", snet));
1325 for (
int n = 0; n <
NET_MAX; n++) {
1327 if (!nets.count(net))
1335 bool proxyRandomize =
gArgs.
GetBoolArg(
"-proxyrandomize", DEFAULT_PROXYRANDOMIZE);
1338 std::string proxyArg =
gArgs.
GetArg(
"-proxy",
"");
1340 if (!proxyArg.empty() && proxyArg !=
"0") {
1343 return UIError(
strprintf(
_(
"%s Invalid %s address or hostname: '%s'"),
"Lookup():",
"-proxy", proxyArg));
1348 return UIError(
strprintf(
_(
"%s Invalid %s address or hostname: '%s'"),
"isValid():",
"-proxy", proxyArg));
1360 std::string onionArg =
gArgs.
GetArg(
"-onion",
"");
1361 if (!onionArg.empty()) {
1362 if (onionArg ==
"0") {
1367 return UIError(
strprintf(
_(
"%s Invalid %s address or hostname: '%s'"),
"Lookup():",
"-onion", onionArg));
1371 return UIError(
strprintf(
_(
"%s Invalid %s address or hostname: '%s'"),
"isValid():",
"-onion", onionArg));
1381 for (
const std::string& strAddr :
gArgs.
GetArgs(
"-externalip")) {
1386 return UIError(ResolveErrMsg(
"externalip", strAddr));
1391 fs::path asmap_path = fs::path(
gArgs.
GetArg(
"-asmap",
""));
1392 if (asmap_path.empty()) {
1393 asmap_path = DEFAULT_ASMAP_FILENAME;
1395 if (!asmap_path.is_absolute()) {
1398 if (!fs::exists(asmap_path)) {
1399 UIError(
strprintf(
_(
"Could not find asmap file %s"), asmap_path));
1403 if (asmap.size() == 0) {
1404 UIError(
strprintf(
_(
"Could not parse asmap file %s"), asmap_path));
1408 connman.
SetAsmap(std::move(asmap));
1409 LogPrintf(
"Using asmap version %s for IP bucketing\n", asmap_version.
ToString());
1411 LogPrintf(
"Using /16 prefix for IP bucketing\n");
1422 if (pzmqNotificationInterface) {
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 LogPrintf(
"Cache configuration:\n");
1446 LogPrintf(
"* Using %.1fMiB for block index database\n", nBlockTreeDBCache * (1.0 / 1024 / 1024));
1447 LogPrintf(
"* Using %.1fMiB for chain state database\n", nCoinDBCache * (1.0 / 1024 / 1024));
1448 LogPrintf(
"* Using %.1fMiB for in-memory UTXO set\n",
nCoinCacheUsage * (1.0 / 1024 / 1024));
1453 bool fLoaded =
false;
1456 std::string strLoadError;
1461 const int64_t load_block_index_start_time =
GetTimeMillis();
1467 pcoinscatcher.reset();
1494 std::string strBlockIndexError;
1497 strLoadError =
_(
"Error loading block database");
1498 strLoadError =
strprintf(
"%s : %s", strLoadError, strBlockIndexError);
1505 return UIError(
_(
"Incorrect or no genesis block found. Wrong datadir for network?"));
1510 strLoadError =
strprintf(
_(
"You need to rebuild the database using %s to change %s"),
"-reindex-chainstate",
"-txindex");
1518 strLoadError =
_(
"Error initializing block database");
1533 strLoadError =
_(
"Error upgrading chainstate database");
1539 strLoadError =
strprintf(
_(
"Unable to replay blocks. You will need to rebuild the database using %s."),
"-reindex");
1548 bool is_coinsview_empty = fReset || fReindexChainState ||
pcoinsTip->GetBestBlock().IsNull();
1549 if (!is_coinsview_empty) {
1552 strLoadError =
_(
"Error initializing block database");
1564 if (fZerocoinActive) {
1565 if (!
pcoinsTip->PruneInvalidEntries()) {
1566 strLoadError =
_(
"System error while flushing the chainstate after pruning invalid entries. Possible corrupt database.");
1581 if (!is_coinsview_empty) {
1586 strLoadError =
_(
"The block database contains a block which appears to be from the future. "
1587 "This may be due to your computer's date and time being set incorrectly. "
1588 "Only rebuild the block database if you are sure that your computer's date and time are correct");
1593 gArgs.
GetArg(
"-checkblocks", DEFAULT_CHECKBLOCKS))) {
1594 strLoadError =
_(
"Corrupted block database detected");
1598 }
catch (
const std::exception& e) {
1599 LogPrintf(
"%s\n", e.what());
1600 strLoadError =
_(
"Error opening block database");
1605 LogPrintf(
" block index %15dms\n",
GetTimeMillis() - load_block_index_start_time);
1612 strLoadError +
".\n\n" +
_(
"Do you want to rebuild the block database now?"),
1618 LogPrintf(
"Aborted block database rebuild. Exiting.\n");
1622 return UIError(strLoadError);
1631 LogPrintf(
"Shutdown requested. Exiting.\n");
1635 fs::path est_path =
GetDataDir() / FEE_ESTIMATES_FILENAME;
1638 if (!est_filein.
IsNull())
1643 #ifdef ENABLE_WALLET
1647 LogPrintf(
"No wallet compiled in!\n");
1665 fHaveGenesis =
true;
1682 std::vector<fs::path> vImportFiles;
1683 for (
const std::string& strFile :
gArgs.
GetArgs(
"-loadblock")) {
1684 vImportFiles.emplace_back(strFile);
1689 LogPrintf(
"Waiting for genesis block to be imported...\n");
1691 std::unique_lock<std::mutex> lockG(cs_GenesisWait);
1696 condvar_GenesisWait.wait_for(lockG, std::chrono::milliseconds(500));
1705 int chain_active_height;
1711 LogPrintf(
"mapBlockIndex.size() = %u\n",
mapBlockIndex.size());
1713 LogPrintf(
"chainActive.Height() = %d\n", chain_active_height);
1716 if (!
fReindex && !fReindexChainState) {
1724 bool load_cache_files = !(
fReindex || fReindexChainState);
1729 load_cache_files =
false;
1733 LoadTierTwo(chain_active_height, load_cache_files);
1743 LogPrintf(
"Shutdown requested. Exiting.\n");
1749 if (!strErrors.str().empty())
1750 return UIError(strErrors.str());
1752 #ifdef ENABLE_WALLET
1756 LogPrintf(
"Wallet %d\n", idx++);
1757 LOCK(pwallet->cs_wallet);
1758 LogPrintf(
"setKeyPool.size() = %u\n", pwallet->GetKeyPoolSize());
1759 LogPrintf(
"mapWallet.size() = %u\n", pwallet->mapWallet.size());
1760 LogPrintf(
"mapAddressBook.size() = %u\n", pwallet->GetAddressBookSize());
1778 connOptions.
nMaxAddnode = MAX_ADDNODE_CONNECTIONS;
1788 for (
const std::string& strBind :
gArgs.
GetArgs(
"-bind")) {
1791 return UIError(ResolveErrMsg(
"bind", strBind));
1793 connOptions.
vBinds.emplace_back(addrBind);
1797 for (
const std::string& strBind :
gArgs.
GetArgs(
"-whitebind")) {
1799 if (!
Lookup(strBind, addrBind, 0,
false)) {
1800 return UIError(ResolveErrMsg(
"whitebind", strBind));
1802 if (addrBind.
GetPort() == 0) {
1803 return UIError(
strprintf(
_(
"Need to specify a port with %s: '%s'"),
"-whitebind", strBind));
1813 return UIError(
strprintf(
_(
"Invalid netmask specified in %s: '%s'"),
"-whitelist", net));
1823 if (connect.size() != 1 || connect[0] !=
"0") {
1831 #ifdef ENABLE_WALLET
1837 #ifdef ENABLE_WALLET
1844 threadGroup.create_thread(std::bind(&ThreadStakeMinter));
int64_t CAmount
Amount in PIV (Can be negative)
void RPCNotifyBlockChange(bool fInitialDownload, const CBlockIndex *pindex)
void UpdateNetworkUpgradeParameters(Consensus::UpgradeIndex idx, int nActivationHeight)
Allows modifying the network upgrade regtest parameters.
const CChainParams & Params()
Return the currently selected parameters.
std::unique_ptr< CChainParams > CreateChainParams(const std::string &chain)
Creates and returns a std::unique_ptr<CChainParams> of the chosen chain.
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.
bool IsArgNegated(const std::string &strArg) const
Return true if the argument was originally passed as a negated option, i.e.
std::vector< std::string > GetArgs(const std::string &strArg) const
Return a vector of strings of the given argument.
bool IsArgSet(const std::string &strArg) const
Return true if the given argument has been manually set.
void WarnForSectionOnlyArgs()
Log warnings for options in m_section_only_args when they are specified in the default section but no...
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
bool SoftSetBoolArg(const std::string &strArg, bool fValue)
Set a boolean argument if it doesn't already have a value.
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
bool DefaultShrinkDebugFile() const
void EnableCategory(LogFlags flag)
std::atomic< bool > m_reopen_file
void DisableCategory(LogFlags flag)
static std::vector< bool > DecodeAsmap(fs::path path)
Non-refcounted RAII wrapper for FILE*.
bool IsNull() const
Return true if the wrapped FILE* is nullptr, false otherwise.
static const std::string TESTNET
static const std::string MAIN
Chain name strings.
The block chain is a tree shaped structure starting with the genesis block at the root,...
uint256 GetBlockHash() const
int64_t GetBlockTime() const
Access to the block database (blocks/index/)
CBlockIndex * Tip(bool fProofOfStake=false) const
Returns the index entry for the tip of this chain, or nullptr if none.
int Height() const
Return the maximal height in the chain.
CChainParams defines various tweakable parameters of a given instance of the PIVX system.
std::string NetworkIDString() const
Return the network string.
bool RequireStandard() const
Policy: Filter transactions that do not match well-defined patterns.
bool IsTestChain() const
If this chain is exclusively used for testing.
const Consensus::Params & GetConsensus() const
Signals for UI communication.
boost::signals2::signal< void(const std::string &message)> InitMessage
Progress message during initialization.
boost::signals2::signal< bool(const std::string &message, const std::string &caption, unsigned int style), boost::signals2::last_value< bool > > ThreadSafeMessageBox
Show message box.
boost::signals2::signal< void(bool fInitialDownload, const CBlockIndex *newTip)> NotifyBlockTip
New block has been accepted.
CCoinsView backed by another CCoinsView.
bool GetCoin(const COutPoint &outpoint, Coin &coin) const override
Retrieve the Coin (unspent transaction output) for a given outpoint.
CCoinsView that adds a memory cache for transactions to another CCoinsView.
CCoinsView backed by the LevelDB coin database (chainstate/)
bool GetCoin(const COutPoint &outpoint, Coin &coin) const override
Retrieve the Coin (unspent transaction output) for a given outpoint.
CCoinsViewErrorCatcher(CCoinsView *view)
Abstract view on the open txout dataset.
void SetAsmap(std::vector< bool > asmap)
bool Start(CScheduler &scheduler, const Options &options)
Fee rate in PIV per kilobyte: CAmount / kB.
CAmount GetFeePerK() const
void UnregisterBackgroundSignalScheduler()
Unregister a CScheduler to give callbacks which should run in the background - these callbacks will n...
void RegisterBackgroundSignalScheduler(CScheduler &scheduler)
Register a CScheduler to give callbacks which should run in the background (may only be called once)
void FlushBackgroundCallbacks()
Call any remaining callbacks on the calling thread.
void Update(const CAmount &_nSupply, int _nHeight)
An outpoint - a combination of a transaction hash and an index n into its vout.
void stop(bool drain=false)
std::function< void(void)> Function
void scheduleEvery(Function f, int64_t deltaMilliSeconds)
A combination of a network address (CNetAddr) and a (TCP) port.
bool SetPrivKey(std::string strPrivKey)
bool ReadFeeEstimates(CAutoFile &filein)
bool WriteFeeEstimates(CAutoFile &fileout) const
Write/Read estimates to disk.
void AddTransactionsUpdated(unsigned int n)
void setSanityCheck(double dFrequency=1.0)
void SetIsLoaded(bool loaded)
Sets the current loaded state.
Capture information about block/transaction validation.
RAII wrapper for VerifyDB: Verify consistency of the block and coin databases.
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances,...
static CZMQNotificationInterface * Create()
Zerocoin database (zerocoin/)
Users of this module must hold an ECCVerifyHandle.
std::string ToString() const
std::string GetHex() const
std::string FormatSubVersion(const std::string &name, int nClientVersion, const std::vector< std::string > &comments)
Format the subversion field according to BIP 14 spec (https://github.com/bitcoin/bips/blob/master/bip...
std::string FormatFullVersion()
const std::string CLIENT_NAME
const std::string CURRENCY_UNIT
bool glibcxx_sanity_test()
uint256 SerializeHash(const T &obj, int nType=SER_GETHASH, int nVersion=PROTOCOL_VERSION)
Compute the 256-bit hash of an object's serialization.
void InterruptHTTPRPC()
Interrupt HTTP RPC subsystem.
void StopHTTPRPC()
Stop HTTP RPC subsystem.
bool StartHTTPRPC()
Start HTTP RPC subsystem.
void StopREST()
Stop HTTP REST subsystem.
bool StartREST()
Start HTTP REST subsystem.
void InterruptREST()
Interrupt RPC REST subsystem.
void InterruptHTTPServer()
Interrupt HTTP server threads.
bool InitHTTPServer()
Initialize HTTP server.
bool StartHTTPServer()
Start HTTP server.
void StopHTTPServer()
Stop HTTP server.
std::unique_ptr< CConnman > g_connman
#define MIN_CORE_FILEDESCRIPTORS
void InitParameterInteraction()
Parameter interaction: change current parameters depending on various rules.
CClientUIInterface uiInterface
bool AppInitMain()
Bitcoin core main initialization.
std::string HelpMessage(HelpMessageMode mode)
Help for options shared between UI and daemon (for -help)
volatile bool fFeeEstimatesInitialized
const char *const PIVX_PID_FILENAME
The PID file facilities.
bool InitSanityCheck(void)
Sanity checks Ensure that PIVX is running in a usable environment with all necessary library support.
void OnRPCPreCommand(const CRPCCommand &cmd)
bool AppInitParameterInteraction()
Initialization: parameter interaction.
bool AppInitBasicSetup()
Initialize PIVX core: Basic context setup.
bool AppInitSanityChecks()
Initialization sanity checks: ecc init, sanity checks, dir lock.
void InitLogging()
Initialize the logging infrastructure.
void Interrupt()
Interrupt threads.
std::string LicenseInfo()
Returns licensing information (for -version)
void HandleSIGTERM(int)
Signal handlers are very limited in what they are allowed to do, so:
void ThreadImport(const std::vector< fs::path > &vImportFiles)
std::unique_ptr< PeerLogicValidation > peerLogic
HelpMessageMode
The help message mode determines what help message to show.
bool ECC_InitSanityCheck()
Check that required EC support is available at runtime.
void ECC_Start()
Initialize the elliptic curve support.
void ECC_Stop()
Deinitialize the elliptic curve support.
BCLog::Logger *const g_logger
NOTE: the logger instances is leaked on exit.
const char *const DEFAULT_DEBUGLOGFILE
std::string ListLogCategories()
Returns a string with the supported log categories.
#define LogPrint(category,...)
void StartMapPort(bool use_upnp, bool use_natpmp)
UpgradeIndex
Index into Params.vUpgrades and NetworkUpgradeInfo.
void OnPreCommand(std::function< void(const CRPCCommand &)> slot)
void OnStarted(std::function< void()> slot)
void OnStopped(std::function< void()> slot)
FILE * fopen(const fs::path &p, const char *mode)
std::set< COutPoint > setInvalidOutPoints
void ThreadRename(std::string &&)
Rename a thread both in terms of an internal (in-memory) name as well as its system thread name.
std::string strSubVersion
Subversion as sent to the P2P network in version messages.
void SetReachable(enum Network net, bool reachable)
Mark a network as reachable or unreachable (no automatic connects to it)
bool AddLocal(const CService &addr, int nScore)
RecursiveMutex cs_main
Global state.
@ NET_MAX
Dummy value to indicate the number of NET_* constants.
@ NET_ONION
TOR (v2 or v3)
@ NET_UNROUTABLE
Addresses from these networks are not publicly routable on the global Internet.
enum Network ParseNetwork(std::string net)
bool Lookup(const std::string &name, std::vector< CService > &vAddr, int portDefault, bool fAllowLookup, unsigned int nMaxSolutions)
bool LookupSubNet(const std::string &strSubnet, CSubNet &ret)
bool SetNameProxy(const proxyType &addrProxy)
bool SetProxy(enum Network net, const proxyType &addrProxy)
ServiceFlags
nServices flags
void RandAddPeriodic() noexcept
Gather entropy from various expensive sources, and feed them to the PRNG state.
bool Random_SanityCheck()
Check that OS randomness is available and returning the requested number of bytes.
void RandomInit()
Initialize global RNG state and log any CPU features that are used.
uint64_t GetRand(uint64_t nMax) noexcept
bool(* handler)(HTTPRequest *req, const std::string &strReq)
UniValue JSONRPCError(int code, const std::string &message)
@ RPC_FORBIDDEN_BY_SAFE_MODE
std::exception thrown in command handling
void RegisterWalletRPCCommands(CRPCTable &tableRPC)
void SetRPCWarmupFinished()
void SetRPCWarmupStatus(const std::string &newStatus)
Set the RPC warmup status.
void InitSignatureCache()
CSporkManager sporkManager
unsigned nMaxDatacarrierBytes
std::vector< CSubNet > vWhitelistedRange
unsigned int nReceiveFloodSize
CClientUIInterface * uiInterface
std::vector< std::string > m_specified_outgoing
NetEventsInterface * m_msgproc
ServiceFlags nLocalServices
std::vector< std::string > m_added_nodes
std::vector< CService > vWhiteBinds
std::vector< CService > vBinds
ServiceFlags nRelevantServices
unsigned int nSendBufferMaxSize
std::vector< std::string > vSeedNodes
bool m_use_addrman_outgoing
Parameters that influence chain consensus.
bool NetworkUpgradeActive(int nHeight, Consensus::UpgradeIndex idx) const
Returns true if the given network upgrade is active as of the given block height.
int height_last_invalid_UTXO
#define TRY_LOCK(cs, name)
fs::path GetDefaultDataDir()
fs::path AbsPathForConfigVal(const fs::path &path, bool net_specific)
const char *const PIVX_CONF_FILENAME
bool DirIsWritable(const fs::path &directory)
bool RenameOver(fs::path src, fs::path dest)
const fs::path & ZC_GetParamsDir()
int RaiseFileDescriptorLimit(int nMinFD)
this function tries to raise the file descriptor limit to the requested number.
const fs::path & GetDataDir(bool fNetSpecific)
int ScheduleBatchPriority(void)
On platforms that support it, tell the kernel the calling thread is CPU-intensive and non-interactive...
fs::path GetConfigFile(const std::string &confPath)
std::string HelpMessageGroup(const std::string &message)
Format a string to be used as group of options in help messages.
bool CheckDiskSpace(const fs::path &dir, uint64_t additional_bytes)
bool LockDirectory(const fs::path &directory, const std::string &lockfile_name, bool probe_only)
const fs::path & GetBlocksDir()
void runCommand(std::string strCommand)
int GetNumCores()
Return the number of cores available on the current system.
std::string HelpMessageOpt(const std::string &option, const std::string &message)
Format a string to be used as option description in help messages.
bool error(const char *fmt, const Args &... args)
std::string _(const char *psz)
Translation function: Call Translate signal on UI interface, which returns a Optional result.
bool InitActiveMN()
Initialize the active Masternode manager.
void InterruptTierTwo()
Interrupt tier two threads.
void ResetTierTwoInterfaces()
Resets the interfaces objects.
std::string GetTierTwoHelpString(bool showDebug)
void SetBudgetFinMode(const std::string &mode)
void InitTierTwoChainTip()
Initialize chain tip.
void RegisterTierTwoValidationInterface()
Register all tier two objects.
void InitTierTwoInterfaces()
Init the interfaces objects.
void InitTierTwoPreChainLoad(bool fReindex)
Inits the tier two global objects.
void StopTierTwoThreads()
Stops tier two workers.
bool LoadTierTwo(int chain_active_height, bool load_cache_files)
Loads from disk all the tier two related objects.
void StartTierTwoThreadsAndScheduleJobs(boost::thread_group &threadGroup, CScheduler &scheduler)
Starts tier two threads and jobs.
void DeleteTierTwo()
Cleans manager and worker objects pointers.
void DumpTierTwo()
Dump tier two managers to disk.
void InitTierTwoPostCoinsCacheLoad(CScheduler *scheduler)
Inits the tier two global objects that require access to the coins tip cache.
int64_t GetAdjustedTime()
const std::string DEFAULT_TOR_CONTROL
Default control port.
void InterruptTorControl()
const struct NUInfo NetworkUpgradeInfo[Consensus::MAX_NETWORK_UPGRADES]
General information about each network upgrade.
bool ParseMoney(const std::string &str, CAmount &nRet)
std::string FormatMoney(const CAmount &n, bool fPlus)
Money parsing/formatting utilities.
std::string FormatParagraph(const std::string in, size_t width, size_t indent)
Format a paragraph of text to a fixed width, adding spaces for indentation to any added line.
bool ParseInt32(const std::string &str, int32_t *out)
Convert string to signed 32-bit integer with strict parse error feedback.
std::string SanitizeString(const std::string &str, int rule)
Remove unsafe chars.
@ SAFE_CHARS_UA_COMMENT
BIP-0014 subset.
int64_t GetTimeMillis()
Returns the system time (not mockable)
void SetMockTime(int64_t nMockTimeIn)
For testing.
int64_t GetTime()
DEPRECATED Use either GetSystemTimeInSeconds (not mockable) or GetTime<T> (mockable)
std::string FormatISO8601DateTime(int64_t nTime)
ISO 8601 formatting is preferred.
void FlushStateToDisk()
Flush all state, indexes and buffers to disk.
bool LoadGenesisBlock()
Ensures we have a genesis block in the block tree, possibly writing one to disk.
std::unique_ptr< CBlockTreeDB > pblocktree
Global variable that points to the active block tree (protected by cs_main)
std::unique_ptr< CZerocoinDB > zerocoinDB
Global variable that points to the zerocoin database (protected by cs_main)
std::condition_variable g_best_block_cv
std::unique_ptr< CSporkDB > pSporkDB
Global variable that points to the spork database (protected by cs_main)
bool LoadBlockIndex(std::string &strError)
Load the block tree and coins database from disk, initializing state if we're running with -reindex.
bool DumpMempool(const CTxMemPool &pool)
Dump the mempool to disk.
CTxMemPool mempool(::minRelayTxFee)
bool LoadMempool(CTxMemPool &pool)
Load the mempool from disk.
CFeeRate minRelayTxFee
Fees smaller than this (in upiv) are considered zero fee (for relaying, mining and transaction creati...
bool ActivateBestChain(CValidationState &state, std::shared_ptr< const CBlock > pblock)
Make the best chain active, in multiple steps.
std::unique_ptr< CCoinsViewCache > pcoinsTip
Global variable that points to the active CCoinsView (protected by cs_main)
int64_t g_best_block_time
std::atomic< bool > fImporting
void ThreadScriptCheck()
Run an instance of the script checking thread.
fs::path GetBlockPosFilename(const FlatFilePos &pos)
Translation to a filesystem path.
bool LoadChainTip(const CChainParams &chainparams)
Update the chain tip based on database information.
FILE * OpenBlockFile(const FlatFilePos &pos, bool fReadOnly)
Open a block file (blk?????.dat)
std::unique_ptr< CCoinsViewDB > pcoinsdbview
Global variable that points to the coins database (protected by cs_main)
bool LoadExternalBlockFile(FILE *fileIn, FlatFilePos *dbp)
Import blocks from an external file.
void UnloadBlockIndex()
Unload database information.
bool ReplayBlocks(const CChainParams ¶ms, CCoinsView *view)
Replay blocks that aren't fully applied to the database.
std::atomic< bool > fReindex
CChain chainActive
The currently-connected chain of blocks (protected by cs_main).
std::unique_ptr< AccumulatorCache > accumulatorCache
In-memory cache for the zerocoin accumulators.
CBlockIndex * LookupBlockIndex(const uint256 &hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
CMainSignals & GetMainSignals()
void UnregisterValidationInterface(CValidationInterface *pwalletIn)
Unregister a wallet from core.
void UnregisterAllValidationInterfaces()
Unregister all wallets from core.
void RegisterValidationInterface(CValidationInterface *pwalletIn)
Register a wallet to receive updates from core.
bool WalletVerify()
Responsible for reading and validating the -wallet arguments and verifying the wallet database.
std::string GetWalletHelpString(bool showDebug)
Return the wallets help message.
bool InitLoadWallet()
Load wallet databases.
bool WalletParameterInteraction()
Wallets parameter interaction.
std::vector< CWalletRef > vpwallets
boost::thread_group threadGroup
std::string GetWarnings(const std::string &strFor)