mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-18 12:53:03 +02:00
wallet: Pass ArgsManager into ExecuteWalletToolFunc instead of using global
This commit is contained in:
parent
143bd108ed
commit
fa7dde1c41
@ -120,8 +120,9 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
ECCVerifyHandle globalVerifyHandle;
|
ECCVerifyHandle globalVerifyHandle;
|
||||||
ECC_Start();
|
ECC_Start();
|
||||||
if (!WalletTool::ExecuteWalletToolFunc(method, name))
|
if (!WalletTool::ExecuteWalletToolFunc(gArgs, method, name)) {
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
ECC_Stop();
|
ECC_Stop();
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -103,17 +103,17 @@ static void WalletShowInfo(CWallet* wallet_instance)
|
|||||||
tfm::format(std::cout, "Address Book: %zu\n", wallet_instance->m_address_book.size());
|
tfm::format(std::cout, "Address Book: %zu\n", wallet_instance->m_address_book.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ExecuteWalletToolFunc(const std::string& command, const std::string& name)
|
bool ExecuteWalletToolFunc(const ArgsManager& args, const std::string& command, const std::string& name)
|
||||||
{
|
{
|
||||||
fs::path path = fs::absolute(name, GetWalletDir());
|
fs::path path = fs::absolute(name, GetWalletDir());
|
||||||
|
|
||||||
// -format is only allowed with createfromdump. Disallow it for all other commands.
|
// -format is only allowed with createfromdump. Disallow it for all other commands.
|
||||||
if (gArgs.IsArgSet("-format") && command != "createfromdump") {
|
if (args.IsArgSet("-format") && command != "createfromdump") {
|
||||||
tfm::format(std::cerr, "The -format option can only be used with the \"createfromdump\" command.\n");
|
tfm::format(std::cerr, "The -format option can only be used with the \"createfromdump\" command.\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// -dumpfile is only allowed with dump and createfromdump. Disallow it for all other commands.
|
// -dumpfile is only allowed with dump and createfromdump. Disallow it for all other commands.
|
||||||
if (gArgs.IsArgSet("-dumpfile") && command != "dump" && command != "createfromdump") {
|
if (args.IsArgSet("-dumpfile") && command != "dump" && command != "createfromdump") {
|
||||||
tfm::format(std::cerr, "The -dumpfile option can only be used with the \"dump\" and \"createfromdump\" commands.\n");
|
tfm::format(std::cerr, "The -dumpfile option can only be used with the \"dump\" and \"createfromdump\" commands.\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -121,7 +121,7 @@ bool ExecuteWalletToolFunc(const std::string& command, const std::string& name)
|
|||||||
if (command == "create") {
|
if (command == "create") {
|
||||||
DatabaseOptions options;
|
DatabaseOptions options;
|
||||||
options.require_create = true;
|
options.require_create = true;
|
||||||
if (gArgs.GetBoolArg("-descriptors", false)) {
|
if (args.GetBoolArg("-descriptors", false)) {
|
||||||
options.create_flags |= WALLET_FLAG_DESCRIPTORS;
|
options.create_flags |= WALLET_FLAG_DESCRIPTORS;
|
||||||
options.require_format = DatabaseFormat::SQLITE;
|
options.require_format = DatabaseFormat::SQLITE;
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
namespace WalletTool {
|
namespace WalletTool {
|
||||||
|
|
||||||
void WalletShowInfo(CWallet* wallet_instance);
|
void WalletShowInfo(CWallet* wallet_instance);
|
||||||
bool ExecuteWalletToolFunc(const std::string& command, const std::string& file);
|
bool ExecuteWalletToolFunc(const ArgsManager& args, const std::string& command, const std::string& file);
|
||||||
|
|
||||||
} // namespace WalletTool
|
} // namespace WalletTool
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user