scripted-diff: stop using the gArgs wrappers

They were temporary additions to ease the transition.

-BEGIN VERIFY SCRIPT-
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'
-END VERIFY SCRIPT-
This commit is contained in:
Marko Bencun 2017-08-01 21:17:40 +02:00 committed by Wladimir J. van der Laan
parent 1227be30ec
commit bb81e17355
39 changed files with 346 additions and 346 deletions

View file

@ -79,10 +79,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" +
" bitcoin-cli [options] <command> [params] " + strprintf(_("Send command to %s"), _(PACKAGE_NAME)) + "\n" + " bitcoin-cli [options] <command> [params] " + strprintf(_("Send command to %s"), _(PACKAGE_NAME)) + "\n" +
" bitcoin-cli [options] -named <command> [name=value] ... " + strprintf(_("Send command to %s (with named arguments)"), _(PACKAGE_NAME)) + "\n" + " bitcoin-cli [options] -named <command> [name=value] ... " + strprintf(_("Send command to %s (with named arguments)"), _(PACKAGE_NAME)) + "\n" +
@ -100,11 +100,11 @@ static int AppInitRPC(int argc, char* argv[])
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
if (!fs::is_directory(GetDataDir(false))) { if (!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;
@ -116,7 +116,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;
@ -198,15 +198,15 @@ UniValue CallRPC(const std::string& strMethod, const UniValue& params)
// 2. port in -rpcconnect (ie following : in ipv4 or ]: in ipv6) // 2. port in -rpcconnect (ie following : in ipv4 or ]: in ipv6)
// 3. default port for chain // 3. default port for chain
int port = BaseParams().RPCPort(); int port = BaseParams().RPCPort();
SplitHostPort(GetArg("-rpcconnect", DEFAULT_RPCCONNECT), port, host); SplitHostPort(gArgs.GetArg("-rpcconnect", DEFAULT_RPCCONNECT), port, host);
port = GetArg("-rpcport", port); port = gArgs.GetArg("-rpcport", port);
// 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);
@ -218,16 +218,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());
@ -244,7 +244,7 @@ UniValue CallRPC(const std::string& strMethod, const UniValue& params)
// check if we should use a special wallet endpoint // check if we should use a special wallet endpoint
std::string endpoint = "/"; std::string endpoint = "/";
std::string walletName = GetArg("-rpcwallet", ""); std::string walletName = gArgs.GetArg("-rpcwallet", "");
if (!walletName.empty()) { if (!walletName.empty()) {
char *encodedURI = evhttp_uriencode(walletName.c_str(), walletName.size(), false); char *encodedURI = evhttp_uriencode(walletName.c_str(), walletName.size(), false);
if (encodedURI) { if (encodedURI) {
@ -294,7 +294,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))
@ -306,14 +306,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

@ -39,7 +39,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 {
@ -49,9 +49,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 bitcoin-tx utility version"), _(PACKAGE_NAME)) + " " + FormatFullVersion() + "\n\n" + std::string strUsage = strprintf(_("%s bitcoin-tx utility version"), _(PACKAGE_NAME)) + " " + FormatFullVersion() + "\n\n" +
@ -737,9 +737,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

@ -71,14 +71,14 @@ bool AppInit(int argc, char* argv[])
// Parameters // Parameters
// //
// If Qt is used, parameters/bitcoin.conf are parsed in qt/bitcoin.cpp's main() // If Qt is used, parameters/bitcoin.conf are parsed in qt/bitcoin.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());
} }
@ -98,12 +98,12 @@ bool AppInit(int argc, char* argv[])
{ {
if (!fs::is_directory(GetDataDir(false))) if (!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;
@ -125,7 +125,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();
@ -144,7 +144,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, "Bitcoin server starting\n"); fprintf(stdout, "Bitcoin server starting\n");

View file

@ -89,8 +89,8 @@ void SelectBaseParams(const std::string& chain)
std::string ChainNameFromCommandLine() std::string ChainNameFromCommandLine()
{ {
bool fRegTest = GetBoolArg("-regtest", false); bool fRegTest = gArgs.GetBoolArg("-regtest", false);
bool fTestNet = GetBoolArg("-testnet", false); bool fTestNet = gArgs.GetBoolArg("-testnet", false);
if (fTestNet && fRegTest) if (fTestNet && fRegTest)
throw std::runtime_error("Invalid combination of -regtest and -testnet."); throw std::runtime_error("Invalid combination of -regtest and -testnet.");

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

@ -210,7 +210,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)) {
@ -221,7 +221,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

@ -309,14 +309,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
@ -369,7 +369,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);
@ -401,7 +401,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, nullptr); evhttp_set_gencb(http, http_request_cb, nullptr);
@ -412,7 +412,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);
@ -442,7 +442,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

@ -199,7 +199,7 @@ void Shutdown()
StopTorControl(); StopTorControl();
UnregisterNodeSignals(GetNodeSignals()); UnregisterNodeSignals(GetNodeSignals());
if (fDumpMempoolLater && GetArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)) { if (fDumpMempoolLater && gArgs.GetArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)) {
DumpMempool(); DumpMempool();
} }
@ -321,7 +321,7 @@ 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);
} }
@ -332,7 +332,7 @@ std::string HelpMessage(HelpMessageMode mode)
const auto testnetBaseParams = CreateBaseChainParams(CBaseChainParams::TESTNET); const auto testnetBaseParams = CreateBaseChainParams(CBaseChainParams::TESTNET);
const auto defaultChainParams = CreateChainParams(CBaseChainParams::MAIN); const auto defaultChainParams = CreateChainParams(CBaseChainParams::MAIN);
const auto testnetChainParams = CreateChainParams(CBaseChainParams::TESTNET); const auto testnetChainParams = CreateChainParams(CBaseChainParams::TESTNET);
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.
@ -546,7 +546,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
@ -683,12 +683,12 @@ 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();
} }
} // End scope of CImportingNow } // End scope of CImportingNow
if (GetArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)) { if (gArgs.GetArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)) {
LoadMempool(); LoadMempool();
fDumpMempoolLater = !fRequestShutdown; fDumpMempoolLater = !fRequestShutdown;
} }
@ -727,7 +727,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;
@ -739,61 +739,61 @@ 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 (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__);
} }
} }
@ -805,10 +805,10 @@ static std::string ResolveErrMsg(const char * const optname, const std::string&
void InitLogging() void InitLogging()
{ {
fPrintToConsole = GetBoolArg("-printtoconsole", false); fPrintToConsole = gArgs.GetBoolArg("-printtoconsole", false);
fLogTimestamps = GetBoolArg("-logtimestamps", DEFAULT_LOGTIMESTAMPS); fLogTimestamps = gArgs.GetBoolArg("-logtimestamps", DEFAULT_LOGTIMESTAMPS);
fLogTimeMicros = GetBoolArg("-logtimemicros", DEFAULT_LOGTIMEMICROS); fLogTimeMicros = gArgs.GetBoolArg("-logtimemicros", DEFAULT_LOGTIMEMICROS);
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("Bitcoin version %s\n", FormatFullVersion()); LogPrintf("Bitcoin version %s\n", FormatFullVersion());
@ -865,7 +865,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);
} }
@ -893,8 +893,8 @@ 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."));
} }
@ -906,7 +906,7 @@ bool AppInitParameterInteraction()
// Make sure enough file descriptors are available // Make sure enough file descriptors are available
int nBind = std::max(nUserBind, size_t(1)); int nBind = std::max(nUserBind, 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
@ -947,55 +947,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)
@ -1004,7 +1004,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."));
} }
@ -1026,14 +1026,14 @@ 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;
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);
@ -1045,55 +1045,55 @@ 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 #endif
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);
if (GetArg("-rpcserialversion", DEFAULT_RPC_SERIALIZE_VERSION) < 0) if (gArgs.GetArg("-rpcserialversion", DEFAULT_RPC_SERIALIZE_VERSION) < 0)
return InitError("rpcserialversion must be non-negative."); return InitError("rpcserialversion must be non-negative.");
if (GetArg("-rpcserialversion", DEFAULT_RPC_SERIALIZE_VERSION) > 1) if (gArgs.GetArg("-rpcserialversion", DEFAULT_RPC_SERIALIZE_VERSION) > 1)
return InitError("unknown rpcserialversion requested."); return InitError("unknown rpcserialversion requested.");
nMaxTipAge = GetArg("-maxtipage", DEFAULT_MAX_TIP_AGE); nMaxTipAge = gArgs.GetArg("-maxtipage", DEFAULT_MAX_TIP_AGE);
fEnableReplacement = GetBoolArg("-mempoolreplacement", DEFAULT_ENABLE_REPLACEMENT); fEnableReplacement = gArgs.GetBoolArg("-mempoolreplacement", DEFAULT_ENABLE_REPLACEMENT);
if ((!fEnableReplacement) && IsArgSet("-mempoolreplacement")) { if ((!fEnableReplacement) && gArgs.IsArgSet("-mempoolreplacement")) {
// Minimal effort at forwards compatibility // Minimal effort at forwards compatibility
std::string strReplacementModeList = GetArg("-mempoolreplacement", ""); // default is impossible std::string strReplacementModeList = gArgs.GetArg("-mempoolreplacement", ""); // default is impossible
std::vector<std::string> vstrReplacementModes; std::vector<std::string> vstrReplacementModes;
boost::split(vstrReplacementModes, strReplacementModeList, boost::is_any_of(",")); boost::split(vstrReplacementModes, strReplacementModeList, boost::is_any_of(","));
fEnableReplacement = (std::find(vstrReplacementModes.begin(), vstrReplacementModes.end(), "fee") != vstrReplacementModes.end()); fEnableReplacement = (std::find(vstrReplacementModes.begin(), vstrReplacementModes.end(), "fee") != vstrReplacementModes.end());
@ -1198,7 +1198,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();
@ -1211,7 +1211,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();
@ -1234,7 +1234,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))
@ -1291,12 +1291,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;
@ -1318,7 +1318,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
@ -1336,9 +1336,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);
for (const std::string& strAddr : gArgs.GetArgs("-externalip")) { for (const std::string& strAddr : gArgs.GetArgs("-externalip")) {
CService addrLocal; CService addrLocal;
@ -1358,27 +1358,27 @@ 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 7: load block chain // ********************************************************* Step 7: 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);
// 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;
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));
LogPrintf("* Using %.1fMiB for chain state database\n", nCoinDBCache * (1.0 / 1024 / 1024)); LogPrintf("* Using %.1fMiB for chain state database\n", nCoinDBCache * (1.0 / 1024 / 1024));
@ -1427,7 +1427,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
return InitError(_("Incorrect or no genesis block found. Wrong datadir for network?")); return InitError(_("Incorrect or no genesis block found. Wrong datadir for network?"));
// 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;
} }
@ -1493,7 +1493,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
if (!is_coinsview_empty) { if (!is_coinsview_empty) {
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);
} }
@ -1510,8 +1510,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;
} }
@ -1610,7 +1610,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;
@ -1634,13 +1634,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("nBestHeight = %d\n", chainActive.Height()); LogPrintf("nBestHeight = %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));
CConnman::Options connOptions; CConnman::Options connOptions;
connOptions.nLocalServices = nLocalServices; connOptions.nLocalServices = nLocalServices;
@ -1651,8 +1651,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

@ -88,20 +88,20 @@ static BlockAssembler::Options DefaultOptions(const CChainParams& params)
options.nBlockMaxWeight = DEFAULT_BLOCK_MAX_WEIGHT; options.nBlockMaxWeight = DEFAULT_BLOCK_MAX_WEIGHT;
options.nBlockMaxSize = DEFAULT_BLOCK_MAX_SIZE; options.nBlockMaxSize = DEFAULT_BLOCK_MAX_SIZE;
bool fWeightSet = false; bool fWeightSet = false;
if (IsArgSet("-blockmaxweight")) { if (gArgs.IsArgSet("-blockmaxweight")) {
options.nBlockMaxWeight = GetArg("-blockmaxweight", DEFAULT_BLOCK_MAX_WEIGHT); options.nBlockMaxWeight = gArgs.GetArg("-blockmaxweight", DEFAULT_BLOCK_MAX_WEIGHT);
options.nBlockMaxSize = MAX_BLOCK_SERIALIZED_SIZE; options.nBlockMaxSize = MAX_BLOCK_SERIALIZED_SIZE;
fWeightSet = true; fWeightSet = true;
} }
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 (!fWeightSet) { if (!fWeightSet) {
options.nBlockMaxWeight = options.nBlockMaxSize * WITNESS_SCALE_FACTOR; options.nBlockMaxWeight = options.nBlockMaxSize * WITNESS_SCALE_FACTOR;
} }
} }
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);
@ -151,7 +151,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();
@ -272,7 +272,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

