Changeset View
Changeset View
Standalone View
Standalone View
src/bitcoin-wallet.cpp
Show First 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | static void SetupWalletToolArgs() { | ||||
gArgs.AddArg("-help", "", ArgsManager::ALLOW_ANY, OptionsCategory::HIDDEN); | gArgs.AddArg("-help", "", ArgsManager::ALLOW_ANY, OptionsCategory::HIDDEN); | ||||
} | } | ||||
static bool WalletAppInit(int argc, char *argv[]) { | static bool WalletAppInit(int argc, char *argv[]) { | ||||
SetupWalletToolArgs(); | SetupWalletToolArgs(); | ||||
std::string error_message; | std::string error_message; | ||||
if (!gArgs.ParseParameters(argc, argv, error_message)) { | if (!gArgs.ParseParameters(argc, argv, error_message)) { | ||||
tfm::format(std::cerr, "Error parsing command line arguments: %s\n", | tfm::format(std::cerr, "Error parsing command line arguments: %s\n", | ||||
error_message.c_str()); | error_message); | ||||
return false; | return false; | ||||
} | } | ||||
if (argc < 2 || HelpRequested(gArgs)) { | if (argc < 2 || HelpRequested(gArgs)) { | ||||
std::string usage = | std::string usage = | ||||
strprintf("%s bitcoin-wallet version", PACKAGE_NAME) + " " + | strprintf("%s bitcoin-wallet version", PACKAGE_NAME) + " " + | ||||
FormatFullVersion() + "\n\n" + | FormatFullVersion() + "\n\n" + | ||||
"wallet-tool is an offline tool for creating and interacting with " | "wallet-tool is an offline tool for creating and interacting with " | ||||
"Bitcoin ABC wallet files.\n" + | "Bitcoin ABC wallet files.\n" + | ||||
"By default wallet-tool will act on wallets in the default mainnet " | "By default wallet-tool will act on wallets in the default mainnet " | ||||
"wallet directory in the datadir.\n" + | "wallet directory in the datadir.\n" + | ||||
"To change the target wallet, use the -datadir, -wallet and " | "To change the target wallet, use the -datadir, -wallet and " | ||||
"-testnet/-regtest arguments.\n\n" + | "-testnet/-regtest arguments.\n\n" + | ||||
"Usage:\n" + " bitcoin-wallet [options] <command>\n\n" + | "Usage:\n" + " bitcoin-wallet [options] <command>\n\n" + | ||||
gArgs.GetHelpMessage(); | gArgs.GetHelpMessage(); | ||||
tfm::format(std::cout, "%s", usage.c_str()); | tfm::format(std::cout, "%s", usage); | ||||
return false; | return false; | ||||
} | } | ||||
// check for printtoconsole, allow -debug | // check for printtoconsole, allow -debug | ||||
LogInstance().m_print_to_console = | LogInstance().m_print_to_console = | ||||
gArgs.GetBoolArg("-printtoconsole", gArgs.GetBoolArg("-debug", false)); | gArgs.GetBoolArg("-printtoconsole", gArgs.GetBoolArg("-debug", false)); | ||||
if (!CheckDataDirOption()) { | if (!CheckDataDirOption()) { | ||||
tfm::format(std::cerr, | tfm::format(std::cerr, | ||||
"Error: Specified data directory \"%s\" does not exist.\n", | "Error: Specified data directory \"%s\" does not exist.\n", | ||||
gArgs.GetArg("-datadir", "").c_str()); | gArgs.GetArg("-datadir", "")); | ||||
return false; | return false; | ||||
} | } | ||||
// Check for -testnet or -regtest parameter (Params() calls are only valid | // Check for -testnet or -regtest parameter (Params() calls are only valid | ||||
// after this clause) | // after this clause) | ||||
SelectParams(gArgs.GetChainName()); | SelectParams(gArgs.GetChainName()); | ||||
return true; | return true; | ||||
} | } | ||||
Show All 19 Lines | #endif | ||||
std::string method{}; | std::string method{}; | ||||
for (int i = 1; i < argc; ++i) { | for (int i = 1; i < argc; ++i) { | ||||
if (!IsSwitchChar(argv[i][0])) { | if (!IsSwitchChar(argv[i][0])) { | ||||
if (!method.empty()) { | if (!method.empty()) { | ||||
tfm::format(std::cerr, | tfm::format(std::cerr, | ||||
"Error: two methods provided (%s and %s). Only one " | "Error: two methods provided (%s and %s). Only one " | ||||
"method should be provided.\n", | "method should be provided.\n", | ||||
method.c_str(), argv[i]); | method, argv[i]); | ||||
return EXIT_FAILURE; | return EXIT_FAILURE; | ||||
} | } | ||||
method = argv[i]; | method = argv[i]; | ||||
} | } | ||||
} | } | ||||
if (method.empty()) { | if (method.empty()) { | ||||
tfm::format(std::cerr, | tfm::format(std::cerr, | ||||
Show All 23 Lines |