Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/walletdb.cpp
Show First 20 Lines • Show All 251 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
class CWalletScanState { | class CWalletScanState { | ||||
public: | public: | ||||
unsigned int nKeys; | unsigned int nKeys; | ||||
unsigned int nCKeys; | unsigned int nCKeys; | ||||
unsigned int nWatchKeys; | unsigned int nWatchKeys; | ||||
unsigned int nKeyMeta; | unsigned int nKeyMeta; | ||||
unsigned int m_unknown_records; | |||||
bool fIsEncrypted; | bool fIsEncrypted; | ||||
bool fAnyUnordered; | bool fAnyUnordered; | ||||
int nFileVersion; | int nFileVersion; | ||||
std::vector<TxId> vWalletUpgrade; | std::vector<TxId> vWalletUpgrade; | ||||
CWalletScanState() { | CWalletScanState() { | ||||
nKeys = nCKeys = nWatchKeys = nKeyMeta = 0; | nKeys = nCKeys = nWatchKeys = nKeyMeta = m_unknown_records = 0; | ||||
fIsEncrypted = false; | fIsEncrypted = false; | ||||
fAnyUnordered = false; | fAnyUnordered = false; | ||||
nFileVersion = 0; | nFileVersion = 0; | ||||
} | } | ||||
}; | }; | ||||
static bool ReadKeyValue(CWallet *pwallet, CDataStream &ssKey, | static bool ReadKeyValue(CWallet *pwallet, CDataStream &ssKey, | ||||
CDataStream &ssValue, CWalletScanState &wss, | CDataStream &ssValue, CWalletScanState &wss, | ||||
▲ Show 20 Lines • Show All 231 Lines • ▼ Show 20 Lines | try { | ||||
} | } | ||||
} else if (strType == "hdchain") { | } else if (strType == "hdchain") { | ||||
CHDChain chain; | CHDChain chain; | ||||
ssValue >> chain; | ssValue >> chain; | ||||
if (!pwallet->SetHDChain(chain, true)) { | if (!pwallet->SetHDChain(chain, true)) { | ||||
strErr = "Error reading wallet database: SetHDChain failed"; | strErr = "Error reading wallet database: SetHDChain failed"; | ||||
return false; | return false; | ||||
} | } | ||||
} else if (strType != "bestblock" && strType != "bestblock_nomerkle") { | |||||
wss.m_unknown_records++; | |||||
} | } | ||||
} catch (...) { | } catch (...) { | ||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
bool WalletBatch::IsKeyType(const std::string &strType) { | bool WalletBatch::IsKeyType(const std::string &strType) { | ||||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | DBErrors WalletBatch::LoadWallet(CWallet *pwallet) { | ||||
// Any wallet corruption at all: skip any rewriting or upgrading, we don't | // Any wallet corruption at all: skip any rewriting or upgrading, we don't | ||||
// want to make it worse. | // want to make it worse. | ||||
if (result != DBErrors::LOAD_OK) { | if (result != DBErrors::LOAD_OK) { | ||||
return result; | return result; | ||||
} | } | ||||
LogPrintf("nFileVersion = %d\n", wss.nFileVersion); | LogPrintf("nFileVersion = %d\n", wss.nFileVersion); | ||||
LogPrintf("Keys: %u plaintext, %u encrypted, %u w/ metadata, %u total\n", | LogPrintf("Keys: %u plaintext, %u encrypted, %u w/ metadata, %u total. " | ||||
wss.nKeys, wss.nCKeys, wss.nKeyMeta, wss.nKeys + wss.nCKeys); | "Unknown wallet records: %u\n", | ||||
wss.nKeys, wss.nCKeys, wss.nKeyMeta, wss.nKeys + wss.nCKeys, | |||||
wss.m_unknown_records); | |||||
// nTimeFirstKey is only reliable if all keys have metadata | // nTimeFirstKey is only reliable if all keys have metadata | ||||
if ((wss.nKeys + wss.nCKeys + wss.nWatchKeys) != wss.nKeyMeta) { | if ((wss.nKeys + wss.nCKeys + wss.nWatchKeys) != wss.nKeyMeta) { | ||||
pwallet->UpdateTimeFirstKey(1); | pwallet->UpdateTimeFirstKey(1); | ||||
} | } | ||||
for (const TxId &txid : wss.vWalletUpgrade) { | for (const TxId &txid : wss.vWalletUpgrade) { | ||||
WriteTx(pwallet->mapWallet.at(txid)); | WriteTx(pwallet->mapWallet.at(txid)); | ||||
▲ Show 20 Lines • Show All 275 Lines • Show Last 20 Lines |