@ -101,7 +101,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
@ -514,7 +514,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;
@ -1575,7 +1575,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;
@ -2336,7 +2336,7 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions)
// 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

@ -581,7 +581,7 @@ void UnregisterNodeSignals(CNodeSignals& nodeSignals)
void AddToCompactExtraTransactions(const CTransactionRef& tx) void AddToCompactExtraTransactions(const CTransactionRef& tx)
{ {
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())
@ -704,7 +704,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);
@ -1175,7 +1175,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;
@ -1541,7 +1541,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);
@ -1782,7 +1782,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;
@ -1901,7 +1901,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);
@ -1926,7 +1926,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
AddToCompactExtraTransactions(ptx); AddToCompactExtraTransactions(ptx);
} }
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
@ -3297,9 +3297,9 @@ bool SendMessages(CNode* pto, CConnman& connman, const std::atomic<bool>& interr
// Message: feefilter // Message: feefilter
// //
// We don't want white listed peers to filter txs to us if we have -whitelistforcerelay // We don't want white listed peers to filter txs to us if we have -whitelistforcerelay
if (pto->nVersion >= FEEFILTER_VERSION && GetBoolArg("-feefilter", DEFAULT_FEEFILTER) && if (pto->nVersion >= FEEFILTER_VERSION && gArgs.GetBoolArg("-feefilter", DEFAULT_FEEFILTER) &&
!(pto->fWhitelisted && GetBoolArg("-whitelistforcerelay", DEFAULT_WHITELISTFORCERELAY))) { !(pto->fWhitelisted && gArgs.GetBoolArg("-whitelistforcerelay", DEFAULT_WHITELISTFORCERELAY))) {
CAmount currentFilter = mempool.GetMinFee(GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000).GetFeePerK(); CAmount currentFilter = mempool.GetMinFee(gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000).GetFeePerK();
int64_t timeNow = GetTimeMicros(); int64_t timeNow = GetTimeMicros();
if (timeNow > pto->nextSendTimeFeeFilter) { if (timeNow > pto->nextSendTimeFeeFilter) {
static CFeeRate default_feerate(DEFAULT_MIN_RELAY_TX_FEE); static CFeeRate default_feerate(DEFAULT_MIN_RELAY_TX_FEE);

View file

@ -106,7 +106,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;
} }
@ -345,7 +345,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");
@ -498,7 +498,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();
} }
@ -550,7 +550,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
@ -606,9 +606,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(nullptr, IsArgSet("-version")); HelpMessageDialog help(nullptr, gArgs.IsArgSet("-version"));
help.showOrPrint(); help.showOrPrint();
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
@ -623,11 +623,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()));
@ -691,12 +691,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());
int rv = EXIT_SUCCESS; int rv = EXIT_SUCCESS;

