Skip to content

Commit 0bbe26a

Browse files
committed
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.
1 parent 544e12a commit 0bbe26a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/wallet/salvage.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ static const char *HEADER_END = "HEADER=END";
1616
static const char *DATA_END = "DATA=END";
1717
typedef std::pair<std::vector<unsigned char>, std::vector<unsigned char> > KeyValPair;
1818

19+
static bool KeyFilter(const std::string& type)
20+
{
21+
return WalletBatch::IsKeyType(type) || type == DBKeys::HDCHAIN;
22+
}
23+
1924
bool RecoverDatabaseFile(const fs::path& file_path, bilingual_str& error, std::vector<bilingual_str>& warnings)
2025
{
2126
std::string filename;
@@ -129,9 +134,9 @@ bool RecoverDatabaseFile(const fs::path& file_path, bilingual_str& error, std::v
129134
{
130135
// Required in LoadKeyMetadata():
131136
LOCK(dummyWallet.cs_wallet);
132-
fReadOK = ReadKeyValue(&dummyWallet, ssKey, ssValue, strType, strErr);
137+
fReadOK = ReadKeyValue(&dummyWallet, ssKey, ssValue, strType, strErr, KeyFilter);
133138
}
134-
if (!WalletBatch::IsKeyType(strType) && strType != DBKeys::HDCHAIN) {
139+
if (!KeyFilter(strType)) {
135140
continue;
136141
}
137142
if (!fReadOK)

0 commit comments

Comments
 (0)