Changeset View
Changeset View
Standalone View
Standalone View
src/bitcoin-cli.cpp
Show All 31 Lines | |||||
static const int CONTINUE_EXECUTION = -1; | static const int CONTINUE_EXECUTION = -1; | ||||
static void SetupCliArgs() { | static void SetupCliArgs() { | ||||
const auto defaultBaseParams = | const auto defaultBaseParams = | ||||
CreateBaseChainParams(CBaseChainParams::MAIN); | CreateBaseChainParams(CBaseChainParams::MAIN); | ||||
const auto testnetBaseParams = | const auto testnetBaseParams = | ||||
CreateBaseChainParams(CBaseChainParams::TESTNET); | CreateBaseChainParams(CBaseChainParams::TESTNET); | ||||
gArgs.AddArg("-?", _("This help message"), false, OptionsCategory::OPTIONS); | gArgs.AddArg("-?", "This help message", false, OptionsCategory::OPTIONS); | ||||
gArgs.AddArg("-version", "Print version and exit", false, | gArgs.AddArg("-version", "Print version and exit", false, | ||||
OptionsCategory::OPTIONS); | OptionsCategory::OPTIONS); | ||||
gArgs.AddArg("-conf=<file>", | gArgs.AddArg("-conf=<file>", | ||||
strprintf(_("Specify configuration file. Relative paths will " | strprintf("Specify configuration file. Relative paths will be " | ||||
"be prefixed by datadir location. (default: %s)"), | "prefixed by datadir location. (default: %s)", | ||||
BITCOIN_CONF_FILENAME), | BITCOIN_CONF_FILENAME), | ||||
false, OptionsCategory::OPTIONS); | false, OptionsCategory::OPTIONS); | ||||
gArgs.AddArg("-datadir=<dir>", _("Specify data directory"), false, | gArgs.AddArg("-datadir=<dir>", _("Specify data directory"), false, | ||||
OptionsCategory::OPTIONS); | OptionsCategory::OPTIONS); | ||||
gArgs.AddArg( | gArgs.AddArg( | ||||
"-getinfo", | "-getinfo", | ||||
_("Get general information from the remote server. Note that unlike " | "Get general information from the remote server. Note that unlike " | ||||
"server-side RPC calls, the results of -getinfo is the result of " | "server-side RPC calls, the results of -getinfo is the result of " | ||||
"multiple non-atomic requests. Some entries in the result may " | "multiple non-atomic requests. Some entries in the result may " | ||||
"represent results from different states (e.g. wallet balance may be " | "represent results from different states (e.g. wallet balance may be " | ||||
"as of a different block from the chain state reported)"), | "as of a different block from the chain state reported)", | ||||
false, OptionsCategory::OPTIONS); | false, OptionsCategory::OPTIONS); | ||||
SetupChainParamsBaseOptions(); | SetupChainParamsBaseOptions(); | ||||
gArgs.AddArg( | gArgs.AddArg( | ||||
"-named", | "-named", | ||||
strprintf(_("Pass named instead of positional arguments (default: %s)"), | strprintf("Pass named instead of positional arguments (default: %s)", | ||||
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>", | ||||
"-rpccookiefile=<loc>", | "Location of the auth cookie. Relative paths will be prefixed " | ||||
_("Location of the auth cookie. Relative paths will be prefixed by a " | "by a net-specific datadir location. (default: data dir)", | ||||
"net-specific datadir location. (default: data dir)"), | |||||
false, OptionsCategory::OPTIONS); | false, OptionsCategory::OPTIONS); | ||||
gArgs.AddArg( | 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", false, | ||||
false, OptionsCategory::OPTIONS); | OptionsCategory::OPTIONS); | ||||
gArgs.AddArg("-rpcpassword=<pw>", _("Password for JSON-RPC connections"), | gArgs.AddArg("-rpcpassword=<pw>", "Password for JSON-RPC connections", | ||||
false, OptionsCategory::OPTIONS); | false, OptionsCategory::OPTIONS); | ||||
gArgs.AddArg("-rpcclienttimeout=<n>", | gArgs.AddArg("-rpcclienttimeout=<n>", | ||||
strprintf(_("Timeout in seconds during HTTP requests, or 0 " | strprintf("Timeout in seconds during HTTP requests, or 0 for " | ||||
"for no timeout. (default: %d)"), | "no timeout. (default: %d)", | ||||
DEFAULT_HTTP_CLIENT_TIMEOUT), | DEFAULT_HTTP_CLIENT_TIMEOUT), | ||||
false, OptionsCategory::OPTIONS); | false, OptionsCategory::OPTIONS); | ||||
gArgs.AddArg( | gArgs.AddArg("-stdinrpcpass", | ||||
"-stdinrpcpass", | strprintf("Read RPC password from standard input as a single " | ||||
strprintf(_("Read RPC password from standard input as a single line. " | "line. When combined with -stdin, the first line " | ||||
"When combined with -stdin, the first line from standard " | "from standard input is used for the RPC password."), | ||||
"input is used for the RPC password.")), | |||||
false, OptionsCategory::OPTIONS); | false, OptionsCategory::OPTIONS); | ||||
gArgs.AddArg("-stdin", | gArgs.AddArg("-stdin", | ||||
_("Read extra arguments from standard input, one per line " | "Read extra arguments from standard input, one per line until " | ||||
"until EOF/Ctrl-D (recommended for sensitive information " | "EOF/Ctrl-D (recommended for sensitive information such as " | ||||
"such as passphrases)"), | "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 " | ||||
"match corresponding -wallet option passed to bitcoind)"), | "corresponding -wallet option passed to bitcoind)", | ||||
false, OptionsCategory::OPTIONS); | false, OptionsCategory::OPTIONS); | ||||
// Hidden | // Hidden | ||||
gArgs.AddArg("-h", "", false, OptionsCategory::HIDDEN); | gArgs.AddArg("-h", "", false, OptionsCategory::HIDDEN); | ||||
gArgs.AddArg("-help", "", false, OptionsCategory::HIDDEN); | gArgs.AddArg("-help", "", false, OptionsCategory::HIDDEN); | ||||
} | } | ||||
/** libevent event log callback */ | /** libevent event log callback */ | ||||
▲ Show 20 Lines • Show All 351 Lines • ▼ Show 20 Lines | if (response.status == 0) { | ||||
throw CConnectionFailed( | throw CConnectionFailed( | ||||
strprintf("Could not connect to the server %s:%d%s\n\nMake sure " | strprintf("Could not connect to the server %s:%d%s\n\nMake sure " | ||||
"the bitcoind server is running and that you are " | "the bitcoind server is running and that you are " | ||||
"connecting to the correct RPC port.", | "connecting to the correct RPC port.", | ||||
host, port, responseErrorMessage)); | host, port, responseErrorMessage)); | ||||
} else if (response.status == HTTP_UNAUTHORIZED) { | } else if (response.status == HTTP_UNAUTHORIZED) { | ||||
if (failedToGetAuthCookie) { | if (failedToGetAuthCookie) { | ||||
throw std::runtime_error(strprintf( | throw std::runtime_error(strprintf( | ||||
_("Could not locate RPC credentials. No authentication cookie " | "Could not locate RPC credentials. No authentication cookie " | ||||
"could be found, and RPC password is not set. See " | "could be found, and RPC password is not set. See " | ||||
"-rpcpassword and -stdinrpcpass. Configuration file: (%s)"), | "-rpcpassword and -stdinrpcpass. Configuration file: (%s)", | ||||
GetConfigFile(gArgs.GetArg("-conf", BITCOIN_CONF_FILENAME)) | GetConfigFile(gArgs.GetArg("-conf", BITCOIN_CONF_FILENAME)) | ||||
.string() | .string() | ||||
.c_str())); | .c_str())); | ||||
} else { | } else { | ||||
throw std::runtime_error( | throw std::runtime_error( | ||||
"Authorization failed: Incorrect rpcuser or rpcpassword"); | "Authorization failed: Incorrect rpcuser or rpcpassword"); | ||||
} | } | ||||
} else if (response.status >= 400 && response.status != HTTP_BAD_REQUEST && | } else if (response.status >= 400 && response.status != HTTP_BAD_REQUEST && | ||||
▲ Show 20 Lines • Show All 170 Lines • Show Last 20 Lines |