@@ -3002,6 +3002,7 @@ CWallet* CWallet::InitLoadWallet(bool fDisableWallet, const std::string& strWall
30023002 CWallet *tempWallet = new CWallet (strWalletFile);
30033003 DBErrors nZapWalletRet = tempWallet->ZapWalletTx (vWtx);
30043004 if (nZapWalletRet != DB_LOAD_OK) {
3005+ errorString = _ (" Error loading wallet.dat: Wallet corrupted" );
30053006 uiInterface.InitMessage (_ (" Error loading wallet.dat: Wallet corrupted" ));
30063007 return NULL ;
30073008 }
@@ -3031,10 +3032,12 @@ CWallet* CWallet::InitLoadWallet(bool fDisableWallet, const std::string& strWall
30313032 {
30323033 errorString += strprintf (_ (" Wallet needed to be rewritten: restart %s to complete" ), _ (PACKAGE_NAME)) + " \n " ;
30333034 LogPrintf (" %s" , errorString);
3034- return walletInstance;
30353035 }
30363036 else
30373037 errorString += _ (" Error loading wallet.dat" ) + " \n " ;
3038+
3039+ if (!errorString.empty ())
3040+ return NULL ;
30383041 }
30393042
30403043 if (GetBoolArg (" -upgradewallet" , fFirstRun ))
@@ -3049,7 +3052,10 @@ CWallet* CWallet::InitLoadWallet(bool fDisableWallet, const std::string& strWall
30493052 else
30503053 LogPrintf (" Allowing wallet upgrade up to %i\n " , nMaxVersion);
30513054 if (nMaxVersion < walletInstance->GetVersion ())
3055+ {
30523056 errorString += _ (" Cannot downgrade wallet" ) + " \n " ;
3057+ return NULL ;
3058+ }
30533059 walletInstance->SetMaxVersion (nMaxVersion);
30543060 }
30553061
@@ -3062,13 +3068,15 @@ CWallet* CWallet::InitLoadWallet(bool fDisableWallet, const std::string& strWall
30623068 if (walletInstance->GetKeyFromPool (newDefaultKey)) {
30633069 walletInstance->SetDefaultKey (newDefaultKey);
30643070 if (!walletInstance->SetAddressBook (walletInstance->vchDefaultKey .GetID (), " " , " receive" ))
3071+ {
30653072 errorString += _ (" Cannot write default address" ) += " \n " ;
3073+ return NULL ;
3074+ }
30663075 }
30673076
30683077 walletInstance->SetBestChain (chainActive.GetLocator ());
30693078 }
30703079
3071- LogPrintf (" %s" , errorString);
30723080 LogPrintf (" wallet %15dms\n " , GetTimeMillis () - nStart);
30733081
30743082 RegisterValidationInterface (walletInstance);
@@ -3099,7 +3107,7 @@ CWallet* CWallet::InitLoadWallet(bool fDisableWallet, const std::string& strWall
30993107 if (pindexRescan != block)
31003108 {
31013109 errorString = _ (" Prune: last wallet synchronisation goes beyond pruned data. You need to -reindex (download the whole blockchain again in case of pruned node)" );
3102- return walletInstance ;
3110+ return NULL ;
31033111 }
31043112 }
31053113
0 commit comments