@@ -79,10 +79,10 @@ static int AppInitRPC(int argc, char* argv[])
7979 //
8080 // Parameters
8181 //
82- ParseParameters (argc, argv);
83- if (argc<2 || IsArgSet (" -?" ) || IsArgSet (" -h" ) || IsArgSet (" -help" ) || IsArgSet (" -version" )) {
82+ gArgs . ParseParameters (argc, argv);
83+ if (argc<2 || gArgs . IsArgSet (" -?" ) || gArgs . IsArgSet (" -h" ) || gArgs . IsArgSet (" -help" ) || gArgs . IsArgSet (" -version" )) {
8484 std::string strUsage = strprintf (_ (" %s RPC client version" ), _ (PACKAGE_NAME)) + " " + FormatFullVersion () + " \n " ;
85- if (!IsArgSet (" -version" )) {
85+ if (!gArgs . IsArgSet (" -version" )) {
8686 strUsage += " \n " + _ (" Usage:" ) + " \n " +
8787 " bitcoin-cli [options] <command> [params] " + strprintf (_ (" Send command to %s" ), _ (PACKAGE_NAME)) + " \n " +
8888 " 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[])
100100 return EXIT_SUCCESS;
101101 }
102102 if (!fs::is_directory (GetDataDir (false ))) {
103- fprintf (stderr, " Error: Specified data directory \" %s\" does not exist.\n " , GetArg (" -datadir" , " " ).c_str ());
103+ fprintf (stderr, " Error: Specified data directory \" %s\" does not exist.\n " , gArgs . GetArg (" -datadir" , " " ).c_str ());
104104 return EXIT_FAILURE;
105105 }
106106 try {
107- ReadConfigFile (GetArg (" -conf" , BITCOIN_CONF_FILENAME));
107+ gArgs . ReadConfigFile (gArgs . GetArg (" -conf" , BITCOIN_CONF_FILENAME));
108108 } catch (const std::exception& e) {
109109 fprintf (stderr," Error reading configuration file: %s\n " , e.what ());
110110 return EXIT_FAILURE;
@@ -116,7 +116,7 @@ static int AppInitRPC(int argc, char* argv[])
116116 fprintf (stderr, " Error: %s\n " , e.what ());
117117 return EXIT_FAILURE;
118118 }
119- if (GetBoolArg (" -rpcssl" , false ))
119+ if (gArgs . GetBoolArg (" -rpcssl" , false ))
120120 {
121121 fprintf (stderr, " Error: SSL mode for RPC (-rpcssl) is no longer supported.\n " );
122122 return EXIT_FAILURE;
@@ -198,15 +198,15 @@ UniValue CallRPC(const std::string& strMethod, const UniValue& params)
198198 // 2. port in -rpcconnect (ie following : in ipv4 or ]: in ipv6)
199199 // 3. default port for chain
200200 int port = BaseParams ().RPCPort ();
201- SplitHostPort (GetArg (" -rpcconnect" , DEFAULT_RPCCONNECT), port, host);
202- port = GetArg (" -rpcport" , port);
201+ SplitHostPort (gArgs . GetArg (" -rpcconnect" , DEFAULT_RPCCONNECT), port, host);
202+ port = gArgs . GetArg (" -rpcport" , port);
203203
204204 // Obtain event base
205205 raii_event_base base = obtain_event_base ();
206206
207207 // Synchronously look up hostname
208208 raii_evhttp_connection evcon = obtain_evhttp_connection_base (base.get (), host, port);
209- evhttp_connection_set_timeout (evcon.get (), GetArg (" -rpcclienttimeout" , DEFAULT_HTTP_CLIENT_TIMEOUT));
209+ evhttp_connection_set_timeout (evcon.get (), gArgs . GetArg (" -rpcclienttimeout" , DEFAULT_HTTP_CLIENT_TIMEOUT));
210210
211211 HTTPReply response;
212212 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)
218218
219219 // Get credentials
220220 std::string strRPCUserColonPass;
221- if (GetArg (" -rpcpassword" , " " ) == " " ) {
221+ if (gArgs . GetArg (" -rpcpassword" , " " ) == " " ) {
222222 // Try fall back to cookie-based authentication if no password is provided
223223 if (!GetAuthCookie (&strRPCUserColonPass)) {
224224 throw std::runtime_error (strprintf (
225225 _ (" Could not locate RPC credentials. No authentication cookie could be found, and no rpcpassword is set in the configuration file (%s)" ),
226- GetConfigFile (GetArg (" -conf" , BITCOIN_CONF_FILENAME)).string ().c_str ()));
226+ GetConfigFile (gArgs . GetArg (" -conf" , BITCOIN_CONF_FILENAME)).string ().c_str ()));
227227
228228 }
229229 } else {
230- strRPCUserColonPass = GetArg (" -rpcuser" , " " ) + " :" + GetArg (" -rpcpassword" , " " );
230+ strRPCUserColonPass = gArgs . GetArg (" -rpcuser" , " " ) + " :" + gArgs . GetArg (" -rpcpassword" , " " );
231231 }
232232
233233 struct evkeyvalq * output_headers = evhttp_request_get_output_headers (req.get ());
@@ -244,7 +244,7 @@ UniValue CallRPC(const std::string& strMethod, const UniValue& params)
244244
245245 // check if we should use a special wallet endpoint
246246 std::string endpoint = " /" ;
247- std::string walletName = GetArg (" -rpcwallet" , " " );
247+ std::string walletName = gArgs . GetArg (" -rpcwallet" , " " );
248248 if (!walletName.empty ()) {
249249 char *encodedURI = evhttp_uriencode (walletName.c_str (), walletName.size (), false );
250250 if (encodedURI) {
@@ -294,7 +294,7 @@ int CommandLineRPC(int argc, char *argv[])
294294 argv++;
295295 }
296296 std::vector<std::string> args = std::vector<std::string>(&argv[1 ], &argv[argc]);
297- if (GetBoolArg (" -stdin" , false )) {
297+ if (gArgs . GetBoolArg (" -stdin" , false )) {
298298 // Read one arg per line from stdin and append
299299 std::string line;
300300 while (std::getline (std::cin,line))
@@ -306,14 +306,14 @@ int CommandLineRPC(int argc, char *argv[])
306306 args.erase (args.begin ()); // Remove trailing method name from arguments vector
307307
308308 UniValue params;
309- if (GetBoolArg (" -named" , DEFAULT_NAMED)) {
309+ if (gArgs . GetBoolArg (" -named" , DEFAULT_NAMED)) {
310310 params = RPCConvertNamedValues (strMethod, args);
311311 } else {
312312 params = RPCConvertValues (strMethod, args);
313313 }
314314
315315 // Execute and handle connection failures with -rpcwait
316- const bool fWait = GetBoolArg (" -rpcwait" , false );
316+ const bool fWait = gArgs . GetBoolArg (" -rpcwait" , false );
317317 do {
318318 try {
319319 const UniValue reply = CallRPC (strMethod, params);
0 commit comments