@@ -143,7 +143,7 @@ void CDBEnv::MakeMock()
143143 fMockDb = true ;
144144}
145145
146- CDBEnv::VerifyResult CDBEnv::Verify (const std::string& strFile, bool (* recoverFunc)( const std::string& strFile) )
146+ CDBEnv::VerifyResult CDBEnv::Verify (const std::string& strFile, recoverFunc_type recoverFunc, std::string& out_backup_filename )
147147{
148148 LOCK (cs_db);
149149 assert (mapFileUseCount.count (strFile) == 0 );
@@ -156,11 +156,11 @@ CDBEnv::VerifyResult CDBEnv::Verify(const std::string& strFile, bool (*recoverFu
156156 return RECOVER_FAIL;
157157
158158 // Try to recover:
159- bool fRecovered = (*recoverFunc)(strFile);
159+ bool fRecovered = (*recoverFunc)(strFile, out_backup_filename );
160160 return (fRecovered ? RECOVER_OK : RECOVER_FAIL);
161161}
162162
163- bool CDB::Recover (const std::string& filename, void *callbackDataIn, bool (*recoverKVcallback)(void * callbackData, CDataStream ssKey, CDataStream ssValue))
163+ bool CDB::Recover (const std::string& filename, void *callbackDataIn, bool (*recoverKVcallback)(void * callbackData, CDataStream ssKey, CDataStream ssValue), std::string& newFilename )
164164{
165165 // Recovery procedure:
166166 // move wallet file to wallet.timestamp.bak
@@ -170,7 +170,7 @@ bool CDB::Recover(const std::string& filename, void *callbackDataIn, bool (*reco
170170 // Set -rescan so any missing transactions will be
171171 // found.
172172 int64_t now = GetTime ();
173- std::string newFilename = strprintf (" wallet.%d.bak" , now);
173+ newFilename = strprintf (" wallet.%d.bak" , now);
174174
175175 int result = bitdb.dbenv ->dbrename (NULL , filename.c_str (), NULL ,
176176 newFilename.c_str (), DB_AUTO_COMMIT);
@@ -261,18 +261,19 @@ bool CDB::VerifyEnvironment(const std::string& walletFile, const fs::path& dataD
261261 return true ;
262262}
263263
264- bool CDB::VerifyDatabaseFile (const std::string& walletFile, const fs::path& dataDir, std::string& warningStr, std::string& errorStr, bool (*recoverFunc)( const std::string& strFile) )
264+ bool CDB::VerifyDatabaseFile (const std::string& walletFile, const fs::path& dataDir, std::string& warningStr, std::string& errorStr, CDBEnv::recoverFunc_type recoverFunc )
265265{
266266 if (fs::exists (dataDir / walletFile))
267267 {
268- CDBEnv::VerifyResult r = bitdb.Verify (walletFile, recoverFunc);
268+ std::string backup_filename;
269+ CDBEnv::VerifyResult r = bitdb.Verify (walletFile, recoverFunc, backup_filename);
269270 if (r == CDBEnv::RECOVER_OK)
270271 {
271272 warningStr = strprintf (_ (" Warning: Wallet file corrupt, data salvaged!"
272273 " Original %s saved as %s in %s; if"
273274 " your balance or transactions are incorrect you should"
274275 " restore from a backup." ),
275- walletFile, " wallet.{timestamp}.bak " , dataDir);
276+ walletFile, backup_filename , dataDir);
276277 }
277278 if (r == CDBEnv::RECOVER_FAIL)
278279 {
0 commit comments