aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2020-07-06 14:32:17 -0400
committerAndrew Chow <achow101-github@achow101.com>2020-07-22 11:55:15 -0400
commit06e263a4e368671ebb4e4a77c1447ebd5104a488 (patch)
tree12c2bf74941e2621907de512aa62140687f57157 /src/wallet
parentc7b4968552c704f1e2e9a046911e1207f5af5fe0 (diff)
downloadbitcoin-06e263a4e368671ebb4e4a77c1447ebd5104a488.tar.xz
Call RecoverDatabaseFile directly from wallettool
When using the salvage command, call RecoverDatabaseFile directly instead of SalvageWallet. Also removes SalvageWallet as it is no longer needed. SalvageWallet was doing an additional verify on the database which would caause the salvage to sometimes fail. This is not needed.
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/wallettool.cpp23
1 files changed, 1 insertions, 22 deletions
diff --git a/src/wallet/wallettool.cpp b/src/wallet/wallettool.cpp
index 8a45d81456..1e699658e4 100644
--- a/src/wallet/wallettool.cpp
+++ b/src/wallet/wallettool.cpp
@@ -104,27 +104,6 @@ static void WalletShowInfo(CWallet* wallet_instance)
tfm::format(std::cout, "Address Book: %zu\n", wallet_instance->m_address_book.size());
}
-static bool SalvageWallet(const fs::path& path)
-{
- // Create a Database handle to allow for the db to be initialized before recovery
- std::unique_ptr<WalletDatabase> database = CreateWalletDatabase(path);
-
- // Initialize the environment before recovery
- bilingual_str error_string;
- try {
- database->Verify(error_string);
- } catch (const fs::filesystem_error& e) {
- error_string = Untranslated(strprintf("Error loading wallet. %s", fsbridge::get_filesystem_error_message(e)));
- }
- if (!error_string.original.empty()) {
- tfm::format(std::cerr, "Failed to open wallet for salvage :%s\n", error_string.original);
- return false;
- }
-
- // Perform the recovery
- return RecoverDatabaseFile(path);
-}
-
bool ExecuteWalletToolFunc(const std::string& command, const std::string& name)
{
fs::path path = fs::absolute(name, GetWalletDir());
@@ -147,7 +126,7 @@ bool ExecuteWalletToolFunc(const std::string& command, const std::string& name)
WalletShowInfo(wallet_instance.get());
wallet_instance->Flush(true);
} else if (command == "salvage") {
- return SalvageWallet(path);
+ return RecoverDatabaseFile(path);
}
} else {
tfm::format(std::cerr, "Invalid command: %s\n", command);