mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-11 13:13:49 +01:00
wallettool: Add createfromdump command
Creates a new wallet file using the dump file produced by the dump command
This commit is contained in:
@@ -107,6 +107,11 @@ bool ExecuteWalletToolFunc(const std::string& command, const std::string& name)
|
||||
{
|
||||
fs::path path = fs::absolute(name, GetWalletDir());
|
||||
|
||||
// -format is only allowed with createfromdump. Disallow it for all other commands.
|
||||
if (gArgs.IsArgSet("-format") && command != "createfromdump") {
|
||||
tfm::format(std::cerr, "The -format option can only be used with the \"createfromdump\" command.\n");
|
||||
return false;
|
||||
}
|
||||
// -dumpfile is only allowed with dump and createfromdump. Disallow it for all other commands.
|
||||
if (gArgs.IsArgSet("-dumpfile") && command != "dump" && command != "createfromdump") {
|
||||
tfm::format(std::cerr, "The -dumpfile option can only be used with the \"dump\" and \"createfromdump\" commands.\n");
|
||||
@@ -164,6 +169,17 @@ bool ExecuteWalletToolFunc(const std::string& command, const std::string& name)
|
||||
}
|
||||
tfm::format(std::cout, "The dumpfile may contain private keys. To ensure the safety of your Bitcoin, do not share the dumpfile.\n");
|
||||
return ret;
|
||||
} else if (command == "createfromdump") {
|
||||
bilingual_str error;
|
||||
std::vector<bilingual_str> warnings;
|
||||
bool ret = CreateFromDump(name, path, error, warnings);
|
||||
for (const auto& warning : warnings) {
|
||||
tfm::format(std::cout, "%s\n", warning.original);
|
||||
}
|
||||
if (!ret && !error.empty()) {
|
||||
tfm::format(std::cerr, "%s\n", error.original);
|
||||
}
|
||||
return ret;
|
||||
} else {
|
||||
tfm::format(std::cerr, "Invalid command: %s\n", command);
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user