@@ -79,10 +79,10 @@ static int AppInitRPC(int argc, char* argv[])
79
79
//
80
80
// Parameters
81
81
//
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" )) {
84
84
std::string strUsage = strprintf (_ (" %s RPC client version" ), _ (PACKAGE_NAME)) + " " + FormatFullVersion () + " \n " ;
85
- if (!IsArgSet (" -version" )) {
85
+ if (!gArgs . IsArgSet (" -version" )) {
86
86
strUsage += " \n " + _ (" Usage:" ) + " \n " +
87
87
" bitcoin-cli [options] <command> [params] " + strprintf (_ (" Send command to %s" ), _ (PACKAGE_NAME)) + " \n " +
88
88
" 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[])
100
100
return EXIT_SUCCESS;
101
101
}
102
102
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 ());
104
104
return EXIT_FAILURE;
105
105
}
106
106
try {
107
- ReadConfigFile (GetArg (" -conf" , BITCOIN_CONF_FILENAME));
107
+ gArgs . ReadConfigFile (gArgs . GetArg (" -conf" , BITCOIN_CONF_FILENAME));
108
108
} catch (const std::exception& e) {
109
109
fprintf (stderr," Error reading configuration file: %s\n " , e.what ());
110
110
return EXIT_FAILURE;
@@ -116,7 +116,7 @@ static int AppInitRPC(int argc, char* argv[])
116
116
fprintf (stderr, " Error: %s\n " , e.what ());
117
117
return EXIT_FAILURE;
118
118
}
119
- if (GetBoolArg (" -rpcssl" , false ))
119
+ if (gArgs . GetBoolArg (" -rpcssl" , false ))
120
120
{
121
121
fprintf (stderr, " Error: SSL mode for RPC (-rpcssl) is no longer supported.\n " );
122
122
return EXIT_FAILURE;
@@ -198,15 +198,15 @@ UniValue CallRPC(const std::string& strMethod, const UniValue& params)
198
198
// 2. port in -rpcconnect (ie following : in ipv4 or ]: in ipv6)
199
199
// 3. default port for chain
200
200
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);
203
203
204
204
// Obtain event base
205
205
raii_event_base base = obtain_event_base ();
206
206
207
207
// Synchronously look up hostname
208
208
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));
210
210
211
211
HTTPReply response;
212
212
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)
218
218
219
219
// Get credentials
220
220
std::string strRPCUserColonPass;
221
- if (GetArg (" -rpcpassword" , " " ) == " " ) {
221
+ if (gArgs . GetArg (" -rpcpassword" , " " ) == " " ) {
222
222
// Try fall back to cookie-based authentication if no password is provided
223
223
if (!GetAuthCookie (&strRPCUserColonPass)) {
224
224
throw std::runtime_error (strprintf (
225
225
_ (" 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 ()));
227
227
228
228
}
229
229
} else {
230
- strRPCUserColonPass = GetArg (" -rpcuser" , " " ) + " :" + GetArg (" -rpcpassword" , " " );
230
+ strRPCUserColonPass = gArgs . GetArg (" -rpcuser" , " " ) + " :" + gArgs . GetArg (" -rpcpassword" , " " );
231
231
}
232
232
233
233
struct evkeyvalq * output_headers = evhttp_request_get_output_headers (req.get ());
@@ -244,7 +244,7 @@ UniValue CallRPC(const std::string& strMethod, const UniValue& params)
244
244
245
245
// check if we should use a special wallet endpoint
246
246
std::string endpoint = " /" ;
247
- std::string walletName = GetArg (" -rpcwallet" , " " );
247
+ std::string walletName = gArgs . GetArg (" -rpcwallet" , " " );
248
248
if (!walletName.empty ()) {
249
249
char *encodedURI = evhttp_uriencode (walletName.c_str (), walletName.size (), false );
250
250
if (encodedURI) {
@@ -294,7 +294,7 @@ int CommandLineRPC(int argc, char *argv[])
294
294
argv++;
295
295
}
296
296
std::vector<std::string> args = std::vector<std::string>(&argv[1 ], &argv[argc]);
297
- if (GetBoolArg (" -stdin" , false )) {
297
+ if (gArgs . GetBoolArg (" -stdin" , false )) {
298
298
// Read one arg per line from stdin and append
299
299
std::string line;
300
300
while (std::getline (std::cin,line))
@@ -306,14 +306,14 @@ int CommandLineRPC(int argc, char *argv[])
306
306
args.erase (args.begin ()); // Remove trailing method name from arguments vector
307
307
308
308
UniValue params;
309
- if (GetBoolArg (" -named" , DEFAULT_NAMED)) {
309
+ if (gArgs . GetBoolArg (" -named" , DEFAULT_NAMED)) {
310
310
params = RPCConvertNamedValues (strMethod, args);
311
311
} else {
312
312
params = RPCConvertValues (strMethod, args);
313
313
}
314
314
315
315
// Execute and handle connection failures with -rpcwait
316
- const bool fWait = GetBoolArg (" -rpcwait" , false );
316
+ const bool fWait = gArgs . GetBoolArg (" -rpcwait" , false );
317
317
do {
318
318
try {
319
319
const UniValue reply = CallRPC (strMethod, params);
0 commit comments