@@ -40,52 +40,53 @@ static void SetupWalletToolArgs(ArgsManager& argsman)
40
40
argsman.AddArg (" createfromdump" , " Create new wallet file from dumped records" , ArgsManager::ALLOW_ANY, OptionsCategory::COMMANDS);
41
41
}
42
42
43
- static bool WalletAppInit (int argc, char * argv[])
43
+ static bool WalletAppInit (ArgsManager& args, int argc, char * argv[])
44
44
{
45
- SetupWalletToolArgs (gArgs );
45
+ SetupWalletToolArgs (args );
46
46
std::string error_message;
47
- if (!gArgs .ParseParameters (argc, argv, error_message)) {
47
+ if (!args .ParseParameters (argc, argv, error_message)) {
48
48
tfm::format (std::cerr, " Error parsing command line arguments: %s\n " , error_message);
49
49
return false ;
50
50
}
51
- if (argc < 2 || HelpRequested (gArgs ) || gArgs .IsArgSet (" -version" )) {
51
+ if (argc < 2 || HelpRequested (args ) || args .IsArgSet (" -version" )) {
52
52
std::string strUsage = strprintf (" %s bitcoin-wallet version" , PACKAGE_NAME) + " " + FormatFullVersion () + " \n " ;
53
- if (!gArgs .IsArgSet (" -version" )) {
54
- strUsage += " \n "
55
- " bitcoin-wallet is an offline tool for creating and interacting with " PACKAGE_NAME " wallet files.\n "
56
- " By default bitcoin-wallet will act on wallets in the default mainnet wallet directory in the datadir.\n "
57
- " To change the target wallet, use the -datadir, -wallet and -testnet/-regtest arguments.\n\n "
58
- " Usage:\n "
59
- " bitcoin-wallet [options] <command>\n " ;
60
- strUsage += " \n " + gArgs .GetHelpMessage ();
61
- }
53
+ if (!args .IsArgSet (" -version" )) {
54
+ strUsage += " \n "
55
+ " bitcoin-wallet is an offline tool for creating and interacting with " PACKAGE_NAME " wallet files.\n "
56
+ " By default bitcoin-wallet will act on wallets in the default mainnet wallet directory in the datadir.\n "
57
+ " To change the target wallet, use the -datadir, -wallet and -testnet/-regtest arguments.\n\n "
58
+ " Usage:\n "
59
+ " bitcoin-wallet [options] <command>\n " ;
60
+ strUsage += " \n " + args .GetHelpMessage ();
61
+ }
62
62
tfm::format (std::cout, " %s" , strUsage);
63
63
return false ;
64
64
}
65
65
66
66
// check for printtoconsole, allow -debug
67
- LogInstance ().m_print_to_console = gArgs .GetBoolArg (" -printtoconsole" , gArgs .GetBoolArg (" -debug" , false ));
67
+ LogInstance ().m_print_to_console = args .GetBoolArg (" -printtoconsole" , args .GetBoolArg (" -debug" , false ));
68
68
69
69
if (!CheckDataDirOption ()) {
70
- tfm::format (std::cerr, " Error: Specified data directory \" %s\" does not exist.\n " , gArgs .GetArg (" -datadir" , " " ));
70
+ tfm::format (std::cerr, " Error: Specified data directory \" %s\" does not exist.\n " , args .GetArg (" -datadir" , " " ));
71
71
return false ;
72
72
}
73
73
// Check for chain settings (Params() calls are only valid after this clause)
74
- SelectParams (gArgs .GetChainName ());
74
+ SelectParams (args .GetChainName ());
75
75
76
76
return true ;
77
77
}
78
78
79
79
int main (int argc, char * argv[])
80
80
{
81
+ ArgsManager& args = gArgs ;
81
82
#ifdef WIN32
82
83
util::WinCmdLineArgs winArgs;
83
84
std::tie (argc, argv) = winArgs.get ();
84
85
#endif
85
86
SetupEnvironment ();
86
87
RandomInit ();
87
88
try {
88
- if (!WalletAppInit (argc, argv)) return EXIT_FAILURE;
89
+ if (!WalletAppInit (args, argc, argv)) return EXIT_FAILURE;
89
90
} catch (const std::exception& e) {
90
91
PrintExceptionContinue (&e, " WalletAppInit()" );
91
92
return EXIT_FAILURE;
@@ -111,16 +112,16 @@ int main(int argc, char* argv[])
111
112
}
112
113
113
114
// A name must be provided when creating a file
114
- if (method == " create" && !gArgs .IsArgSet (" -wallet" )) {
115
+ if (method == " create" && !args .IsArgSet (" -wallet" )) {
115
116
tfm::format (std::cerr, " Wallet name must be provided when creating a new wallet.\n " );
116
117
return EXIT_FAILURE;
117
118
}
118
119
119
- std::string name = gArgs .GetArg (" -wallet" , " " );
120
+ std::string name = args .GetArg (" -wallet" , " " );
120
121
121
122
ECCVerifyHandle globalVerifyHandle;
122
123
ECC_Start ();
123
- if (!WalletTool::ExecuteWalletToolFunc (gArgs , method, name)) {
124
+ if (!WalletTool::ExecuteWalletToolFunc (args , method, name)) {
124
125
return EXIT_FAILURE;
125
126
}
126
127
ECC_Stop ();
0 commit comments