View file

@ -651,7 +651,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]);
@ -760,7 +760,7 @@ bool SetStartOnSystemStartup(bool fAutoStart)
optionFile << "Name=Bitcoin\n"; optionFile << "Name=Bitcoin\n";
else else
optionFile << strprintf("Name=Bitcoin (%s)\n", chain); optionFile << strprintf("Name=Bitcoin (%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

@ -131,7 +131,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) {
@ -191,14 +191,14 @@ 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 dataDir = getDefaultDataDirectory(); QString dataDir = getDefaultDataDirectory();
/* 2) Allow QSettings to override default dir */ /* 2) Allow QSettings to override default dir */
dataDir = settings.value("strDataDir", dataDir).toString(); dataDir = settings.value("strDataDir", dataDir).toString();
if(!fs::exists(GUIUtil::qstringToBoostPath(dataDir)) || GetBoolArg("-choosedatadir", DEFAULT_CHOOSE_DATADIR) || settings.value("fReset", false).toBool() || GetBoolArg("-resetguisettings", false)) if(!fs::exists(GUIUtil::qstringToBoostPath(dataDir)) || gArgs.GetBoolArg("-choosedatadir", DEFAULT_CHOOSE_DATADIR) || settings.value("fReset", false).toBool() || gArgs.GetBoolArg("-resetguisettings", false))
{ {
/* If current default data directory does not exist, let the user choose one */ /* If current default data directory does not exist, let the user choose one */
Intro intro; Intro intro;
@ -231,7 +231,7 @@ bool Intro::pickDataDirectory()
* (to be consistent with bitcoind behavior) * (to be consistent with bitcoind behavior)
*/ */
if(dataDir != getDefaultDataDirectory()) if(dataDir != getDefaultDataDirectory())
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

@ -36,7 +36,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
@ -86,18 +86,18 @@ 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");
if (!settings.contains("strDataDir")) if (!settings.contains("strDataDir"))
@ -107,19 +107,19 @@ void OptionsModel::Init(bool resetSettings)
#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");
#endif #endif
// 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"))
@ -127,9 +127,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"))
@ -137,15 +137,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

@ -122,7 +122,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

@ -41,7 +41,7 @@ void RPCNestedTests::rpcNestedTests()
std::string path = QDir::tempPath().toStdString() + "/" + strprintf("test_bitcoin_qt_%lu_%i", (unsigned long)GetTime(), (int)(GetRand(100000))); std::string path = QDir::tempPath().toStdString() + "/" + strprintf("test_bitcoin_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);
TestingSetup test; TestingSetup test;

View file

@ -78,7 +78,7 @@ HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) :
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

@ -739,7 +739,7 @@ bool WalletModel::bumpFee(uint256 hash)
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

@ -1018,8 +1018,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"
@ -1324,7 +1324,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

@ -68,7 +68,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

@ -552,7 +552,7 @@ void RPCRunLater(const std::string& name, std::function<void(void)> func, int64_
int RPCSerializationFlags() int RPCSerializationFlags()
{ {
int flag = 0; int flag = 0;
if (GetArg("-rpcserialversion", DEFAULT_RPC_SERIALIZE_VERSION) == 0) if (gArgs.GetArg("-rpcserialversion", DEFAULT_RPC_SERIALIZE_VERSION) == 0)
flag |= SERIALIZE_TRANSACTION_NO_WITNESS; flag |= SERIALIZE_TRANSACTION_NO_WITNESS;
return flag; return flag;
} }

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) / 2), 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) / 2), 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/2 requested for signature cache, able to store %zu elements\n", LogPrintf("Using %zu MiB out of %zu/2 requested for signature cache, able to store %zu elements\n",
(nElems*sizeof(uint256)) >>20, (nMaxCacheSize*2)>>20, nElems); (nElems*sizeof(uint256)) >>20, (nMaxCacheSize*2)>>20, nElems);

