wallettool: Disallow creating new unnamed wallets

This commit is contained in:
Ava Chow
2026-01-06 15:43:29 -08:00
parent 5875a9c502
commit 75b704df9d
3 changed files with 21 additions and 7 deletions

View File

@@ -111,7 +111,7 @@ bool ExecuteWalletToolFunc(const ArgsManager& args, const std::string& command)
tfm::format(std::cerr, "The -dumpfile option can only be used with the \"dump\" and \"createfromdump\" commands.\n");
return false;
}
if (command == "create" && !args.IsArgSet("-wallet")) {
if ((command == "create" || command == "createfromdump") && !args.IsArgSet("-wallet")) {
tfm::format(std::cerr, "Wallet name must be provided when creating a new wallet.\n");
return false;
}
@@ -119,6 +119,10 @@ bool ExecuteWalletToolFunc(const ArgsManager& args, const std::string& command)
const fs::path path = fsbridge::AbsPathJoin(GetWalletDir(), fs::PathFromString(name));
if (command == "create") {
if (name.empty()) {
tfm::format(std::cerr, "Wallet name cannot be empty\n");
return false;
}
DatabaseOptions options;
ReadDatabaseArgs(args, options);
options.require_create = true;