Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/walletdb.cpp
Show First 20 Lines • Show All 499 Lines • ▼ Show 20 Lines | try { | ||||
ssValue >> strValue; | ssValue >> strValue; | ||||
pwallet->LoadDestData( | pwallet->LoadDestData( | ||||
DecodeDestination(strAddress, pwallet->chainParams), strKey, | DecodeDestination(strAddress, pwallet->chainParams), strKey, | ||||
strValue); | strValue); | ||||
} else if (strType == "hdchain") { | } else if (strType == "hdchain") { | ||||
CHDChain chain; | CHDChain chain; | ||||
ssValue >> chain; | ssValue >> chain; | ||||
pwallet->SetHDChain(chain, true); | pwallet->SetHDChain(chain, true); | ||||
} else if (strType == "flags") { | |||||
uint64_t flags; | |||||
ssValue >> flags; | |||||
if (!pwallet->SetWalletFlags(flags, true)) { | |||||
strErr = "Error reading wallet database: Unknown non-tolerable " | |||||
"wallet flags found"; | |||||
return false; | |||||
} | |||||
} else if (strType != "bestblock" && strType != "bestblock_nomerkle") { | } else if (strType != "bestblock" && strType != "bestblock_nomerkle") { | ||||
wss.m_unknown_records++; | wss.m_unknown_records++; | ||||
} | } | ||||
} catch (...) { | } catch (...) { | ||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | try { | ||||
// Try to be tolerant of single corrupt records: | // Try to be tolerant of single corrupt records: | ||||
std::string strType, strErr; | std::string strType, strErr; | ||||
if (!ReadKeyValue(pwallet, ssKey, ssValue, wss, strType, strErr)) { | if (!ReadKeyValue(pwallet, ssKey, ssValue, wss, strType, strErr)) { | ||||
// losing keys is considered a catastrophic error, anything else | // losing keys is considered a catastrophic error, anything else | ||||
// we assume the user can live with: | // we assume the user can live with: | ||||
if (IsKeyType(strType) || strType == "defaultkey") { | if (IsKeyType(strType) || strType == "defaultkey") { | ||||
result = DBErrors::CORRUPT; | result = DBErrors::CORRUPT; | ||||
} else if (strType == "flags") { | |||||
// Reading the wallet flags can only fail if unknown flags | |||||
// are present. | |||||
result = DBErrors::TOO_NEW; | |||||
} else { | } else { | ||||
// Leave other errors alone, if we try to fix them we might | // Leave other errors alone, if we try to fix them we might | ||||
// make things worse. But do warn the user there is | // make things worse. But do warn the user there is | ||||
// something wrong. | // something wrong. | ||||
fNoncriticalErrors = true; | fNoncriticalErrors = true; | ||||
if (strType == "tx") { | if (strType == "tx") { | ||||
// Rescan if there is a bad transaction record: | // Rescan if there is a bad transaction record: | ||||
gArgs.SoftSetBoolArg("-rescan", true); | gArgs.SoftSetBoolArg("-rescan", true); | ||||
▲ Show 20 Lines • Show All 286 Lines • ▼ Show 20 Lines | return EraseIC(std::make_pair( | ||||
std::string("destdata"), | std::string("destdata"), | ||||
std::make_pair(EncodeLegacyAddr(address, Params()), key))); | std::make_pair(EncodeLegacyAddr(address, Params()), key))); | ||||
} | } | ||||
bool WalletBatch::WriteHDChain(const CHDChain &chain) { | bool WalletBatch::WriteHDChain(const CHDChain &chain) { | ||||
return WriteIC(std::string("hdchain"), chain); | return WriteIC(std::string("hdchain"), chain); | ||||
} | } | ||||
bool WalletBatch::WriteWalletFlags(const uint64_t flags) { | |||||
return WriteIC(std::string("flags"), flags); | |||||
} | |||||
bool WalletBatch::TxnBegin() { | bool WalletBatch::TxnBegin() { | ||||
return m_batch.TxnBegin(); | return m_batch.TxnBegin(); | ||||
} | } | ||||
bool WalletBatch::TxnCommit() { | bool WalletBatch::TxnCommit() { | ||||
return m_batch.TxnCommit(); | return m_batch.TxnCommit(); | ||||
} | } | ||||
Show All 11 Lines |