aboutsummaryrefslogtreecommitdiff
path: root/src/bitcoind.cpp
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2018-04-28 19:40:51 -0400
committerAndrew Chow <achow101-github@achow101.com>2018-05-30 11:27:50 -0400
commit4f8704d57f8fb2958a43534779b20201b77eecae (patch)
tree4ccb64e2e65e99726786919d6d0feecde2e26377 /src/bitcoind.cpp
parent174f7c80801383cde5ea514b19fb8b108b56b31c (diff)
Give an error and exit if there are unknown parameters
If an unknown option is given via either the command line args or the conf file, throw an error and exit Update tests for ArgsManager knowing args Ignore unknown options in the config file for bitcoin-cli Fix tests and bitcoin-cli to match actual options used
Diffstat (limited to 'src/bitcoind.cpp')
-rw-r--r--src/bitcoind.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp
index 35c05dad41..a9b952e5a4 100644
--- a/src/bitcoind.cpp
+++ b/src/bitcoind.cpp
@@ -65,7 +65,11 @@ static bool AppInit(int argc, char* argv[])
#if HAVE_DECL_DAEMON
gArgs.AddArg("-daemon", "Run in the background as a daemon and accept commands", false, OptionsCategory::OPTIONS);
#endif
- gArgs.ParseParameters(argc, argv);
+ std::string error;
+ if (!gArgs.ParseParameters(argc, argv, error)) {
+ fprintf(stderr, "Error parsing command line arguments: %s\n", error.c_str());
+ return false;
+ }
// Process help and version before taking care about datadir
if (HelpRequested(gArgs) || gArgs.IsArgSet("-version")) {
@@ -94,11 +98,8 @@ static bool AppInit(int argc, char* argv[])
fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", "").c_str());
return false;
}
- try
- {
- gArgs.ReadConfigFiles();
- } catch (const std::exception& e) {
- fprintf(stderr,"Error reading configuration file: %s\n", e.what());
+ if (!gArgs.ReadConfigFiles(error)) {
+ fprintf(stderr, "Error reading configuration file: %s\n", error.c_str());
return false;
}
// Check for -testnet or -regtest parameter (Params() calls are only valid after this clause)