aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/salvage.cpp
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2020-08-25 13:15:50 -0400
committerAndrew Chow <achow101-github@achow101.com>2020-08-25 13:23:40 -0400
commit0bbe26a1af2aab2287b18048f80b3f70e63e0044 (patch)
tree0b2a2b9567679d3eb96c4f877544b05570c0b6e2 /src/wallet/salvage.cpp
parent544e12a4e81633d222574eec253a1ff292d3c4a5 (diff)
wallet: filter for keys only before record deser in salvage
When salvaging a wallet, avoid deserializing any records that we don't care about, i.e. filter for keys only before the deserialization.
Diffstat (limited to 'src/wallet/salvage.cpp')
-rw-r--r--src/wallet/salvage.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/wallet/salvage.cpp b/src/wallet/salvage.cpp
index c0755db751..934e3d5c86 100644
--- a/src/wallet/salvage.cpp
+++ b/src/wallet/salvage.cpp
@@ -16,6 +16,11 @@ static const char *HEADER_END = "HEADER=END";
static const char *DATA_END = "DATA=END";
typedef std::pair<std::vector<unsigned char>, std::vector<unsigned char> > KeyValPair;
+static bool KeyFilter(const std::string& type)
+{
+ return WalletBatch::IsKeyType(type) || type == DBKeys::HDCHAIN;
+}
+
bool RecoverDatabaseFile(const fs::path& file_path, bilingual_str& error, std::vector<bilingual_str>& warnings)
{
std::string filename;
@@ -129,9 +134,9 @@ bool RecoverDatabaseFile(const fs::path& file_path, bilingual_str& error, std::v
{
// Required in LoadKeyMetadata():
LOCK(dummyWallet.cs_wallet);
- fReadOK = ReadKeyValue(&dummyWallet, ssKey, ssValue, strType, strErr);
+ fReadOK = ReadKeyValue(&dummyWallet, ssKey, ssValue, strType, strErr, KeyFilter);
}
- if (!WalletBatch::IsKeyType(strType) && strType != DBKeys::HDCHAIN) {
+ if (!KeyFilter(strType)) {
continue;
}
if (!fReadOK)