Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3870,6 +3870,7 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile)
DBErrors nZapWalletRet = tempWallet->ZapWalletTx(vWtx);
if (nZapWalletRet != DB_LOAD_OK) {
InitError(strprintf(_("Error loading %s: Wallet corrupted"), walletFile));
delete tempWallet;
return NULL;
}

Expand All @@ -3888,6 +3889,7 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile)
{
if (nLoadWalletRet == DB_CORRUPT) {
InitError(strprintf(_("Error loading %s: Wallet corrupted"), walletFile));
delete walletInstance;
return NULL;
}
else if (nLoadWalletRet == DB_NONCRITICAL_ERROR)
Expand All @@ -3898,15 +3900,18 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile)
}
else if (nLoadWalletRet == DB_TOO_NEW) {
InitError(strprintf(_("Error loading %s: Wallet requires newer version of %s"), walletFile, _(PACKAGE_NAME)));
delete walletInstance;
return NULL;
}
else if (nLoadWalletRet == DB_NEED_REWRITE)
{
InitError(strprintf(_("Wallet needed to be rewritten: restart %s to complete"), _(PACKAGE_NAME)));
delete walletInstance;
return NULL;
}
else {
InitError(strprintf(_("Error loading %s"), walletFile));
delete walletInstance;
return NULL;
}
}
Expand All @@ -3925,6 +3930,7 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile)
if (nMaxVersion < walletInstance->GetVersion())
{
InitError(_("Cannot downgrade wallet"));
delete walletInstance;
return NULL;
}
walletInstance->SetMaxVersion(nMaxVersion);
Expand All @@ -3948,6 +3954,7 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile)
walletInstance->SetDefaultKey(newDefaultKey);
if (!walletInstance->SetAddressBook(walletInstance->vchDefaultKey.GetID(), "", "receive")) {
InitError(_("Cannot write default address") += "\n");
delete walletInstance;
return NULL;
}
}
Expand All @@ -3958,10 +3965,12 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile)
bool useHD = GetBoolArg("-usehd", DEFAULT_USE_HD_WALLET);
if (walletInstance->IsHDEnabled() && !useHD) {
InitError(strprintf(_("Error loading %s: You can't disable HD on an already existing HD wallet"), walletFile));
delete walletInstance;
return NULL;
}
if (!walletInstance->IsHDEnabled() && useHD) {
InitError(strprintf(_("Error loading %s: You can't enable HD on an already existing non-HD wallet"), walletFile));
delete walletInstance;
return NULL;
}
}
Expand Down Expand Up @@ -3991,6 +4000,7 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile)

if (pindexRescan != block) {
InitError(_("Prune: last wallet synchronisation goes beyond pruned data. You need to -reindex (download the whole blockchain again in case of pruned node)"));
delete walletInstance;
return NULL;
}
}
Expand Down