Scripted diff find src/ -name "*.cpp" ! -wholename "src/util.h" ! -wholename "src/util.cpp" | xargs perl -i -pe 's/(?<!\.)(ParseParameters|ReadConfigFile|IsArgSet|(Soft|Force)?(Get|Set)(|Bool|)Arg(s)?)\(/gArgs.\1(/g' based on bb81e1735575e1c00e808326735168cc9810c174

(#10607)

Signed-off-by: Pasta <pasta@dashboost.org>
This commit is contained in:
Pasta 2019-06-24 11:44:27 -05:00
parent 5bdb2c0ce1
commit 6bfbe6053d
No known key found for this signature in database
GPG Key ID: D362C9F7142766AE
48 changed files with 420 additions and 420 deletions

View File

@ -120,9 +120,9 @@ void SelectBaseParams(const std::string& chain)
std::string ChainNameFromCommandLine() std::string ChainNameFromCommandLine()
{ {
bool fRegTest = GetBoolArg("-regtest", false); bool fRegTest = gArgs.GetBoolArg("-regtest", false);
bool fDevNet = IsArgSet("-devnet"); bool fDevNet = gArgs.IsArgSet("-devnet");
bool fTestNet = GetBoolArg("-testnet", false); bool fTestNet = gArgs.GetBoolArg("-testnet", false);
int nameParamsCount = (fRegTest ? 1 : 0) + (fDevNet ? 1 : 0) + (fTestNet ? 1 : 0); int nameParamsCount = (fRegTest ? 1 : 0) + (fDevNet ? 1 : 0) + (fTestNet ? 1 : 0);
if (nameParamsCount > 1) if (nameParamsCount > 1)
@ -140,7 +140,7 @@ std::string ChainNameFromCommandLine()
std::string GetDevNetName() std::string GetDevNetName()
{ {
// This function should never be called for non-devnets // This function should never be called for non-devnets
assert(IsArgSet("-devnet")); assert(gArgs.IsArgSet("-devnet"));
std::string devNetName = GetArg("-devnet", ""); std::string devNetName = gArgs.GetArg("-devnet", "");
return "devnet" + (devNetName.empty() ? "" : "-" + devNetName); return "devnet" + (devNetName.empty() ? "" : "-" + devNetName);
} }

View File

@ -78,10 +78,10 @@ static int AppInitRPC(int argc, char* argv[])
// //
// Parameters // Parameters
// //
ParseParameters(argc, argv); gArgs.ParseParameters(argc, argv);
if (argc<2 || IsArgSet("-?") || IsArgSet("-h") || IsArgSet("-help") || IsArgSet("-version")) { if (argc<2 || gArgs.IsArgSet("-?") || gArgs.IsArgSet("-h") || gArgs.IsArgSet("-help") || gArgs.IsArgSet("-version")) {
std::string strUsage = strprintf(_("%s RPC client version"), _(PACKAGE_NAME)) + " " + FormatFullVersion() + "\n"; std::string strUsage = strprintf(_("%s RPC client version"), _(PACKAGE_NAME)) + " " + FormatFullVersion() + "\n";
if (!IsArgSet("-version")) { if (!gArgs.IsArgSet("-version")) {
strUsage += "\n" + _("Usage:") + "\n" + strUsage += "\n" + _("Usage:") + "\n" +
" dash-cli [options] <command> [params] " + strprintf(_("Send command to %s"), _(PACKAGE_NAME)) + "\n" + " dash-cli [options] <command> [params] " + strprintf(_("Send command to %s"), _(PACKAGE_NAME)) + "\n" +
" dash-cli [options] -named <command> [name=value] ... " + strprintf(_("Send command to %s (with named arguments)"), _(PACKAGE_NAME)) + "\n" + " dash-cli [options] -named <command> [name=value] ... " + strprintf(_("Send command to %s (with named arguments)"), _(PACKAGE_NAME)) + "\n" +
@ -98,19 +98,19 @@ static int AppInitRPC(int argc, char* argv[])
} }
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
bool datadirFromCmdLine = IsArgSet("-datadir"); bool datadirFromCmdLine = gArgs.IsArgSet("-datadir");
if (datadirFromCmdLine && !fs::is_directory(GetDataDir(false))) { if (datadirFromCmdLine && !fs::is_directory(GetDataDir(false))) {
fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", GetArg("-datadir", "").c_str()); fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", "").c_str());
return EXIT_FAILURE; return EXIT_FAILURE;
} }
try { try {
ReadConfigFile(GetArg("-conf", BITCOIN_CONF_FILENAME)); gArgs.ReadConfigFile(gArgs.GetArg("-conf", BITCOIN_CONF_FILENAME));
} catch (const std::exception& e) { } catch (const std::exception& e) {
fprintf(stderr,"Error reading configuration file: %s\n", e.what()); fprintf(stderr,"Error reading configuration file: %s\n", e.what());
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if (!datadirFromCmdLine && !fs::is_directory(GetDataDir(false))) { if (!datadirFromCmdLine && !fs::is_directory(GetDataDir(false))) {
fprintf(stderr, "Error: Specified data directory \"%s\" from config file does not exist.\n", GetArg("-datadir", "").c_str()); fprintf(stderr, "Error: Specified data directory \"%s\" from config file does not exist.\n", gArgs.GetArg("-datadir", "").c_str());
return EXIT_FAILURE; return EXIT_FAILURE;
} }
// Check for -testnet or -regtest parameter (BaseParams() calls are only valid after this clause) // Check for -testnet or -regtest parameter (BaseParams() calls are only valid after this clause)
@ -120,7 +120,7 @@ static int AppInitRPC(int argc, char* argv[])
fprintf(stderr, "Error: %s\n", e.what()); fprintf(stderr, "Error: %s\n", e.what());
return EXIT_FAILURE; return EXIT_FAILURE;
} }
if (GetBoolArg("-rpcssl", false)) if (gArgs.GetBoolArg("-rpcssl", false))
{ {
fprintf(stderr, "Error: SSL mode for RPC (-rpcssl) is no longer supported.\n"); fprintf(stderr, "Error: SSL mode for RPC (-rpcssl) is no longer supported.\n");
return EXIT_FAILURE; return EXIT_FAILURE;
@ -196,15 +196,15 @@ static void http_error_cb(enum evhttp_request_error err, void *ctx)
UniValue CallRPC(const std::string& strMethod, const UniValue& params) UniValue CallRPC(const std::string& strMethod, const UniValue& params)
{ {
std::string host = GetArg("-rpcconnect", DEFAULT_RPCCONNECT); std::string host = gArgs.GetArg("-rpcconnect", DEFAULT_RPCCONNECT);
int port = GetArg("-rpcport", BaseParams().RPCPort()); int port = gArgs.GetArg("-rpcport", BaseParams().RPCPort());
// Obtain event base // Obtain event base
raii_event_base base = obtain_event_base(); raii_event_base base = obtain_event_base();
// Synchronously look up hostname // Synchronously look up hostname
raii_evhttp_connection evcon = obtain_evhttp_connection_base(base.get(), host, port); raii_evhttp_connection evcon = obtain_evhttp_connection_base(base.get(), host, port);
evhttp_connection_set_timeout(evcon.get(), GetArg("-rpcclienttimeout", DEFAULT_HTTP_CLIENT_TIMEOUT)); evhttp_connection_set_timeout(evcon.get(), gArgs.GetArg("-rpcclienttimeout", DEFAULT_HTTP_CLIENT_TIMEOUT));
HTTPReply response; HTTPReply response;
raii_evhttp_request req = obtain_evhttp_request(http_request_done, (void*)&response); raii_evhttp_request req = obtain_evhttp_request(http_request_done, (void*)&response);
@ -216,16 +216,16 @@ UniValue CallRPC(const std::string& strMethod, const UniValue& params)
// Get credentials // Get credentials
std::string strRPCUserColonPass; std::string strRPCUserColonPass;
if (GetArg("-rpcpassword", "") == "") { if (gArgs.GetArg("-rpcpassword", "") == "") {
// Try fall back to cookie-based authentication if no password is provided // Try fall back to cookie-based authentication if no password is provided
if (!GetAuthCookie(&strRPCUserColonPass)) { if (!GetAuthCookie(&strRPCUserColonPass)) {
throw std::runtime_error(strprintf( throw std::runtime_error(strprintf(
_("Could not locate RPC credentials. No authentication cookie could be found, and no rpcpassword is set in the configuration file (%s)"), _("Could not locate RPC credentials. No authentication cookie could be found, and no rpcpassword is set in the configuration file (%s)"),
GetConfigFile(GetArg("-conf", BITCOIN_CONF_FILENAME)).string().c_str())); GetConfigFile(gArgs.GetArg("-conf", BITCOIN_CONF_FILENAME)).string().c_str()));
} }
} else { } else {
strRPCUserColonPass = GetArg("-rpcuser", "") + ":" + GetArg("-rpcpassword", ""); strRPCUserColonPass = gArgs.GetArg("-rpcuser", "") + ":" + gArgs.GetArg("-rpcpassword", "");
} }
struct evkeyvalq* output_headers = evhttp_request_get_output_headers(req.get()); struct evkeyvalq* output_headers = evhttp_request_get_output_headers(req.get());
@ -279,7 +279,7 @@ int CommandLineRPC(int argc, char *argv[])
argv++; argv++;
} }
std::vector<std::string> args = std::vector<std::string>(&argv[1], &argv[argc]); std::vector<std::string> args = std::vector<std::string>(&argv[1], &argv[argc]);
if (GetBoolArg("-stdin", false)) { if (gArgs.GetBoolArg("-stdin", false)) {
// Read one arg per line from stdin and append // Read one arg per line from stdin and append
std::string line; std::string line;
while (std::getline(std::cin,line)) while (std::getline(std::cin,line))
@ -291,14 +291,14 @@ int CommandLineRPC(int argc, char *argv[])
args.erase(args.begin()); // Remove trailing method name from arguments vector args.erase(args.begin()); // Remove trailing method name from arguments vector
UniValue params; UniValue params;
if(GetBoolArg("-named", DEFAULT_NAMED)) { if(gArgs.GetBoolArg("-named", DEFAULT_NAMED)) {
params = RPCConvertNamedValues(strMethod, args); params = RPCConvertNamedValues(strMethod, args);
} else { } else {
params = RPCConvertValues(strMethod, args); params = RPCConvertValues(strMethod, args);
} }
// Execute and handle connection failures with -rpcwait // Execute and handle connection failures with -rpcwait
const bool fWait = GetBoolArg("-rpcwait", false); const bool fWait = gArgs.GetBoolArg("-rpcwait", false);
do { do {
try { try {
const UniValue reply = CallRPC(strMethod, params); const UniValue reply = CallRPC(strMethod, params);

View File

@ -41,7 +41,7 @@ static int AppInitRawTx(int argc, char* argv[])
// //
// Parameters // Parameters
// //
ParseParameters(argc, argv); gArgs.ParseParameters(argc, argv);
// Check for -testnet or -regtest parameter (Params() calls are only valid after this clause) // Check for -testnet or -regtest parameter (Params() calls are only valid after this clause)
try { try {
@ -51,9 +51,9 @@ static int AppInitRawTx(int argc, char* argv[])
return EXIT_FAILURE; return EXIT_FAILURE;
} }
fCreateBlank = GetBoolArg("-create", false); fCreateBlank = gArgs.GetBoolArg("-create", false);
if (argc<2 || IsArgSet("-?") || IsArgSet("-h") || IsArgSet("-help")) if (argc<2 || gArgs.IsArgSet("-?") || gArgs.IsArgSet("-h") || gArgs.IsArgSet("-help"))
{ {
// First part of help message is specific to this utility // First part of help message is specific to this utility
std::string strUsage = strprintf(_("%s dash-tx utility version"), _(PACKAGE_NAME)) + " " + FormatFullVersion() + "\n\n" + std::string strUsage = strprintf(_("%s dash-tx utility version"), _(PACKAGE_NAME)) + " " + FormatFullVersion() + "\n\n" +
@ -675,9 +675,9 @@ static void OutputTxHex(const CTransaction& tx)
static void OutputTx(const CTransaction& tx) static void OutputTx(const CTransaction& tx)
{ {
if (GetBoolArg("-json", false)) if (gArgs.GetBoolArg("-json", false))
OutputTxJSON(tx); OutputTxJSON(tx);
else if (GetBoolArg("-txid", false)) else if (gArgs.GetBoolArg("-txid", false))
OutputTxHash(tx); OutputTxHash(tx);
else else
OutputTxHex(tx); OutputTxHex(tx);

View File

@ -74,14 +74,14 @@ bool AppInit(int argc, char* argv[])
// Parameters // Parameters
// //
// If Qt is used, parameters/dash.conf are parsed in qt/dash.cpp's main() // If Qt is used, parameters/dash.conf are parsed in qt/dash.cpp's main()
ParseParameters(argc, argv); gArgs.ParseParameters(argc, argv);
// Process help and version before taking care about datadir // Process help and version before taking care about datadir
if (IsArgSet("-?") || IsArgSet("-h") || IsArgSet("-help") || IsArgSet("-version")) if (gArgs.IsArgSet("-?") || gArgs.IsArgSet("-h") || gArgs.IsArgSet("-help") || gArgs.IsArgSet("-version"))
{ {
std::string strUsage = strprintf(_("%s Daemon"), _(PACKAGE_NAME)) + " " + _("version") + " " + FormatFullVersion() + "\n"; std::string strUsage = strprintf(_("%s Daemon"), _(PACKAGE_NAME)) + " " + _("version") + " " + FormatFullVersion() + "\n";
if (IsArgSet("-version")) if (gArgs.IsArgSet("-version"))
{ {
strUsage += FormatParagraph(LicenseInfo()); strUsage += FormatParagraph(LicenseInfo());
} }
@ -99,22 +99,22 @@ bool AppInit(int argc, char* argv[])
try try
{ {
bool datadirFromCmdLine = IsArgSet("-datadir"); bool datadirFromCmdLine = gArgs.IsArgSet("-datadir");
if (datadirFromCmdLine && !fs::is_directory(GetDataDir(false))) if (datadirFromCmdLine && !fs::is_directory(GetDataDir(false)))
{ {
fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", GetArg("-datadir", "").c_str()); fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", "").c_str());
return false; return false;
} }
try try
{ {
ReadConfigFile(GetArg("-conf", BITCOIN_CONF_FILENAME)); gArgs.ReadConfigFile(gArgs.GetArg("-conf", BITCOIN_CONF_FILENAME));
} catch (const std::exception& e) { } catch (const std::exception& e) {
fprintf(stderr,"Error reading configuration file: %s\n", e.what()); fprintf(stderr,"Error reading configuration file: %s\n", e.what());
return false; return false;
} }
if (!datadirFromCmdLine && !fs::is_directory(GetDataDir(false))) if (!datadirFromCmdLine && !fs::is_directory(GetDataDir(false)))
{ {
fprintf(stderr, "Error: Specified data directory \"%s\" from config file does not exist.\n", GetArg("-datadir", "").c_str()); fprintf(stderr, "Error: Specified data directory \"%s\" from config file does not exist.\n", gArgs.GetArg("-datadir", "").c_str());
return EXIT_FAILURE; return EXIT_FAILURE;
} }
// Check for -testnet or -regtest parameter (Params() calls are only valid after this clause) // Check for -testnet or -regtest parameter (Params() calls are only valid after this clause)
@ -134,7 +134,7 @@ bool AppInit(int argc, char* argv[])
} }
// -server defaults to true for bitcoind but not for the GUI so do this here // -server defaults to true for bitcoind but not for the GUI so do this here
SoftSetBoolArg("-server", true); gArgs.SoftSetBoolArg("-server", true);
// Set this early so that parameter interactions go to console // Set this early so that parameter interactions go to console
InitLogging(); InitLogging();
InitParameterInteraction(); InitParameterInteraction();
@ -153,7 +153,7 @@ bool AppInit(int argc, char* argv[])
// InitError will have been called with detailed error, which ends up on console // InitError will have been called with detailed error, which ends up on console
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (GetBoolArg("-daemon", false)) if (gArgs.GetBoolArg("-daemon", false))
{ {
#if HAVE_DECL_DAEMON #if HAVE_DECL_DAEMON
fprintf(stdout, "Dash Core server starting\n"); fprintf(stdout, "Dash Core server starting\n");

View File

@ -115,7 +115,7 @@ CDBWrapper::CDBWrapper(const fs::path& path, size_t nCacheSize, bool fMemory, bo
dbwrapper_private::HandleError(status); dbwrapper_private::HandleError(status);
LogPrintf("Opened LevelDB successfully\n"); LogPrintf("Opened LevelDB successfully\n");
if (GetBoolArg("-forcecompactdb", false)) { if (gArgs.GetBoolArg("-forcecompactdb", false)) {
LogPrintf("Starting database compaction of %s\n", path.string()); LogPrintf("Starting database compaction of %s\n", path.string());
pdb->CompactRange(nullptr, nullptr); pdb->CompactRange(nullptr, nullptr);
LogPrintf("Finished database compaction of %s\n", path.string()); LogPrintf("Finished database compaction of %s\n", path.string());

View File

@ -215,7 +215,7 @@ static bool HTTPReq_JSONRPC(HTTPRequest* req, const std::string &)
static bool InitRPCAuthentication() static bool InitRPCAuthentication()
{ {
if (GetArg("-rpcpassword", "") == "") if (gArgs.GetArg("-rpcpassword", "") == "")
{ {
LogPrintf("No rpcpassword set - using random cookie authentication\n"); LogPrintf("No rpcpassword set - using random cookie authentication\n");
if (!GenerateAuthCookie(&strRPCUserColonPass)) { if (!GenerateAuthCookie(&strRPCUserColonPass)) {
@ -226,7 +226,7 @@ static bool InitRPCAuthentication()
} }
} else { } else {
LogPrintf("Config options rpcuser and rpcpassword will soon be deprecated. Locally-run instances may remove rpcuser to use cookie-based auth, or may be replaced with rpcauth. Please see share/rpcuser for rpcauth auth generation.\n"); LogPrintf("Config options rpcuser and rpcpassword will soon be deprecated. Locally-run instances may remove rpcuser to use cookie-based auth, or may be replaced with rpcauth. Please see share/rpcuser for rpcauth auth generation.\n");
strRPCUserColonPass = GetArg("-rpcuser", "") + ":" + GetArg("-rpcpassword", ""); strRPCUserColonPass = gArgs.GetArg("-rpcuser", "") + ":" + gArgs.GetArg("-rpcpassword", "");
} }
return true; return true;
} }

View File

@ -311,14 +311,14 @@ static bool ThreadHTTP(struct event_base* base, struct evhttp* http)
/** Bind HTTP server to specified addresses */ /** Bind HTTP server to specified addresses */
static bool HTTPBindAddresses(struct evhttp* http) static bool HTTPBindAddresses(struct evhttp* http)
{ {
int defaultPort = GetArg("-rpcport", BaseParams().RPCPort()); int defaultPort = gArgs.GetArg("-rpcport", BaseParams().RPCPort());
std::vector<std::pair<std::string, uint16_t> > endpoints; std::vector<std::pair<std::string, uint16_t> > endpoints;
// Determine what addresses to bind to // Determine what addresses to bind to
if (!IsArgSet("-rpcallowip")) { // Default to loopback if not allowing external IPs if (!gArgs.IsArgSet("-rpcallowip")) { // Default to loopback if not allowing external IPs
endpoints.push_back(std::make_pair("::1", defaultPort)); endpoints.push_back(std::make_pair("::1", defaultPort));
endpoints.push_back(std::make_pair("127.0.0.1", defaultPort)); endpoints.push_back(std::make_pair("127.0.0.1", defaultPort));
if (IsArgSet("-rpcbind")) { if (gArgs.IsArgSet("-rpcbind")) {
LogPrintf("WARNING: option -rpcbind was ignored because -rpcallowip was not specified, refusing to allow everyone to connect\n"); LogPrintf("WARNING: option -rpcbind was ignored because -rpcallowip was not specified, refusing to allow everyone to connect\n");
} }
} else if (gArgs.IsArgSet("-rpcbind")) { // Specific bind address } else if (gArgs.IsArgSet("-rpcbind")) { // Specific bind address
@ -375,7 +375,7 @@ bool InitHTTPServer()
if (!InitHTTPAllowList()) if (!InitHTTPAllowList())
return false; return false;
if (GetBoolArg("-rpcssl", false)) { if (gArgs.GetBoolArg("-rpcssl", false)) {
uiInterface.ThreadSafeMessageBox( uiInterface.ThreadSafeMessageBox(
"SSL mode for RPC (-rpcssl) is no longer supported.", "SSL mode for RPC (-rpcssl) is no longer supported.",
"", CClientUIInterface::MSG_ERROR); "", CClientUIInterface::MSG_ERROR);
@ -411,7 +411,7 @@ bool InitHTTPServer()
return false; return false;
} }
evhttp_set_timeout(http, GetArg("-rpcservertimeout", DEFAULT_HTTP_SERVER_TIMEOUT)); evhttp_set_timeout(http, gArgs.GetArg("-rpcservertimeout", DEFAULT_HTTP_SERVER_TIMEOUT));
evhttp_set_max_headers_size(http, MAX_HEADERS_SIZE); evhttp_set_max_headers_size(http, MAX_HEADERS_SIZE);
evhttp_set_max_body_size(http, MAX_SIZE); evhttp_set_max_body_size(http, MAX_SIZE);
evhttp_set_gencb(http, http_request_cb, NULL); evhttp_set_gencb(http, http_request_cb, NULL);
@ -424,7 +424,7 @@ bool InitHTTPServer()
} }
LogPrint(BCLog::HTTP, "Initialized HTTP server\n"); LogPrint(BCLog::HTTP, "Initialized HTTP server\n");
int workQueueDepth = std::max((long)GetArg("-rpcworkqueue", DEFAULT_HTTP_WORKQUEUE), 1L); int workQueueDepth = std::max((long)gArgs.GetArg("-rpcworkqueue", DEFAULT_HTTP_WORKQUEUE), 1L);
LogPrintf("HTTP: creating work queue of depth %d\n", workQueueDepth); LogPrintf("HTTP: creating work queue of depth %d\n", workQueueDepth);
workQueue = new WorkQueue<HTTPClosure>(workQueueDepth); workQueue = new WorkQueue<HTTPClosure>(workQueueDepth);
@ -453,7 +453,7 @@ std::future<bool> threadResult;
bool StartHTTPServer() bool StartHTTPServer()
{ {
LogPrint(BCLog::HTTP, "Starting HTTP server\n"); LogPrint(BCLog::HTTP, "Starting HTTP server\n");
int rpcThreads = std::max((long)GetArg("-rpcthreads", DEFAULT_HTTP_THREADS), 1L); int rpcThreads = std::max((long)gArgs.GetArg("-rpcthreads", DEFAULT_HTTP_THREADS), 1L);
LogPrintf("HTTP: starting %d worker threads\n", rpcThreads); LogPrintf("HTTP: starting %d worker threads\n", rpcThreads);
std::packaged_task<bool(event_base*, evhttp*)> task(ThreadHTTP); std::packaged_task<bool(event_base*, evhttp*)> task(ThreadHTTP);
threadResult = task.get_future(); threadResult = task.get_future();

View File

@ -277,7 +277,7 @@ void PrepareShutdown()
} }
UnregisterNodeSignals(GetNodeSignals()); UnregisterNodeSignals(GetNodeSignals());
if (fDumpMempoolLater && GetArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)) { if (fDumpMempoolLater && gArgs.GetArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)) {
DumpMempool(); DumpMempool();
} }
@ -427,14 +427,14 @@ void OnRPCPreCommand(const CRPCCommand& cmd)
{ {
// Observe safe mode // Observe safe mode
std::string strWarning = GetWarnings("rpc"); std::string strWarning = GetWarnings("rpc");
if (strWarning != "" && !GetBoolArg("-disablesafemode", DEFAULT_DISABLE_SAFEMODE) && if (strWarning != "" && !gArgs.GetBoolArg("-disablesafemode", DEFAULT_DISABLE_SAFEMODE) &&
!cmd.okSafeMode) !cmd.okSafeMode)
throw JSONRPCError(RPC_FORBIDDEN_BY_SAFE_MODE, std::string("Safe mode: ") + strWarning); throw JSONRPCError(RPC_FORBIDDEN_BY_SAFE_MODE, std::string("Safe mode: ") + strWarning);
} }
std::string HelpMessage(HelpMessageMode mode) std::string HelpMessage(HelpMessageMode mode)
{ {
const bool showDebug = GetBoolArg("-help-debug", false); const bool showDebug = gArgs.GetBoolArg("-help-debug", false);
// When adding new options to the categories, please keep and ensure alphabetical ordering. // When adding new options to the categories, please keep and ensure alphabetical ordering.
// Do not translate _(...) -help-debug options, Many technical terms, and only a very small audience, so is unnecessary stress to translators. // Do not translate _(...) -help-debug options, Many technical terms, and only a very small audience, so is unnecessary stress to translators.
@ -681,7 +681,7 @@ static void BlockNotifyCallback(bool initialSync, const CBlockIndex *pBlockIndex
if (initialSync || !pBlockIndex) if (initialSync || !pBlockIndex)
return; return;
std::string strCmd = GetArg("-blocknotify", ""); std::string strCmd = gArgs.GetArg("-blocknotify", "");
boost::replace_all(strCmd, "%s", pBlockIndex->GetBlockHash().GetHex()); boost::replace_all(strCmd, "%s", pBlockIndex->GetBlockHash().GetHex());
boost::thread t(runCommand, strCmd); // thread runs free boost::thread t(runCommand, strCmd); // thread runs free
@ -818,7 +818,7 @@ void ThreadImport(std::vector<fs::path> vImportFiles)
StartShutdown(); StartShutdown();
} }
if (GetBoolArg("-stopafterblockimport", DEFAULT_STOPAFTERBLOCKIMPORT)) { if (gArgs.GetBoolArg("-stopafterblockimport", DEFAULT_STOPAFTERBLOCKIMPORT)) {
LogPrintf("Stopping after block import\n"); LogPrintf("Stopping after block import\n");
StartShutdown(); StartShutdown();
} }
@ -841,7 +841,7 @@ void ThreadImport(std::vector<fs::path> vImportFiles)
} }
#endif #endif
if (GetArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)) { if (gArgs.GetArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)) {
LoadMempool(); LoadMempool();
fDumpMempoolLater = !fRequestShutdown; fDumpMempoolLater = !fRequestShutdown;
} }
@ -884,7 +884,7 @@ bool AppInitServers(boost::thread_group& threadGroup)
return false; return false;
if (!StartHTTPRPC()) if (!StartHTTPRPC())
return false; return false;
if (GetBoolArg("-rest", DEFAULT_REST_ENABLE) && !StartREST()) if (gArgs.GetBoolArg("-rest", DEFAULT_REST_ENABLE) && !StartREST())
return false; return false;
if (!StartHTTPServer()) if (!StartHTTPServer())
return false; return false;
@ -896,93 +896,93 @@ void InitParameterInteraction()
{ {
// when specifying an explicit binding address, you want to listen on it // when specifying an explicit binding address, you want to listen on it
// even when -connect or -proxy is specified // even when -connect or -proxy is specified
if (IsArgSet("-bind")) { if (gArgs.IsArgSet("-bind")) {
if (SoftSetBoolArg("-listen", true)) if (gArgs.SoftSetBoolArg("-listen", true))
LogPrintf("%s: parameter interaction: -bind set -> setting -listen=1\n", __func__); LogPrintf("%s: parameter interaction: -bind set -> setting -listen=1\n", __func__);
} }
if (IsArgSet("-whitebind")) { if (gArgs.IsArgSet("-whitebind")) {
if (SoftSetBoolArg("-listen", true)) if (gArgs.SoftSetBoolArg("-listen", true))
LogPrintf("%s: parameter interaction: -whitebind set -> setting -listen=1\n", __func__); LogPrintf("%s: parameter interaction: -whitebind set -> setting -listen=1\n", __func__);
} }
if (GetBoolArg("-masternode", false)) { if (gArgs.GetBoolArg("-masternode", false)) {
// masternodes MUST accept connections from outside // masternodes MUST accept connections from outside
ForceSetArg("-listen", "1"); gArgs.ForceSetArg("-listen", "1");
LogPrintf("%s: parameter interaction: -masternode=1 -> setting -listen=1\n", __func__); LogPrintf("%s: parameter interaction: -masternode=1 -> setting -listen=1\n", __func__);
if (GetArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS) < DEFAULT_MAX_PEER_CONNECTIONS) { if (gArgs.GetArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS) < DEFAULT_MAX_PEER_CONNECTIONS) {
// masternodes MUST be able to handle at least DEFAULT_MAX_PEER_CONNECTIONS connections // masternodes MUST be able to handle at least DEFAULT_MAX_PEER_CONNECTIONS connections
ForceSetArg("-maxconnections", itostr(DEFAULT_MAX_PEER_CONNECTIONS)); gArgs.ForceSetArg("-maxconnections", itostr(DEFAULT_MAX_PEER_CONNECTIONS));
LogPrintf("%s: parameter interaction: -masternode=1 -> setting -maxconnections=%d\n", __func__, DEFAULT_MAX_PEER_CONNECTIONS); LogPrintf("%s: parameter interaction: -masternode=1 -> setting -maxconnections=%d\n", __func__, DEFAULT_MAX_PEER_CONNECTIONS);
} }
} }
if (gArgs.IsArgSet("-connect")) { if (gArgs.IsArgSet("-connect")) {
// when only connecting to trusted nodes, do not seed via DNS, or listen by default // when only connecting to trusted nodes, do not seed via DNS, or listen by default
if (SoftSetBoolArg("-dnsseed", false)) if (gArgs.SoftSetBoolArg("-dnsseed", false))
LogPrintf("%s: parameter interaction: -connect set -> setting -dnsseed=0\n", __func__); LogPrintf("%s: parameter interaction: -connect set -> setting -dnsseed=0\n", __func__);
if (SoftSetBoolArg("-listen", false)) if (gArgs.SoftSetBoolArg("-listen", false))
LogPrintf("%s: parameter interaction: -connect set -> setting -listen=0\n", __func__); LogPrintf("%s: parameter interaction: -connect set -> setting -listen=0\n", __func__);
} }
if (IsArgSet("-proxy")) { if (gArgs.IsArgSet("-proxy")) {
// to protect privacy, do not listen by default if a default proxy server is specified // to protect privacy, do not listen by default if a default proxy server is specified
if (SoftSetBoolArg("-listen", false)) if (gArgs.SoftSetBoolArg("-listen", false))
LogPrintf("%s: parameter interaction: -proxy set -> setting -listen=0\n", __func__); LogPrintf("%s: parameter interaction: -proxy set -> setting -listen=0\n", __func__);
// to protect privacy, do not use UPNP when a proxy is set. The user may still specify -listen=1 // to protect privacy, do not use UPNP when a proxy is set. The user may still specify -listen=1
// to listen locally, so don't rely on this happening through -listen below. // to listen locally, so don't rely on this happening through -listen below.
if (SoftSetBoolArg("-upnp", false)) if (gArgs.SoftSetBoolArg("-upnp", false))
LogPrintf("%s: parameter interaction: -proxy set -> setting -upnp=0\n", __func__); LogPrintf("%s: parameter interaction: -proxy set -> setting -upnp=0\n", __func__);
// to protect privacy, do not discover addresses by default // to protect privacy, do not discover addresses by default
if (SoftSetBoolArg("-discover", false)) if (gArgs.SoftSetBoolArg("-discover", false))
LogPrintf("%s: parameter interaction: -proxy set -> setting -discover=0\n", __func__); LogPrintf("%s: parameter interaction: -proxy set -> setting -discover=0\n", __func__);
} }
if (!GetBoolArg("-listen", DEFAULT_LISTEN)) { if (!gArgs.GetBoolArg("-listen", DEFAULT_LISTEN)) {
// do not map ports or try to retrieve public IP when not listening (pointless) // do not map ports or try to retrieve public IP when not listening (pointless)
if (SoftSetBoolArg("-upnp", false)) if (gArgs.SoftSetBoolArg("-upnp", false))
LogPrintf("%s: parameter interaction: -listen=0 -> setting -upnp=0\n", __func__); LogPrintf("%s: parameter interaction: -listen=0 -> setting -upnp=0\n", __func__);
if (SoftSetBoolArg("-discover", false)) if (gArgs.SoftSetBoolArg("-discover", false))
LogPrintf("%s: parameter interaction: -listen=0 -> setting -discover=0\n", __func__); LogPrintf("%s: parameter interaction: -listen=0 -> setting -discover=0\n", __func__);
if (SoftSetBoolArg("-listenonion", false)) if (gArgs.SoftSetBoolArg("-listenonion", false))
LogPrintf("%s: parameter interaction: -listen=0 -> setting -listenonion=0\n", __func__); LogPrintf("%s: parameter interaction: -listen=0 -> setting -listenonion=0\n", __func__);
} }
if (IsArgSet("-externalip")) { if (gArgs.IsArgSet("-externalip")) {
// if an explicit public IP is specified, do not try to find others // if an explicit public IP is specified, do not try to find others
if (SoftSetBoolArg("-discover", false)) if (gArgs.SoftSetBoolArg("-discover", false))
LogPrintf("%s: parameter interaction: -externalip set -> setting -discover=0\n", __func__); LogPrintf("%s: parameter interaction: -externalip set -> setting -discover=0\n", __func__);
} }
// disable whitelistrelay in blocksonly mode // disable whitelistrelay in blocksonly mode
if (GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY)) { if (gArgs.GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY)) {
if (SoftSetBoolArg("-whitelistrelay", false)) if (gArgs.SoftSetBoolArg("-whitelistrelay", false))
LogPrintf("%s: parameter interaction: -blocksonly=1 -> setting -whitelistrelay=0\n", __func__); LogPrintf("%s: parameter interaction: -blocksonly=1 -> setting -whitelistrelay=0\n", __func__);
} }
// Forcing relay from whitelisted hosts implies we will accept relays from them in the first place. // Forcing relay from whitelisted hosts implies we will accept relays from them in the first place.
if (GetBoolArg("-whitelistforcerelay", DEFAULT_WHITELISTFORCERELAY)) { if (gArgs.GetBoolArg("-whitelistforcerelay", DEFAULT_WHITELISTFORCERELAY)) {
if (SoftSetBoolArg("-whitelistrelay", true)) if (gArgs.SoftSetBoolArg("-whitelistrelay", true))
LogPrintf("%s: parameter interaction: -whitelistforcerelay=1 -> setting -whitelistrelay=1\n", __func__); LogPrintf("%s: parameter interaction: -whitelistforcerelay=1 -> setting -whitelistrelay=1\n", __func__);
} }
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
int nLiqProvTmp = GetArg("-liquidityprovider", DEFAULT_PRIVATESEND_LIQUIDITY); int nLiqProvTmp = gArgs.GetArg("-liquidityprovider", DEFAULT_PRIVATESEND_LIQUIDITY);
if (nLiqProvTmp > 0) { if (nLiqProvTmp > 0) {
ForceSetArg("-enableprivatesend", "1"); gArgs.ForceSetArg("-enableprivatesend", "1");
LogPrintf("%s: parameter interaction: -liquidityprovider=%d -> setting -enableprivatesend=1\n", __func__, nLiqProvTmp); LogPrintf("%s: parameter interaction: -liquidityprovider=%d -> setting -enableprivatesend=1\n", __func__, nLiqProvTmp);
ForceSetArg("-privatesendsessions", itostr(MIN_PRIVATESEND_SESSIONS)); gArgs.ForceSetArg("-privatesendsessions", itostr(MIN_PRIVATESEND_SESSIONS));
LogPrintf("%s: parameter interaction: -liquidityprovider=%d -> setting -privatesendsessions=%d\n", __func__, nLiqProvTmp, itostr(std::numeric_limits<int>::max())); LogPrintf("%s: parameter interaction: -liquidityprovider=%d -> setting -privatesendsessions=%d\n", __func__, nLiqProvTmp, itostr(std::numeric_limits<int>::max()));
ForceSetArg("-privatesendrounds", itostr(std::numeric_limits<int>::max())); gArgs.ForceSetArg("-privatesendrounds", itostr(std::numeric_limits<int>::max()));
LogPrintf("%s: parameter interaction: -liquidityprovider=%d -> setting -privatesendrounds=%d\n", __func__, nLiqProvTmp, itostr(std::numeric_limits<int>::max())); LogPrintf("%s: parameter interaction: -liquidityprovider=%d -> setting -privatesendrounds=%d\n", __func__, nLiqProvTmp, itostr(std::numeric_limits<int>::max()));
ForceSetArg("-privatesendamount", itostr(MAX_PRIVATESEND_AMOUNT)); gArgs.ForceSetArg("-privatesendamount", itostr(MAX_PRIVATESEND_AMOUNT));
LogPrintf("%s: parameter interaction: -liquidityprovider=%d -> setting -privatesendamount=%d\n", __func__, nLiqProvTmp, MAX_PRIVATESEND_AMOUNT); LogPrintf("%s: parameter interaction: -liquidityprovider=%d -> setting -privatesendamount=%d\n", __func__, nLiqProvTmp, MAX_PRIVATESEND_AMOUNT);
ForceSetArg("-privatesenddenoms", itostr(MAX_PRIVATESEND_DENOMS)); gArgs.ForceSetArg("-privatesenddenoms", itostr(MAX_PRIVATESEND_DENOMS));
LogPrintf("%s: parameter interaction: -liquidityprovider=%d -> setting -privatesenddenoms=%d\n", __func__, nLiqProvTmp, itostr(MAX_PRIVATESEND_DENOMS)); LogPrintf("%s: parameter interaction: -liquidityprovider=%d -> setting -privatesenddenoms=%d\n", __func__, nLiqProvTmp, itostr(MAX_PRIVATESEND_DENOMS));
ForceSetArg("-privatesendmultisession", "0"); gArgs.ForceSetArg("-privatesendmultisession", "0");
LogPrintf("%s: parameter interaction: -liquidityprovider=%d -> setting -privatesendmultisession=0\n", __func__, nLiqProvTmp); LogPrintf("%s: parameter interaction: -liquidityprovider=%d -> setting -privatesendmultisession=0\n", __func__, nLiqProvTmp);
} }
if (IsArgSet("-hdseed") && IsHex(GetArg("-hdseed", "not hex")) && (IsArgSet("-mnemonic") || IsArgSet("-mnemonicpassphrase"))) { if (gArgs.IsArgSet("-hdseed") && IsHex(gArgs.GetArg("-hdseed", "not hex")) && (gArgs.IsArgSet("-mnemonic") || gArgs.IsArgSet("-mnemonicpassphrase"))) {
ForceRemoveArg("-mnemonic"); ForceRemoveArg("-mnemonic");
ForceRemoveArg("-mnemonicpassphrase"); ForceRemoveArg("-mnemonicpassphrase");
LogPrintf("%s: parameter interaction: can't use -hdseed and -mnemonic/-mnemonicpassphrase together, will prefer -seed\n", __func__); LogPrintf("%s: parameter interaction: can't use -hdseed and -mnemonic/-mnemonicpassphrase together, will prefer -seed\n", __func__);
@ -992,12 +992,12 @@ void InitParameterInteraction()
// Make sure additional indexes are recalculated correctly in VerifyDB // Make sure additional indexes are recalculated correctly in VerifyDB
// (we must reconnect blocks whenever we disconnect them for these indexes to work) // (we must reconnect blocks whenever we disconnect them for these indexes to work)
bool fAdditionalIndexes = bool fAdditionalIndexes =
GetBoolArg("-addressindex", DEFAULT_ADDRESSINDEX) || gArgs.GetBoolArg("-addressindex", DEFAULT_ADDRESSINDEX) ||
GetBoolArg("-spentindex", DEFAULT_SPENTINDEX) || gArgs.GetBoolArg("-spentindex", DEFAULT_SPENTINDEX) ||
GetBoolArg("-timestampindex", DEFAULT_TIMESTAMPINDEX); gArgs.GetBoolArg("-timestampindex", DEFAULT_TIMESTAMPINDEX);
if (fAdditionalIndexes && GetArg("-checklevel", DEFAULT_CHECKLEVEL) < 4) { if (fAdditionalIndexes && gArgs.GetArg("-checklevel", DEFAULT_CHECKLEVEL) < 4) {
ForceSetArg("-checklevel", "4"); gArgs.ForceSetArg("-checklevel", "4");
LogPrintf("%s: parameter interaction: additional indexes -> setting -checklevel=4\n", __func__); LogPrintf("%s: parameter interaction: additional indexes -> setting -checklevel=4\n", __func__);
} }
} }
@ -1009,12 +1009,12 @@ static std::string ResolveErrMsg(const char * const optname, const std::string&
void InitLogging() void InitLogging()
{ {
fPrintToConsole = GetBoolArg("-printtoconsole", false); fPrintToConsole = gArgs.GetBoolArg("-printtoconsole", false);
fPrintToDebugLog = GetBoolArg("-printtodebuglog", true) && !fPrintToConsole; fPrintToDebugLog = gArgs.GetBoolArg("-printtodebuglog", true) && !fPrintToConsole;
fLogTimestamps = GetBoolArg("-logtimestamps", DEFAULT_LOGTIMESTAMPS); fLogTimestamps = gArgs.GetBoolArg("-logtimestamps", DEFAULT_LOGTIMESTAMPS);
fLogTimeMicros = GetBoolArg("-logtimemicros", DEFAULT_LOGTIMEMICROS); fLogTimeMicros = gArgs.GetBoolArg("-logtimemicros", DEFAULT_LOGTIMEMICROS);
fLogThreadNames = GetBoolArg("-logthreadnames", DEFAULT_LOGTHREADNAMES); fLogThreadNames = gArgs.GetBoolArg("-logthreadnames", DEFAULT_LOGTHREADNAMES);
fLogIPs = GetBoolArg("-logips", DEFAULT_LOGIPS); fLogIPs = gArgs.GetBoolArg("-logips", DEFAULT_LOGIPS);
LogPrintf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); LogPrintf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
LogPrintf("Dash Core version %s\n", FormatFullVersion()); LogPrintf("Dash Core version %s\n", FormatFullVersion());
@ -1073,7 +1073,7 @@ bool AppInitBasicSetup()
return InitError("Initializing networking failed"); return InitError("Initializing networking failed");
#ifndef WIN32 #ifndef WIN32
if (!GetBoolArg("-sysperms", false)) { if (!gArgs.GetBoolArg("-sysperms", false)) {
umask(077); umask(077);
} }
@ -1101,17 +1101,17 @@ bool AppInitParameterInteraction()
// also see: InitParameterInteraction() // also see: InitParameterInteraction()
// if using block pruning, then disallow txindex // if using block pruning, then disallow txindex
if (GetArg("-prune", 0)) { if (gArgs.GetArg("-prune", 0)) {
if (GetBoolArg("-txindex", DEFAULT_TXINDEX)) if (gArgs.GetBoolArg("-txindex", DEFAULT_TXINDEX))
return InitError(_("Prune mode is incompatible with -txindex.")); return InitError(_("Prune mode is incompatible with -txindex."));
} }
if (IsArgSet("-devnet")) { if (gArgs.IsArgSet("-devnet")) {
// Require setting of ports when running devnet // Require setting of ports when running devnet
if (GetArg("-listen", DEFAULT_LISTEN) && !IsArgSet("-port")) { if (gArgs.GetArg("-listen", DEFAULT_LISTEN) && !gArgs.IsArgSet("-port")) {
return InitError(_("-port must be specified when -devnet and -listen are specified")); return InitError(_("-port must be specified when -devnet and -listen are specified"));
} }
if (GetArg("-server", false) && !IsArgSet("-rpcport")) { if (gArgs.GetArg("-server", false) && !gArgs.IsArgSet("-rpcport")) {
return InitError(_("-rpcport must be specified when -devnet and -server are specified")); return InitError(_("-rpcport must be specified when -devnet and -server are specified"));
} }
if (gArgs.GetArgs("-devnet").size() > 1) { if (gArgs.GetArgs("-devnet").size() > 1) {
@ -1119,13 +1119,13 @@ bool AppInitParameterInteraction()
} }
} }
fAllowPrivateNet = GetBoolArg("-allowprivatenet", DEFAULT_ALLOWPRIVATENET); fAllowPrivateNet = gArgs.GetBoolArg("-allowprivatenet", DEFAULT_ALLOWPRIVATENET);
// Make sure enough file descriptors are available // Make sure enough file descriptors are available
int nBind = std::max( int nBind = std::max(
(gArgs.IsArgSet("-bind") ? gArgs.GetArgs("-bind").size() : 0) + (gArgs.IsArgSet("-bind") ? gArgs.GetArgs("-bind").size() : 0) +
(gArgs.IsArgSet("-whitebind") ? gArgs.GetArgs("-whitebind").size() : 0), size_t(1)); (gArgs.IsArgSet("-whitebind") ? gArgs.GetArgs("-whitebind").size() : 0), size_t(1));
nUserMaxConnections = GetArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS); nUserMaxConnections = gArgs.GetArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS);
nMaxConnections = std::max(nUserMaxConnections, 0); nMaxConnections = std::max(nUserMaxConnections, 0);
// Trim requested connection counts, to fit into system limitations // Trim requested connection counts, to fit into system limitations
@ -1144,7 +1144,7 @@ bool AppInitParameterInteraction()
// Special-case: if -debug=0/-nodebug is set, turn off debugging messages // Special-case: if -debug=0/-nodebug is set, turn off debugging messages
const std::vector<std::string> categories = gArgs.GetArgs("-debug"); const std::vector<std::string> categories = gArgs.GetArgs("-debug");
if (!(GetBoolArg("-nodebug", false) || find(categories.begin(), categories.end(), std::string("0")) != categories.end())) { if (!(gArgs.GetBoolArg("-nodebug", false) || find(categories.begin(), categories.end(), std::string("0")) != categories.end())) {
for (const auto& cat : categories) { for (const auto& cat : categories) {
uint64_t flag; uint64_t flag;
if (!GetLogCategory(&flag, &cat)) { if (!GetLogCategory(&flag, &cat)) {
@ -1167,55 +1167,55 @@ bool AppInitParameterInteraction()
} }
// Check for -debugnet // Check for -debugnet
if (GetBoolArg("-debugnet", false)) if (gArgs.GetBoolArg("-debugnet", false))
InitWarning(_("Unsupported argument -debugnet ignored, use -debug=net.")); InitWarning(_("Unsupported argument -debugnet ignored, use -debug=net."));
// Check for -socks - as this is a privacy risk to continue, exit here // Check for -socks - as this is a privacy risk to continue, exit here
if (IsArgSet("-socks")) if (gArgs.IsArgSet("-socks"))
return InitError(_("Unsupported argument -socks found. Setting SOCKS version isn't possible anymore, only SOCKS5 proxies are supported.")); return InitError(_("Unsupported argument -socks found. Setting SOCKS version isn't possible anymore, only SOCKS5 proxies are supported."));
// Check for -tor - as this is a privacy risk to continue, exit here // Check for -tor - as this is a privacy risk to continue, exit here
if (GetBoolArg("-tor", false)) if (gArgs.GetBoolArg("-tor", false))
return InitError(_("Unsupported argument -tor found, use -onion.")); return InitError(_("Unsupported argument -tor found, use -onion."));
if (GetBoolArg("-benchmark", false)) if (gArgs.GetBoolArg("-benchmark", false))
InitWarning(_("Unsupported argument -benchmark ignored, use -debug=bench.")); InitWarning(_("Unsupported argument -benchmark ignored, use -debug=bench."));
if (GetBoolArg("-whitelistalwaysrelay", false)) if (gArgs.GetBoolArg("-whitelistalwaysrelay", false))
InitWarning(_("Unsupported argument -whitelistalwaysrelay ignored, use -whitelistrelay and/or -whitelistforcerelay.")); InitWarning(_("Unsupported argument -whitelistalwaysrelay ignored, use -whitelistrelay and/or -whitelistforcerelay."));
if (IsArgSet("-blockminsize")) if (gArgs.IsArgSet("-blockminsize"))
InitWarning("Unsupported argument -blockminsize ignored."); InitWarning("Unsupported argument -blockminsize ignored.");
// Checkmempool and checkblockindex default to true in regtest mode // Checkmempool and checkblockindex default to true in regtest mode
int ratio = std::min<int>(std::max<int>(GetArg("-checkmempool", chainparams.DefaultConsistencyChecks() ? 1 : 0), 0), 1000000); int ratio = std::min<int>(std::max<int>(gArgs.GetArg("-checkmempool", chainparams.DefaultConsistencyChecks() ? 1 : 0), 0), 1000000);
if (ratio != 0) { if (ratio != 0) {
mempool.setSanityCheck(1.0 / ratio); mempool.setSanityCheck(1.0 / ratio);
} }
fCheckBlockIndex = GetBoolArg("-checkblockindex", chainparams.DefaultConsistencyChecks()); fCheckBlockIndex = gArgs.GetBoolArg("-checkblockindex", chainparams.DefaultConsistencyChecks());
fCheckpointsEnabled = GetBoolArg("-checkpoints", DEFAULT_CHECKPOINTS_ENABLED); fCheckpointsEnabled = gArgs.GetBoolArg("-checkpoints", DEFAULT_CHECKPOINTS_ENABLED);
hashAssumeValid = uint256S(GetArg("-assumevalid", chainparams.GetConsensus().defaultAssumeValid.GetHex())); hashAssumeValid = uint256S(gArgs.GetArg("-assumevalid", chainparams.GetConsensus().defaultAssumeValid.GetHex()));
if (!hashAssumeValid.IsNull()) if (!hashAssumeValid.IsNull())
LogPrintf("Assuming ancestors of block %s have valid signatures.\n", hashAssumeValid.GetHex()); LogPrintf("Assuming ancestors of block %s have valid signatures.\n", hashAssumeValid.GetHex());
else else
LogPrintf("Validating signatures for all blocks.\n"); LogPrintf("Validating signatures for all blocks.\n");
// mempool limits // mempool limits
int64_t nMempoolSizeMax = GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000; int64_t nMempoolSizeMax = gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000;
int64_t nMempoolSizeMin = GetArg("-limitdescendantsize", DEFAULT_DESCENDANT_SIZE_LIMIT) * 1000 * 40; int64_t nMempoolSizeMin = gArgs.GetArg("-limitdescendantsize", DEFAULT_DESCENDANT_SIZE_LIMIT) * 1000 * 40;
if (nMempoolSizeMax < 0 || nMempoolSizeMax < nMempoolSizeMin) if (nMempoolSizeMax < 0 || nMempoolSizeMax < nMempoolSizeMin)
return InitError(strprintf(_("-maxmempool must be at least %d MB"), std::ceil(nMempoolSizeMin / 1000000.0))); return InitError(strprintf(_("-maxmempool must be at least %d MB"), std::ceil(nMempoolSizeMin / 1000000.0)));
// incremental relay fee sets the minimum feerate increase necessary for BIP 125 replacement in the mempool // incremental relay fee sets the minimum feerate increase necessary for BIP 125 replacement in the mempool
// and the amount the mempool min fee increases above the feerate of txs evicted due to mempool limiting. // and the amount the mempool min fee increases above the feerate of txs evicted due to mempool limiting.
if (IsArgSet("-incrementalrelayfee")) if (gArgs.IsArgSet("-incrementalrelayfee"))
{ {
CAmount n = 0; CAmount n = 0;
if (!ParseMoney(GetArg("-incrementalrelayfee", ""), n)) if (!ParseMoney(gArgs.GetArg("-incrementalrelayfee", ""), n))
return InitError(AmountErrMsg("incrementalrelayfee", GetArg("-incrementalrelayfee", ""))); return InitError(AmountErrMsg("incrementalrelayfee", gArgs.GetArg("-incrementalrelayfee", "")));
incrementalRelayFee = CFeeRate(n); incrementalRelayFee = CFeeRate(n);
} }
// -par=0 means autodetect, but nScriptCheckThreads==0 means no concurrency // -par=0 means autodetect, but nScriptCheckThreads==0 means no concurrency
nScriptCheckThreads = GetArg("-par", DEFAULT_SCRIPTCHECK_THREADS); nScriptCheckThreads = gArgs.GetArg("-par", DEFAULT_SCRIPTCHECK_THREADS);
if (nScriptCheckThreads <= 0) if (nScriptCheckThreads <= 0)
nScriptCheckThreads += GetNumCores(); nScriptCheckThreads += GetNumCores();
if (nScriptCheckThreads <= 1) if (nScriptCheckThreads <= 1)
@ -1224,7 +1224,7 @@ bool AppInitParameterInteraction()
nScriptCheckThreads = MAX_SCRIPTCHECK_THREADS; nScriptCheckThreads = MAX_SCRIPTCHECK_THREADS;
// block pruning; get the amount of disk space (in MiB) to allot for block & undo files // block pruning; get the amount of disk space (in MiB) to allot for block & undo files
int64_t nPruneArg = GetArg("-prune", 0); int64_t nPruneArg = gArgs.GetArg("-prune", 0);
if (nPruneArg < 0) { if (nPruneArg < 0) {
return InitError(_("Prune cannot be configured with a negative value.")); return InitError(_("Prune cannot be configured with a negative value."));
} }
@ -1234,7 +1234,7 @@ bool AppInitParameterInteraction()
nPruneTarget = std::numeric_limits<uint64_t>::max(); nPruneTarget = std::numeric_limits<uint64_t>::max();
fPruneMode = true; fPruneMode = true;
} else if (nPruneTarget) { } else if (nPruneTarget) {
if (GetBoolArg("-regtest", false)) { if (gArgs.GetBoolArg("-regtest", false)) {
// we use 1MB blocks to test this on regtest // we use 1MB blocks to test this on regtest
if (nPruneTarget < 550 * 1024 * 1024) { if (nPruneTarget < 550 * 1024 * 1024) {
return InitError(strprintf(_("Prune configured below the minimum of %d MiB. Please use a higher number."), 550)); return InitError(strprintf(_("Prune configured below the minimum of %d MiB. Please use a higher number."), 550));
@ -1253,7 +1253,7 @@ bool AppInitParameterInteraction()
RegisterWalletRPCCommands(tableRPC); RegisterWalletRPCCommands(tableRPC);
#endif #endif
nConnectTimeout = GetArg("-timeout", DEFAULT_CONNECT_TIMEOUT); nConnectTimeout = gArgs.GetArg("-timeout", DEFAULT_CONNECT_TIMEOUT);
if (nConnectTimeout <= 0) if (nConnectTimeout <= 0)
nConnectTimeout = DEFAULT_CONNECT_TIMEOUT; nConnectTimeout = DEFAULT_CONNECT_TIMEOUT;
@ -1263,11 +1263,11 @@ bool AppInitParameterInteraction()
// a transaction spammer can cheaply fill blocks using // a transaction spammer can cheaply fill blocks using
// 0-fee transactions. It should be set above the real // 0-fee transactions. It should be set above the real
// cost to you of processing a transaction. // cost to you of processing a transaction.
if (IsArgSet("-minrelaytxfee")) if (gArgs.IsArgSet("-minrelaytxfee"))
{ {
CAmount n = 0; CAmount n = 0;
if (!ParseMoney(GetArg("-minrelaytxfee", ""), n)) { if (!ParseMoney(gArgs.GetArg("-minrelaytxfee", ""), n)) {
return InitError(AmountErrMsg("minrelaytxfee", GetArg("-minrelaytxfee", ""))); return InitError(AmountErrMsg("minrelaytxfee", gArgs.GetArg("-minrelaytxfee", "")));
} }
// High fee check is done afterward in CWallet::ParameterInteraction() // High fee check is done afterward in CWallet::ParameterInteraction()
::minRelayTxFee = CFeeRate(n); ::minRelayTxFee = CFeeRate(n);
@ -1279,44 +1279,44 @@ bool AppInitParameterInteraction()
// Sanity check argument for min fee for including tx in block // Sanity check argument for min fee for including tx in block
// TODO: Harmonize which arguments need sanity checking and where that happens // TODO: Harmonize which arguments need sanity checking and where that happens
if (IsArgSet("-blockmintxfee")) if (gArgs.IsArgSet("-blockmintxfee"))
{ {
CAmount n = 0; CAmount n = 0;
if (!ParseMoney(GetArg("-blockmintxfee", ""), n)) if (!ParseMoney(gArgs.GetArg("-blockmintxfee", ""), n))
return InitError(AmountErrMsg("blockmintxfee", GetArg("-blockmintxfee", ""))); return InitError(AmountErrMsg("blockmintxfee", gArgs.GetArg("-blockmintxfee", "")));
} }
// Feerate used to define dust. Shouldn't be changed lightly as old // Feerate used to define dust. Shouldn't be changed lightly as old
// implementations may inadvertently create non-standard transactions // implementations may inadvertently create non-standard transactions
if (IsArgSet("-dustrelayfee")) if (gArgs.IsArgSet("-dustrelayfee"))
{ {
CAmount n = 0; CAmount n = 0;
if (!ParseMoney(GetArg("-dustrelayfee", ""), n) || 0 == n) if (!ParseMoney(gArgs.GetArg("-dustrelayfee", ""), n) || 0 == n)
return InitError(AmountErrMsg("dustrelayfee", GetArg("-dustrelayfee", ""))); return InitError(AmountErrMsg("dustrelayfee", gArgs.GetArg("-dustrelayfee", "")));
dustRelayFee = CFeeRate(n); dustRelayFee = CFeeRate(n);
} }
fRequireStandard = !GetBoolArg("-acceptnonstdtxn", !chainparams.RequireStandard()); fRequireStandard = !gArgs.GetBoolArg("-acceptnonstdtxn", !chainparams.RequireStandard());
if (chainparams.RequireStandard() && !fRequireStandard) if (chainparams.RequireStandard() && !fRequireStandard)
return InitError(strprintf("acceptnonstdtxn is not currently supported for %s chain", chainparams.NetworkIDString())); return InitError(strprintf("acceptnonstdtxn is not currently supported for %s chain", chainparams.NetworkIDString()));
nBytesPerSigOp = GetArg("-bytespersigop", nBytesPerSigOp); nBytesPerSigOp = gArgs.GetArg("-bytespersigop", nBytesPerSigOp);
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
if (!CWallet::ParameterInteraction()) if (!CWallet::ParameterInteraction())
return false; return false;
#endif // ENABLE_WALLET #endif // ENABLE_WALLET
fIsBareMultisigStd = GetBoolArg("-permitbaremultisig", DEFAULT_PERMIT_BAREMULTISIG); fIsBareMultisigStd = gArgs.GetBoolArg("-permitbaremultisig", DEFAULT_PERMIT_BAREMULTISIG);
fAcceptDatacarrier = GetBoolArg("-datacarrier", DEFAULT_ACCEPT_DATACARRIER); fAcceptDatacarrier = gArgs.GetBoolArg("-datacarrier", DEFAULT_ACCEPT_DATACARRIER);
nMaxDatacarrierBytes = GetArg("-datacarriersize", nMaxDatacarrierBytes); nMaxDatacarrierBytes = gArgs.GetArg("-datacarriersize", nMaxDatacarrierBytes);
// Option to startup with mocktime set (used for regression testing): // Option to startup with mocktime set (used for regression testing):
SetMockTime(GetArg("-mocktime", 0)); // SetMockTime(0) is a no-op SetMockTime(gArgs.GetArg("-mocktime", 0)); // SetMockTime(0) is a no-op
if (GetBoolArg("-peerbloomfilters", DEFAULT_PEERBLOOMFILTERS)) if (gArgs.GetBoolArg("-peerbloomfilters", DEFAULT_PEERBLOOMFILTERS))
nLocalServices = ServiceFlags(nLocalServices | NODE_BLOOM); nLocalServices = ServiceFlags(nLocalServices | NODE_BLOOM);
nMaxTipAge = GetArg("-maxtipage", DEFAULT_MAX_TIP_AGE); nMaxTipAge = gArgs.GetArg("-maxtipage", DEFAULT_MAX_TIP_AGE);
if (gArgs.IsArgSet("-bip9params")) { if (gArgs.IsArgSet("-bip9params")) {
// Allow overriding BIP9 parameters for testing // Allow overriding BIP9 parameters for testing
@ -1360,12 +1360,12 @@ bool AppInitParameterInteraction()
} }
} }
if (IsArgSet("-dip3params")) { if (gArgs.IsArgSet("-dip3params")) {
// Allow overriding budget parameters for testing // Allow overriding budget parameters for testing
if (!chainparams.MineBlocksOnDemand()) { if (!chainparams.MineBlocksOnDemand()) {
return InitError("DIP3 parameters may only be overridden on regtest."); return InitError("DIP3 parameters may only be overridden on regtest.");
} }
std::string strDIP3Params = GetArg("-dip3params", ""); std::string strDIP3Params = gArgs.GetArg("-dip3params", "");
std::vector<std::string> vDIP3Params; std::vector<std::string> vDIP3Params;
boost::split(vDIP3Params, strDIP3Params, boost::is_any_of(":")); boost::split(vDIP3Params, strDIP3Params, boost::is_any_of(":"));
if (vDIP3Params.size() != 2) { if (vDIP3Params.size() != 2) {
@ -1381,13 +1381,13 @@ bool AppInitParameterInteraction()
UpdateRegtestDIP3Parameters(nDIP3ActivationHeight, nDIP3EnforcementHeight); UpdateRegtestDIP3Parameters(nDIP3ActivationHeight, nDIP3EnforcementHeight);
} }
if (IsArgSet("-budgetparams")) { if (gArgs.IsArgSet("-budgetparams")) {
// Allow overriding budget parameters for testing // Allow overriding budget parameters for testing
if (!chainparams.MineBlocksOnDemand()) { if (!chainparams.MineBlocksOnDemand()) {
return InitError("Budget parameters may only be overridden on regtest."); return InitError("Budget parameters may only be overridden on regtest.");
} }
std::string strBudgetParams = GetArg("-budgetparams", ""); std::string strBudgetParams = gArgs.GetArg("-budgetparams", "");
std::vector<std::string> vBudgetParams; std::vector<std::string> vBudgetParams;
boost::split(vBudgetParams, strBudgetParams, boost::is_any_of(":")); boost::split(vBudgetParams, strBudgetParams, boost::is_any_of(":"));
if (vBudgetParams.size() != 3) { if (vBudgetParams.size() != 3) {
@ -1407,16 +1407,16 @@ bool AppInitParameterInteraction()
} }
if (chainparams.NetworkIDString() == CBaseChainParams::DEVNET) { if (chainparams.NetworkIDString() == CBaseChainParams::DEVNET) {
int nMinimumDifficultyBlocks = GetArg("-minimumdifficultyblocks", chainparams.GetConsensus().nMinimumDifficultyBlocks); int nMinimumDifficultyBlocks = gArgs.GetArg("-minimumdifficultyblocks", chainparams.GetConsensus().nMinimumDifficultyBlocks);
int nHighSubsidyBlocks = GetArg("-highsubsidyblocks", chainparams.GetConsensus().nHighSubsidyBlocks); int nHighSubsidyBlocks = gArgs.GetArg("-highsubsidyblocks", chainparams.GetConsensus().nHighSubsidyBlocks);
int nHighSubsidyFactor = GetArg("-highsubsidyfactor", chainparams.GetConsensus().nHighSubsidyFactor); int nHighSubsidyFactor = gArgs.GetArg("-highsubsidyfactor", chainparams.GetConsensus().nHighSubsidyFactor);
UpdateDevnetSubsidyAndDiffParams(nMinimumDifficultyBlocks, nHighSubsidyBlocks, nHighSubsidyFactor); UpdateDevnetSubsidyAndDiffParams(nMinimumDifficultyBlocks, nHighSubsidyBlocks, nHighSubsidyFactor);
} else if (IsArgSet("-minimumdifficultyblocks") || IsArgSet("-highsubsidyblocks") || IsArgSet("-highsubsidyfactor")) { } else if (gArgs.IsArgSet("-minimumdifficultyblocks") || gArgs.IsArgSet("-highsubsidyblocks") || gArgs.IsArgSet("-highsubsidyfactor")) {
return InitError("Difficulty and subsidy parameters may only be overridden on devnet."); return InitError("Difficulty and subsidy parameters may only be overridden on devnet.");
} }
if (chainparams.NetworkIDString() == CBaseChainParams::DEVNET) { if (chainparams.NetworkIDString() == CBaseChainParams::DEVNET) {
std::string llmqChainLocks = GetArg("-llmqchainlocks", Params().GetConsensus().llmqs.at(Params().GetConsensus().llmqChainLocks).name); std::string llmqChainLocks = gArgs.GetArg("-llmqchainlocks", Params().GetConsensus().llmqs.at(Params().GetConsensus().llmqChainLocks).name);
Consensus::LLMQType llmqType = Consensus::LLMQ_NONE; Consensus::LLMQType llmqType = Consensus::LLMQ_NONE;
for (const auto& p : Params().GetConsensus().llmqs) { for (const auto& p : Params().GetConsensus().llmqs) {
if (p.second.name == llmqChainLocks) { if (p.second.name == llmqChainLocks) {
@ -1428,7 +1428,7 @@ bool AppInitParameterInteraction()
return InitError("Invalid LLMQ type specified for -llmqchainlocks."); return InitError("Invalid LLMQ type specified for -llmqchainlocks.");
} }
UpdateDevnetLLMQChainLocks(llmqType); UpdateDevnetLLMQChainLocks(llmqType);
} else if (IsArgSet("-llmqchainlocks")) { } else if (gArgs.IsArgSet("-llmqchainlocks")) {
return InitError("LLMQ type for ChainLocks can only be overridden on devnet."); return InitError("LLMQ type for ChainLocks can only be overridden on devnet.");
} }
@ -1489,7 +1489,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
#ifndef WIN32 #ifndef WIN32
CreatePidFile(GetPidFile(), getpid()); CreatePidFile(GetPidFile(), getpid());
#endif #endif
if (GetBoolArg("-shrinkdebugfile", logCategories == BCLog::NONE)) { if (gArgs.GetBoolArg("-shrinkdebugfile", logCategories == BCLog::NONE)) {
// Do this first since it both loads a bunch of debug.log into memory, // Do this first since it both loads a bunch of debug.log into memory,
// and because this needs to happen before any other debug.log printing // and because this needs to happen before any other debug.log printing
ShrinkDebugFile(); ShrinkDebugFile();
@ -1502,7 +1502,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
LogPrintf("Startup time: %s\n", DateTimeStrFormat("%Y-%m-%d %H:%M:%S", GetTime())); LogPrintf("Startup time: %s\n", DateTimeStrFormat("%Y-%m-%d %H:%M:%S", GetTime()));
LogPrintf("Default data directory %s\n", GetDefaultDataDir().string()); LogPrintf("Default data directory %s\n", GetDefaultDataDir().string());
LogPrintf("Using data directory %s\n", GetDataDir().string()); LogPrintf("Using data directory %s\n", GetDataDir().string());
LogPrintf("Using config file %s\n", GetConfigFile(GetArg("-conf", BITCOIN_CONF_FILENAME)).string()); LogPrintf("Using config file %s\n", GetConfigFile(gArgs.GetArg("-conf", BITCOIN_CONF_FILENAME)).string());
LogPrintf("Using at most %i automatic connections (%i file descriptors available)\n", nMaxConnections, nFD); LogPrintf("Using at most %i automatic connections (%i file descriptors available)\n", nMaxConnections, nFD);
InitSignatureCache(); InitSignatureCache();
@ -1525,14 +1525,14 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
} }
} }
int minsporkkeys = GetArg("-minsporkkeys", Params().MinSporkKeys()); int minsporkkeys = gArgs.GetArg("-minsporkkeys", Params().MinSporkKeys());
if (!sporkManager.SetMinSporkKeys(minsporkkeys)) { if (!sporkManager.SetMinSporkKeys(minsporkkeys)) {
return InitError(_("Invalid minimum number of spork signers specified with -minsporkkeys")); return InitError(_("Invalid minimum number of spork signers specified with -minsporkkeys"));
} }
if (IsArgSet("-sporkkey")) { // spork priv key if (gArgs.IsArgSet("-sporkkey")) { // spork priv key
if (!sporkManager.SetPrivKey(GetArg("-sporkkey", ""))) { if (!sporkManager.SetPrivKey(gArgs.GetArg("-sporkkey", ""))) {
return InitError(_("Unable to sign spork message, wrong key?")); return InitError(_("Unable to sign spork message, wrong key?"));
} }
} }
@ -1546,7 +1546,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
* that the server is there and will be ready later). Warmup mode will * that the server is there and will be ready later). Warmup mode will
* be disabled when initialisation is finished. * be disabled when initialisation is finished.
*/ */
if (GetBoolArg("-server", false)) if (gArgs.GetBoolArg("-server", false))
{ {
uiInterface.InitMessage.connect(SetRPCWarmupStatus); uiInterface.InitMessage.connect(SetRPCWarmupStatus);
if (!AppInitServers(threadGroup)) if (!AppInitServers(threadGroup))
@ -1626,12 +1626,12 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
} }
// Check for host lookup allowed before parsing any network related parameters // Check for host lookup allowed before parsing any network related parameters
fNameLookup = GetBoolArg("-dns", DEFAULT_NAME_LOOKUP); fNameLookup = gArgs.GetBoolArg("-dns", DEFAULT_NAME_LOOKUP);
bool proxyRandomize = GetBoolArg("-proxyrandomize", DEFAULT_PROXYRANDOMIZE); bool proxyRandomize = gArgs.GetBoolArg("-proxyrandomize", DEFAULT_PROXYRANDOMIZE);
// -proxy sets a proxy for all outgoing network traffic // -proxy sets a proxy for all outgoing network traffic
// -noproxy (or -proxy=0) as well as the empty string can be used to not set a proxy, this is the default // -noproxy (or -proxy=0) as well as the empty string can be used to not set a proxy, this is the default
std::string proxyArg = GetArg("-proxy", ""); std::string proxyArg = gArgs.GetArg("-proxy", "");
SetLimited(NET_TOR); SetLimited(NET_TOR);
if (proxyArg != "" && proxyArg != "0") { if (proxyArg != "" && proxyArg != "0") {
CService proxyAddr; CService proxyAddr;
@ -1653,7 +1653,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
// -onion can be used to set only a proxy for .onion, or override normal proxy for .onion addresses // -onion can be used to set only a proxy for .onion, or override normal proxy for .onion addresses
// -noonion (or -onion=0) disables connecting to .onion entirely // -noonion (or -onion=0) disables connecting to .onion entirely
// An empty string is used to not override the onion proxy (in which case it defaults to -proxy set above, or none) // An empty string is used to not override the onion proxy (in which case it defaults to -proxy set above, or none)
std::string onionArg = GetArg("-onion", ""); std::string onionArg = gArgs.GetArg("-onion", "");
if (onionArg != "") { if (onionArg != "") {
if (onionArg == "0") { // Handle -noonion/-onion=0 if (onionArg == "0") { // Handle -noonion/-onion=0
SetLimited(NET_TOR); // set onions as unreachable SetLimited(NET_TOR); // set onions as unreachable
@ -1671,9 +1671,9 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
} }
// see Step 2: parameter interactions for more information about these // see Step 2: parameter interactions for more information about these
fListen = GetBoolArg("-listen", DEFAULT_LISTEN); fListen = gArgs.GetBoolArg("-listen", DEFAULT_LISTEN);
fDiscover = GetBoolArg("-discover", true); fDiscover = gArgs.GetBoolArg("-discover", true);
fRelayTxes = !GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY); fRelayTxes = !gArgs.GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY);
if (fListen) { if (fListen) {
bool fBound = false; bool fBound = false;
@ -1729,14 +1729,14 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
uint64_t nMaxOutboundLimit = 0; //unlimited unless -maxuploadtarget is set uint64_t nMaxOutboundLimit = 0; //unlimited unless -maxuploadtarget is set
uint64_t nMaxOutboundTimeframe = MAX_UPLOAD_TIMEFRAME; uint64_t nMaxOutboundTimeframe = MAX_UPLOAD_TIMEFRAME;
if (IsArgSet("-maxuploadtarget")) { if (gArgs.IsArgSet("-maxuploadtarget")) {
nMaxOutboundLimit = GetArg("-maxuploadtarget", DEFAULT_MAX_UPLOAD_TARGET)*1024*1024; nMaxOutboundLimit = gArgs.GetArg("-maxuploadtarget", DEFAULT_MAX_UPLOAD_TARGET)*1024*1024;
} }
// ********************************************************* Step 7a: check lite mode and load sporks // ********************************************************* Step 7a: check lite mode and load sporks
// lite mode disables all Dash-specific functionality // lite mode disables all Dash-specific functionality
fLiteMode = GetBoolArg("-litemode", false); fLiteMode = gArgs.GetBoolArg("-litemode", false);
LogPrintf("fLiteMode %d\n", fLiteMode); LogPrintf("fLiteMode %d\n", fLiteMode);
if(fLiteMode) { if(fLiteMode) {
@ -1758,23 +1758,23 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
// ********************************************************* Step 7b: load block chain // ********************************************************* Step 7b: load block chain
fReindex = GetBoolArg("-reindex", false); fReindex = gArgs.GetBoolArg("-reindex", false);
bool fReindexChainState = GetBoolArg("-reindex-chainstate", false); bool fReindexChainState = gArgs.GetBoolArg("-reindex-chainstate", false);
fs::create_directories(GetDataDir() / "blocks"); fs::create_directories(GetDataDir() / "blocks");
// cache size calculations // cache size calculations
int64_t nTotalCache = (GetArg("-dbcache", nDefaultDbCache) << 20); int64_t nTotalCache = (gArgs.GetArg("-dbcache", nDefaultDbCache) << 20);
nTotalCache = std::max(nTotalCache, nMinDbCache << 20); // total cache cannot be less than nMinDbCache nTotalCache = std::max(nTotalCache, nMinDbCache << 20); // total cache cannot be less than nMinDbCache
nTotalCache = std::min(nTotalCache, nMaxDbCache << 20); // total cache cannot be greater than nMaxDbcache nTotalCache = std::min(nTotalCache, nMaxDbCache << 20); // total cache cannot be greater than nMaxDbcache
int64_t nBlockTreeDBCache = nTotalCache / 8; int64_t nBlockTreeDBCache = nTotalCache / 8;
nBlockTreeDBCache = std::min(nBlockTreeDBCache, (GetBoolArg("-txindex", DEFAULT_TXINDEX) ? nMaxBlockDBAndTxIndexCache : nMaxBlockDBCache) << 20); nBlockTreeDBCache = std::min(nBlockTreeDBCache, (gArgs.GetBoolArg("-txindex", DEFAULT_TXINDEX) ? nMaxBlockDBAndTxIndexCache : nMaxBlockDBCache) << 20);
nTotalCache -= nBlockTreeDBCache; nTotalCache -= nBlockTreeDBCache;
int64_t nCoinDBCache = std::min(nTotalCache / 2, (nTotalCache / 4) + (1 << 23)); // use 25%-50% of the remainder for disk cache int64_t nCoinDBCache = std::min(nTotalCache / 2, (nTotalCache / 4) + (1 << 23)); // use 25%-50% of the remainder for disk cache
nCoinDBCache = std::min(nCoinDBCache, nMaxCoinsDBCache << 20); // cap total coins db cache nCoinDBCache = std::min(nCoinDBCache, nMaxCoinsDBCache << 20); // cap total coins db cache
nTotalCache -= nCoinDBCache; nTotalCache -= nCoinDBCache;
nCoinCacheUsage = nTotalCache; // the rest goes to in-memory cache nCoinCacheUsage = nTotalCache; // the rest goes to in-memory cache
int64_t nMempoolSizeMax = GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000; int64_t nMempoolSizeMax = gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000;
int64_t nEvoDbCache = 1024 * 1024 * 16; // TODO int64_t nEvoDbCache = 1024 * 1024 * 16; // TODO
LogPrintf("Cache configuration:\n"); LogPrintf("Cache configuration:\n");
LogPrintf("* Using %.1fMiB for block index database\n", nBlockTreeDBCache * (1.0 / 1024 / 1024)); LogPrintf("* Using %.1fMiB for block index database\n", nBlockTreeDBCache * (1.0 / 1024 / 1024));
@ -1844,7 +1844,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
} }
// Check for changed -txindex state // Check for changed -txindex state
if (fTxIndex != GetBoolArg("-txindex", DEFAULT_TXINDEX)) { if (fTxIndex != gArgs.GetBoolArg("-txindex", DEFAULT_TXINDEX)) {
strLoadError = _("You need to rebuild the database using -reindex-chainstate to change -txindex"); strLoadError = _("You need to rebuild the database using -reindex-chainstate to change -txindex");
break; break;
} }
@ -1857,7 +1857,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
} }
uiInterface.InitMessage(_("Verifying blocks...")); uiInterface.InitMessage(_("Verifying blocks..."));
if (fHavePruned && GetArg("-checkblocks", DEFAULT_CHECKBLOCKS) > MIN_BLOCKS_TO_KEEP) { if (fHavePruned && gArgs.GetArg("-checkblocks", DEFAULT_CHECKBLOCKS) > MIN_BLOCKS_TO_KEEP) {
LogPrintf("Prune: pruned datadir may not have more than %d blocks; only checking available blocks", LogPrintf("Prune: pruned datadir may not have more than %d blocks; only checking available blocks",
MIN_BLOCKS_TO_KEEP); MIN_BLOCKS_TO_KEEP);
} }
@ -1874,8 +1874,8 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
} }
} }
if (!CVerifyDB().VerifyDB(chainparams, pcoinsdbview, GetArg("-checklevel", DEFAULT_CHECKLEVEL), if (!CVerifyDB().VerifyDB(chainparams, pcoinsdbview, gArgs.GetArg("-checklevel", DEFAULT_CHECKLEVEL),
GetArg("-checkblocks", DEFAULT_CHECKBLOCKS))) { gArgs.GetArg("-checkblocks", DEFAULT_CHECKBLOCKS))) {
strLoadError = _("Corrupted block database detected"); strLoadError = _("Corrupted block database detected");
break; break;
} }
@ -1947,7 +1947,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
} }
// ********************************************************* Step 10a: Prepare Masternode related stuff // ********************************************************* Step 10a: Prepare Masternode related stuff
fMasternodeMode = GetBoolArg("-masternode", false); fMasternodeMode = gArgs.GetBoolArg("-masternode", false);
// TODO: masternode should have no wallet // TODO: masternode should have no wallet
if(fLiteMode && fMasternodeMode) { if(fLiteMode && fMasternodeMode) {
@ -1957,7 +1957,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
if(fMasternodeMode) { if(fMasternodeMode) {
LogPrintf("MASTERNODE:\n"); LogPrintf("MASTERNODE:\n");
std::string strMasterNodeBLSPrivKey = GetArg("-masternodeblsprivkey", ""); std::string strMasterNodeBLSPrivKey = gArgs.GetArg("-masternodeblsprivkey", "");
if(!strMasterNodeBLSPrivKey.empty()) { if(!strMasterNodeBLSPrivKey.empty()) {
auto binKey = ParseHex(strMasterNodeBLSPrivKey); auto binKey = ParseHex(strMasterNodeBLSPrivKey);
CBLSSecretKey keyOperator; CBLSSecretKey keyOperator;
@ -1988,7 +1988,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
// ********************************************************* Step 10b: setup PrivateSend // ********************************************************* Step 10b: setup PrivateSend
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
privateSendClient.nLiquidityProvider = std::min(std::max((int)GetArg("-liquidityprovider", DEFAULT_PRIVATESEND_LIQUIDITY), MIN_PRIVATESEND_LIQUIDITY), MAX_PRIVATESEND_LIQUIDITY); privateSendClient.nLiquidityProvider = std::min(std::max((int)gArgs.GetArg("-liquidityprovider", DEFAULT_PRIVATESEND_LIQUIDITY), MIN_PRIVATESEND_LIQUIDITY), MAX_PRIVATESEND_LIQUIDITY);
int nMaxRounds = MAX_PRIVATESEND_ROUNDS; int nMaxRounds = MAX_PRIVATESEND_ROUNDS;
if(privateSendClient.nLiquidityProvider) { if(privateSendClient.nLiquidityProvider) {
// special case for liquidity providers only, normal clients should use default value // special case for liquidity providers only, normal clients should use default value
@ -1996,12 +1996,12 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
nMaxRounds = std::numeric_limits<int>::max(); nMaxRounds = std::numeric_limits<int>::max();
} }
privateSendClient.fEnablePrivateSend = GetBoolArg("-enableprivatesend", false); privateSendClient.fEnablePrivateSend = gArgs.GetBoolArg("-enableprivatesend", false);
privateSendClient.fPrivateSendMultiSession = GetBoolArg("-privatesendmultisession", DEFAULT_PRIVATESEND_MULTISESSION); privateSendClient.fPrivateSendMultiSession = gArgs.GetBoolArg("-privatesendmultisession", DEFAULT_PRIVATESEND_MULTISESSION);
privateSendClient.nPrivateSendSessions = std::min(std::max((int)GetArg("-privatesendsessions", DEFAULT_PRIVATESEND_SESSIONS), MIN_PRIVATESEND_SESSIONS), MAX_PRIVATESEND_SESSIONS); privateSendClient.nPrivateSendSessions = std::min(std::max((int)gArgs.GetArg("-privatesendsessions", DEFAULT_PRIVATESEND_SESSIONS), MIN_PRIVATESEND_SESSIONS), MAX_PRIVATESEND_SESSIONS);
privateSendClient.nPrivateSendRounds = std::min(std::max((int)GetArg("-privatesendrounds", DEFAULT_PRIVATESEND_ROUNDS), MIN_PRIVATESEND_ROUNDS), nMaxRounds); privateSendClient.nPrivateSendRounds = std::min(std::max((int)gArgs.GetArg("-privatesendrounds", DEFAULT_PRIVATESEND_ROUNDS), MIN_PRIVATESEND_ROUNDS), nMaxRounds);
privateSendClient.nPrivateSendAmount = std::min(std::max((int)GetArg("-privatesendamount", DEFAULT_PRIVATESEND_AMOUNT), MIN_PRIVATESEND_AMOUNT), MAX_PRIVATESEND_AMOUNT); privateSendClient.nPrivateSendAmount = std::min(std::max((int)gArgs.GetArg("-privatesendamount", DEFAULT_PRIVATESEND_AMOUNT), MIN_PRIVATESEND_AMOUNT), MAX_PRIVATESEND_AMOUNT);
privateSendClient.nPrivateSendDenoms = std::min(std::max((int)GetArg("-privatesenddenoms", DEFAULT_PRIVATESEND_DENOMS), MIN_PRIVATESEND_DENOMS), MAX_PRIVATESEND_DENOMS); privateSendClient.nPrivateSendDenoms = std::min(std::max((int)gArgs.GetArg("-privatesenddenoms", DEFAULT_PRIVATESEND_DENOMS), MIN_PRIVATESEND_DENOMS), MAX_PRIVATESEND_DENOMS);
LogPrintf("PrivateSend liquidityprovider: %d\n", privateSendClient.nLiquidityProvider); LogPrintf("PrivateSend liquidityprovider: %d\n", privateSendClient.nLiquidityProvider);
LogPrintf("PrivateSend rounds: %d\n", privateSendClient.nPrivateSendRounds); LogPrintf("PrivateSend rounds: %d\n", privateSendClient.nPrivateSendRounds);
@ -2013,7 +2013,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
// ********************************************************* Step 10b: setup InstantSend // ********************************************************* Step 10b: setup InstantSend
fEnableInstantSend = GetBoolArg("-enableinstantsend", 1); fEnableInstantSend = gArgs.GetBoolArg("-enableinstantsend", 1);
// ********************************************************* Step 10c: Load cache data // ********************************************************* Step 10c: Load cache data
@ -2091,7 +2091,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
fHaveGenesis = true; fHaveGenesis = true;
} }
if (IsArgSet("-blocknotify")) if (gArgs.IsArgSet("-blocknotify"))
uiInterface.NotifyBlockTip.connect(BlockNotifyCallback); uiInterface.NotifyBlockTip.connect(BlockNotifyCallback);
std::vector<fs::path> vImportFiles; std::vector<fs::path> vImportFiles;
@ -2117,13 +2117,13 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
//// debug print //// debug print
LogPrintf("mapBlockIndex.size() = %u\n", mapBlockIndex.size()); LogPrintf("mapBlockIndex.size() = %u\n", mapBlockIndex.size());
LogPrintf("chainActive.Height() = %d\n", chainActive.Height()); LogPrintf("chainActive.Height() = %d\n", chainActive.Height());
if (GetBoolArg("-listenonion", DEFAULT_LISTEN_ONION)) if (gArgs.GetBoolArg("-listenonion", DEFAULT_LISTEN_ONION))
StartTorControl(threadGroup, scheduler); StartTorControl(threadGroup, scheduler);
Discover(threadGroup); Discover(threadGroup);
// Map ports with UPnP // Map ports with UPnP
MapPort(GetBoolArg("-upnp", DEFAULT_UPNP)); MapPort(gArgs.GetBoolArg("-upnp", DEFAULT_UPNP));
std::string strNodeError; std::string strNodeError;
CConnman::Options connOptions; CConnman::Options connOptions;
@ -2135,8 +2135,8 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
connOptions.nMaxFeeler = 1; connOptions.nMaxFeeler = 1;
connOptions.nBestHeight = chainActive.Height(); connOptions.nBestHeight = chainActive.Height();
connOptions.uiInterface = &uiInterface; connOptions.uiInterface = &uiInterface;
connOptions.nSendBufferMaxSize = 1000*GetArg("-maxsendbuffer", DEFAULT_MAXSENDBUFFER); connOptions.nSendBufferMaxSize = 1000*gArgs.GetArg("-maxsendbuffer", DEFAULT_MAXSENDBUFFER);
connOptions.nReceiveFloodSize = 1000*GetArg("-maxreceivebuffer", DEFAULT_MAXRECEIVEBUFFER); connOptions.nReceiveFloodSize = 1000*gArgs.GetArg("-maxreceivebuffer", DEFAULT_MAXRECEIVEBUFFER);
connOptions.nMaxOutboundTimeframe = nMaxOutboundTimeframe; connOptions.nMaxOutboundTimeframe = nMaxOutboundTimeframe;
connOptions.nMaxOutboundLimit = nMaxOutboundLimit; connOptions.nMaxOutboundLimit = nMaxOutboundLimit;

View File

@ -101,11 +101,11 @@ CKeePassIntegrator::CKeePassIntegrator()
// Initialze from application context // Initialze from application context
void CKeePassIntegrator::init() void CKeePassIntegrator::init()
{ {
bIsActive = GetBoolArg("-keepass", false); bIsActive = gArgs.GetBoolArg("-keepass", false);
nPort = GetArg("-keepassport", DEFAULT_KEEPASS_HTTP_PORT); nPort = gArgs.GetArg("-keepassport", DEFAULT_KEEPASS_HTTP_PORT);
sKeyBase64 = SecureString(GetArg("-keepasskey", "").c_str()); sKeyBase64 = SecureString(gArgs.GetArg("-keepasskey", "").c_str());
strKeePassId = GetArg("-keepassid", ""); strKeePassId = gArgs.GetArg("-keepassid", "");
strKeePassEntryName = GetArg("-keepassname", ""); strKeePassEntryName = gArgs.GetArg("-keepassname", "");
// Convert key if available // Convert key if available
if(sKeyBase64.size() > 0) if(sKeyBase64.size() > 0)
{ {

View File

@ -186,7 +186,7 @@ void CQuorumManager::EnsureQuorumConnections(Consensus::LLMQType llmqType, const
connmanQuorumsToDelete.erase(curDkgBlock); connmanQuorumsToDelete.erase(curDkgBlock);
for (auto& quorum : lastQuorums) { for (auto& quorum : lastQuorums) {
if (!quorum->IsMember(myProTxHash) && !GetBoolArg("-watchquorums", DEFAULT_WATCH_QUORUMS)) { if (!quorum->IsMember(myProTxHash) && !gArgs.GetBoolArg("-watchquorums", DEFAULT_WATCH_QUORUMS)) {
continue; continue;
} }

View File

@ -467,7 +467,7 @@ void CDKGSessionHandler::HandleDKGRound()
return changed; return changed;
}); });
if (curSession->AreWeMember() || GetBoolArg("-watchquorums", DEFAULT_WATCH_QUORUMS)) { if (curSession->AreWeMember() || gArgs.GetBoolArg("-watchquorums", DEFAULT_WATCH_QUORUMS)) {
std::set<uint256> connections; std::set<uint256> connections;
if (curSession->AreWeMember()) { if (curSession->AreWeMember()) {
connections = CLLMQUtils::GetQuorumConnections(params.type, curQuorumHash, curSession->myProTxHash); connections = CLLMQUtils::GetQuorumConnections(params.type, curQuorumHash, curSession->myProTxHash);

View File

@ -687,7 +687,7 @@ void CSigningManager::Cleanup()
return; return;
} }
int64_t maxAge = GetArg("-recsigsmaxage", DEFAULT_MAX_RECOVERED_SIGS_AGE); int64_t maxAge = gArgs.GetArg("-recsigsmaxage", DEFAULT_MAX_RECOVERED_SIGS_AGE);
db.CleanupOldRecoveredSigs(maxAge); db.CleanupOldRecoveredSigs(maxAge);
db.CleanupOldVotes(maxAge); db.CleanupOldVotes(maxAge);

View File

@ -86,12 +86,12 @@ static BlockAssembler::Options DefaultOptions(const CChainParams& params)
// Block resource limits // Block resource limits
BlockAssembler::Options options; BlockAssembler::Options options;
options.nBlockMaxSize = DEFAULT_BLOCK_MAX_SIZE; options.nBlockMaxSize = DEFAULT_BLOCK_MAX_SIZE;
if (IsArgSet("-blockmaxsize")) { if (gArgs.IsArgSet("-blockmaxsize")) {
options.nBlockMaxSize = GetArg("-blockmaxsize", DEFAULT_BLOCK_MAX_SIZE); options.nBlockMaxSize = gArgs.GetArg("-blockmaxsize", DEFAULT_BLOCK_MAX_SIZE);
} }
if (IsArgSet("-blockmintxfee")) { if (gArgs.IsArgSet("-blockmintxfee")) {
CAmount n = 0; CAmount n = 0;
ParseMoney(GetArg("-blockmintxfee", ""), n); ParseMoney(gArgs.GetArg("-blockmintxfee", ""), n);
options.blockMinFeeRate = CFeeRate(n); options.blockMinFeeRate = CFeeRate(n);
} else { } else {
options.blockMinFeeRate = CFeeRate(DEFAULT_BLOCK_MIN_TX_FEE); options.blockMinFeeRate = CFeeRate(DEFAULT_BLOCK_MIN_TX_FEE);
@ -143,7 +143,7 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
// -regtest only: allow overriding block.nVersion with // -regtest only: allow overriding block.nVersion with
// -blockversion=N to test forking scenarios // -blockversion=N to test forking scenarios
if (chainparams.MineBlocksOnDemand()) if (chainparams.MineBlocksOnDemand())
pblock->nVersion = GetArg("-blockversion", pblock->nVersion); pblock->nVersion = gArgs.GetArg("-blockversion", pblock->nVersion);
pblock->nTime = GetAdjustedTime(); pblock->nTime = GetAdjustedTime();
const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast(); const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast();
@ -295,7 +295,7 @@ void BlockAssembler::AddToBlock(CTxMemPool::txiter iter)
nFees += iter->GetFee(); nFees += iter->GetFee();
inBlock.insert(iter); inBlock.insert(iter);
bool fPrintPriority = GetBoolArg("-printpriority", DEFAULT_PRINTPRIORITY); bool fPrintPriority = gArgs.GetBoolArg("-printpriority", DEFAULT_PRINTPRIORITY);
if (fPrintPriority) { if (fPrintPriority) {
LogPrintf("fee %s txid %s\n", LogPrintf("fee %s txid %s\n",
CFeeRate(iter->GetModifiedFee(), iter->GetTxSize()).ToString(), CFeeRate(iter->GetModifiedFee(), iter->GetTxSize()).ToString(),

View File

@ -104,7 +104,7 @@ void CConnman::AddOneShot(const std::string& strDest)
unsigned short GetListenPort() unsigned short GetListenPort()
{ {
return (unsigned short)(GetArg("-port", Params().GetDefaultPort())); return (unsigned short)(gArgs.GetArg("-port", Params().GetDefaultPort()));
} }
// find 'best' local address for a particular peer // find 'best' local address for a particular peer
@ -504,7 +504,7 @@ void CConnman::Ban(const CSubNet& subNet, const BanReason &banReason, int64_t ba
banEntry.banReason = banReason; banEntry.banReason = banReason;
if (bantimeoffset <= 0) if (bantimeoffset <= 0)
{ {
bantimeoffset = GetArg("-bantime", DEFAULT_MISBEHAVING_BANTIME); bantimeoffset = gArgs.GetArg("-bantime", DEFAULT_MISBEHAVING_BANTIME);
sinceUnixEpoch = false; sinceUnixEpoch = false;
} }
banEntry.nBanUntil = (sinceUnixEpoch ? 0 : GetTime() )+bantimeoffset; banEntry.nBanUntil = (sinceUnixEpoch ? 0 : GetTime() )+bantimeoffset;
@ -1664,7 +1664,7 @@ void CConnman::ThreadDNSAddressSeed()
// creating fewer identifying DNS requests, reduces trust by giving seeds // creating fewer identifying DNS requests, reduces trust by giving seeds
// less influence on the network topology, and reduces traffic to the seeds. // less influence on the network topology, and reduces traffic to the seeds.
if ((addrman.size() > 0) && if ((addrman.size() > 0) &&
(!GetBoolArg("-forcednsseed", DEFAULT_FORCEDNSSEED))) { (!gArgs.GetBoolArg("-forcednsseed", DEFAULT_FORCEDNSSEED))) {
if (!interruptNet.sleep_for(std::chrono::seconds(11))) if (!interruptNet.sleep_for(std::chrono::seconds(11)))
return; return;
@ -2042,7 +2042,7 @@ void CConnman::ThreadOpenAddedConnections()
void CConnman::ThreadOpenMasternodeConnections() void CConnman::ThreadOpenMasternodeConnections()
{ {
// Connecting to specific addresses, no masternode connections available // Connecting to specific addresses, no masternode connections available
if (IsArgSet("-connect") && gArgs.GetArgs("-connect").size() > 0) if (gArgs.IsArgSet("-connect") && gArgs.GetArgs("-connect").size() > 0)
return; return;
while (!interruptNet) while (!interruptNet)
@ -2523,7 +2523,7 @@ bool CConnman::Start(CScheduler& scheduler, std::string& strNodeError, Options c
// Send and receive from sockets, accept connections // Send and receive from sockets, accept connections
threadSocketHandler = std::thread(&TraceThread<std::function<void()> >, "net", std::function<void()>(std::bind(&CConnman::ThreadSocketHandler, this))); threadSocketHandler = std::thread(&TraceThread<std::function<void()> >, "net", std::function<void()>(std::bind(&CConnman::ThreadSocketHandler, this)));
if (!GetBoolArg("-dnsseed", true)) if (!gArgs.GetBoolArg("-dnsseed", true))
LogPrintf("DNS seeding disabled\n"); LogPrintf("DNS seeding disabled\n");
else else
threadDNSAddressSeed = std::thread(&TraceThread<std::function<void()> >, "dnsseed", std::function<void()>(std::bind(&CConnman::ThreadDNSAddressSeed, this))); threadDNSAddressSeed = std::thread(&TraceThread<std::function<void()> >, "dnsseed", std::function<void()>(std::bind(&CConnman::ThreadDNSAddressSeed, this)));

View File

@ -631,7 +631,7 @@ void UnregisterNodeSignals(CNodeSignals& nodeSignals)
void AddToCompactExtraTransactions(const CTransactionRef& tx) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans) void AddToCompactExtraTransactions(const CTransactionRef& tx) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans)
{ {
size_t max_extra_txn = GetArg("-blockreconstructionextratxn", DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN); size_t max_extra_txn = gArgs.GetArg("-blockreconstructionextratxn", DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN);
if (max_extra_txn <= 0) if (max_extra_txn <= 0)
return; return;
if (!vExtraTxnForCompact.size()) if (!vExtraTxnForCompact.size())
@ -757,7 +757,7 @@ void Misbehaving(NodeId pnode, int howmuch)
return; return;
state->nMisbehavior += howmuch; state->nMisbehavior += howmuch;
int banscore = GetArg("-banscore", DEFAULT_BANSCORE_THRESHOLD); int banscore = gArgs.GetArg("-banscore", DEFAULT_BANSCORE_THRESHOLD);
if (state->nMisbehavior >= banscore && state->nMisbehavior - howmuch < banscore) if (state->nMisbehavior >= banscore && state->nMisbehavior - howmuch < banscore)
{ {
LogPrintf("%s: %s peer=%d (%d -> %d) BAN THRESHOLD EXCEEDED\n", __func__, state->name, pnode, state->nMisbehavior-howmuch, state->nMisbehavior); LogPrintf("%s: %s peer=%d (%d -> %d) BAN THRESHOLD EXCEEDED\n", __func__, state->name, pnode, state->nMisbehavior-howmuch, state->nMisbehavior);
@ -1413,7 +1413,7 @@ inline void static SendBlockTransactions(const CBlock& block, const BlockTransac
bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, int64_t nTimeReceived, const CChainParams& chainparams, CConnman& connman, const std::atomic<bool>& interruptMsgProc) bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, int64_t nTimeReceived, const CChainParams& chainparams, CConnman& connman, const std::atomic<bool>& interruptMsgProc)
{ {
LogPrint(BCLog::NET, "received: %s (%u bytes) peer=%d\n", SanitizeString(strCommand), vRecv.size(), pfrom->GetId()); LogPrint(BCLog::NET, "received: %s (%u bytes) peer=%d\n", SanitizeString(strCommand), vRecv.size(), pfrom->GetId());
if (IsArgSet("-dropmessagestest") && GetRand(GetArg("-dropmessagestest", 0)) == 0) if (gArgs.IsArgSet("-dropmessagestest") && GetRand(gArgs.GetArg("-dropmessagestest", 0)) == 0)
{ {
LogPrintf("dropmessagestest DROPPING RECV MESSAGE\n"); LogPrintf("dropmessagestest DROPPING RECV MESSAGE\n");
return true; return true;
@ -1699,7 +1699,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::QSENDRECSIGS, true)); connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::QSENDRECSIGS, true));
} }
if (GetBoolArg("-watchquorums", llmq::DEFAULT_WATCH_QUORUMS)) { if (gArgs.GetBoolArg("-watchquorums", llmq::DEFAULT_WATCH_QUORUMS)) {
connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::QWATCH)); connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::QWATCH));
} }
@ -1810,7 +1810,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
bool fBlocksOnly = !fRelayTxes; bool fBlocksOnly = !fRelayTxes;
// Allow whitelisted peers to send data other than blocks in blocks only mode if whitelistrelay is true // Allow whitelisted peers to send data other than blocks in blocks only mode if whitelistrelay is true
if (pfrom->fWhitelisted && GetBoolArg("-whitelistrelay", DEFAULT_WHITELISTRELAY)) if (pfrom->fWhitelisted && gArgs.GetBoolArg("-whitelistrelay", DEFAULT_WHITELISTRELAY))
fBlocksOnly = false; fBlocksOnly = false;
LOCK(cs_main); LOCK(cs_main);
@ -2095,7 +2095,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
{ {
// Stop processing the transaction early if // Stop processing the transaction early if
// We are in blocks only mode and peer is either not whitelisted or whitelistrelay is off // We are in blocks only mode and peer is either not whitelisted or whitelistrelay is off
if (!fRelayTxes && (!pfrom->fWhitelisted || !GetBoolArg("-whitelistrelay", DEFAULT_WHITELISTRELAY))) if (!fRelayTxes && (!pfrom->fWhitelisted || !gArgs.GetBoolArg("-whitelistrelay", DEFAULT_WHITELISTRELAY)))
{ {
LogPrint(BCLog::NET, "transaction sent in violation of protocol peer=%d\n", pfrom->GetId()); LogPrint(BCLog::NET, "transaction sent in violation of protocol peer=%d\n", pfrom->GetId());
return true; return true;
@ -2290,7 +2290,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
AddOrphanTx(ptx, pfrom->GetId()); AddOrphanTx(ptx, pfrom->GetId());
// DoS prevention: do not allow mapOrphanTransactions to grow unbounded // DoS prevention: do not allow mapOrphanTransactions to grow unbounded
unsigned int nMaxOrphanTx = (unsigned int)std::max((int64_t)0, GetArg("-maxorphantx", DEFAULT_MAX_ORPHAN_TRANSACTIONS)); unsigned int nMaxOrphanTx = (unsigned int)std::max((int64_t)0, gArgs.GetArg("-maxorphantx", DEFAULT_MAX_ORPHAN_TRANSACTIONS));
unsigned int nEvicted = LimitOrphanTxSize(nMaxOrphanTx); unsigned int nEvicted = LimitOrphanTxSize(nMaxOrphanTx);
if (nEvicted > 0) { if (nEvicted > 0) {
LogPrint(BCLog::MEMPOOL, "mapOrphan overflow, removed %u tx\n", nEvicted); LogPrint(BCLog::MEMPOOL, "mapOrphan overflow, removed %u tx\n", nEvicted);
@ -2323,7 +2323,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
connman.RelayTransaction(tx); connman.RelayTransaction(tx);
} }
if (pfrom->fWhitelisted && GetBoolArg("-whitelistforcerelay", DEFAULT_WHITELISTFORCERELAY)) { if (pfrom->fWhitelisted && gArgs.GetBoolArg("-whitelistforcerelay", DEFAULT_WHITELISTFORCERELAY)) {
// Always relay transactions received from whitelisted peers, even // Always relay transactions received from whitelisted peers, even
// if they were already in the mempool or rejected from it due // if they were already in the mempool or rejected from it due
// to policy, allowing the node to function as a gateway for // to policy, allowing the node to function as a gateway for

View File

@ -564,7 +564,7 @@ CFeeRate CBlockPolicyEstimator::estimateSmartFee(int confTarget, int *answerFoun
*answerFoundAtTarget = confTarget - 1; *answerFoundAtTarget = confTarget - 1;
// If mempool is limiting txs , return at least the min feerate from the mempool // If mempool is limiting txs , return at least the min feerate from the mempool
CAmount minPoolFee = pool.GetMinFee(GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000).GetFeePerK(); CAmount minPoolFee = pool.GetMinFee(gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000).GetFeePerK();
if (minPoolFee > 0 && minPoolFee > median) if (minPoolFee > 0 && minPoolFee > median)
return CFeeRate(minPoolFee); return CFeeRate(minPoolFee);

View File

@ -144,7 +144,7 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *_platformStyle, const NetworkStyle *
} else { } else {
windowTitle += tr("Node"); windowTitle += tr("Node");
} }
QString userWindowTitle = QString::fromStdString(GetArg("-windowtitle", "")); QString userWindowTitle = QString::fromStdString(gArgs.GetArg("-windowtitle", ""));
if(!userWindowTitle.isEmpty()) windowTitle += " - " + userWindowTitle; if(!userWindowTitle.isEmpty()) windowTitle += " - " + userWindowTitle;
windowTitle += " " + networkStyle->getTitleAddText(); windowTitle += " " + networkStyle->getTitleAddText();
#ifndef Q_OS_MAC #ifndef Q_OS_MAC

View File

@ -109,7 +109,7 @@ static QString GetLangTerritory()
if(!lang_territory_qsettings.isEmpty()) if(!lang_territory_qsettings.isEmpty())
lang_territory = lang_territory_qsettings; lang_territory = lang_territory_qsettings;
// 3) -lang command line argument // 3) -lang command line argument
lang_territory = QString::fromStdString(GetArg("-lang", lang_territory.toStdString())); lang_territory = QString::fromStdString(gArgs.GetArg("-lang", lang_territory.toStdString()));
return lang_territory; return lang_territory;
} }
@ -361,7 +361,7 @@ BitcoinApplication::BitcoinApplication(int &argc, char **argv):
// This must be done inside the BitcoinApplication constructor, or after it, because // This must be done inside the BitcoinApplication constructor, or after it, because
// PlatformStyle::instantiate requires a QApplication // PlatformStyle::instantiate requires a QApplication
std::string platformName; std::string platformName;
platformName = GetArg("-uiplatform", BitcoinGUI::DEFAULT_UIPLATFORM); platformName = gArgs.GetArg("-uiplatform", BitcoinGUI::DEFAULT_UIPLATFORM);
platformStyle = PlatformStyle::instantiate(QString::fromStdString(platformName)); platformStyle = PlatformStyle::instantiate(QString::fromStdString(platformName));
if (!platformStyle) // Fall back to "other" if specified name not found if (!platformStyle) // Fall back to "other" if specified name not found
platformStyle = PlatformStyle::instantiate("other"); platformStyle = PlatformStyle::instantiate("other");
@ -520,7 +520,7 @@ void BitcoinApplication::initializeResult(bool success)
#endif #endif
// If -min option passed, start window minimized. // If -min option passed, start window minimized.
if(GetBoolArg("-min", false)) if(gArgs.GetBoolArg("-min", false))
{ {
window->showMinimized(); window->showMinimized();
} }
@ -575,7 +575,7 @@ int main(int argc, char *argv[])
/// 1. Parse command-line options. These take precedence over anything else. /// 1. Parse command-line options. These take precedence over anything else.
// Command-line options take precedence: // Command-line options take precedence:
ParseParameters(argc, argv); gArgs.ParseParameters(argc, argv);
// Do not refer to data directory yet, this can be overridden by Intro::pickDataDirectory // Do not refer to data directory yet, this can be overridden by Intro::pickDataDirectory
@ -624,9 +624,9 @@ int main(int argc, char *argv[])
// Show help message immediately after parsing command-line options (for "-lang") and setting locale, // Show help message immediately after parsing command-line options (for "-lang") and setting locale,
// but before showing splash screen. // but before showing splash screen.
if (IsArgSet("-?") || IsArgSet("-h") || IsArgSet("-help") || IsArgSet("-version")) if (gArgs.IsArgSet("-?") || gArgs.IsArgSet("-h") || gArgs.IsArgSet("-help") || gArgs.IsArgSet("-version"))
{ {
HelpMessageDialog help(NULL, IsArgSet("-version") ? HelpMessageDialog::about : HelpMessageDialog::cmdline); HelpMessageDialog help(NULL, gArgs.IsArgSet("-version") ? HelpMessageDialog::about : HelpMessageDialog::cmdline);
help.showOrPrint(); help.showOrPrint();
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
@ -641,11 +641,11 @@ int main(int argc, char *argv[])
if (!fs::is_directory(GetDataDir(false))) if (!fs::is_directory(GetDataDir(false)))
{ {
QMessageBox::critical(0, QObject::tr(PACKAGE_NAME), QMessageBox::critical(0, QObject::tr(PACKAGE_NAME),
QObject::tr("Error: Specified data directory \"%1\" does not exist.").arg(QString::fromStdString(GetArg("-datadir", "")))); QObject::tr("Error: Specified data directory \"%1\" does not exist.").arg(QString::fromStdString(gArgs.GetArg("-datadir", ""))));
return EXIT_FAILURE; return EXIT_FAILURE;
} }
try { try {
ReadConfigFile(GetArg("-conf", BITCOIN_CONF_FILENAME)); gArgs.ReadConfigFile(gArgs.GetArg("-conf", BITCOIN_CONF_FILENAME));
} catch (const std::exception& e) { } catch (const std::exception& e) {
QMessageBox::critical(0, QObject::tr(PACKAGE_NAME), QMessageBox::critical(0, QObject::tr(PACKAGE_NAME),
QObject::tr("Error: Cannot parse configuration file: %1. Only use key=value syntax.").arg(e.what())); QObject::tr("Error: Cannot parse configuration file: %1. Only use key=value syntax.").arg(e.what()));
@ -709,12 +709,12 @@ int main(int argc, char *argv[])
// Allow parameter interaction before we create the options model // Allow parameter interaction before we create the options model
app.parameterSetup(); app.parameterSetup();
// Load GUI settings from QSettings // Load GUI settings from QSettings
app.createOptionsModel(IsArgSet("-resetguisettings")); app.createOptionsModel(gArgs.IsArgSet("-resetguisettings"));
// Subscribe to global signals from core // Subscribe to global signals from core
uiInterface.InitMessage.connect(InitMessage); uiInterface.InitMessage.connect(InitMessage);
if (GetBoolArg("-splash", DEFAULT_SPLASHSCREEN) && !GetBoolArg("-min", false)) if (gArgs.GetBoolArg("-splash", DEFAULT_SPLASHSCREEN) && !gArgs.GetBoolArg("-min", false))
app.createSplashScreen(networkStyle.data()); app.createSplashScreen(networkStyle.data());
try try

View File

@ -434,7 +434,7 @@ void openDebugLogfile()
void openConfigfile() void openConfigfile()
{ {
fs::path pathConfig = GetConfigFile(GetArg("-conf", BITCOIN_CONF_FILENAME)); fs::path pathConfig = GetConfigFile(gArgs.GetArg("-conf", BITCOIN_CONF_FILENAME));
/* Open dash.conf with the associated application */ /* Open dash.conf with the associated application */
if (fs::exists(pathConfig)) if (fs::exists(pathConfig))
@ -673,7 +673,7 @@ bool SetStartOnSystemStartup(bool fAutoStart)
// Start client minimized // Start client minimized
QString strArgs = "-min"; QString strArgs = "-min";
// Set -testnet /-regtest options // Set -testnet /-regtest options
strArgs += QString::fromStdString(strprintf(" -testnet=%d -regtest=%d", GetBoolArg("-testnet", false), GetBoolArg("-regtest", false))); strArgs += QString::fromStdString(strprintf(" -testnet=%d -regtest=%d", gArgs.GetBoolArg("-testnet", false), gArgs.GetBoolArg("-regtest", false)));
#ifdef UNICODE #ifdef UNICODE
boost::scoped_array<TCHAR> args(new TCHAR[strArgs.length() + 1]); boost::scoped_array<TCHAR> args(new TCHAR[strArgs.length() + 1]);
@ -782,7 +782,7 @@ bool SetStartOnSystemStartup(bool fAutoStart)
optionFile << "Name=Dash Core\n"; optionFile << "Name=Dash Core\n";
else else
optionFile << strprintf("Name=Dash Core (%s)\n", chain); optionFile << strprintf("Name=Dash Core (%s)\n", chain);
optionFile << "Exec=" << pszExePath << strprintf(" -min -testnet=%d -regtest=%d\n", GetBoolArg("-testnet", false), GetBoolArg("-regtest", false)); optionFile << "Exec=" << pszExePath << strprintf(" -min -testnet=%d -regtest=%d\n", gArgs.GetBoolArg("-testnet", false), gArgs.GetBoolArg("-regtest", false));
optionFile << "Terminal=false\n"; optionFile << "Terminal=false\n";
optionFile << "Hidden=false\n"; optionFile << "Hidden=false\n";
optionFile.close(); optionFile.close();

View File

@ -132,7 +132,7 @@ Intro::Intro(QWidget *parent) :
); );
ui->lblExplanation2->setText(ui->lblExplanation2->text().arg(tr(PACKAGE_NAME))); ui->lblExplanation2->setText(ui->lblExplanation2->text().arg(tr(PACKAGE_NAME)));
uint64_t pruneTarget = std::max<int64_t>(0, GetArg("-prune", 0)); uint64_t pruneTarget = std::max<int64_t>(0, gArgs.GetArg("-prune", 0));
requiredSpace = BLOCK_CHAIN_SIZE; requiredSpace = BLOCK_CHAIN_SIZE;
QString storageRequiresMsg = tr("At least %1 GB of data will be stored in this directory, and it will grow over time."); QString storageRequiresMsg = tr("At least %1 GB of data will be stored in this directory, and it will grow over time.");
if (pruneTarget) { if (pruneTarget) {
@ -192,7 +192,7 @@ bool Intro::pickDataDirectory()
QSettings settings; QSettings settings;
/* If data directory provided on command line, no need to look at settings /* If data directory provided on command line, no need to look at settings
or show a picking dialog */ or show a picking dialog */
if(!GetArg("-datadir", "").empty()) if(!gArgs.GetArg("-datadir", "").empty())
return true; return true;
/* 1) Default data directory for operating system */ /* 1) Default data directory for operating system */
QString dataDirDefaultCurrent = getDefaultDataDirectory(); QString dataDirDefaultCurrent = getDefaultDataDirectory();
@ -201,7 +201,7 @@ bool Intro::pickDataDirectory()
/* 3) Check to see if default datadir is the one we expect */ /* 3) Check to see if default datadir is the one we expect */
QString dataDirDefaultSettings = settings.value("strDataDirDefault").toString(); QString dataDirDefaultSettings = settings.value("strDataDirDefault").toString();
if(!fs::exists(GUIUtil::qstringToBoostPath(dataDir)) || GetBoolArg("-choosedatadir", DEFAULT_CHOOSE_DATADIR) || dataDirDefaultCurrent != dataDirDefaultSettings) if(!fs::exists(GUIUtil::qstringToBoostPath(dataDir)) || gArgs.GetBoolArg("-choosedatadir", DEFAULT_CHOOSE_DATADIR) || dataDirDefaultCurrent != dataDirDefaultSettings)
{ {
/* Let the user choose one */ /* Let the user choose one */
Intro intro; Intro intro;
@ -234,7 +234,7 @@ bool Intro::pickDataDirectory()
* (to be consistent with dashd behavior) * (to be consistent with dashd behavior)
*/ */
if(dataDir != dataDirDefaultCurrent) if(dataDir != dataDirDefaultCurrent)
SoftSetArg("-datadir", GUIUtil::qstringToBoostPath(dataDir).string()); // use OS locale for path setting gArgs.SoftSetArg("-datadir", GUIUtil::qstringToBoostPath(dataDir).string()); // use OS locale for path setting
return true; return true;
} }

View File

@ -38,7 +38,7 @@ OptionsModel::OptionsModel(QObject *parent, bool resetSettings) :
void OptionsModel::addOverriddenOption(const std::string &option) void OptionsModel::addOverriddenOption(const std::string &option)
{ {
strOverriddenByCommandLine += QString::fromStdString(option) + "=" + QString::fromStdString(GetArg(option, "")) + " "; strOverriddenByCommandLine += QString::fromStdString(option) + "=" + QString::fromStdString(gArgs.GetArg(option, "")) + " ";
} }
// Writes all missing QSettings with their default values // Writes all missing QSettings with their default values
@ -109,31 +109,31 @@ void OptionsModel::Init(bool resetSettings)
// //
// If setting doesn't exist create it with defaults. // If setting doesn't exist create it with defaults.
// //
// If SoftSetArg() or SoftSetBoolArg() return false we were overridden // If gArgs.SoftSetArg() or gArgs.SoftSetBoolArg() return false we were overridden
// by command-line and show this in the UI. // by command-line and show this in the UI.
// Main // Main
if (!settings.contains("nDatabaseCache")) if (!settings.contains("nDatabaseCache"))
settings.setValue("nDatabaseCache", (qint64)nDefaultDbCache); settings.setValue("nDatabaseCache", (qint64)nDefaultDbCache);
if (!SoftSetArg("-dbcache", settings.value("nDatabaseCache").toString().toStdString())) if (!gArgs.SoftSetArg("-dbcache", settings.value("nDatabaseCache").toString().toStdString()))
addOverriddenOption("-dbcache"); addOverriddenOption("-dbcache");
if (!settings.contains("nThreadsScriptVerif")) if (!settings.contains("nThreadsScriptVerif"))
settings.setValue("nThreadsScriptVerif", DEFAULT_SCRIPTCHECK_THREADS); settings.setValue("nThreadsScriptVerif", DEFAULT_SCRIPTCHECK_THREADS);
if (!SoftSetArg("-par", settings.value("nThreadsScriptVerif").toString().toStdString())) if (!gArgs.SoftSetArg("-par", settings.value("nThreadsScriptVerif").toString().toStdString()))
addOverriddenOption("-par"); addOverriddenOption("-par");
// Wallet // Wallet
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
if (!settings.contains("bSpendZeroConfChange")) if (!settings.contains("bSpendZeroConfChange"))
settings.setValue("bSpendZeroConfChange", true); settings.setValue("bSpendZeroConfChange", true);
if (!SoftSetBoolArg("-spendzeroconfchange", settings.value("bSpendZeroConfChange").toBool())) if (!gArgs.SoftSetBoolArg("-spendzeroconfchange", settings.value("bSpendZeroConfChange").toBool()))
addOverriddenOption("-spendzeroconfchange"); addOverriddenOption("-spendzeroconfchange");
// PrivateSend // PrivateSend
if (!settings.contains("nPrivateSendRounds")) if (!settings.contains("nPrivateSendRounds"))
settings.setValue("nPrivateSendRounds", DEFAULT_PRIVATESEND_ROUNDS); settings.setValue("nPrivateSendRounds", DEFAULT_PRIVATESEND_ROUNDS);
if (!SoftSetArg("-privatesendrounds", settings.value("nPrivateSendRounds").toString().toStdString())) if (!gArgs.SoftSetArg("-privatesendrounds", settings.value("nPrivateSendRounds").toString().toStdString()))
addOverriddenOption("-privatesendrounds"); addOverriddenOption("-privatesendrounds");
privateSendClient.nPrivateSendRounds = settings.value("nPrivateSendRounds").toInt(); privateSendClient.nPrivateSendRounds = settings.value("nPrivateSendRounds").toInt();
@ -144,13 +144,13 @@ void OptionsModel::Init(bool resetSettings)
else else
settings.setValue("nPrivateSendAmount", settings.value("nAnonymizeDashAmount").toInt()); settings.setValue("nPrivateSendAmount", settings.value("nAnonymizeDashAmount").toInt());
} }
if (!SoftSetArg("-privatesendamount", settings.value("nPrivateSendAmount").toString().toStdString())) if (!gArgs.SoftSetArg("-privatesendamount", settings.value("nPrivateSendAmount").toString().toStdString()))
addOverriddenOption("-privatesendamount"); addOverriddenOption("-privatesendamount");
privateSendClient.nPrivateSendAmount = settings.value("nPrivateSendAmount").toInt(); privateSendClient.nPrivateSendAmount = settings.value("nPrivateSendAmount").toInt();
if (!settings.contains("fPrivateSendMultiSession")) if (!settings.contains("fPrivateSendMultiSession"))
settings.setValue("fPrivateSendMultiSession", DEFAULT_PRIVATESEND_MULTISESSION); settings.setValue("fPrivateSendMultiSession", DEFAULT_PRIVATESEND_MULTISESSION);
if (!SoftSetBoolArg("-privatesendmultisession", settings.value("fPrivateSendMultiSession").toBool())) if (!gArgs.SoftSetBoolArg("-privatesendmultisession", settings.value("fPrivateSendMultiSession").toBool()))
addOverriddenOption("-privatesendmultisession"); addOverriddenOption("-privatesendmultisession");
privateSendClient.fPrivateSendMultiSession = settings.value("fPrivateSendMultiSession").toBool(); privateSendClient.fPrivateSendMultiSession = settings.value("fPrivateSendMultiSession").toBool();
#endif #endif
@ -158,12 +158,12 @@ void OptionsModel::Init(bool resetSettings)
// Network // Network
if (!settings.contains("fUseUPnP")) if (!settings.contains("fUseUPnP"))
settings.setValue("fUseUPnP", DEFAULT_UPNP); settings.setValue("fUseUPnP", DEFAULT_UPNP);
if (!SoftSetBoolArg("-upnp", settings.value("fUseUPnP").toBool())) if (!gArgs.SoftSetBoolArg("-upnp", settings.value("fUseUPnP").toBool()))
addOverriddenOption("-upnp"); addOverriddenOption("-upnp");
if (!settings.contains("fListen")) if (!settings.contains("fListen"))
settings.setValue("fListen", DEFAULT_LISTEN); settings.setValue("fListen", DEFAULT_LISTEN);
if (!SoftSetBoolArg("-listen", settings.value("fListen").toBool())) if (!gArgs.SoftSetBoolArg("-listen", settings.value("fListen").toBool()))
addOverriddenOption("-listen"); addOverriddenOption("-listen");
if (!settings.contains("fUseProxy")) if (!settings.contains("fUseProxy"))
@ -171,9 +171,9 @@ void OptionsModel::Init(bool resetSettings)
if (!settings.contains("addrProxy")) if (!settings.contains("addrProxy"))
settings.setValue("addrProxy", "127.0.0.1:9050"); settings.setValue("addrProxy", "127.0.0.1:9050");
// Only try to set -proxy, if user has enabled fUseProxy // Only try to set -proxy, if user has enabled fUseProxy
if (settings.value("fUseProxy").toBool() && !SoftSetArg("-proxy", settings.value("addrProxy").toString().toStdString())) if (settings.value("fUseProxy").toBool() && !gArgs.SoftSetArg("-proxy", settings.value("addrProxy").toString().toStdString()))
addOverriddenOption("-proxy"); addOverriddenOption("-proxy");
else if(!settings.value("fUseProxy").toBool() && !GetArg("-proxy", "").empty()) else if(!settings.value("fUseProxy").toBool() && !gArgs.GetArg("-proxy", "").empty())
addOverriddenOption("-proxy"); addOverriddenOption("-proxy");
if (!settings.contains("fUseSeparateProxyTor")) if (!settings.contains("fUseSeparateProxyTor"))
@ -181,15 +181,15 @@ void OptionsModel::Init(bool resetSettings)
if (!settings.contains("addrSeparateProxyTor")) if (!settings.contains("addrSeparateProxyTor"))
settings.setValue("addrSeparateProxyTor", "127.0.0.1:9050"); settings.setValue("addrSeparateProxyTor", "127.0.0.1:9050");
// Only try to set -onion, if user has enabled fUseSeparateProxyTor // Only try to set -onion, if user has enabled fUseSeparateProxyTor
if (settings.value("fUseSeparateProxyTor").toBool() && !SoftSetArg("-onion", settings.value("addrSeparateProxyTor").toString().toStdString())) if (settings.value("fUseSeparateProxyTor").toBool() && !gArgs.SoftSetArg("-onion", settings.value("addrSeparateProxyTor").toString().toStdString()))
addOverriddenOption("-onion"); addOverriddenOption("-onion");
else if(!settings.value("fUseSeparateProxyTor").toBool() && !GetArg("-onion", "").empty()) else if(!settings.value("fUseSeparateProxyTor").toBool() && !gArgs.GetArg("-onion", "").empty())
addOverriddenOption("-onion"); addOverriddenOption("-onion");
// Display // Display
if (!settings.contains("language")) if (!settings.contains("language"))
settings.setValue("language", ""); settings.setValue("language", "");
if (!SoftSetArg("-lang", settings.value("language").toString().toStdString())) if (!gArgs.SoftSetArg("-lang", settings.value("language").toString().toStdString()))
addOverriddenOption("-lang"); addOverriddenOption("-lang");
language = settings.value("language").toString(); language = settings.value("language").toString();

View File

@ -145,7 +145,7 @@ bool PaymentRequestPlus::getMerchant(X509_STORE* certStore, QString& merchant) c
int error = X509_STORE_CTX_get_error(store_ctx); int error = X509_STORE_CTX_get_error(store_ctx);
// For testing payment requests, we allow self signed root certs! // For testing payment requests, we allow self signed root certs!
// This option is just shown in the UI options, if -help-debug is enabled. // This option is just shown in the UI options, if -help-debug is enabled.
if (!(error == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT && GetBoolArg("-allowselfsignedrootcertificates", DEFAULT_SELFSIGNED_ROOTCERTS))) { if (!(error == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT && gArgs.GetBoolArg("-allowselfsignedrootcertificates", DEFAULT_SELFSIGNED_ROOTCERTS))) {
throw SSLVerifyError(X509_verify_cert_error_string(error)); throw SSLVerifyError(X509_verify_cert_error_string(error));
} else { } else {
qDebug() << "PaymentRequestPlus::getMerchant: Allowing self signed root certificate, because -allowselfsignedrootcertificates is true."; qDebug() << "PaymentRequestPlus::getMerchant: Allowing self signed root certificate, because -allowselfsignedrootcertificates is true.";

View File

@ -123,7 +123,7 @@ void PaymentServer::LoadRootCAs(X509_STORE* _store)
// Note: use "-system-" default here so that users can pass -rootcertificates="" // Note: use "-system-" default here so that users can pass -rootcertificates=""
// and get 'I don't like X.509 certificates, don't trust anybody' behavior: // and get 'I don't like X.509 certificates, don't trust anybody' behavior:
QString certFile = QString::fromStdString(GetArg("-rootcertificates", "-system-")); QString certFile = QString::fromStdString(gArgs.GetArg("-rootcertificates", "-system-"));
// Empty store // Empty store
if (certFile.isEmpty()) { if (certFile.isEmpty()) {

View File

@ -467,7 +467,7 @@ RPCConsole::RPCConsole(const PlatformStyle *_platformStyle, QWidget *parent) :
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
ui->berkeleyDBVersion->setText(DbEnv::version(0, 0, 0)); ui->berkeleyDBVersion->setText(DbEnv::version(0, 0, 0));
std::string walletPath = GetDataDir().string(); std::string walletPath = GetDataDir().string();
walletPath += QDir::separator().toLatin1() + GetArg("-wallet", "wallet.dat"); walletPath += QDir::separator().toLatin1() + gArgs.GetArg("-wallet", "wallet.dat");
ui->wallet_path->setText(QString::fromStdString(walletPath)); ui->wallet_path->setText(QString::fromStdString(walletPath));
#else #else
ui->label_berkeleyDBVersion->hide(); ui->label_berkeleyDBVersion->hide();

View File

@ -52,11 +52,11 @@ SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle)
QString titleAddText = networkStyle->getTitleAddText(); QString titleAddText = networkStyle->getTitleAddText();
// networkstyle.cpp can't (yet) read themes, so we do it here to get the correct Splash-screen // networkstyle.cpp can't (yet) read themes, so we do it here to get the correct Splash-screen
QString splashScreenPath = ":/images/" + GUIUtil::getThemeName() + "/splash"; QString splashScreenPath = ":/images/" + GUIUtil::getThemeName() + "/splash";
if(GetBoolArg("-regtest", false)) if(gArgs.GetBoolArg("-regtest", false))
splashScreenPath = ":/images/" + GUIUtil::getThemeName() + "/splash_testnet"; splashScreenPath = ":/images/" + GUIUtil::getThemeName() + "/splash_testnet";
if(GetBoolArg("-testnet", false)) if(gArgs.GetBoolArg("-testnet", false))
splashScreenPath = ":/images/" + GUIUtil::getThemeName() + "/splash_testnet"; splashScreenPath = ":/images/" + GUIUtil::getThemeName() + "/splash_testnet";
if(IsArgSet("-devnet")) if(gArgs.IsArgSet("-devnet"))
splashScreenPath = ":/images/" + GUIUtil::getThemeName() + "/splash_testnet"; splashScreenPath = ":/images/" + GUIUtil::getThemeName() + "/splash_testnet";
QString font = QApplication::font().toString(); QString font = QApplication::font().toString();

View File

@ -47,7 +47,7 @@ void RPCNestedTests::rpcNestedTests()
std::string path = QDir::tempPath().toStdString() + "/" + strprintf("test_dash_qt_%lu_%i", (unsigned long)GetTime(), (int)(GetRand(100000))); std::string path = QDir::tempPath().toStdString() + "/" + strprintf("test_dash_qt_%lu_%i", (unsigned long)GetTime(), (int)(GetRand(100000)));
QDir dir(QString::fromStdString(path)); QDir dir(QString::fromStdString(path));
dir.mkpath("."); dir.mkpath(".");
ForceSetArg("-datadir", path); gArgs.ForceSetArg("-datadir", path);
//mempool.setSanityCheck(1.0); //mempool.setSanityCheck(1.0);
evoDb = new CEvoDB(1 << 20, true, true); evoDb = new CEvoDB(1 << 20, true, true);
pblocktree = new CBlockTreeDB(1 << 20, true); pblocktree = new CBlockTreeDB(1 << 20, true);

View File

@ -80,7 +80,7 @@ HelpMessageDialog::HelpMessageDialog(QWidget *parent, HelpMode helpMode) :
cursor.insertBlock(); cursor.insertBlock();
std::string strUsage = HelpMessage(HMM_BITCOIN_QT); std::string strUsage = HelpMessage(HMM_BITCOIN_QT);
const bool showDebug = GetBoolArg("-help-debug", false); const bool showDebug = gArgs.GetBoolArg("-help-debug", false);
strUsage += HelpMessageGroup(tr("UI Options:").toStdString()); strUsage += HelpMessageGroup(tr("UI Options:").toStdString());
if (showDebug) { if (showDebug) {
strUsage += HelpMessageOpt("-allowselfsignedrootcertificates", strprintf("Allow self signed root certificates (default: %u)", DEFAULT_SELFSIGNED_ROOTCERTS)); strUsage += HelpMessageOpt("-allowselfsignedrootcertificates", strprintf("Allow self signed root certificates (default: %u)", DEFAULT_SELFSIGNED_ROOTCERTS));

View File

@ -835,7 +835,7 @@ bool WalletModel::abandonTransaction(uint256 hash) const
bool WalletModel::isWalletEnabled() bool WalletModel::isWalletEnabled()
{ {
return !GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET); return !gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET);
} }
bool WalletModel::hdEnabled() const bool WalletModel::hdEnabled() const

View File

@ -1254,8 +1254,8 @@ UniValue gettxout(const JSONRPCRequest& request)
UniValue verifychain(const JSONRPCRequest& request) UniValue verifychain(const JSONRPCRequest& request)
{ {
int nCheckLevel = GetArg("-checklevel", DEFAULT_CHECKLEVEL); int nCheckLevel = gArgs.GetArg("-checklevel", DEFAULT_CHECKLEVEL);
int nCheckDepth = GetArg("-checkblocks", DEFAULT_CHECKBLOCKS); int nCheckDepth = gArgs.GetArg("-checkblocks", DEFAULT_CHECKBLOCKS);
if (request.fHelp || request.params.size() > 2) if (request.fHelp || request.params.size() > 2)
throw std::runtime_error( throw std::runtime_error(
"verifychain ( checklevel nblocks )\n" "verifychain ( checklevel nblocks )\n"
@ -1588,7 +1588,7 @@ UniValue mempoolInfoToJSON()
ret.push_back(Pair("size", (int64_t) mempool.size())); ret.push_back(Pair("size", (int64_t) mempool.size()));
ret.push_back(Pair("bytes", (int64_t) mempool.GetTotalTxSize())); ret.push_back(Pair("bytes", (int64_t) mempool.GetTotalTxSize()));
ret.push_back(Pair("usage", (int64_t) mempool.DynamicMemoryUsage())); ret.push_back(Pair("usage", (int64_t) mempool.DynamicMemoryUsage()));
size_t maxmempool = GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000; size_t maxmempool = gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000;
ret.push_back(Pair("maxmempool", (int64_t) maxmempool)); ret.push_back(Pair("maxmempool", (int64_t) maxmempool));
ret.push_back(Pair("mempoolminfee", ValueFromAmount(mempool.GetMinFee(maxmempool).GetFeePerK()))); ret.push_back(Pair("mempoolminfee", ValueFromAmount(mempool.GetMinFee(maxmempool).GetFeePerK())));

View File

@ -69,7 +69,7 @@ static const std::string COOKIEAUTH_FILE = ".cookie";
fs::path GetAuthCookieFile() fs::path GetAuthCookieFile()
{ {
fs::path path(GetArg("-rpccookiefile", COOKIEAUTH_FILE)); fs::path path(gArgs.GetArg("-rpccookiefile", COOKIEAUTH_FILE));
if (!path.is_complete()) path = GetDataDir() / path; if (!path.is_complete()) path = GetDataDir() / path;
return path; return path;
} }

View File

@ -575,7 +575,7 @@ std::string HelpExampleRpc(const std::string& methodname, const std::string& arg
{ {
return "> curl --user myusername --data-binary '{\"jsonrpc\": \"1.0\", \"id\":\"curltest\", " return "> curl --user myusername --data-binary '{\"jsonrpc\": \"1.0\", \"id\":\"curltest\", "
"\"method\": \"" + methodname + "\", \"params\": [" + args + "] }' -H 'content-type: text/plain;'" "\"method\": \"" + methodname + "\", \"params\": [" + args + "] }' -H 'content-type: text/plain;'"
" http://127.0.0.1:" + strprintf("%d", GetArg("-rpcport", BaseParams().RPCPort())) + "/\n"; " http://127.0.0.1:" + strprintf("%d", gArgs.GetArg("-rpcport", BaseParams().RPCPort())) + "/\n";
} }
void RPCSetTimerInterfaceIfUnset(RPCTimerInterface *iface) void RPCSetTimerInterfaceIfUnset(RPCTimerInterface *iface)

View File

@ -74,7 +74,7 @@ void InitSignatureCache()
{ {
// nMaxCacheSize is unsigned. If -maxsigcachesize is set to zero, // nMaxCacheSize is unsigned. If -maxsigcachesize is set to zero,
// setup_bytes creates the minimum possible cache (2 elements). // setup_bytes creates the minimum possible cache (2 elements).
size_t nMaxCacheSize = std::min(std::max((int64_t)0, GetArg("-maxsigcachesize", DEFAULT_MAX_SIG_CACHE_SIZE)), MAX_MAX_SIG_CACHE_SIZE) * ((size_t) 1 << 20); size_t nMaxCacheSize = std::min(std::max((int64_t)0, gArgs.GetArg("-maxsigcachesize", DEFAULT_MAX_SIG_CACHE_SIZE)), MAX_MAX_SIG_CACHE_SIZE) * ((size_t) 1 << 20);
size_t nElems = signatureCache.setup_bytes(nMaxCacheSize); size_t nElems = signatureCache.setup_bytes(nMaxCacheSize);
LogPrintf("Using %zu MiB out of %zu requested for signature cache, able to store %zu elements\n", LogPrintf("Using %zu MiB out of %zu requested for signature cache, able to store %zu elements\n",
(nElems*sizeof(uint256)) >>20, nMaxCacheSize>>20, nElems); (nElems*sizeof(uint256)) >>20, nMaxCacheSize>>20, nElems);

View File

@ -81,7 +81,7 @@ BOOST_AUTO_TEST_CASE(DoS_banscore)
std::atomic<bool> interruptDummy(false); std::atomic<bool> interruptDummy(false);
connman->ClearBanned(); connman->ClearBanned();
ForceSetArg("-banscore", "111"); // because 11 is my favorite number gArgs.ForceSetArg("-banscore", "111"); // because 11 is my favorite number
CAddress addr1(ip(0xa0b0c001), NODE_NONE); CAddress addr1(ip(0xa0b0c001), NODE_NONE);
CNode dummyNode1(id++, NODE_NETWORK, 0, INVALID_SOCKET, addr1, 3, 1, "", true); CNode dummyNode1(id++, NODE_NETWORK, 0, INVALID_SOCKET, addr1, 3, 1, "", true);
dummyNode1.SetSendVersion(PROTOCOL_VERSION); dummyNode1.SetSendVersion(PROTOCOL_VERSION);
@ -97,7 +97,7 @@ BOOST_AUTO_TEST_CASE(DoS_banscore)
Misbehaving(dummyNode1.GetId(), 1); Misbehaving(dummyNode1.GetId(), 1);
SendMessages(&dummyNode1, *connman, interruptDummy); SendMessages(&dummyNode1, *connman, interruptDummy);
BOOST_CHECK(connman->IsBanned(addr1)); BOOST_CHECK(connman->IsBanned(addr1));
ForceSetArg("-banscore", std::to_string(DEFAULT_BANSCORE_THRESHOLD)); gArgs.ForceSetArg("-banscore", std::to_string(DEFAULT_BANSCORE_THRESHOLD));
} }
BOOST_AUTO_TEST_CASE(DoS_bantime) BOOST_AUTO_TEST_CASE(DoS_bantime)

View File

@ -28,135 +28,135 @@ static void ResetArgs(const std::string& strArg)
BOOST_FOREACH(std::string& s, vecArg) BOOST_FOREACH(std::string& s, vecArg)
vecChar.push_back(s.c_str()); vecChar.push_back(s.c_str());
ParseParameters(vecChar.size(), &vecChar[0]); gArgs.ParseParameters(vecChar.size(), &vecChar[0]);
} }
BOOST_AUTO_TEST_CASE(boolarg) BOOST_AUTO_TEST_CASE(boolarg)
{ {
ResetArgs("-foo"); ResetArgs("-foo");
BOOST_CHECK(GetBoolArg("-foo", false)); BOOST_CHECK(gArgs.GetBoolArg("-foo", false));
BOOST_CHECK(GetBoolArg("-foo", true)); BOOST_CHECK(gArgs.GetBoolArg("-foo", true));
BOOST_CHECK(!GetBoolArg("-fo", false)); BOOST_CHECK(!gArgs.GetBoolArg("-fo", false));
BOOST_CHECK(GetBoolArg("-fo", true)); BOOST_CHECK(gArgs.GetBoolArg("-fo", true));
BOOST_CHECK(!GetBoolArg("-fooo", false)); BOOST_CHECK(!gArgs.GetBoolArg("-fooo", false));
BOOST_CHECK(GetBoolArg("-fooo", true)); BOOST_CHECK(gArgs.GetBoolArg("-fooo", true));
ResetArgs("-foo=0"); ResetArgs("-foo=0");
BOOST_CHECK(!GetBoolArg("-foo", false)); BOOST_CHECK(!gArgs.GetBoolArg("-foo", false));
BOOST_CHECK(!GetBoolArg("-foo", true)); BOOST_CHECK(!gArgs.GetBoolArg("-foo", true));
ResetArgs("-foo=1"); ResetArgs("-foo=1");
BOOST_CHECK(GetBoolArg("-foo", false)); BOOST_CHECK(gArgs.GetBoolArg("-foo", false));
BOOST_CHECK(GetBoolArg("-foo", true)); BOOST_CHECK(gArgs.GetBoolArg("-foo", true));
// New 0.6 feature: auto-map -nosomething to !-something: // New 0.6 feature: auto-map -nosomething to !-something:
ResetArgs("-nofoo"); ResetArgs("-nofoo");
BOOST_CHECK(!GetBoolArg("-foo", false)); BOOST_CHECK(!gArgs.GetBoolArg("-foo", false));
BOOST_CHECK(!GetBoolArg("-foo", true)); BOOST_CHECK(!gArgs.GetBoolArg("-foo", true));
ResetArgs("-nofoo=1"); ResetArgs("-nofoo=1");
BOOST_CHECK(!GetBoolArg("-foo", false)); BOOST_CHECK(!gArgs.GetBoolArg("-foo", false));
BOOST_CHECK(!GetBoolArg("-foo", true)); BOOST_CHECK(!gArgs.GetBoolArg("-foo", true));
ResetArgs("-foo -nofoo"); // -nofoo should win ResetArgs("-foo -nofoo"); // -nofoo should win
BOOST_CHECK(!GetBoolArg("-foo", false)); BOOST_CHECK(!gArgs.GetBoolArg("-foo", false));
BOOST_CHECK(!GetBoolArg("-foo", true)); BOOST_CHECK(!gArgs.GetBoolArg("-foo", true));
ResetArgs("-foo=1 -nofoo=1"); // -nofoo should win ResetArgs("-foo=1 -nofoo=1"); // -nofoo should win
BOOST_CHECK(!GetBoolArg("-foo", false)); BOOST_CHECK(!gArgs.GetBoolArg("-foo", false));
BOOST_CHECK(!GetBoolArg("-foo", true)); BOOST_CHECK(!gArgs.GetBoolArg("-foo", true));
ResetArgs("-foo=0 -nofoo=0"); // -nofoo=0 should win ResetArgs("-foo=0 -nofoo=0"); // -nofoo=0 should win
BOOST_CHECK(GetBoolArg("-foo", false)); BOOST_CHECK(gArgs.GetBoolArg("-foo", false));
BOOST_CHECK(GetBoolArg("-foo", true)); BOOST_CHECK(gArgs.GetBoolArg("-foo", true));
// New 0.6 feature: treat -- same as -: // New 0.6 feature: treat -- same as -:
ResetArgs("--foo=1"); ResetArgs("--foo=1");
BOOST_CHECK(GetBoolArg("-foo", false)); BOOST_CHECK(gArgs.GetBoolArg("-foo", false));
BOOST_CHECK(GetBoolArg("-foo", true)); BOOST_CHECK(gArgs.GetBoolArg("-foo", true));
ResetArgs("--nofoo=1"); ResetArgs("--nofoo=1");
BOOST_CHECK(!GetBoolArg("-foo", false)); BOOST_CHECK(!gArgs.GetBoolArg("-foo", false));
BOOST_CHECK(!GetBoolArg("-foo", true)); BOOST_CHECK(!gArgs.GetBoolArg("-foo", true));
} }
BOOST_AUTO_TEST_CASE(stringarg) BOOST_AUTO_TEST_CASE(stringarg)
{ {
ResetArgs(""); ResetArgs("");
BOOST_CHECK_EQUAL(GetArg("-foo", ""), ""); BOOST_CHECK_EQUAL(gArgs.GetArg("-foo", ""), "");
BOOST_CHECK_EQUAL(GetArg("-foo", "eleven"), "eleven"); BOOST_CHECK_EQUAL(gArgs.GetArg("-foo", "eleven"), "eleven");
ResetArgs("-foo -bar"); ResetArgs("-foo -bar");
BOOST_CHECK_EQUAL(GetArg("-foo", ""), ""); BOOST_CHECK_EQUAL(gArgs.GetArg("-foo", ""), "");
BOOST_CHECK_EQUAL(GetArg("-foo", "eleven"), ""); BOOST_CHECK_EQUAL(gArgs.GetArg("-foo", "eleven"), "");
ResetArgs("-foo="); ResetArgs("-foo=");
BOOST_CHECK_EQUAL(GetArg("-foo", ""), ""); BOOST_CHECK_EQUAL(gArgs.GetArg("-foo", ""), "");
BOOST_CHECK_EQUAL(GetArg("-foo", "eleven"), ""); BOOST_CHECK_EQUAL(gArgs.GetArg("-foo", "eleven"), "");
ResetArgs("-foo=11"); ResetArgs("-foo=11");
BOOST_CHECK_EQUAL(GetArg("-foo", ""), "11"); BOOST_CHECK_EQUAL(gArgs.GetArg("-foo", ""), "11");
BOOST_CHECK_EQUAL(GetArg("-foo", "eleven"), "11"); BOOST_CHECK_EQUAL(gArgs.GetArg("-foo", "eleven"), "11");
ResetArgs("-foo=eleven"); ResetArgs("-foo=eleven");
BOOST_CHECK_EQUAL(GetArg("-foo", ""), "eleven"); BOOST_CHECK_EQUAL(gArgs.GetArg("-foo", ""), "eleven");
BOOST_CHECK_EQUAL(GetArg("-foo", "eleven"), "eleven"); BOOST_CHECK_EQUAL(gArgs.GetArg("-foo", "eleven"), "eleven");
} }
BOOST_AUTO_TEST_CASE(intarg) BOOST_AUTO_TEST_CASE(intarg)
{ {
ResetArgs(""); ResetArgs("");
BOOST_CHECK_EQUAL(GetArg("-foo", 11), 11); BOOST_CHECK_EQUAL(gArgs.GetArg("-foo", 11), 11);
BOOST_CHECK_EQUAL(GetArg("-foo", 0), 0); BOOST_CHECK_EQUAL(gArgs.GetArg("-foo", 0), 0);
ResetArgs("-foo -bar"); ResetArgs("-foo -bar");
BOOST_CHECK_EQUAL(GetArg("-foo", 11), 0); BOOST_CHECK_EQUAL(gArgs.GetArg("-foo", 11), 0);
BOOST_CHECK_EQUAL(GetArg("-bar", 11), 0); BOOST_CHECK_EQUAL(gArgs.GetArg("-bar", 11), 0);
ResetArgs("-foo=11 -bar=12"); ResetArgs("-foo=11 -bar=12");
BOOST_CHECK_EQUAL(GetArg("-foo", 0), 11); BOOST_CHECK_EQUAL(gArgs.GetArg("-foo", 0), 11);
BOOST_CHECK_EQUAL(GetArg("-bar", 11), 12); BOOST_CHECK_EQUAL(gArgs.GetArg("-bar", 11), 12);
ResetArgs("-foo=NaN -bar=NotANumber"); ResetArgs("-foo=NaN -bar=NotANumber");
BOOST_CHECK_EQUAL(GetArg("-foo", 1), 0); BOOST_CHECK_EQUAL(gArgs.GetArg("-foo", 1), 0);
BOOST_CHECK_EQUAL(GetArg("-bar", 11), 0); BOOST_CHECK_EQUAL(gArgs.GetArg("-bar", 11), 0);
} }
BOOST_AUTO_TEST_CASE(doubledash) BOOST_AUTO_TEST_CASE(doubledash)
{ {
ResetArgs("--foo"); ResetArgs("--foo");
BOOST_CHECK_EQUAL(GetBoolArg("-foo", false), true); BOOST_CHECK_EQUAL(gArgs.GetBoolArg("-foo", false), true);
ResetArgs("--foo=verbose --bar=1"); ResetArgs("--foo=verbose --bar=1");
BOOST_CHECK_EQUAL(GetArg("-foo", ""), "verbose"); BOOST_CHECK_EQUAL(gArgs.GetArg("-foo", ""), "verbose");
BOOST_CHECK_EQUAL(GetArg("-bar", 0), 1); BOOST_CHECK_EQUAL(gArgs.GetArg("-bar", 0), 1);
} }
BOOST_AUTO_TEST_CASE(boolargno) BOOST_AUTO_TEST_CASE(boolargno)
{ {
ResetArgs("-nofoo"); ResetArgs("-nofoo");
BOOST_CHECK(!GetBoolArg("-foo", true)); BOOST_CHECK(!gArgs.GetBoolArg("-foo", true));
BOOST_CHECK(!GetBoolArg("-foo", false)); BOOST_CHECK(!gArgs.GetBoolArg("-foo", false));
ResetArgs("-nofoo=1"); ResetArgs("-nofoo=1");
BOOST_CHECK(!GetBoolArg("-foo", true)); BOOST_CHECK(!gArgs.GetBoolArg("-foo", true));
BOOST_CHECK(!GetBoolArg("-foo", false)); BOOST_CHECK(!gArgs.GetBoolArg("-foo", false));
ResetArgs("-nofoo=0"); ResetArgs("-nofoo=0");
BOOST_CHECK(GetBoolArg("-foo", true)); BOOST_CHECK(gArgs.GetBoolArg("-foo", true));
BOOST_CHECK(GetBoolArg("-foo", false)); BOOST_CHECK(gArgs.GetBoolArg("-foo", false));
ResetArgs("-foo --nofoo"); // --nofoo should win ResetArgs("-foo --nofoo"); // --nofoo should win
BOOST_CHECK(!GetBoolArg("-foo", true)); BOOST_CHECK(!gArgs.GetBoolArg("-foo", true));
BOOST_CHECK(!GetBoolArg("-foo", false)); BOOST_CHECK(!gArgs.GetBoolArg("-foo", false));
ResetArgs("-nofoo -foo"); // foo always wins: ResetArgs("-nofoo -foo"); // foo always wins:
BOOST_CHECK(GetBoolArg("-foo", true)); BOOST_CHECK(gArgs.GetBoolArg("-foo", true));
BOOST_CHECK(GetBoolArg("-foo", false)); BOOST_CHECK(gArgs.GetBoolArg("-foo", false));
} }
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()

View File

@ -93,7 +93,7 @@ bool TestSequenceLocks(const CTransaction &tx, int flags)
void TestPackageSelection(const CChainParams& chainparams, CScript scriptPubKey, std::vector<CTransactionRef>& txFirst) void TestPackageSelection(const CChainParams& chainparams, CScript scriptPubKey, std::vector<CTransactionRef>& txFirst)
{ {
// Disable free transactions, otherwise TX selection is non-deterministic // Disable free transactions, otherwise TX selection is non-deterministic
SoftSetArg("-blockprioritysize", "0"); gArgs.SoftSetArg("-blockprioritysize", "0");
// Test the ancestor feerate transaction selection. // Test the ancestor feerate transaction selection.
TestMemPoolEntryHelper entry; TestMemPoolEntryHelper entry;

View File

@ -80,7 +80,7 @@ BOOST_AUTO_TEST_CASE(cnode_listen_port)
BOOST_CHECK(port == Params().GetDefaultPort()); BOOST_CHECK(port == Params().GetDefaultPort());
// test set port // test set port
unsigned short altPort = 12345; unsigned short altPort = 12345;
SoftSetArg("-port", std::to_string(altPort)); gArgs.SoftSetArg("-port", std::to_string(altPort));
port = GetListenPort(); port = GetListenPort();
BOOST_CHECK(port == altPort); BOOST_CHECK(port == altPort);
} }

View File

@ -122,7 +122,7 @@ BOOST_AUTO_TEST_CASE(get_next_work)
BOOST_CHECK_EQUAL(GetNextWorkRequired(&blockIndexLast, &blockHeader, params), 0x1b1441de); // Block #123457 has 0x1b1441de BOOST_CHECK_EQUAL(GetNextWorkRequired(&blockIndexLast, &blockHeader, params), 0x1b1441de); // Block #123457 has 0x1b1441de
// test special rules for slow blocks on devnet/testnet // test special rules for slow blocks on devnet/testnet
SoftSetBoolArg("-devnet", true); gArgs.SoftSetBoolArg("-devnet", true);
SelectParams(CBaseChainParams::DEVNET); SelectParams(CBaseChainParams::DEVNET);
const Consensus::Params& paramsdev = Params().GetConsensus(); const Consensus::Params& paramsdev = Params().GetConsensus();

View File

@ -71,7 +71,7 @@ TestingSetup::TestingSetup(const std::string& chainName) : BasicTestingSetup(cha
ClearDatadirCache(); ClearDatadirCache();
pathTemp = GetTempPath() / strprintf("test_dash_%lu_%i", (unsigned long)GetTime(), (int)(GetRand(100000))); pathTemp = GetTempPath() / strprintf("test_dash_%lu_%i", (unsigned long)GetTime(), (int)(GetRand(100000)));
fs::create_directories(pathTemp); fs::create_directories(pathTemp);
ForceSetArg("-datadir", pathTemp.string()); gArgs.ForceSetArg("-datadir", pathTemp.string());
mempool.setSanityCheck(1.0); mempool.setSanityCheck(1.0);
g_connman = std::unique_ptr<CConnman>(new CConnman(0x1337, 0x1337)); // Deterministic randomness for tests. g_connman = std::unique_ptr<CConnman>(new CConnman(0x1337, 0x1337)); // Deterministic randomness for tests.
connman = g_connman.get(); connman = g_connman.get();

View File

@ -82,7 +82,7 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample)
int64_t nMedian = vTimeOffsets.median(); int64_t nMedian = vTimeOffsets.median();
std::vector<int64_t> vSorted = vTimeOffsets.sorted(); std::vector<int64_t> vSorted = vTimeOffsets.sorted();
// Only let other nodes change our time by so much // Only let other nodes change our time by so much
if (abs64(nMedian) <= std::max<int64_t>(0, GetArg("-maxtimeadjustment", DEFAULT_MAX_TIME_ADJUSTMENT))) if (abs64(nMedian) <= std::max<int64_t>(0, gArgs.GetArg("-maxtimeadjustment", DEFAULT_MAX_TIME_ADJUSTMENT)))
{ {
nTimeOffset = nMedian; nTimeOffset = nMedian;
} }

View File

@ -525,7 +525,7 @@ void TorController::auth_cb(TorControlConnection& _conn, const TorControlReply&
// Now that we know Tor is running setup the proxy for onion addresses // Now that we know Tor is running setup the proxy for onion addresses
// if -onion isn't set to something else. // if -onion isn't set to something else.
if (GetArg("-onion", "") == "") { if (gArgs.GetArg("-onion", "") == "") {
CService resolved(LookupNumeric("127.0.0.1", 9050)); CService resolved(LookupNumeric("127.0.0.1", 9050));
proxyType addrOnion = proxyType(resolved, true); proxyType addrOnion = proxyType(resolved, true);
SetProxy(NET_TOR, addrOnion); SetProxy(NET_TOR, addrOnion);
@ -642,7 +642,7 @@ void TorController::protocolinfo_cb(TorControlConnection& _conn, const TorContro
* cookie: hex-encoded ~/.tor/control_auth_cookie * cookie: hex-encoded ~/.tor/control_auth_cookie
* password: "password" * password: "password"
*/ */
std::string torpassword = GetArg("-torpassword", ""); std::string torpassword = gArgs.GetArg("-torpassword", "");
if (!torpassword.empty()) { if (!torpassword.empty()) {
if (methods.count("HASHEDPASSWORD")) { if (methods.count("HASHEDPASSWORD")) {
LogPrint(BCLog::TOR, "tor: Using HASHEDPASSWORD authentication\n"); LogPrint(BCLog::TOR, "tor: Using HASHEDPASSWORD authentication\n");
@ -735,7 +735,7 @@ static boost::thread torControlThread;
static void TorControlThread() static void TorControlThread()
{ {
TorController ctrl(gBase, GetArg("-torcontrol", DEFAULT_TOR_CONTROL)); TorController ctrl(gBase, gArgs.GetArg("-torcontrol", DEFAULT_TOR_CONTROL));
event_base_dispatch(gBase); event_base_dispatch(gBase);
} }

View File

@ -1400,7 +1400,7 @@ double CTxMemPool::UsedMemoryShare() const
// this param is calculated in such way in other places (see AppInit // this param is calculated in such way in other places (see AppInit
// function in src/init.cpp or mempoolInfoToJSON function in // function in src/init.cpp or mempoolInfoToJSON function in
// src/rpc/blockchain.cpp) // src/rpc/blockchain.cpp)
size_t maxmempool = GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000; size_t maxmempool = gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000;
return double(DynamicMemoryUsage()) / maxmempool; return double(DynamicMemoryUsage()) / maxmempool;
} }

View File

@ -653,7 +653,7 @@ void UpdateMempoolForReorg(DisconnectedBlockTransactions &disconnectpool, bool f
// We also need to remove any now-immature transactions // We also need to remove any now-immature transactions
mempool.removeForReorg(pcoinsTip, chainActive.Tip()->nHeight + 1, STANDARD_LOCKTIME_VERIFY_FLAGS); mempool.removeForReorg(pcoinsTip, chainActive.Tip()->nHeight + 1, STANDARD_LOCKTIME_VERIFY_FLAGS);
// Re-limit mempool size, in case we added any transactions // Re-limit mempool size, in case we added any transactions
LimitMempoolSize(mempool, GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000, GetArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY) * 60 * 60); LimitMempoolSize(mempool, gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000, gArgs.GetArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY) * 60 * 60);
} }
static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool& pool, CValidationState& state, const CTransactionRef& ptx, bool fLimitFree, static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool& pool, CValidationState& state, const CTransactionRef& ptx, bool fLimitFree,
@ -841,7 +841,7 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
return state.DoS(0, false, REJECT_NONSTANDARD, "bad-txns-too-many-sigops", false, return state.DoS(0, false, REJECT_NONSTANDARD, "bad-txns-too-many-sigops", false,
strprintf("%d", nSigOps)); strprintf("%d", nSigOps));
CAmount mempoolRejectFee = pool.GetMinFee(GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000).GetFee(nSize); CAmount mempoolRejectFee = pool.GetMinFee(gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000).GetFee(nSize);
if (mempoolRejectFee > 0 && nModifiedFees < mempoolRejectFee) { if (mempoolRejectFee > 0 && nModifiedFees < mempoolRejectFee) {
return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "mempool min fee not met", false, strprintf("%d < %d", nFees, mempoolRejectFee)); return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "mempool min fee not met", false, strprintf("%d < %d", nFees, mempoolRejectFee));
} }
@ -858,10 +858,10 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
// Calculate in-mempool ancestors, up to a limit. // Calculate in-mempool ancestors, up to a limit.
CTxMemPool::setEntries setAncestors; CTxMemPool::setEntries setAncestors;
size_t nLimitAncestors = GetArg("-limitancestorcount", DEFAULT_ANCESTOR_LIMIT); size_t nLimitAncestors = gArgs.GetArg("-limitancestorcount", DEFAULT_ANCESTOR_LIMIT);
size_t nLimitAncestorSize = GetArg("-limitancestorsize", DEFAULT_ANCESTOR_SIZE_LIMIT)*1000; size_t nLimitAncestorSize = gArgs.GetArg("-limitancestorsize", DEFAULT_ANCESTOR_SIZE_LIMIT)*1000;
size_t nLimitDescendants = GetArg("-limitdescendantcount", DEFAULT_DESCENDANT_LIMIT); size_t nLimitDescendants = gArgs.GetArg("-limitdescendantcount", DEFAULT_DESCENDANT_LIMIT);
size_t nLimitDescendantSize = GetArg("-limitdescendantsize", DEFAULT_DESCENDANT_SIZE_LIMIT)*1000; size_t nLimitDescendantSize = gArgs.GetArg("-limitdescendantsize", DEFAULT_DESCENDANT_SIZE_LIMIT)*1000;
std::string errString; std::string errString;
if (!pool.CalculateMemPoolAncestors(entry, setAncestors, nLimitAncestors, nLimitAncestorSize, nLimitDescendants, nLimitDescendantSize, errString)) { if (!pool.CalculateMemPoolAncestors(entry, setAncestors, nLimitAncestors, nLimitAncestorSize, nLimitDescendants, nLimitDescendantSize, errString)) {
return state.DoS(0, false, REJECT_NONSTANDARD, "too-long-mempool-chain", false, errString); return state.DoS(0, false, REJECT_NONSTANDARD, "too-long-mempool-chain", false, errString);
@ -921,7 +921,7 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
// trim mempool and check if tx was trimmed // trim mempool and check if tx was trimmed
if (!fOverrideMempoolLimit) { if (!fOverrideMempoolLimit) {
LimitMempoolSize(pool, GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000, GetArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY) * 60 * 60); LimitMempoolSize(pool, gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000, gArgs.GetArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY) * 60 * 60);
if (!pool.exists(hash)) if (!pool.exists(hash))
return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "mempool full"); return state.DoS(0, false, REJECT_INSUFFICIENTFEE, "mempool full");
} }
@ -1258,7 +1258,7 @@ CBlockIndex *pindexBestForkTip = NULL, *pindexBestForkBase = NULL;
static void AlertNotify(const std::string& strMessage) static void AlertNotify(const std::string& strMessage)
{ {
uiInterface.NotifyAlertChanged(); uiInterface.NotifyAlertChanged();
std::string strCmd = GetArg("-alertnotify", ""); std::string strCmd = gArgs.GetArg("-alertnotify", "");
if (strCmd.empty()) return; if (strCmd.empty()) return;
// Alert text should be plain ascii coming from a trusted source, but to // Alert text should be plain ascii coming from a trusted source, but to
@ -2421,7 +2421,7 @@ bool static FlushStateToDisk(const CChainParams& chainparams, CValidationState &
if (nLastSetChain == 0) { if (nLastSetChain == 0) {
nLastSetChain = nNow; nLastSetChain = nNow;
} }
int64_t nMempoolSizeMax = GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000; int64_t nMempoolSizeMax = gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000;
int64_t cacheSize = pcoinsTip->DynamicMemoryUsage() * DB_PEAK_USAGE_FACTOR; int64_t cacheSize = pcoinsTip->DynamicMemoryUsage() * DB_PEAK_USAGE_FACTOR;
int64_t nTotalSpace = nCoinCacheUsage + std::max<int64_t>(nMempoolSizeMax - nMempoolUsage, 0); int64_t nTotalSpace = nCoinCacheUsage + std::max<int64_t>(nMempoolSizeMax - nMempoolUsage, 0);
// The cache is large and we're within 10% and 10 MiB of the limit, but we have time now (not in the middle of a block processing). // The cache is large and we're within 10% and 10 MiB of the limit, but we have time now (not in the middle of a block processing).
@ -3012,7 +3012,7 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams,
return false; return false;
} }
int nStopAtHeight = GetArg("-stopatheight", DEFAULT_STOPATHEIGHT); int nStopAtHeight = gArgs.GetArg("-stopatheight", DEFAULT_STOPATHEIGHT);
if (nStopAtHeight && pindexNewTip && pindexNewTip->nHeight >= nStopAtHeight) StartShutdown(); if (nStopAtHeight && pindexNewTip && pindexNewTip->nHeight >= nStopAtHeight) StartShutdown();
return true; return true;
@ -4257,18 +4257,18 @@ bool InitBlockIndex(const CChainParams& chainparams)
return true; return true;
// Use the provided setting for -txindex in the new database // Use the provided setting for -txindex in the new database
fTxIndex = GetBoolArg("-txindex", DEFAULT_TXINDEX); fTxIndex = gArgs.GetBoolArg("-txindex", DEFAULT_TXINDEX);
pblocktree->WriteFlag("txindex", fTxIndex); pblocktree->WriteFlag("txindex", fTxIndex);
// Use the provided setting for -addressindex in the new database // Use the provided setting for -addressindex in the new database
fAddressIndex = GetBoolArg("-addressindex", DEFAULT_ADDRESSINDEX); fAddressIndex = gArgs.GetBoolArg("-addressindex", DEFAULT_ADDRESSINDEX);
pblocktree->WriteFlag("addressindex", fAddressIndex); pblocktree->WriteFlag("addressindex", fAddressIndex);
// Use the provided setting for -timestampindex in the new database // Use the provided setting for -timestampindex in the new database
fTimestampIndex = GetBoolArg("-timestampindex", DEFAULT_TIMESTAMPINDEX); fTimestampIndex = gArgs.GetBoolArg("-timestampindex", DEFAULT_TIMESTAMPINDEX);
pblocktree->WriteFlag("timestampindex", fTimestampIndex); pblocktree->WriteFlag("timestampindex", fTimestampIndex);
fSpentIndex = GetBoolArg("-spentindex", DEFAULT_SPENTINDEX); fSpentIndex = gArgs.GetBoolArg("-spentindex", DEFAULT_SPENTINDEX);
pblocktree->WriteFlag("spentindex", fSpentIndex); pblocktree->WriteFlag("spentindex", fSpentIndex);
LogPrintf("Initializing databases...\n"); LogPrintf("Initializing databases...\n");
@ -4633,13 +4633,13 @@ static const uint64_t MEMPOOL_DUMP_VERSION = 1;
bool LoadMempool(void) bool LoadMempool(void)
{ {
if (GetBoolArg("-zapwallettxes", false)) { if (gArgs.GetBoolArg("-zapwallettxes", false)) {
LogPrintf("Skipping mempool.dat because of zapwallettxes\n"); LogPrintf("Skipping mempool.dat because of zapwallettxes\n");
return true; return true;
} }
const CChainParams& chainparams = Params(); const CChainParams& chainparams = Params();
int64_t nExpiryTimeout = GetArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY) * 60 * 60; int64_t nExpiryTimeout = gArgs.GetArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY) * 60 * 60;
FILE* filestr = fsbridge::fopen(GetDataDir() / "mempool.dat", "rb"); FILE* filestr = fsbridge::fopen(GetDataDir() / "mempool.dat", "rb");
CAutoFile file(filestr, SER_DISK, CLIENT_VERSION); CAutoFile file(filestr, SER_DISK, CLIENT_VERSION);
if (file.IsNull()) { if (file.IsNull()) {

View File

@ -80,7 +80,7 @@ bool CDBEnv::Open(const fs::path& pathIn)
LogPrintf("CDBEnv::Open: LogDir=%s ErrorFile=%s\n", pathLogDir.string(), pathErrorFile.string()); LogPrintf("CDBEnv::Open: LogDir=%s ErrorFile=%s\n", pathLogDir.string(), pathErrorFile.string());
unsigned int nEnvFlags = 0; unsigned int nEnvFlags = 0;
if (GetBoolArg("-privdb", DEFAULT_WALLET_PRIVDB)) if (gArgs.GetBoolArg("-privdb", DEFAULT_WALLET_PRIVDB))
nEnvFlags |= DB_PRIVATE; nEnvFlags |= DB_PRIVATE;
dbenv->set_lg_dir(pathLogDir.string().c_str()); dbenv->set_lg_dir(pathLogDir.string().c_str());
@ -430,7 +430,7 @@ void CDB::Flush()
if (fReadOnly) if (fReadOnly)
nMinutes = 1; nMinutes = 1;
env->dbenv->txn_checkpoint(nMinutes ? GetArg("-dblogsize", DEFAULT_WALLET_DBLOGSIZE) * 1024 : 0, nMinutes, 0); env->dbenv->txn_checkpoint(nMinutes ? gArgs.GetArg("-dblogsize", DEFAULT_WALLET_DBLOGSIZE) * 1024 : 0, nMinutes, 0);
} }
void CDB::Close() void CDB::Close()

View File

@ -3050,7 +3050,7 @@ static const CRPCCommand commands[] =
void RegisterWalletRPCCommands(CRPCTable &t) void RegisterWalletRPCCommands(CRPCTable &t)
{ {
if (GetBoolArg("-disablewallet", false)) if (gArgs.GetBoolArg("-disablewallet", false))
return; return;
for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++)

View File

@ -421,7 +421,7 @@ bool CWallet::Unlock(const SecureString& strWalletPassphrase, bool fForMixingOnl
return true; return true;
// Verify KeePassIntegration // Verify KeePassIntegration
if (strWalletPassphrase == "keepass" && GetBoolArg("-keepass", false)) { if (strWalletPassphrase == "keepass" && gArgs.GetBoolArg("-keepass", false)) {
try { try {
strWalletPassphraseFinal = keePassInt.retrievePassphrase(); strWalletPassphraseFinal = keePassInt.retrievePassphrase();
} catch (std::exception& e) { } catch (std::exception& e) {
@ -447,7 +447,7 @@ bool CWallet::Unlock(const SecureString& strWalletPassphrase, bool fForMixingOnl
if(nWalletBackups == -2) { if(nWalletBackups == -2) {
TopUpKeyPool(); TopUpKeyPool();
LogPrintf("Keypool replenished, re-initializing automatic backups.\n"); LogPrintf("Keypool replenished, re-initializing automatic backups.\n");
nWalletBackups = GetArg("-createwalletbackups", 10); nWalletBackups = gArgs.GetArg("-createwalletbackups", 10);
} }
return true; return true;
} }
@ -464,7 +464,7 @@ bool CWallet::ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase,
SecureString strOldWalletPassphraseFinal; SecureString strOldWalletPassphraseFinal;
// Verify KeePassIntegration // Verify KeePassIntegration
if(strOldWalletPassphrase == "keepass" && GetBoolArg("-keepass", false)) { if(strOldWalletPassphrase == "keepass" && gArgs.GetBoolArg("-keepass", false)) {
bUseKeePass = true; bUseKeePass = true;
try { try {
strOldWalletPassphraseFinal = keePassInt.retrievePassphrase(); strOldWalletPassphraseFinal = keePassInt.retrievePassphrase();
@ -604,17 +604,17 @@ void CWallet::Flush(bool shutdown)
bool CWallet::Verify() bool CWallet::Verify()
{ {
if (GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET))
return true; return true;
uiInterface.InitMessage(_("Verifying wallet...")); uiInterface.InitMessage(_("Verifying wallet..."));
std::string walletFile = GetArg("-wallet", DEFAULT_WALLET_DAT); std::string walletFile = gArgs.GetArg("-wallet", DEFAULT_WALLET_DAT);
std::string strError; std::string strError;
if (!CWalletDB::VerifyEnvironment(walletFile, GetDataDir().string(), strError)) if (!CWalletDB::VerifyEnvironment(walletFile, GetDataDir().string(), strError))
return InitError(strError); return InitError(strError);
if (GetBoolArg("-salvagewallet", false)) if (gArgs.GetBoolArg("-salvagewallet", false))
{ {
// Recover readable keypairs: // Recover readable keypairs:
CWallet dummyWallet; CWallet dummyWallet;
@ -824,7 +824,7 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
dbw->Rewrite(); dbw->Rewrite();
// Update KeePass if necessary // Update KeePass if necessary
if(GetBoolArg("-keepass", false)) { if(gArgs.GetBoolArg("-keepass", false)) {
LogPrintf("CWallet::EncryptWallet -- Updating KeePass with new passphrase"); LogPrintf("CWallet::EncryptWallet -- Updating KeePass with new passphrase");
try { try {
keePassInt.updatePassphrase(strWalletPassphrase); keePassInt.updatePassphrase(strWalletPassphrase);
@ -1086,7 +1086,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFlushOnClose)
NotifyTransactionChanged(this, hash, fInsertedNew ? CT_NEW : CT_UPDATED); NotifyTransactionChanged(this, hash, fInsertedNew ? CT_NEW : CT_UPDATED);
// notify an external script when a wallet transaction comes in or is updated // notify an external script when a wallet transaction comes in or is updated
std::string strCmd = GetArg("-walletnotify", ""); std::string strCmd = gArgs.GetArg("-walletnotify", "");
if ( !strCmd.empty()) if ( !strCmd.empty())
{ {
@ -1555,21 +1555,21 @@ void CWallet::GenerateNewHDChain()
{ {
CHDChain newHdChain; CHDChain newHdChain;
std::string strSeed = GetArg("-hdseed", "not hex"); std::string strSeed = gArgs.GetArg("-hdseed", "not hex");
if(IsArgSet("-hdseed") && IsHex(strSeed)) { if(gArgs.IsArgSet("-hdseed") && IsHex(strSeed)) {
std::vector<unsigned char> vchSeed = ParseHex(strSeed); std::vector<unsigned char> vchSeed = ParseHex(strSeed);
if (!newHdChain.SetSeed(SecureVector(vchSeed.begin(), vchSeed.end()), true)) if (!newHdChain.SetSeed(SecureVector(vchSeed.begin(), vchSeed.end()), true))
throw std::runtime_error(std::string(__func__) + ": SetSeed failed"); throw std::runtime_error(std::string(__func__) + ": SetSeed failed");
} }
else { else {
if (IsArgSet("-hdseed") && !IsHex(strSeed)) if (gArgs.IsArgSet("-hdseed") && !IsHex(strSeed))
LogPrintf("CWallet::GenerateNewHDChain -- Incorrect seed, generating random one instead\n"); LogPrintf("CWallet::GenerateNewHDChain -- Incorrect seed, generating random one instead\n");
// NOTE: empty mnemonic means "generate a new one for me" // NOTE: empty mnemonic means "generate a new one for me"
std::string strMnemonic = GetArg("-mnemonic", ""); std::string strMnemonic = gArgs.GetArg("-mnemonic", "");
// NOTE: default mnemonic passphrase is an empty string // NOTE: default mnemonic passphrase is an empty string
std::string strMnemonicPassphrase = GetArg("-mnemonicpassphrase", ""); std::string strMnemonicPassphrase = gArgs.GetArg("-mnemonicpassphrase", "");
SecureVector vchMnemonic(strMnemonic.begin(), strMnemonic.end()); SecureVector vchMnemonic(strMnemonic.begin(), strMnemonic.end());
SecureVector vchMnemonicPassphrase(strMnemonicPassphrase.begin(), strMnemonicPassphrase.end()); SecureVector vchMnemonicPassphrase(strMnemonicPassphrase.begin(), strMnemonicPassphrase.end());
@ -2917,8 +2917,8 @@ bool CWallet::SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAm
++it; ++it;
} }
size_t nMaxChainLength = std::min(GetArg("-limitancestorcount", DEFAULT_ANCESTOR_LIMIT), GetArg("-limitdescendantcount", DEFAULT_DESCENDANT_LIMIT)); size_t nMaxChainLength = std::min(gArgs.GetArg("-limitancestorcount", DEFAULT_ANCESTOR_LIMIT), gArgs.GetArg("-limitdescendantcount", DEFAULT_DESCENDANT_LIMIT));
bool fRejectLongChains = GetBoolArg("-walletrejectlongchains", DEFAULT_WALLET_REJECT_LONG_CHAINS); bool fRejectLongChains = gArgs.GetBoolArg("-walletrejectlongchains", DEFAULT_WALLET_REJECT_LONG_CHAINS);
bool res = nTargetValue <= nValueFromPresetInputs || bool res = nTargetValue <= nValueFromPresetInputs ||
SelectCoinsMinConf(nTargetValue - nValueFromPresetInputs, 1, 6, 0, vCoins, setCoinsRet, nValueRet, nCoinType, fUseInstantSend) || SelectCoinsMinConf(nTargetValue - nValueFromPresetInputs, 1, 6, 0, vCoins, setCoinsRet, nValueRet, nCoinType, fUseInstantSend) ||
@ -3768,15 +3768,15 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
wtxNew.SetTx(MakeTransactionRef(std::move(txNew))); wtxNew.SetTx(MakeTransactionRef(std::move(txNew)));
} }
if (GetBoolArg("-walletrejectlongchains", DEFAULT_WALLET_REJECT_LONG_CHAINS)) { if (gArgs.GetBoolArg("-walletrejectlongchains", DEFAULT_WALLET_REJECT_LONG_CHAINS)) {
// Lastly, ensure this tx will pass the mempool's chain limits // Lastly, ensure this tx will pass the mempool's chain limits
LockPoints lp; LockPoints lp;
CTxMemPoolEntry entry(wtxNew.tx, 0, 0, 0, false, 0, lp); CTxMemPoolEntry entry(wtxNew.tx, 0, 0, 0, false, 0, lp);
CTxMemPool::setEntries setAncestors; CTxMemPool::setEntries setAncestors;
size_t nLimitAncestors = GetArg("-limitancestorcount", DEFAULT_ANCESTOR_LIMIT); size_t nLimitAncestors = gArgs.GetArg("-limitancestorcount", DEFAULT_ANCESTOR_LIMIT);
size_t nLimitAncestorSize = GetArg("-limitancestorsize", DEFAULT_ANCESTOR_SIZE_LIMIT)*1000; size_t nLimitAncestorSize = gArgs.GetArg("-limitancestorsize", DEFAULT_ANCESTOR_SIZE_LIMIT)*1000;
size_t nLimitDescendants = GetArg("-limitdescendantcount", DEFAULT_DESCENDANT_LIMIT); size_t nLimitDescendants = gArgs.GetArg("-limitdescendantcount", DEFAULT_DESCENDANT_LIMIT);
size_t nLimitDescendantSize = GetArg("-limitdescendantsize", DEFAULT_DESCENDANT_SIZE_LIMIT)*1000; size_t nLimitDescendantSize = gArgs.GetArg("-limitdescendantsize", DEFAULT_DESCENDANT_SIZE_LIMIT)*1000;
std::string errString; std::string errString;
if (!mempool.CalculateMemPoolAncestors(entry, setAncestors, nLimitAncestors, nLimitAncestorSize, nLimitDescendants, nLimitDescendantSize, errString)) { if (!mempool.CalculateMemPoolAncestors(entry, setAncestors, nLimitAncestors, nLimitAncestorSize, nLimitDescendants, nLimitDescendantSize, errString)) {
strFailReason = _("Transaction has too long of a mempool chain"); strFailReason = _("Transaction has too long of a mempool chain");
@ -4106,7 +4106,7 @@ bool CWallet::TopUpKeyPool(unsigned int kpSize)
if (kpSize > 0) if (kpSize > 0)
nTargetSize = kpSize; nTargetSize = kpSize;
else else
nTargetSize = std::max(GetArg("-keypool", DEFAULT_KEYPOOL_SIZE), (int64_t) 0); nTargetSize = std::max(gArgs.GetArg("-keypool", DEFAULT_KEYPOOL_SIZE), (int64_t) 0);
// count amount of available keys (internal, external) // count amount of available keys (internal, external)
// make sure the keypool of external and internal keys fits the user selected target (-keypool) // make sure the keypool of external and internal keys fits the user selected target (-keypool)
@ -4795,7 +4795,7 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile)
// needed to restore wallet transaction meta data after -zapwallettxes // needed to restore wallet transaction meta data after -zapwallettxes
std::vector<CWalletTx> vWtx; std::vector<CWalletTx> vWtx;
if (GetBoolArg("-zapwallettxes", false)) { if (gArgs.GetBoolArg("-zapwallettxes", false)) {
uiInterface.InitMessage(_("Zapping all transactions from wallet...")); uiInterface.InitMessage(_("Zapping all transactions from wallet..."));
std::unique_ptr<CWalletDBWrapper> dbw(new CWalletDBWrapper(&bitdb, walletFile)); std::unique_ptr<CWalletDBWrapper> dbw(new CWalletDBWrapper(&bitdb, walletFile));
@ -4844,9 +4844,9 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile)
} }
} }
if (GetBoolArg("-upgradewallet", fFirstRun)) if (gArgs.GetBoolArg("-upgradewallet", fFirstRun))
{ {
int nMaxVersion = GetArg("-upgradewallet", 0); int nMaxVersion = gArgs.GetArg("-upgradewallet", 0);
if (nMaxVersion == 0) // the -upgradewallet without argument case if (nMaxVersion == 0) // the -upgradewallet without argument case
{ {
LogPrintf("Performing wallet upgrade to %i\n", FEATURE_LATEST); LogPrintf("Performing wallet upgrade to %i\n", FEATURE_LATEST);
@ -4866,8 +4866,8 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile)
if (fFirstRun) if (fFirstRun)
{ {
// Create new keyUser and set as default key // Create new keyUser and set as default key
if (GetBoolArg("-usehd", DEFAULT_USE_HD_WALLET) && !walletInstance->IsHDEnabled()) { if (gArgs.GetBoolArg("-usehd", DEFAULT_USE_HD_WALLET) && !walletInstance->IsHDEnabled()) {
if (GetArg("-mnemonicpassphrase", "").size() > 256) { if (gArgs.GetArg("-mnemonicpassphrase", "").size() > 256) {
InitError(_("Mnemonic passphrase is too long, must be at most 256 characters")); InitError(_("Mnemonic passphrase is too long, must be at most 256 characters"));
return NULL; return NULL;
} }
@ -4903,8 +4903,8 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile)
} }
} }
else if (IsArgSet("-usehd")) { else if (gArgs.IsArgSet("-usehd")) {
bool useHD = GetBoolArg("-usehd", DEFAULT_USE_HD_WALLET); bool useHD = gArgs.GetBoolArg("-usehd", DEFAULT_USE_HD_WALLET);
if (walletInstance->IsHDEnabled() && !useHD) { if (walletInstance->IsHDEnabled() && !useHD) {
InitError(strprintf(_("Error loading %s: You can't disable HD on a already existing HD wallet"), InitError(strprintf(_("Error loading %s: You can't disable HD on a already existing HD wallet"),
walletInstance->GetName())); walletInstance->GetName()));
@ -4918,7 +4918,7 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile)
} }
// Warn user every time he starts non-encrypted HD wallet // Warn user every time he starts non-encrypted HD wallet
if (GetBoolArg("-usehd", DEFAULT_USE_HD_WALLET) && !walletInstance->IsLocked()) { if (gArgs.GetBoolArg("-usehd", DEFAULT_USE_HD_WALLET) && !walletInstance->IsLocked()) {
InitWarning(_("Make sure to encrypt your wallet and delete all non-encrypted backups after you verified that wallet works!")); InitWarning(_("Make sure to encrypt your wallet and delete all non-encrypted backups after you verified that wallet works!"));
} }
@ -4927,7 +4927,7 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile)
RegisterValidationInterface(walletInstance); RegisterValidationInterface(walletInstance);
CBlockIndex *pindexRescan = chainActive.Genesis(); CBlockIndex *pindexRescan = chainActive.Genesis();
if (!GetBoolArg("-rescan", false)) if (!gArgs.GetBoolArg("-rescan", false))
{ {
CWalletDB walletdb(*walletInstance->dbw); CWalletDB walletdb(*walletInstance->dbw);
CBlockLocator locator; CBlockLocator locator;
@ -4960,7 +4960,7 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile)
CWalletDB::IncrementUpdateCounter(); CWalletDB::IncrementUpdateCounter();
// Restore wallet transaction metadata after -zapwallettxes=1 // Restore wallet transaction metadata after -zapwallettxes=1
if (GetBoolArg("-zapwallettxes", false) && GetArg("-zapwallettxes", "1") != "2") if (gArgs.GetBoolArg("-zapwallettxes", false) && gArgs.GetArg("-zapwallettxes", "1") != "2")
{ {
CWalletDB walletdb(*walletInstance->dbw); CWalletDB walletdb(*walletInstance->dbw);
@ -4984,7 +4984,7 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile)
} }
} }
} }
walletInstance->SetBroadcastTransactions(GetBoolArg("-walletbroadcast", DEFAULT_WALLETBROADCAST)); walletInstance->SetBroadcastTransactions(gArgs.GetBoolArg("-walletbroadcast", DEFAULT_WALLETBROADCAST));
{ {
LOCK(walletInstance->cs_wallet); LOCK(walletInstance->cs_wallet);
@ -4999,13 +4999,13 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile)
bool CWallet::InitLoadWallet() bool CWallet::InitLoadWallet()
{ {
if (GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) { if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) {
pwalletMain = NULL; pwalletMain = NULL;
LogPrintf("Wallet disabled!\n"); LogPrintf("Wallet disabled!\n");
return true; return true;
} }
std::string walletFile = GetArg("-wallet", DEFAULT_WALLET_DAT); std::string walletFile = gArgs.GetArg("-wallet", DEFAULT_WALLET_DAT);
if (boost::filesystem::path(walletFile).filename() != walletFile) { if (boost::filesystem::path(walletFile).filename() != walletFile) {
return InitError(_("-wallet parameter must only specify a filename (not a path)")); return InitError(_("-wallet parameter must only specify a filename (not a path)"));
@ -5038,57 +5038,57 @@ void CWallet::postInitProcess(CScheduler& scheduler)
bool CWallet::ParameterInteraction() bool CWallet::ParameterInteraction()
{ {
if (GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET))
return true; return true;
if (GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY) && SoftSetBoolArg("-walletbroadcast", false)) { if (gArgs.GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY) && gArgs.SoftSetBoolArg("-walletbroadcast", false)) {
LogPrintf("%s: parameter interaction: -blocksonly=1 -> setting -walletbroadcast=0\n", __func__); LogPrintf("%s: parameter interaction: -blocksonly=1 -> setting -walletbroadcast=0\n", __func__);
} }
if (GetBoolArg("-salvagewallet", false) && SoftSetBoolArg("-rescan", true)) { if (gArgs.GetBoolArg("-salvagewallet", false) && gArgs.SoftSetBoolArg("-rescan", true)) {
// Rewrite just private keys: rescan to find transactions // Rewrite just private keys: rescan to find transactions
LogPrintf("%s: parameter interaction: -salvagewallet=1 -> setting -rescan=1\n", __func__); LogPrintf("%s: parameter interaction: -salvagewallet=1 -> setting -rescan=1\n", __func__);
} }
// -zapwallettx implies a rescan // -zapwallettx implies a rescan
if (GetBoolArg("-zapwallettxes", false) && SoftSetBoolArg("-rescan", true)) { if (gArgs.GetBoolArg("-zapwallettxes", false) && gArgs.SoftSetBoolArg("-rescan", true)) {
LogPrintf("%s: parameter interaction: -zapwallettxes=<mode> -> setting -rescan=1\n", __func__); LogPrintf("%s: parameter interaction: -zapwallettxes=<mode> -> setting -rescan=1\n", __func__);
} }
if (GetBoolArg("-sysperms", false)) if (gArgs.GetBoolArg("-sysperms", false))
return InitError("-sysperms is not allowed in combination with enabled wallet functionality"); return InitError("-sysperms is not allowed in combination with enabled wallet functionality");
if (GetArg("-prune", 0) && GetBoolArg("-rescan", false)) if (gArgs.GetArg("-prune", 0) && gArgs.GetBoolArg("-rescan", false))
return InitError(_("Rescans are not possible in pruned mode. You will need to use -reindex which will download the whole blockchain again.")); return InitError(_("Rescans are not possible in pruned mode. You will need to use -reindex which will download the whole blockchain again."));
if (::minRelayTxFee.GetFeePerK() > HIGH_TX_FEE_PER_KB) if (::minRelayTxFee.GetFeePerK() > HIGH_TX_FEE_PER_KB)
InitWarning(AmountHighWarn("-minrelaytxfee") + " " + InitWarning(AmountHighWarn("-minrelaytxfee") + " " +
_("The wallet will avoid paying less than the minimum relay fee.")); _("The wallet will avoid paying less than the minimum relay fee."));
if (IsArgSet("-mintxfee")) if (gArgs.IsArgSet("-mintxfee"))
{ {
CAmount n = 0; CAmount n = 0;
if (!ParseMoney(GetArg("-mintxfee", ""), n) || 0 == n) if (!ParseMoney(gArgs.GetArg("-mintxfee", ""), n) || 0 == n)
return InitError(AmountErrMsg("mintxfee", GetArg("-mintxfee", ""))); return InitError(AmountErrMsg("mintxfee", gArgs.GetArg("-mintxfee", "")));
if (n > HIGH_TX_FEE_PER_KB) if (n > HIGH_TX_FEE_PER_KB)
InitWarning(AmountHighWarn("-mintxfee") + " " + InitWarning(AmountHighWarn("-mintxfee") + " " +
_("This is the minimum transaction fee you pay on every transaction.")); _("This is the minimum transaction fee you pay on every transaction."));
CWallet::minTxFee = CFeeRate(n); CWallet::minTxFee = CFeeRate(n);
} }
if (IsArgSet("-fallbackfee")) if (gArgs.IsArgSet("-fallbackfee"))
{ {
CAmount nFeePerK = 0; CAmount nFeePerK = 0;
if (!ParseMoney(GetArg("-fallbackfee", ""), nFeePerK)) if (!ParseMoney(gArgs.GetArg("-fallbackfee", ""), nFeePerK))
return InitError(strprintf(_("Invalid amount for -fallbackfee=<amount>: '%s'"), GetArg("-fallbackfee", ""))); return InitError(strprintf(_("Invalid amount for -fallbackfee=<amount>: '%s'"), gArgs.GetArg("-fallbackfee", "")));
if (nFeePerK > HIGH_TX_FEE_PER_KB) if (nFeePerK > HIGH_TX_FEE_PER_KB)
InitWarning(AmountHighWarn("-fallbackfee") + " " + InitWarning(AmountHighWarn("-fallbackfee") + " " +
_("This is the transaction fee you may pay when fee estimates are not available.")); _("This is the transaction fee you may pay when fee estimates are not available."));
CWallet::fallbackFee = CFeeRate(nFeePerK); CWallet::fallbackFee = CFeeRate(nFeePerK);
} }
if (IsArgSet("-paytxfee")) if (gArgs.IsArgSet("-paytxfee"))
{ {
CAmount nFeePerK = 0; CAmount nFeePerK = 0;
if (!ParseMoney(GetArg("-paytxfee", ""), nFeePerK)) if (!ParseMoney(gArgs.GetArg("-paytxfee", ""), nFeePerK))
return InitError(AmountErrMsg("paytxfee", GetArg("-paytxfee", ""))); return InitError(AmountErrMsg("paytxfee", gArgs.GetArg("-paytxfee", "")));
if (nFeePerK > HIGH_TX_FEE_PER_KB) if (nFeePerK > HIGH_TX_FEE_PER_KB)
InitWarning(AmountHighWarn("-paytxfee") + " " + InitWarning(AmountHighWarn("-paytxfee") + " " +
_("This is the transaction fee you will pay if you send a transaction.")); _("This is the transaction fee you will pay if you send a transaction."));
@ -5097,28 +5097,28 @@ bool CWallet::ParameterInteraction()
if (payTxFee < ::minRelayTxFee) if (payTxFee < ::minRelayTxFee)
{ {
return InitError(strprintf(_("Invalid amount for -paytxfee=<amount>: '%s' (must be at least %s)"), return InitError(strprintf(_("Invalid amount for -paytxfee=<amount>: '%s' (must be at least %s)"),
GetArg("-paytxfee", ""), ::minRelayTxFee.ToString())); gArgs.GetArg("-paytxfee", ""), ::minRelayTxFee.ToString()));
} }
} }
if (IsArgSet("-maxtxfee")) if (gArgs.IsArgSet("-maxtxfee"))
{ {
CAmount nMaxFee = 0; CAmount nMaxFee = 0;
if (!ParseMoney(GetArg("-maxtxfee", ""), nMaxFee)) if (!ParseMoney(gArgs.GetArg("-maxtxfee", ""), nMaxFee))
return InitError(AmountErrMsg("maxtxfee", GetArg("-maxtxfee", ""))); return InitError(AmountErrMsg("maxtxfee", gArgs.GetArg("-maxtxfee", "")));
if (nMaxFee > HIGH_MAX_TX_FEE) if (nMaxFee > HIGH_MAX_TX_FEE)
InitWarning(_("-maxtxfee is set very high! Fees this large could be paid on a single transaction.")); InitWarning(_("-maxtxfee is set very high! Fees this large could be paid on a single transaction."));
maxTxFee = nMaxFee; maxTxFee = nMaxFee;
if (CFeeRate(maxTxFee, 1000) < ::minRelayTxFee) if (CFeeRate(maxTxFee, 1000) < ::minRelayTxFee)
{ {
return InitError(strprintf(_("Invalid amount for -maxtxfee=<amount>: '%s' (must be at least the minrelay fee of %s to prevent stuck transactions)"), return InitError(strprintf(_("Invalid amount for -maxtxfee=<amount>: '%s' (must be at least the minrelay fee of %s to prevent stuck transactions)"),
GetArg("-maxtxfee", ""), ::minRelayTxFee.ToString())); gArgs.GetArg("-maxtxfee", ""), ::minRelayTxFee.ToString()));
} }
} }
nTxConfirmTarget = GetArg("-txconfirmtarget", DEFAULT_TX_CONFIRM_TARGET); nTxConfirmTarget = gArgs.GetArg("-txconfirmtarget", DEFAULT_TX_CONFIRM_TARGET);
bSpendZeroConfChange = GetBoolArg("-spendzeroconfchange", DEFAULT_SPEND_ZEROCONF_CHANGE); bSpendZeroConfChange = gArgs.GetBoolArg("-spendzeroconfchange", DEFAULT_SPEND_ZEROCONF_CHANGE);
if (IsArgSet("-walletbackupsdir")) { if (gArgs.IsArgSet("-walletbackupsdir")) {
if (!fs::is_directory(GetArg("-walletbackupsdir", ""))) { if (!fs::is_directory(gArgs.GetArg("-walletbackupsdir", ""))) {
LogPrintf("%s: Warning: incorrect parameter -walletbackupsdir, path must exist! Using default path.\n", __func__); LogPrintf("%s: Warning: incorrect parameter -walletbackupsdir, path must exist! Using default path.\n", __func__);
InitWarning("Warning: incorrect parameter -walletbackupsdir, path must exist! Using default path.\n"); InitWarning("Warning: incorrect parameter -walletbackupsdir, path must exist! Using default path.\n");
@ -5131,16 +5131,16 @@ bool CWallet::ParameterInteraction()
bool CWallet::InitAutoBackup() bool CWallet::InitAutoBackup()
{ {
if (GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET))
return true; return true;
std::string strWarning; std::string strWarning;
std::string strError; std::string strError;
nWalletBackups = GetArg("-createwalletbackups", 10); nWalletBackups = gArgs.GetArg("-createwalletbackups", 10);
nWalletBackups = std::max(0, std::min(10, nWalletBackups)); nWalletBackups = std::max(0, std::min(10, nWalletBackups));
std::string strWalletFile = GetArg("-wallet", DEFAULT_WALLET_DAT); std::string strWalletFile = gArgs.GetArg("-wallet", DEFAULT_WALLET_DAT);
if(!AutoBackupWallet(NULL, strWalletFile, strWarning, strError)) { if(!AutoBackupWallet(NULL, strWalletFile, strWarning, strError)) {
if (!strWarning.empty()) if (!strWarning.empty())
@ -5292,7 +5292,7 @@ void CWallet::NotifyTransactionLock(const CTransaction &tx, const llmq::CInstant
NotifyTransactionChanged(this, txHash, CT_UPDATED); NotifyTransactionChanged(this, txHash, CT_UPDATED);
NotifyISLockReceived(); NotifyISLockReceived();
// notify an external script // notify an external script
std::string strCmd = GetArg("-instantsendnotify", ""); std::string strCmd = gArgs.GetArg("-instantsendnotify", "");
if (!strCmd.empty()) { if (!strCmd.empty()) {
boost::replace_all(strCmd, "%s", txHash.GetHex()); boost::replace_all(strCmd, "%s", txHash.GetHex());
boost::thread t(runCommand, strCmd); // thread runs free boost::thread t(runCommand, strCmd); // thread runs free

View File

@ -632,7 +632,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
fNoncriticalErrors = true; // ... but do warn the user there is something wrong. fNoncriticalErrors = true; // ... but do warn the user there is something wrong.
if (strType == "tx") if (strType == "tx")
// Rescan if there is a bad transaction record: // Rescan if there is a bad transaction record:
SoftSetBoolArg("-rescan", true); gArgs.SoftSetBoolArg("-rescan", true);
} }
} }
if (!strErr.empty()) if (!strErr.empty())
@ -814,7 +814,7 @@ void MaybeCompactWalletDB()
if (fOneThread.exchange(true)) { if (fOneThread.exchange(true)) {
return; return;
} }
if (!GetBoolArg("-flushwallet", DEFAULT_FLUSHWALLET)) { if (!gArgs.GetBoolArg("-flushwallet", DEFAULT_FLUSHWALLET)) {
return; return;
} }

View File

@ -58,7 +58,7 @@ std::string GetWarnings(const std::string& strFor)
strGUI = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications"); strGUI = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications");
} }
if (GetBoolArg("-testsafemode", DEFAULT_TESTSAFEMODE)) if (gArgs.GetBoolArg("-testsafemode", DEFAULT_TESTSAFEMODE))
strStatusBar = strRPC = strGUI = "testsafemode enabled"; strStatusBar = strRPC = strGUI = "testsafemode enabled";
// Misc warnings like out of disk space and clock is wrong // Misc warnings like out of disk space and clock is wrong

View File

@ -55,10 +55,10 @@ CZMQNotificationInterface* CZMQNotificationInterface::Create()
for (std::map<std::string, CZMQNotifierFactory>::const_iterator i=factories.begin(); i!=factories.end(); ++i) for (std::map<std::string, CZMQNotifierFactory>::const_iterator i=factories.begin(); i!=factories.end(); ++i)
{ {
std::string arg("-zmq" + i->first); std::string arg("-zmq" + i->first);
if (IsArgSet(arg)) if (gArgs.IsArgSet(arg))
{ {
CZMQNotifierFactory factory = i->second; CZMQNotifierFactory factory = i->second;
std::string address = GetArg(arg, ""); std::string address = gArgs.GetArg(arg, "");
CZMQAbstractNotifier *notifier = factory(); CZMQAbstractNotifier *notifier = factory();
notifier->SetType(i->first); notifier->SetType(i->first);
notifier->SetAddress(address); notifier->SetAddress(address);