wallettool: Have RecoverDatabaseFile return errors and warnings

Instead of logging or printing these errors and warnings, return them to
the caller.
This commit is contained in:
Andrew Chow
2020-07-06 14:34:49 -04:00
parent 06e263a4e3
commit 9f536d4fe9
3 changed files with 26 additions and 18 deletions

View File

@@ -126,7 +126,18 @@ bool ExecuteWalletToolFunc(const std::string& command, const std::string& name)
WalletShowInfo(wallet_instance.get());
wallet_instance->Flush(true);
} else if (command == "salvage") {
return RecoverDatabaseFile(path);
bilingual_str error;
std::vector<bilingual_str> warnings;
bool ret = RecoverDatabaseFile(path, error, warnings);
if (!ret) {
for (const auto warning : warnings) {
tfm::format(std::cerr, "%s\n", warning.original);
}
if (!error.empty()) {
tfm::format(std::cerr, "%s\n", error.original);
}
}
return ret;
}
} else {
tfm::format(std::cerr, "Invalid command: %s\n", command);