@@ -268,21 +268,14 @@ BerkeleyEnvironment::BerkeleyEnvironment()
268268 fMockDb = true ;
269269}
270270
271- BerkeleyEnvironment::VerifyResult BerkeleyEnvironment::Verify (const std::string& strFile, recoverFunc_type recoverFunc, std::string& out_backup_filename )
271+ bool BerkeleyEnvironment::Verify (const std::string& strFile)
272272{
273273 LOCK (cs_db);
274274 assert (mapFileUseCount.count (strFile) == 0 );
275275
276276 Db db (dbenv.get (), 0 );
277277 int result = db.verify (strFile.c_str (), nullptr , nullptr , 0 );
278- if (result == 0 )
279- return VerifyResult::VERIFY_OK;
280- else if (recoverFunc == nullptr )
281- return VerifyResult::RECOVER_FAIL;
282-
283- // Try to recover:
284- bool fRecovered = (*recoverFunc)(fs::path (strPath) / strFile, out_backup_filename);
285- return (fRecovered ? VerifyResult::RECOVER_OK : VerifyResult::RECOVER_FAIL);
278+ return result == 0 ;
286279}
287280
288281BerkeleyBatch::SafeDbt::SafeDbt ()
@@ -410,27 +403,16 @@ bool BerkeleyBatch::VerifyEnvironment(const fs::path& file_path, bilingual_str&
410403 return true ;
411404}
412405
413- bool BerkeleyBatch::VerifyDatabaseFile (const fs::path& file_path, std::vector< bilingual_str>& warnings, bilingual_str& errorStr, BerkeleyEnvironment::recoverFunc_type recoverFunc )
406+ bool BerkeleyBatch::VerifyDatabaseFile (const fs::path& file_path, bilingual_str& errorStr)
414407{
415408 std::string walletFile;
416409 std::shared_ptr<BerkeleyEnvironment> env = GetWalletEnv (file_path, walletFile);
417410 fs::path walletDir = env->Directory ();
418411
419412 if (fs::exists (walletDir / walletFile))
420413 {
421- std::string backup_filename;
422- BerkeleyEnvironment::VerifyResult r = env->Verify (walletFile, recoverFunc, backup_filename);
423- if (r == BerkeleyEnvironment::VerifyResult::RECOVER_OK)
424- {
425- warnings.push_back (strprintf (_ (" Warning: Wallet file corrupt, data salvaged!"
426- " Original %s saved as %s in %s; if"
427- " your balance or transactions are incorrect you should"
428- " restore from a backup." ),
429- walletFile, backup_filename, walletDir));
430- }
431- if (r == BerkeleyEnvironment::VerifyResult::RECOVER_FAIL)
432- {
433- errorStr = strprintf (_ (" %s corrupt, salvage failed" ), walletFile);
414+ if (!env->Verify (walletFile)) {
415+ errorStr = strprintf (_ (" %s corrupt. Try using the wallet tool bitcoin-wallet to salvage or restoring a backup." ), walletFile);
434416 return false ;
435417 }
436418 }
0 commit comments