Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Wallet] BugFix: automatic upgrade for unlocked wallet #2048

Merged
merged 1 commit into from
Dec 12, 2020
Merged
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
8 changes: 7 additions & 1 deletion src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ bool CWallet::ActivateSaplingWallet(bool memOnly)
{
if (m_sspk_man->SetupGeneration(m_spk_man->GetHDChain().GetID(), true, memOnly)) {
LogPrintf("%s : sapling spkm setup completed\n", __func__);
// Just to be triple sure, if the version isn't updated, set it.
if (!SetMinVersion(WalletFeature::FEATURE_SAPLING)) {
LogPrintf("%s : ERROR: wallet cannot upgrade to sapling features. Try to upgrade using the 'upgradewallet' RPC command\n", __func__);
return false;
}
return true;
}
return false;
Expand Down Expand Up @@ -4002,7 +4007,8 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile)

// Forced upgrade
const bool fLegacyWallet = gArgs.GetBoolArg("-legacywallet", false);
if (gArgs.GetBoolArg("-upgradewallet", fFirstRun && !fLegacyWallet)) {
if (gArgs.GetBoolArg("-upgradewallet", fFirstRun && !fLegacyWallet) ||
(!walletInstance->IsLocked() && prev_version == FEATURE_PRE_SPLIT_KEYPOOL)) {
if (prev_version <= FEATURE_PRE_PIVX && walletInstance->IsLocked()) {
// Cannot upgrade a locked wallet
UIError("Cannot upgrade a locked wallet.");
Expand Down