diff options
Diffstat (limited to 'src/wallet/wallettool.cpp')
-rw-r--r-- | src/wallet/wallettool.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/wallet/wallettool.cpp b/src/wallet/wallettool.cpp index 39dad87184..fe3fcb32c2 100644 --- a/src/wallet/wallettool.cpp +++ b/src/wallet/wallettool.cpp @@ -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; |