Changeset View
Changeset View
Standalone View
Standalone View
src/bitcoin-cli.cpp
Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | gArgs.AddArg( | ||||
DEFAULT_NAMED), | DEFAULT_NAMED), | ||||
false, OptionsCategory::OPTIONS); | false, OptionsCategory::OPTIONS); | ||||
gArgs.AddArg( | gArgs.AddArg( | ||||
"-rpcconnect=<ip>", | "-rpcconnect=<ip>", | ||||
strprintf(_("Send commands to node running on <ip> (default: %s)"), | strprintf(_("Send commands to node running on <ip> (default: %s)"), | ||||
DEFAULT_RPCCONNECT), | DEFAULT_RPCCONNECT), | ||||
false, OptionsCategory::OPTIONS); | false, OptionsCategory::OPTIONS); | ||||
gArgs.AddArg( | gArgs.AddArg( | ||||
"-rpccookiefile=<loc>", | |||||
_("Location of the auth cookie. Relative paths will be prefixed by a " | |||||
"net-specific datadir location. (default: data dir)"), | |||||
false, OptionsCategory::OPTIONS); | |||||
gArgs.AddArg( | |||||
"-rpcport=<port>", | "-rpcport=<port>", | ||||
strprintf( | strprintf( | ||||
_("Connect to JSON-RPC on <port> (default: %u or testnet: %u)"), | _("Connect to JSON-RPC on <port> (default: %u or testnet: %u)"), | ||||
defaultBaseParams->RPCPort(), testnetBaseParams->RPCPort()), | defaultBaseParams->RPCPort(), testnetBaseParams->RPCPort()), | ||||
false, OptionsCategory::OPTIONS); | false, OptionsCategory::OPTIONS); | ||||
gArgs.AddArg("-rpcwait", _("Wait for RPC server to start"), false, | gArgs.AddArg("-rpcwait", _("Wait for RPC server to start"), false, | ||||
OptionsCategory::OPTIONS); | OptionsCategory::OPTIONS); | ||||
gArgs.AddArg("-rpcuser=<user>", _("Username for JSON-RPC connections"), | gArgs.AddArg("-rpcuser=<user>", _("Username for JSON-RPC connections"), | ||||
Show All 17 Lines | gArgs.AddArg("-stdin", | ||||
"until EOF/Ctrl-D (recommended for sensitive information " | "until EOF/Ctrl-D (recommended for sensitive information " | ||||
"such as passphrases)"), | "such as passphrases)"), | ||||
false, OptionsCategory::OPTIONS); | false, OptionsCategory::OPTIONS); | ||||
gArgs.AddArg( | gArgs.AddArg( | ||||
"-rpcwallet=<walletname>", | "-rpcwallet=<walletname>", | ||||
_("Send RPC for non-default wallet on RPC server (needs to exactly " | _("Send RPC for non-default wallet on RPC server (needs to exactly " | ||||
"match corresponding -wallet option passed to bitcoind)"), | "match corresponding -wallet option passed to bitcoind)"), | ||||
false, OptionsCategory::OPTIONS); | false, OptionsCategory::OPTIONS); | ||||
// Hidden | |||||
gArgs.AddArg("-h", "", false, OptionsCategory::HIDDEN); | |||||
gArgs.AddArg("-help", "", false, OptionsCategory::HIDDEN); | |||||
} | } | ||||
////////////////////////////////////////////////////////////////////////////// | ////////////////////////////////////////////////////////////////////////////// | ||||
// | // | ||||
// Start | // Start | ||||
// | // | ||||
// | // | ||||
Show All 10 Lines | |||||
// This function returns either one of EXIT_ codes when it's expected to stop | // This function returns either one of EXIT_ codes when it's expected to stop | ||||
// the process or CONTINUE_EXECUTION when it's expected to continue further. | // the process or CONTINUE_EXECUTION when it's expected to continue further. | ||||
// | // | ||||
static int AppInitRPC(int argc, char *argv[]) { | static int AppInitRPC(int argc, char *argv[]) { | ||||
// | // | ||||
// Parameters | // Parameters | ||||
// | // | ||||
SetupCliArgs(); | SetupCliArgs(); | ||||
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 EXIT_FAILURE; | |||||
} | |||||
if (argc < 2 || HelpRequested(gArgs) || gArgs.IsArgSet("-version")) { | if (argc < 2 || HelpRequested(gArgs) || gArgs.IsArgSet("-version")) { | ||||
std::string strUsage = | std::string strUsage = | ||||
PACKAGE_NAME " RPC client version " + FormatFullVersion() + "\n"; | PACKAGE_NAME " RPC client version " + FormatFullVersion() + "\n"; | ||||
if (!gArgs.IsArgSet("-version")) { | if (!gArgs.IsArgSet("-version")) { | ||||
strUsage += "\n" | strUsage += "\n" | ||||
"Usage: bitcoin-cli [options] <command> [params] " | "Usage: bitcoin-cli [options] <command> [params] " | ||||
"Send command to " PACKAGE_NAME "\n" | "Send command to " PACKAGE_NAME "\n" | ||||
"or: bitcoin-cli [options] -named <command> " | "or: bitcoin-cli [options] -named <command> " | ||||
Show All 15 Lines | if (argc < 2 || HelpRequested(gArgs) || gArgs.IsArgSet("-version")) { | ||||
return EXIT_SUCCESS; | return EXIT_SUCCESS; | ||||
} | } | ||||
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 EXIT_FAILURE; | return EXIT_FAILURE; | ||||
} | } | ||||
try { | if (!gArgs.ReadConfigFiles(error, true)) { | ||||
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 EXIT_FAILURE; | return EXIT_FAILURE; | ||||
} | } | ||||
// Check for -testnet or -regtest parameter (BaseParams() calls are only | // Check for -testnet or -regtest parameter (BaseParams() calls are only | ||||
// valid after this clause) | // valid after this clause) | ||||
try { | try { | ||||
SelectBaseParams(gArgs.GetChainName()); | SelectBaseParams(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 452 Lines • Show Last 20 Lines |