aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallettool.cpp
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2020-06-01 18:00:22 -0400
committerAndrew Chow <achow101-github@achow101.com>2020-12-16 12:33:06 -0500
commita88c320041bd1cd1786b2dfd9ab698a67c2a57c6 (patch)
tree4068ec0a74df5218029732b74752036afd362c70 /src/wallet/wallettool.cpp
parente1e7a90d5f0616a46ffadd62a9f1c65406cca6b4 (diff)
downloadbitcoin-a88c320041bd1cd1786b2dfd9ab698a67c2a57c6.tar.xz
wallettool: Add createfromdump command
Creates a new wallet file using the dump file produced by the dump command
Diffstat (limited to 'src/wallet/wallettool.cpp')
-rw-r--r--src/wallet/wallettool.cpp16
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;