Skip to content

Commit 2741774

Browse files
committed
Expose a version of ReadKeyValue and use it in RecoverKeysOnlyFilter
We need this exposed for BerkeleyBatch::Recover to be moved out.
1 parent ced95d0 commit 2741774

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/wallet/walletdb.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,13 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
588588
return true;
589589
}
590590

591+
bool ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, std::string& strType, std::string& strErr)
592+
{
593+
CWalletScanState dummy_wss;
594+
LOCK(pwallet->cs_wallet);
595+
return ReadKeyValue(pwallet, ssKey, ssValue, dummy_wss, strType, strErr);
596+
}
597+
591598
bool WalletBatch::IsKeyType(const std::string& strType)
592599
{
593600
return (strType == DBKeys::KEY ||
@@ -896,14 +903,12 @@ bool WalletBatch::Recover(const fs::path& wallet_path, std::string& out_backup_f
896903
bool WalletBatch::RecoverKeysOnlyFilter(void *callbackData, CDataStream ssKey, CDataStream ssValue)
897904
{
898905
CWallet *dummyWallet = reinterpret_cast<CWallet*>(callbackData);
899-
CWalletScanState dummyWss;
900906
std::string strType, strErr;
901907
bool fReadOK;
902908
{
903909
// Required in LoadKeyMetadata():
904910
LOCK(dummyWallet->cs_wallet);
905-
fReadOK = ReadKeyValue(dummyWallet, ssKey, ssValue,
906-
dummyWss, strType, strErr);
911+
fReadOK = ReadKeyValue(dummyWallet, ssKey, ssValue, strType, strErr);
907912
}
908913
if (!IsKeyType(strType) && strType != DBKeys::HDCHAIN) {
909914
return false;

src/wallet/walletdb.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,4 +294,7 @@ class WalletBatch
294294
//! Compacts BDB state so that wallet.dat is self-contained (if there are changes)
295295
void MaybeCompactWalletDB();
296296

297+
//! Unserialize a given Key-Value pair and load it into the wallet
298+
bool ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, std::string& strType, std::string& strErr);
299+
297300
#endif // BITCOIN_WALLET_WALLETDB_H

0 commit comments

Comments
 (0)