| 258 | } |
| 259 | |
| 260 | bool BerkeleyDatabase::Verify(bilingual_str& errorStr) |
| 261 | { |
| 262 | fs::path walletDir = env->Directory(); |
| 263 | fs::path file_path = walletDir / strFile; |
| 264 | |
| 265 | LogPrintf("Using BerkeleyDB version %s\n", BerkeleyDatabaseVersion()); |
| 266 | LogPrintf("Using wallet %s\n", fs::PathToString(file_path)); |
| 267 | |
| 268 | if (!env->Open(errorStr)) { |
| 269 | return false; |
| 270 | } |
| 271 | |
| 272 | if (fs::exists(file_path)) |
| 273 | { |
| 274 | assert(m_refcount == 0); |
| 275 | |
| 276 | Db db(env->dbenv.get(), 0); |
| 277 | int result = db.verify(strFile.c_str(), nullptr, nullptr, 0); |
| 278 | if (result != 0) { |
| 279 | errorStr = strprintf(_("%s corrupt. Try using the wallet tool bitcoin-wallet to salvage or restoring a backup."), fs::quoted(fs::PathToString(file_path))); |
| 280 | return false; |
| 281 | } |
| 282 | } |
| 283 | // also return true if files does not exists |
| 284 | return true; |
| 285 | } |
| 286 | |
| 287 | void BerkeleyEnvironment::CheckpointLSN(const std::string& strFile) |
| 288 | { |