Changeset View
Changeset View
Standalone View
Standalone View
src/bitcoind.cpp
Show First 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | static bool AppInit(int argc, char *argv[]) { | ||||
// If Qt is used, parameters/bitcoin.conf are parsed in qt/bitcoin.cpp's | // If Qt is used, parameters/bitcoin.conf are parsed in qt/bitcoin.cpp's | ||||
// main() | // main() | ||||
SetupServerArgs(); | SetupServerArgs(); | ||||
#if HAVE_DECL_DAEMON | #if HAVE_DECL_DAEMON | ||||
gArgs.AddArg("-daemon", | gArgs.AddArg("-daemon", | ||||
_("Run in the background as a daemon and accept commands"), | _("Run in the background as a daemon and accept commands"), | ||||
false, OptionsCategory::OPTIONS); | false, OptionsCategory::OPTIONS); | ||||
#endif | #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 | // Process help and version before taking care about datadir | ||||
if (HelpRequested(gArgs) || gArgs.IsArgSet("-version")) { | if (HelpRequested(gArgs) || gArgs.IsArgSet("-version")) { | ||||
std::string strUsage = | std::string strUsage = | ||||
PACKAGE_NAME " Daemon version " + FormatFullVersion() + "\n"; | PACKAGE_NAME " Daemon version " + FormatFullVersion() + "\n"; | ||||
if (gArgs.IsArgSet("-version")) { | if (gArgs.IsArgSet("-version")) { | ||||
strUsage += FormatParagraph(LicenseInfo()); | strUsage += FormatParagraph(LicenseInfo()); | ||||
Show All 10 Lines | #endif | ||||
try { | try { | ||||
if (!fs::is_directory(GetDataDir(false))) { | if (!fs::is_directory(GetDataDir(false))) { | ||||
fprintf(stderr, | fprintf(stderr, | ||||
"Error: Specified data directory \"%s\" does not exist.\n", | "Error: Specified data directory \"%s\" does not exist.\n", | ||||
gArgs.GetArg("-datadir", "").c_str()); | gArgs.GetArg("-datadir", "").c_str()); | ||||
return false; | return false; | ||||
} | } | ||||
try { | if (!gArgs.ReadConfigFiles(error)) { | ||||
gArgs.ReadConfigFiles(); | fprintf(stderr, "Error reading configuration file: %s\n", | ||||
} catch (const std::exception &e) { | error.c_str()); | ||||
fprintf(stderr, "Error reading configuration file: %s\n", e.what()); | |||||
return false; | return false; | ||||
} | } | ||||
// Check for -testnet or -regtest parameter (Params() calls are only | // Check for -testnet or -regtest parameter (Params() calls are only | ||||
// valid after this clause) | // valid after this clause) | ||||
try { | try { | ||||
SelectParams(gArgs.GetChainName()); | SelectParams(gArgs.GetChainName()); | ||||
} catch (const std::exception &e) { | } catch (const std::exception &e) { | ||||
fprintf(stderr, "Error: %s\n", e.what()); | fprintf(stderr, "Error: %s\n", e.what()); | ||||
▲ Show 20 Lines • Show All 102 Lines • Show Last 20 Lines |