Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/walletdb.cpp
Show First 20 Lines • Show All 501 Lines • ▼ Show 20 Lines | DBErrors WalletBatch::LoadWallet(CWallet *pwallet) { | ||||
// want to make it worse. | // want to make it worse. | ||||
if (result != DBErrors::LOAD_OK) { | if (result != DBErrors::LOAD_OK) { | ||||
return result; | return result; | ||||
} | } | ||||
// Last client version to open this wallet, was previously the file version | // Last client version to open this wallet, was previously the file version | ||||
// number | // number | ||||
int last_client = CLIENT_VERSION; | int last_client = CLIENT_VERSION; | ||||
ReadVersion(last_client); | m_batch.Read(std::string("version"), last_client); | ||||
int wallet_version = pwallet->GetVersion(); | int wallet_version = pwallet->GetVersion(); | ||||
pwallet->WalletLogPrintf("Wallet File Version = %d\n", | pwallet->WalletLogPrintf("Wallet File Version = %d\n", | ||||
wallet_version > 0 ? wallet_version : last_client); | wallet_version > 0 ? wallet_version : last_client); | ||||
pwallet->WalletLogPrintf("Keys: %u plaintext, %u encrypted, %u w/ " | pwallet->WalletLogPrintf("Keys: %u plaintext, %u encrypted, %u w/ " | ||||
"metadata, %u total. Unknown wallet records: %u\n", | "metadata, %u total. Unknown wallet records: %u\n", | ||||
wss.nKeys, wss.nCKeys, wss.nKeyMeta, | wss.nKeys, wss.nCKeys, wss.nKeyMeta, | ||||
Show All 10 Lines | DBErrors WalletBatch::LoadWallet(CWallet *pwallet) { | ||||
// Rewrite encrypted wallets of versions 0.4.0 and 0.5.0rc: | // Rewrite encrypted wallets of versions 0.4.0 and 0.5.0rc: | ||||
if (wss.fIsEncrypted && (last_client == 40000 || last_client == 50000)) { | if (wss.fIsEncrypted && (last_client == 40000 || last_client == 50000)) { | ||||
return DBErrors::NEED_REWRITE; | return DBErrors::NEED_REWRITE; | ||||
} | } | ||||
if (last_client < CLIENT_VERSION) { | if (last_client < CLIENT_VERSION) { | ||||
// Update | // Update | ||||
WriteVersion(CLIENT_VERSION); | m_batch.Write(std::string("version"), CLIENT_VERSION); | ||||
} | } | ||||
if (wss.fAnyUnordered) { | if (wss.fAnyUnordered) { | ||||
result = pwallet->ReorderTransactions(); | result = pwallet->ReorderTransactions(); | ||||
} | } | ||||
// Upgrade all of the wallet keymetadata to have the hd master key id | // Upgrade all of the wallet keymetadata to have the hd master key id | ||||
// This operation is not atomic, but if it fails, updated entries are still | // This operation is not atomic, but if it fails, updated entries are still | ||||
▲ Show 20 Lines • Show All 246 Lines • ▼ Show 20 Lines | |||||
bool WalletBatch::TxnCommit() { | bool WalletBatch::TxnCommit() { | ||||
return m_batch.TxnCommit(); | return m_batch.TxnCommit(); | ||||
} | } | ||||
bool WalletBatch::TxnAbort() { | bool WalletBatch::TxnAbort() { | ||||
return m_batch.TxnAbort(); | return m_batch.TxnAbort(); | ||||
} | } | ||||
bool WalletBatch::ReadVersion(int &nVersion) { | |||||
return m_batch.ReadVersion(nVersion); | |||||
} | |||||
bool WalletBatch::WriteVersion(int nVersion) { | |||||
return m_batch.WriteVersion(nVersion); | |||||
} |