diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index dc515daafd58..6afae95992b8 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -380,15 +380,15 @@ UniValue upgradewallet(const JSONRPCRequest& request) ); EnsureWallet(); - EnsureWalletIsUnlocked(); - LOCK2(cs_main, pwalletMain->cs_wallet); - // Do not do anything to non-HD wallets - if (pwalletMain->HasSaplingSPKM()) { + // Do not do anything to wallets already upgraded + if (pwalletMain->CanSupportFeature(FEATURE_LATEST)) { throw JSONRPCError(RPC_WALLET_ERROR, "Cannot upgrade the wallet. The wallet is already running the latest version"); } + EnsureWalletIsUnlocked(); + // Get version int prev_version = pwalletMain->GetVersion(); // Upgrade wallet's version