aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet.cpp
diff options
context:
space:
mode:
authorJonas Schnelli <dev@jonasschnelli.ch>2016-03-05 16:08:10 -0500
committerJonas Schnelli <dev@jonasschnelli.ch>2016-03-14 09:33:27 +0100
commit15e6e13624e3bd322db67861ec27bd5f9d18b6e8 (patch)
tree88eeca02bb7bd30ded80cc7b70352f67016ab83c /src/wallet/wallet.cpp
parentfc7c60d6998a330966ffe99274c93b5278ed2ee1 (diff)
downloadbitcoin-15e6e13624e3bd322db67861ec27bd5f9d18b6e8.tar.xz
[Wallet] optimize return value of InitLoadWallet()
Diffstat (limited to 'src/wallet/wallet.cpp')
-rw-r--r--src/wallet/wallet.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 56287d4f44..d409d74801 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -3002,6 +3002,7 @@ CWallet* CWallet::InitLoadWallet(bool fDisableWallet, const std::string& strWall
CWallet *tempWallet = new CWallet(strWalletFile);
DBErrors nZapWalletRet = tempWallet->ZapWalletTx(vWtx);
if (nZapWalletRet != DB_LOAD_OK) {
+ errorString = _("Error loading wallet.dat: Wallet corrupted");
uiInterface.InitMessage(_("Error loading wallet.dat: Wallet corrupted"));
return NULL;
}
@@ -3031,10 +3032,12 @@ CWallet* CWallet::InitLoadWallet(bool fDisableWallet, const std::string& strWall
{
errorString += strprintf(_("Wallet needed to be rewritten: restart %s to complete"), _(PACKAGE_NAME)) + "\n";
LogPrintf("%s", errorString);
- return walletInstance;
}
else
errorString += _("Error loading wallet.dat") + "\n";
+
+ if (!errorString.empty())
+ return NULL;
}
if (GetBoolArg("-upgradewallet", fFirstRun))
@@ -3049,7 +3052,10 @@ CWallet* CWallet::InitLoadWallet(bool fDisableWallet, const std::string& strWall
else
LogPrintf("Allowing wallet upgrade up to %i\n", nMaxVersion);
if (nMaxVersion < walletInstance->GetVersion())
+ {
errorString += _("Cannot downgrade wallet") + "\n";
+ return NULL;
+ }
walletInstance->SetMaxVersion(nMaxVersion);
}
@@ -3062,13 +3068,15 @@ CWallet* CWallet::InitLoadWallet(bool fDisableWallet, const std::string& strWall
if (walletInstance->GetKeyFromPool(newDefaultKey)) {
walletInstance->SetDefaultKey(newDefaultKey);
if (!walletInstance->SetAddressBook(walletInstance->vchDefaultKey.GetID(), "", "receive"))
+ {
errorString += _("Cannot write default address") += "\n";
+ return NULL;
+ }
}
walletInstance->SetBestChain(chainActive.GetLocator());
}
- LogPrintf("%s", errorString);
LogPrintf(" wallet %15dms\n", GetTimeMillis() - nStart);
RegisterValidationInterface(walletInstance);
@@ -3099,7 +3107,7 @@ CWallet* CWallet::InitLoadWallet(bool fDisableWallet, const std::string& strWall
if (pindexRescan != block)
{
errorString = _("Prune: last wallet synchronisation goes beyond pruned data. You need to -reindex (download the whole blockchain again in case of pruned node)");
- return walletInstance;
+ return NULL;
}
}