mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-05 18:23:03 +01:00
Expose a version of ReadKeyValue and use it in RecoverKeysOnlyFilter
We need this exposed for BerkeleyBatch::Recover to be moved out.
This commit is contained in:
@@ -588,6 +588,13 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, std::string& strType, std::string& strErr)
|
||||||
|
{
|
||||||
|
CWalletScanState dummy_wss;
|
||||||
|
LOCK(pwallet->cs_wallet);
|
||||||
|
return ReadKeyValue(pwallet, ssKey, ssValue, dummy_wss, strType, strErr);
|
||||||
|
}
|
||||||
|
|
||||||
bool WalletBatch::IsKeyType(const std::string& strType)
|
bool WalletBatch::IsKeyType(const std::string& strType)
|
||||||
{
|
{
|
||||||
return (strType == DBKeys::KEY ||
|
return (strType == DBKeys::KEY ||
|
||||||
@@ -896,14 +903,12 @@ bool WalletBatch::Recover(const fs::path& wallet_path, std::string& out_backup_f
|
|||||||
bool WalletBatch::RecoverKeysOnlyFilter(void *callbackData, CDataStream ssKey, CDataStream ssValue)
|
bool WalletBatch::RecoverKeysOnlyFilter(void *callbackData, CDataStream ssKey, CDataStream ssValue)
|
||||||
{
|
{
|
||||||
CWallet *dummyWallet = reinterpret_cast<CWallet*>(callbackData);
|
CWallet *dummyWallet = reinterpret_cast<CWallet*>(callbackData);
|
||||||
CWalletScanState dummyWss;
|
|
||||||
std::string strType, strErr;
|
std::string strType, strErr;
|
||||||
bool fReadOK;
|
bool fReadOK;
|
||||||
{
|
{
|
||||||
// Required in LoadKeyMetadata():
|
// Required in LoadKeyMetadata():
|
||||||
LOCK(dummyWallet->cs_wallet);
|
LOCK(dummyWallet->cs_wallet);
|
||||||
fReadOK = ReadKeyValue(dummyWallet, ssKey, ssValue,
|
fReadOK = ReadKeyValue(dummyWallet, ssKey, ssValue, strType, strErr);
|
||||||
dummyWss, strType, strErr);
|
|
||||||
}
|
}
|
||||||
if (!IsKeyType(strType) && strType != DBKeys::HDCHAIN) {
|
if (!IsKeyType(strType) && strType != DBKeys::HDCHAIN) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -294,4 +294,7 @@ private:
|
|||||||
//! Compacts BDB state so that wallet.dat is self-contained (if there are changes)
|
//! Compacts BDB state so that wallet.dat is self-contained (if there are changes)
|
||||||
void MaybeCompactWalletDB();
|
void MaybeCompactWalletDB();
|
||||||
|
|
||||||
|
//! Unserialize a given Key-Value pair and load it into the wallet
|
||||||
|
bool ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, std::string& strType, std::string& strErr);
|
||||||
|
|
||||||
#endif // BITCOIN_WALLET_WALLETDB_H
|
#endif // BITCOIN_WALLET_WALLETDB_H
|
||||||
|
|||||||
Reference in New Issue
Block a user