aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bitcoin-cli.cpp4
-rw-r--r--src/bitcoin-tx.cpp2
-rw-r--r--src/bitcoind.cpp4
-rw-r--r--src/httpserver.cpp4
-rw-r--r--src/init.cpp20
-rw-r--r--src/miner.cpp4
-rw-r--r--src/net_processing.cpp2
-rw-r--r--src/qt/bitcoin.cpp6
-rw-r--r--src/test/util_tests.cpp4
-rw-r--r--src/util.cpp7
-rw-r--r--src/util.h8
-rw-r--r--src/wallet/wallet.cpp10
12 files changed, 44 insertions, 31 deletions
diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp
index cee9ae31b5..a4360dcd13 100644
--- a/src/bitcoin-cli.cpp
+++ b/src/bitcoin-cli.cpp
@@ -76,9 +76,9 @@ static int AppInitRPC(int argc, char* argv[])
// Parameters
//
ParseParameters(argc, argv);
- if (argc<2 || mapArgs.count("-?") || mapArgs.count("-h") || mapArgs.count("-help") || mapArgs.count("-version")) {
+ if (argc<2 || IsArgSet("-?") || IsArgSet("-h") || IsArgSet("-help") || IsArgSet("-version")) {
std::string strUsage = strprintf(_("%s RPC client version"), _(PACKAGE_NAME)) + " " + FormatFullVersion() + "\n";
- if (!mapArgs.count("-version")) {
+ if (!IsArgSet("-version")) {
strUsage += "\n" + _("Usage:") + "\n" +
" bitcoin-cli [options] <command> [params] " + strprintf(_("Send command to %s"), _(PACKAGE_NAME)) + "\n" +
" bitcoin-cli [options] help " + _("List commands") + "\n" +
diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp
index 816687a45d..d46f330453 100644
--- a/src/bitcoin-tx.cpp
+++ b/src/bitcoin-tx.cpp
@@ -51,7 +51,7 @@ static int AppInitRawTx(int argc, char* argv[])
fCreateBlank = GetBoolArg("-create", false);
- if (argc<2 || mapArgs.count("-?") || mapArgs.count("-h") || mapArgs.count("-help"))
+ if (argc<2 || IsArgSet("-?") || IsArgSet("-h") || IsArgSet("-help"))
{
// First part of help message is specific to this utility
std::string strUsage = strprintf(_("%s bitcoin-tx utility version"), _(PACKAGE_NAME)) + " " + FormatFullVersion() + "\n\n" +
diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp
index 3dd0856289..ee27f41220 100644
--- a/src/bitcoind.cpp
+++ b/src/bitcoind.cpp
@@ -75,11 +75,11 @@ bool AppInit(int argc, char* argv[])
ParseParameters(argc, argv);
// Process help and version before taking care about datadir
- if (mapArgs.count("-?") || mapArgs.count("-h") || mapArgs.count("-help") || mapArgs.count("-version"))
+ if (IsArgSet("-?") || IsArgSet("-h") || IsArgSet("-help") || IsArgSet("-version"))
{
std::string strUsage = strprintf(_("%s Daemon"), _(PACKAGE_NAME)) + " " + _("version") + " " + FormatFullVersion() + "\n";
- if (mapArgs.count("-version"))
+ if (IsArgSet("-version"))
{
strUsage += FormatParagraph(LicenseInfo());
}
diff --git a/src/httpserver.cpp b/src/httpserver.cpp
index 2d25168a16..2573900746 100644
--- a/src/httpserver.cpp
+++ b/src/httpserver.cpp
@@ -322,10 +322,10 @@ static bool HTTPBindAddresses(struct evhttp* http)
std::vector<std::pair<std::string, uint16_t> > endpoints;
// Determine what addresses to bind to
- if (!mapArgs.count("-rpcallowip")) { // Default to loopback if not allowing external IPs
+ if (!IsArgSet("-rpcallowip")) { // Default to loopback if not allowing external IPs
endpoints.push_back(std::make_pair("::1", defaultPort));
endpoints.push_back(std::make_pair("127.0.0.1", defaultPort));
- if (mapArgs.count("-rpcbind")) {
+ if (IsArgSet("-rpcbind")) {
LogPrintf("WARNING: option -rpcbind was ignored because -rpcallowip was not specified, refusing to allow everyone to connect\n");
}
} else if (mapMultiArgs.count("-rpcbind")) { // Specific bind address
diff --git a/src/init.cpp b/src/init.cpp
index ecfd33fb62..778d66fba8 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -708,11 +708,11 @@ void InitParameterInteraction()
{
// when specifying an explicit binding address, you want to listen on it
// even when -connect or -proxy is specified
- if (mapArgs.count("-bind")) {
+ if (IsArgSet("-bind")) {
if (SoftSetBoolArg("-listen", true))
LogPrintf("%s: parameter interaction: -bind set -> setting -listen=1\n", __func__);
}
- if (mapArgs.count("-whitebind")) {
+ if (IsArgSet("-whitebind")) {
if (SoftSetBoolArg("-listen", true))
LogPrintf("%s: parameter interaction: -whitebind set -> setting -listen=1\n", __func__);
}
@@ -725,7 +725,7 @@ void InitParameterInteraction()
LogPrintf("%s: parameter interaction: -connect set -> setting -listen=0\n", __func__);
}
- if (mapArgs.count("-proxy")) {
+ if (IsArgSet("-proxy")) {
// to protect privacy, do not listen by default if a default proxy server is specified
if (SoftSetBoolArg("-listen", false))
LogPrintf("%s: parameter interaction: -proxy set -> setting -listen=0\n", __func__);
@@ -748,7 +748,7 @@ void InitParameterInteraction()
LogPrintf("%s: parameter interaction: -listen=0 -> setting -listenonion=0\n", __func__);
}
- if (mapArgs.count("-externalip")) {
+ if (IsArgSet("-externalip")) {
// if an explicit public IP is specified, do not try to find others
if (SoftSetBoolArg("-discover", false))
LogPrintf("%s: parameter interaction: -externalip set -> setting -discover=0\n", __func__);
@@ -892,7 +892,7 @@ bool AppInitParameterInteraction()
if (GetBoolArg("-debugnet", false))
InitWarning(_("Unsupported argument -debugnet ignored, use -debug=net."));
// Check for -socks - as this is a privacy risk to continue, exit here
- if (mapArgs.count("-socks"))
+ if (IsArgSet("-socks"))
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
if (GetBoolArg("-tor", false))
@@ -904,7 +904,7 @@ bool AppInitParameterInteraction()
if (GetBoolArg("-whitelistalwaysrelay", false))
InitWarning(_("Unsupported argument -whitelistalwaysrelay ignored, use -whitelistrelay and/or -whitelistforcerelay."));
- if (mapArgs.count("-blockminsize"))
+ if (IsArgSet("-blockminsize"))
InitWarning("Unsupported argument -blockminsize ignored.");
// Checkmempool and checkblockindex default to true in regtest mode
@@ -959,7 +959,7 @@ bool AppInitParameterInteraction()
// a transaction spammer can cheaply fill blocks using
// 1-satoshi-fee transactions. It should be set above the real
// cost to you of processing a transaction.
- if (mapArgs.count("-minrelaytxfee"))
+ if (IsArgSet("-minrelaytxfee"))
{
CAmount n = 0;
if (!ParseMoney(mapArgs["-minrelaytxfee"], n) || 0 == n)
@@ -997,7 +997,7 @@ bool AppInitParameterInteraction()
nMaxTipAge = GetArg("-maxtipage", DEFAULT_MAX_TIP_AGE);
fEnableReplacement = GetBoolArg("-mempoolreplacement", DEFAULT_ENABLE_REPLACEMENT);
- if ((!fEnableReplacement) && mapArgs.count("-mempoolreplacement")) {
+ if ((!fEnableReplacement) && IsArgSet("-mempoolreplacement")) {
// Minimal effort at forwards compatibility
std::string strReplacementModeList = GetArg("-mempoolreplacement", ""); // default is impossible
std::vector<std::string> vstrReplacementModes;
@@ -1291,7 +1291,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
uint64_t nMaxOutboundLimit = 0; //unlimited unless -maxuploadtarget is set
uint64_t nMaxOutboundTimeframe = MAX_UPLOAD_TIMEFRAME;
- if (mapArgs.count("-maxuploadtarget")) {
+ if (IsArgSet("-maxuploadtarget")) {
nMaxOutboundLimit = GetArg("-maxuploadtarget", DEFAULT_MAX_UPLOAD_TARGET)*1024*1024;
}
@@ -1523,7 +1523,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
fHaveGenesis = true;
}
- if (mapArgs.count("-blocknotify"))
+ if (IsArgSet("-blocknotify"))
uiInterface.NotifyBlockTip.connect(BlockNotifyCallback);
std::vector<boost::filesystem::path> vImportFiles;
diff --git a/src/miner.cpp b/src/miner.cpp
index b48b9cee49..55231730fa 100644
--- a/src/miner.cpp
+++ b/src/miner.cpp
@@ -84,12 +84,12 @@ BlockAssembler::BlockAssembler(const CChainParams& _chainparams)
nBlockMaxWeight = DEFAULT_BLOCK_MAX_WEIGHT;
nBlockMaxSize = DEFAULT_BLOCK_MAX_SIZE;
bool fWeightSet = false;
- if (mapArgs.count("-blockmaxweight")) {
+ if (IsArgSet("-blockmaxweight")) {
nBlockMaxWeight = GetArg("-blockmaxweight", DEFAULT_BLOCK_MAX_WEIGHT);
nBlockMaxSize = MAX_BLOCK_SERIALIZED_SIZE;
fWeightSet = true;
}
- if (mapArgs.count("-blockmaxsize")) {
+ if (IsArgSet("-blockmaxsize")) {
nBlockMaxSize = GetArg("-blockmaxsize", DEFAULT_BLOCK_MAX_SIZE);
if (!fWeightSet) {
nBlockMaxWeight = nBlockMaxSize * WITNESS_SCALE_FACTOR;
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index 87d367c2fb..98872200dd 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -1060,7 +1060,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
unsigned int nMaxSendBufferSize = connman.GetSendBufferSize();
LogPrint("net", "received: %s (%u bytes) peer=%d\n", SanitizeString(strCommand), vRecv.size(), pfrom->id);
- if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0)
+ if (IsArgSet("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0)
{
LogPrintf("dropmessagestest DROPPING RECV MESSAGE\n");
return true;
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp
index 3ae54f3119..9d80a38008 100644
--- a/src/qt/bitcoin.cpp
+++ b/src/qt/bitcoin.cpp
@@ -587,9 +587,9 @@ int main(int argc, char *argv[])
// Show help message immediately after parsing command-line options (for "-lang") and setting locale,
// but before showing splash screen.
- if (mapArgs.count("-?") || mapArgs.count("-h") || mapArgs.count("-help") || mapArgs.count("-version"))
+ if (IsArgSet("-?") || IsArgSet("-h") || IsArgSet("-help") || IsArgSet("-version"))
{
- HelpMessageDialog help(NULL, mapArgs.count("-version"));
+ HelpMessageDialog help(NULL, IsArgSet("-version"));
help.showOrPrint();
return EXIT_SUCCESS;
}
@@ -672,7 +672,7 @@ int main(int argc, char *argv[])
// Allow parameter interaction before we create the options model
app.parameterSetup();
// Load GUI settings from QSettings
- app.createOptionsModel(mapArgs.count("-resetguisettings") != 0);
+ app.createOptionsModel(IsArgSet("-resetguisettings"));
// Subscribe to global signals from core
uiInterface.InitMessage.connect(InitMessage);
diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp
index 493d58641c..6ce065b377 100644
--- a/src/test/util_tests.cpp
+++ b/src/test/util_tests.cpp
@@ -115,8 +115,8 @@ BOOST_AUTO_TEST_CASE(util_ParseParameters)
// -a, -b and -ccc end up in map, -d ignored because it is after
// a non-option argument (non-GNU option parsing)
BOOST_CHECK(mapArgs.size() == 3 && mapMultiArgs.size() == 3);
- BOOST_CHECK(mapArgs.count("-a") && mapArgs.count("-b") && mapArgs.count("-ccc")
- && !mapArgs.count("f") && !mapArgs.count("-d"));
+ BOOST_CHECK(IsArgSet("-a") && IsArgSet("-b") && IsArgSet("-ccc")
+ && !IsArgSet("f") && !IsArgSet("-d"));
BOOST_CHECK(mapMultiArgs.count("-a") && mapMultiArgs.count("-b") && mapMultiArgs.count("-ccc")
&& !mapMultiArgs.count("f") && !mapMultiArgs.count("-d"));
diff --git a/src/util.cpp b/src/util.cpp
index 6625ac9325..cef3e97c28 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -379,6 +379,11 @@ void ParseParameters(int argc, const char* const argv[])
}
}
+bool IsArgSet(const std::string& strArg)
+{
+ return mapArgs.count(strArg);
+}
+
std::string GetArg(const std::string& strArg, const std::string& strDefault)
{
if (mapArgs.count(strArg))
@@ -498,7 +503,7 @@ const boost::filesystem::path &GetDataDir(bool fNetSpecific)
if (!path.empty())
return path;
- if (mapArgs.count("-datadir")) {
+ if (IsArgSet("-datadir")) {
path = fs::system_complete(mapArgs["-datadir"]);
if (!fs::is_directory(path)) {
path = "";
diff --git a/src/util.h b/src/util.h
index 5d1d80d2df..aff4c3271f 100644
--- a/src/util.h
+++ b/src/util.h
@@ -124,6 +124,14 @@ inline bool IsSwitchChar(char c)
}
/**
+ * Return true if the given argument has been manually set
+ *
+ * @param strArg Argument to get (e.g. "-foo")
+ * @return true if the argument has been set
+ */
+bool IsArgSet(const std::string& strArg);
+
+/**
* Return string argument or default value
*
* @param strArg Argument to get (e.g. "-foo")
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 1261aad3f2..51423f88e8 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -3494,7 +3494,7 @@ bool CWallet::InitLoadWallet()
walletInstance->SetBestChain(chainActive.GetLocator());
}
- else if (mapArgs.count("-usehd")) {
+ else if (IsArgSet("-usehd")) {
bool useHD = GetBoolArg("-usehd", DEFAULT_USE_HD_WALLET);
if (walletInstance->IsHDEnabled() && !useHD)
return InitError(strprintf(_("Error loading %s: You can't disable HD on a already existing HD wallet"), walletFile));
@@ -3618,7 +3618,7 @@ bool CWallet::ParameterInteraction()
InitWarning(AmountHighWarn("-minrelaytxfee") + " " +
_("The wallet will avoid paying less than the minimum relay fee."));
- if (mapArgs.count("-mintxfee"))
+ if (IsArgSet("-mintxfee"))
{
CAmount n = 0;
if (!ParseMoney(mapArgs["-mintxfee"], n) || 0 == n)
@@ -3628,7 +3628,7 @@ bool CWallet::ParameterInteraction()
_("This is the minimum transaction fee you pay on every transaction."));
CWallet::minTxFee = CFeeRate(n);
}
- if (mapArgs.count("-fallbackfee"))
+ if (IsArgSet("-fallbackfee"))
{
CAmount nFeePerK = 0;
if (!ParseMoney(mapArgs["-fallbackfee"], nFeePerK))
@@ -3638,7 +3638,7 @@ bool CWallet::ParameterInteraction()
_("This is the transaction fee you may pay when fee estimates are not available."));
CWallet::fallbackFee = CFeeRate(nFeePerK);
}
- if (mapArgs.count("-paytxfee"))
+ if (IsArgSet("-paytxfee"))
{
CAmount nFeePerK = 0;
if (!ParseMoney(mapArgs["-paytxfee"], nFeePerK))
@@ -3654,7 +3654,7 @@ bool CWallet::ParameterInteraction()
mapArgs["-paytxfee"], ::minRelayTxFee.ToString()));
}
}
- if (mapArgs.count("-maxtxfee"))
+ if (IsArgSet("-maxtxfee"))
{
CAmount nMaxFee = 0;
if (!ParseMoney(mapArgs["-maxtxfee"], nMaxFee))