Skip to content

Commit 06e263a

Browse files
committed
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.
1 parent c7b4968 commit 06e263a

File tree

1 file changed

+1
-22
lines changed

1 file changed

+1
-22
lines changed

src/wallet/wallettool.cpp

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -104,27 +104,6 @@ static void WalletShowInfo(CWallet* wallet_instance)
104104
tfm::format(std::cout, "Address Book: %zu\n", wallet_instance->m_address_book.size());
105105
}
106106

107-
static bool SalvageWallet(const fs::path& path)
108-
{
109-
// Create a Database handle to allow for the db to be initialized before recovery
110-
std::unique_ptr<WalletDatabase> database = CreateWalletDatabase(path);
111-
112-
// Initialize the environment before recovery
113-
bilingual_str error_string;
114-
try {
115-
database->Verify(error_string);
116-
} catch (const fs::filesystem_error& e) {
117-
error_string = Untranslated(strprintf("Error loading wallet. %s", fsbridge::get_filesystem_error_message(e)));
118-
}
119-
if (!error_string.original.empty()) {
120-
tfm::format(std::cerr, "Failed to open wallet for salvage :%s\n", error_string.original);
121-
return false;
122-
}
123-
124-
// Perform the recovery
125-
return RecoverDatabaseFile(path);
126-
}
127-
128107
bool ExecuteWalletToolFunc(const std::string& command, const std::string& name)
129108
{
130109
fs::path path = fs::absolute(name, GetWalletDir());
@@ -147,7 +126,7 @@ bool ExecuteWalletToolFunc(const std::string& command, const std::string& name)
147126
WalletShowInfo(wallet_instance.get());
148127
wallet_instance->Flush(true);
149128
} else if (command == "salvage") {
150-
return SalvageWallet(path);
129+
return RecoverDatabaseFile(path);
151130
}
152131
} else {
153132
tfm::format(std::cerr, "Invalid command: %s\n", command);

0 commit comments

Comments
 (0)