View file

@ -78,7 +78,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, CAddress(), "", true); CNode dummyNode1(id++, NODE_NETWORK, 0, INVALID_SOCKET, addr1, 3, 1, CAddress(), "", true);
dummyNode1.SetSendVersion(PROTOCOL_VERSION); dummyNode1.SetSendVersion(PROTOCOL_VERSION);
@ -94,7 +94,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

@ -27,135 +27,135 @@ static void ResetArgs(const std::string& strArg)
for (std::string& s : vecArg) for (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

@ -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

@ -63,7 +63,7 @@ TestingSetup::TestingSetup(const std::string& chainName) : BasicTestingSetup(cha
ClearDatadirCache(); ClearDatadirCache();
pathTemp = GetTempPath() / strprintf("test_bitcoin_%lu_%i", (unsigned long)GetTime(), (int)(InsecureRandRange(100000))); pathTemp = GetTempPath() / strprintf("test_bitcoin_%lu_%i", (unsigned long)GetTime(), (int)(InsecureRandRange(100000)));
fs::create_directories(pathTemp); fs::create_directories(pathTemp);
ForceSetArg("-datadir", pathTemp.string()); gArgs.ForceSetArg("-datadir", pathTemp.string());
// Note that because we don't bother running a scheduler thread here, // Note that because we don't bother running a scheduler thread here,
// callbacks via CValidationInterface are unreliable, but that's OK, // callbacks via CValidationInterface are unreliable, but that's OK,

View file

@ -81,7 +81,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

@ -85,8 +85,8 @@ bool CCoinsViewDB::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock) {
CDBBatch batch(db); CDBBatch batch(db);
size_t count = 0; size_t count = 0;
size_t changed = 0; size_t changed = 0;
size_t batch_size = (size_t)GetArg("-dbbatchsize", nDefaultDbBatchSize); size_t batch_size = (size_t)gArgs.GetArg("-dbbatchsize", nDefaultDbBatchSize);
int crash_simulate = GetArg("-dbcrashratio", 0); int crash_simulate = gArgs.GetArg("-dbcrashratio", 0);
assert(!hashBlock.IsNull()); assert(!hashBlock.IsNull());
uint256 old_tip = GetBestBlock(); uint256 old_tip = GetBestBlock();

View file

@ -398,7 +398,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);
} }
// Used to avoid mempool polluting consensus critical paths if CCoinsViewMempool // Used to avoid mempool polluting consensus critical paths if CCoinsViewMempool
@ -456,7 +456,7 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
// Reject transactions with witness before segregated witness activates (override with -prematurewitness) // Reject transactions with witness before segregated witness activates (override with -prematurewitness)
bool witnessEnabled = IsWitnessEnabled(chainActive.Tip(), chainparams.GetConsensus()); bool witnessEnabled = IsWitnessEnabled(chainActive.Tip(), chainparams.GetConsensus());
if (!GetBoolArg("-prematurewitness", false) && tx.HasWitness() && !witnessEnabled) { if (!gArgs.GetBoolArg("-prematurewitness", false) && tx.HasWitness() && !witnessEnabled) {
return state.DoS(0, false, REJECT_NONSTANDARD, "no-witness-yet", true); return state.DoS(0, false, REJECT_NONSTANDARD, "no-witness-yet", true);
} }
@ -611,7 +611,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", nSigOpsCost)); strprintf("%d", nSigOpsCost));
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));
} }
@ -628,10 +628,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);
@ -783,7 +783,7 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
unsigned int scriptVerifyFlags = STANDARD_SCRIPT_VERIFY_FLAGS; unsigned int scriptVerifyFlags = STANDARD_SCRIPT_VERIFY_FLAGS;
if (!chainparams.RequireStandard()) { if (!chainparams.RequireStandard()) {
scriptVerifyFlags = GetArg("-promiscuousmempoolflags", scriptVerifyFlags); scriptVerifyFlags = gArgs.GetArg("-promiscuousmempoolflags", scriptVerifyFlags);
} }
// Check against previous transactions // Check against previous transactions
@ -860,7 +860,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");
} }
@ -1061,7 +1061,7 @@ CBlockIndex *pindexBestForkTip = nullptr, *pindexBestForkBase = nullptr;
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
@ -1216,7 +1216,7 @@ static uint256 scriptExecutionCacheNonce(GetRandHash());
void InitScriptExecutionCache() { void InitScriptExecutionCache() {
// 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) / 2), 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) / 2), MAX_MAX_SIG_CACHE_SIZE) * ((size_t) 1 << 20);
size_t nElems = scriptExecutionCache.setup_bytes(nMaxCacheSize); size_t nElems = scriptExecutionCache.setup_bytes(nMaxCacheSize);
LogPrintf("Using %zu MiB out of %zu/2 requested for script execution cache, able to store %zu elements\n", LogPrintf("Using %zu MiB out of %zu/2 requested for script execution cache, able to store %zu elements\n",
(nElems*sizeof(uint256)) >>20, (nMaxCacheSize*2)>>20, nElems); (nElems*sizeof(uint256)) >>20, (nMaxCacheSize*2)>>20, nElems);
@ -1900,7 +1900,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(); int64_t cacheSize = pcoinsTip->DynamicMemoryUsage();
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).
@ -2421,7 +2421,7 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams,
CBlockIndex *pindexMostWork = nullptr; CBlockIndex *pindexMostWork = nullptr;
CBlockIndex *pindexNewTip = nullptr; CBlockIndex *pindexNewTip = nullptr;
int nStopAtHeight = GetArg("-stopatheight", DEFAULT_STOPATHEIGHT); int nStopAtHeight = gArgs.GetArg("-stopatheight", DEFAULT_STOPATHEIGHT);
do { do {
boost::this_thread::interruption_point(); boost::this_thread::interruption_point();
if (ShutdownRequested()) if (ShutdownRequested())
@ -3892,7 +3892,7 @@ bool LoadBlockIndex(const CChainParams& chainparams)
LogPrintf("Initializing databases...\n"); LogPrintf("Initializing databases...\n");
// 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);
} }
return true; return true;
@ -4263,7 +4263,7 @@ static const uint64_t MEMPOOL_DUMP_VERSION = 1;
bool LoadMempool(void) bool LoadMempool(void)
{ {
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

@ -78,7 +78,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());
@ -429,7 +429,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 CWalletDBWrapper::IncrementUpdateCounter() void CWalletDBWrapper::IncrementUpdateCounter()

View file

@ -193,7 +193,7 @@ CFeeBumper::CFeeBumper(const CWallet *pWallet, const uint256 txidIn, const CCoin
// This may occur if the user set TotalFee or paytxfee too low, if fallbackfee is too low, or, perhaps, // This may occur if the user set TotalFee or paytxfee too low, if fallbackfee is too low, or, perhaps,
// in a rare situation where the mempool minimum fee increased significantly since the fee estimation just a // in a rare situation where the mempool minimum fee increased significantly since the fee estimation just a
// moment earlier. In this case, we report an error to the user, who may use totalFee to make an adjustment. // moment earlier. In this case, we report an error to the user, who may use totalFee to make an adjustment.
CFeeRate minMempoolFeeRate = mempool.GetMinFee(GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000); CFeeRate minMempoolFeeRate = mempool.GetMinFee(gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000);
if (nNewFeeRate.GetFeePerK() < minMempoolFeeRate.GetFeePerK()) { if (nNewFeeRate.GetFeePerK() < minMempoolFeeRate.GetFeePerK()) {
vErrors.push_back(strprintf("New fee rate (%s) is less than the minimum fee rate (%s) to get into the mempool. totalFee value should to be at least %s or settxfee value should be at least %s to add transaction.", FormatMoney(nNewFeeRate.GetFeePerK()), FormatMoney(minMempoolFeeRate.GetFeePerK()), FormatMoney(minMempoolFeeRate.GetFee(maxNewTxSize)), FormatMoney(minMempoolFeeRate.GetFeePerK()))); vErrors.push_back(strprintf("New fee rate (%s) is less than the minimum fee rate (%s) to get into the mempool. totalFee value should to be at least %s or settxfee value should be at least %s to add transaction.", FormatMoney(nNewFeeRate.GetFeePerK()), FormatMoney(minMempoolFeeRate.GetFeePerK()), FormatMoney(minMempoolFeeRate.GetFee(maxNewTxSize)), FormatMoney(minMempoolFeeRate.GetFeePerK())));
currentResult = BumpFeeResult::WALLET_ERROR; currentResult = BumpFeeResult::WALLET_ERROR;

View file

@ -1197,7 +1197,7 @@ UniValue addwitnessaddress(const JSONRPCRequest& request)
{ {
LOCK(cs_main); LOCK(cs_main);
if (!IsWitnessEnabled(chainActive.Tip(), Params().GetConsensus()) && !GetBoolArg("-walletprematurewitness", false)) { if (!IsWitnessEnabled(chainActive.Tip(), Params().GetConsensus()) && !gArgs.GetBoolArg("-walletprematurewitness", false)) {
throw JSONRPCError(RPC_WALLET_ERROR, "Segregated witness not enabled on network"); throw JSONRPCError(RPC_WALLET_ERROR, "Segregated witness not enabled on network");
} }
} }
@ -3202,7 +3202,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

@ -496,7 +496,7 @@ 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(s)...")); uiInterface.InitMessage(_("Verifying wallet(s)..."));
@ -528,7 +528,7 @@ bool CWallet::Verify()
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;
std::string backup_filename; std::string backup_filename;
@ -986,7 +986,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())
{ {
@ -2501,8 +2501,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) || SelectCoinsMinConf(nTargetValue - nValueFromPresetInputs, 1, 6, 0, vCoins, setCoinsRet, nValueRet) ||
@ -2937,15 +2937,15 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
} }
} }
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");
@ -3072,7 +3072,7 @@ CAmount CWallet::GetMinimumFee(unsigned int nTxBytes, const CCoinControl& coin_c
if (feeCalc) feeCalc->reason = FeeReason::FALLBACK; if (feeCalc) feeCalc->reason = FeeReason::FALLBACK;
} }
// Obey mempool min fee when using smart fee estimation // Obey mempool min fee when using smart fee estimation
CAmount min_mempool_fee = pool.GetMinFee(GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000).GetFee(nTxBytes); CAmount min_mempool_fee = pool.GetMinFee(gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000).GetFee(nTxBytes);
if (fee_needed < min_mempool_fee) { if (fee_needed < min_mempool_fee) {
fee_needed = min_mempool_fee; fee_needed = min_mempool_fee;
if (feeCalc) feeCalc->reason = FeeReason::MEMPOOL_MIN; if (feeCalc) feeCalc->reason = FeeReason::MEMPOOL_MIN;
@ -3307,7 +3307,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)
@ -3933,7 +3933,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));
@ -3982,9 +3982,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);
@ -4004,7 +4004,7 @@ 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()) {
// ensure this wallet.dat can only be opened by clients supporting HD with chain split // ensure this wallet.dat can only be opened by clients supporting HD with chain split
walletInstance->SetMinVersion(FEATURE_HD_SPLIT); walletInstance->SetMinVersion(FEATURE_HD_SPLIT);
@ -4025,8 +4025,8 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile)
walletInstance->SetBestChain(chainActive.GetLocator()); walletInstance->SetBestChain(chainActive.GetLocator());
} }
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 an already existing HD wallet"), walletFile)); InitError(strprintf(_("Error loading %s: You can't disable HD on an already existing HD wallet"), walletFile));
return nullptr; return nullptr;
@ -4045,7 +4045,7 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile)
walletInstance->TopUpKeyPool(); walletInstance->TopUpKeyPool();
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;
@ -4085,7 +4085,7 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile)
walletInstance->dbw->IncrementUpdateCounter(); walletInstance->dbw->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);
@ -4109,7 +4109,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);
@ -4123,7 +4123,7 @@ 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)) {
LogPrintf("Wallet disabled!\n"); LogPrintf("Wallet disabled!\n");
return true; return true;
} }
@ -4155,29 +4155,29 @@ void CWallet::postInitProcess(CScheduler& scheduler)
bool CWallet::ParameterInteraction() bool CWallet::ParameterInteraction()
{ {
SoftSetArg("-wallet", DEFAULT_WALLET_DAT); gArgs.SoftSetArg("-wallet", DEFAULT_WALLET_DAT);
const bool is_multiwallet = gArgs.GetArgs("-wallet").size() > 1; const bool is_multiwallet = gArgs.GetArgs("-wallet").size() > 1;
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)) { if (gArgs.GetBoolArg("-salvagewallet", false)) {
if (is_multiwallet) { if (is_multiwallet) {
return InitError(strprintf("%s is only allowed with a single wallet file", "-salvagewallet")); return InitError(strprintf("%s is only allowed with a single wallet file", "-salvagewallet"));
} }
// Rewrite just private keys: rescan to find transactions // Rewrite just private keys: rescan to find transactions
if (SoftSetBoolArg("-rescan", true)) { if (gArgs.SoftSetBoolArg("-rescan", true)) {
LogPrintf("%s: parameter interaction: -salvagewallet=1 -> setting -rescan=1\n", __func__); LogPrintf("%s: parameter interaction: -salvagewallet=1 -> setting -rescan=1\n", __func__);
} }
} }
int zapwallettxes = GetArg("-zapwallettxes", 0); int zapwallettxes = gArgs.GetArg("-zapwallettxes", 0);
// -zapwallettxes implies dropping the mempool on startup // -zapwallettxes implies dropping the mempool on startup
if (zapwallettxes != 0 && SoftSetBoolArg("-persistmempool", false)) { if (zapwallettxes != 0 && gArgs.SoftSetBoolArg("-persistmempool", false)) {
LogPrintf("%s: parameter interaction: -zapwallettxes=%s -> setting -persistmempool=0\n", __func__, zapwallettxes); LogPrintf("%s: parameter interaction: -zapwallettxes=%s -> setting -persistmempool=0\n", __func__, zapwallettxes);
} }
@ -4186,61 +4186,61 @@ bool CWallet::ParameterInteraction()
if (is_multiwallet) { if (is_multiwallet) {
return InitError(strprintf("%s is only allowed with a single wallet file", "-zapwallettxes")); return InitError(strprintf("%s is only allowed with a single wallet file", "-zapwallettxes"));
} }
if (SoftSetBoolArg("-rescan", true)) { if (gArgs.SoftSetBoolArg("-rescan", true)) {
LogPrintf("%s: parameter interaction: -zapwallettxes=%s -> setting -rescan=1\n", __func__, zapwallettxes); LogPrintf("%s: parameter interaction: -zapwallettxes=%s -> setting -rescan=1\n", __func__, zapwallettxes);
} }
} }
if (is_multiwallet) { if (is_multiwallet) {
if (GetBoolArg("-upgradewallet", false)) { if (gArgs.GetBoolArg("-upgradewallet", false)) {
return InitError(strprintf("%s is only allowed with a single wallet file", "-upgradewallet")); return InitError(strprintf("%s is only allowed with a single wallet file", "-upgradewallet"));
} }
} }
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("-discardfee")) if (gArgs.IsArgSet("-discardfee"))
{ {
CAmount nFeePerK = 0; CAmount nFeePerK = 0;
if (!ParseMoney(GetArg("-discardfee", ""), nFeePerK)) if (!ParseMoney(gArgs.GetArg("-discardfee", ""), nFeePerK))
return InitError(strprintf(_("Invalid amount for -discardfee=<amount>: '%s'"), GetArg("-discardfee", ""))); return InitError(strprintf(_("Invalid amount for -discardfee=<amount>: '%s'"), gArgs.GetArg("-discardfee", "")));
if (nFeePerK > HIGH_TX_FEE_PER_KB) if (nFeePerK > HIGH_TX_FEE_PER_KB)
InitWarning(AmountHighWarn("-discardfee") + " " + InitWarning(AmountHighWarn("-discardfee") + " " +
_("This is the transaction fee you may discard if change is smaller than dust at this level")); _("This is the transaction fee you may discard if change is smaller than dust at this level"));
CWallet::m_discard_rate = CFeeRate(nFeePerK); CWallet::m_discard_rate = 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."));
@ -4249,26 +4249,26 @@ 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);
fWalletRbf = GetBoolArg("-walletrbf", DEFAULT_WALLET_RBF); fWalletRbf = gArgs.GetBoolArg("-walletrbf", DEFAULT_WALLET_RBF);
return true; return true;
} }

View file

@ -573,7 +573,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())
@ -751,7 +751,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

@ -51,7 +51,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

@ -43,10 +43,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);