|
24 | 24 | #include "util.h"
|
25 | 25 | #include "utilmoneystr.h"
|
26 | 26 | #ifdef ENABLE_WALLET
|
27 |
| -#include "wallet/db.h" |
28 | 27 | #include "wallet/wallet.h"
|
29 | 28 | #include "wallet/walletdb.h"
|
30 | 29 | #endif
|
@@ -151,7 +150,7 @@ void Shutdown()
|
151 | 150 | StopRPCThreads();
|
152 | 151 | #ifdef ENABLE_WALLET
|
153 | 152 | if (pwalletMain)
|
154 |
| - bitdb.Flush(false); |
| 153 | + pwalletMain->Flush(false); |
155 | 154 | GenerateBitcoins(false, NULL, 0);
|
156 | 155 | #endif
|
157 | 156 | StopNode();
|
@@ -184,7 +183,7 @@ void Shutdown()
|
184 | 183 | }
|
185 | 184 | #ifdef ENABLE_WALLET
|
186 | 185 | if (pwalletMain)
|
187 |
| - bitdb.Flush(true); |
| 186 | + pwalletMain->Flush(true); |
188 | 187 | #endif
|
189 | 188 | #ifndef WIN32
|
190 | 189 | boost::filesystem::remove(GetPidFile());
|
@@ -852,47 +851,17 @@ bool AppInit2(boost::thread_group& threadGroup)
|
852 | 851 | LogPrintf("Using wallet %s\n", strWalletFile);
|
853 | 852 | uiInterface.InitMessage(_("Verifying wallet..."));
|
854 | 853 |
|
855 |
| - if (!bitdb.Open(GetDataDir())) |
856 |
| - { |
857 |
| - // try moving the database env out of the way |
858 |
| - boost::filesystem::path pathDatabase = GetDataDir() / "database"; |
859 |
| - boost::filesystem::path pathDatabaseBak = GetDataDir() / strprintf("database.%d.bak", GetTime()); |
860 |
| - try { |
861 |
| - boost::filesystem::rename(pathDatabase, pathDatabaseBak); |
862 |
| - LogPrintf("Moved old %s to %s. Retrying.\n", pathDatabase.string(), pathDatabaseBak.string()); |
863 |
| - } catch (const boost::filesystem::filesystem_error&) { |
864 |
| - // failure is ok (well, not really, but it's not worse than what we started with) |
865 |
| - } |
866 |
| - |
867 |
| - // try again |
868 |
| - if (!bitdb.Open(GetDataDir())) { |
869 |
| - // if it still fails, it probably means we can't even create the database env |
870 |
| - string msg = strprintf(_("Error initializing wallet database environment %s!"), strDataDir); |
871 |
| - return InitError(msg); |
872 |
| - } |
873 |
| - } |
874 |
| - |
875 |
| - if (GetBoolArg("-salvagewallet", false)) |
876 |
| - { |
877 |
| - // Recover readable keypairs: |
878 |
| - if (!CWalletDB::Recover(bitdb, strWalletFile, true)) |
879 |
| - return false; |
880 |
| - } |
881 |
| - |
882 |
| - if (boost::filesystem::exists(GetDataDir() / strWalletFile)) |
883 |
| - { |
884 |
| - CDBEnv::VerifyResult r = bitdb.Verify(strWalletFile, CWalletDB::Recover); |
885 |
| - if (r == CDBEnv::RECOVER_OK) |
886 |
| - { |
887 |
| - string msg = strprintf(_("Warning: wallet.dat corrupt, data salvaged!" |
888 |
| - " Original wallet.dat saved as wallet.{timestamp}.bak in %s; if" |
889 |
| - " your balance or transactions are incorrect you should" |
890 |
| - " restore from a backup."), strDataDir); |
891 |
| - InitWarning(msg); |
892 |
| - } |
893 |
| - if (r == CDBEnv::RECOVER_FAIL) |
894 |
| - return InitError(_("wallet.dat corrupt, salvage failed")); |
895 |
| - } |
| 854 | + std::string warningString; |
| 855 | + std::string errorString; |
| 856 | + |
| 857 | + if (!CWallet::Verify(strWalletFile, warningString, errorString)) |
| 858 | + return false; |
| 859 | + |
| 860 | + if (!warningString.empty()) |
| 861 | + InitWarning(warningString); |
| 862 | + if (!errorString.empty()) |
| 863 | + return InitError(warningString); |
| 864 | + |
896 | 865 | } // (!fDisableWallet)
|
897 | 866 | #endif // ENABLE_WALLET
|
898 | 867 | // ********************************************************* Step 6: network initialization
|
|
0 commit comments