@@ -79,10 +79,10 @@ static int AppInitRPC(int argc, char* argv[])
//
// Parameters
//
- ParseParameters (argc, argv);
- if (argc<2 || IsArgSet (" -?" ) || IsArgSet (" -h" ) || IsArgSet (" -help" ) || IsArgSet (" -version" )) {
+ gArgs . ParseParameters (argc, argv);
+ if (argc<2 || gArgs . IsArgSet (" -?" ) || gArgs . IsArgSet (" -h" ) || gArgs . IsArgSet (" -help" ) || gArgs . IsArgSet (" -version" )) {
std::string strUsage = strprintf (_ (" %s RPC client version" ), _ (PACKAGE_NAME)) + " " + FormatFullVersion () + " \n " ;
- if (!IsArgSet (" -version" )) {
+ if (!gArgs . IsArgSet (" -version" )) {
strUsage += " \n " + _ (" Usage:" ) + " \n " +
" bitcoin-cli [options] <command> [params] " + strprintf (_ (" Send command to %s" ), _ (PACKAGE_NAME)) + " \n " +
" bitcoin-cli [options] -named <command> [name=value] ... " + strprintf (_ (" Send command to %s (with named arguments)" ), _ (PACKAGE_NAME)) + " \n " +
@@ -100,11 +100,11 @@ static int AppInitRPC(int argc, char* argv[])
return EXIT_SUCCESS;
}
if (!fs::is_directory (GetDataDir (false ))) {
- fprintf (stderr, " Error: Specified data directory \" %s\" does not exist.\n " , GetArg (" -datadir" , " " ).c_str ());
+ fprintf (stderr, " Error: Specified data directory \" %s\" does not exist.\n " , gArgs . GetArg (" -datadir" , " " ).c_str ());
return EXIT_FAILURE;
}
try {
- ReadConfigFile (GetArg (" -conf" , BITCOIN_CONF_FILENAME));
+ gArgs . ReadConfigFile (gArgs . GetArg (" -conf" , BITCOIN_CONF_FILENAME));
} catch (const std::exception& e) {
fprintf (stderr," Error reading configuration file: %s\n " , e.what ());
return EXIT_FAILURE;
@@ -116,7 +116,7 @@ static int AppInitRPC(int argc, char* argv[])
fprintf (stderr, " Error: %s\n " , e.what ());
return EXIT_FAILURE;
}
- if (GetBoolArg (" -rpcssl" , false ))
+ if (gArgs . GetBoolArg (" -rpcssl" , false ))
{
fprintf (stderr, " Error: SSL mode for RPC (-rpcssl) is no longer supported.\n " );
return EXIT_FAILURE;
@@ -198,15 +198,15 @@ UniValue CallRPC(const std::string& strMethod, const UniValue& params)
// 2. port in -rpcconnect (ie following : in ipv4 or ]: in ipv6)
// 3. default port for chain
int port = BaseParams ().RPCPort ();
- SplitHostPort (GetArg (" -rpcconnect" , DEFAULT_RPCCONNECT), port, host);
- port = GetArg (" -rpcport" , port);
+ SplitHostPort (gArgs . GetArg (" -rpcconnect" , DEFAULT_RPCCONNECT), port, host);
+ port = gArgs . GetArg (" -rpcport" , port);
// Obtain event base
raii_event_base base = obtain_event_base ();
// Synchronously look up hostname
raii_evhttp_connection evcon = obtain_evhttp_connection_base (base.get (), host, port);
- evhttp_connection_set_timeout (evcon.get (), GetArg (" -rpcclienttimeout" , DEFAULT_HTTP_CLIENT_TIMEOUT));
+ evhttp_connection_set_timeout (evcon.get (), gArgs . GetArg (" -rpcclienttimeout" , DEFAULT_HTTP_CLIENT_TIMEOUT));
HTTPReply response;
raii_evhttp_request req = obtain_evhttp_request (http_request_done, (void *)&response);
@@ -218,16 +218,16 @@ UniValue CallRPC(const std::string& strMethod, const UniValue& params)
// Get credentials
std::string strRPCUserColonPass;
- if (GetArg (" -rpcpassword" , " " ) == " " ) {
+ if (gArgs . GetArg (" -rpcpassword" , " " ) == " " ) {
// Try fall back to cookie-based authentication if no password is provided
if (!GetAuthCookie (&strRPCUserColonPass)) {
throw std::runtime_error (strprintf (
_ (" Could not locate RPC credentials. No authentication cookie could be found, and no rpcpassword is set in the configuration file (%s)" ),
- GetConfigFile (GetArg (" -conf" , BITCOIN_CONF_FILENAME)).string ().c_str ()));
+ GetConfigFile (gArgs . GetArg (" -conf" , BITCOIN_CONF_FILENAME)).string ().c_str ()));
}
} else {
- strRPCUserColonPass = GetArg (" -rpcuser" , " " ) + " :" + GetArg (" -rpcpassword" , " " );
+ strRPCUserColonPass = gArgs . GetArg (" -rpcuser" , " " ) + " :" + gArgs . GetArg (" -rpcpassword" , " " );
}
struct evkeyvalq * output_headers = evhttp_request_get_output_headers (req.get ());
@@ -244,7 +244,7 @@ UniValue CallRPC(const std::string& strMethod, const UniValue& params)
// check if we should use a special wallet endpoint
std::string endpoint = " /" ;
- std::string walletName = GetArg (" -rpcwallet" , " " );
+ std::string walletName = gArgs . GetArg (" -rpcwallet" , " " );
if (!walletName.empty ()) {
char *encodedURI = evhttp_uriencode (walletName.c_str (), walletName.size (), false );
if (encodedURI) {
@@ -294,7 +294,7 @@ int CommandLineRPC(int argc, char *argv[])
argv++;
}
std::vector<std::string> args = std::vector<std::string>(&argv[1 ], &argv[argc]);
- if (GetBoolArg (" -stdin" , false )) {
+ if (gArgs . GetBoolArg (" -stdin" , false )) {
// Read one arg per line from stdin and append
std::string line;
while (std::getline (std::cin,line))
@@ -306,14 +306,14 @@ int CommandLineRPC(int argc, char *argv[])
args.erase (args.begin ()); // Remove trailing method name from arguments vector
UniValue params;
- if (GetBoolArg (" -named" , DEFAULT_NAMED)) {
+ if (gArgs . GetBoolArg (" -named" , DEFAULT_NAMED)) {
params = RPCConvertNamedValues (strMethod, args);
} else {
params = RPCConvertValues (strMethod, args);
}
// Execute and handle connection failures with -rpcwait
- const bool fWait = GetBoolArg (" -rpcwait" , false );
+ const bool fWait = gArgs . GetBoolArg (" -rpcwait" , false );
do {
try {
const UniValue reply = CallRPC (strMethod, params);