diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -3166,11 +3166,16 @@
         return DB_LOAD_OK;
     }
 
+    AssertLockHeld(cs_wallet); // mapWallet
+    vchDefaultKey = CPubKey();
     DBErrors nZapSelectTxRet =
-        CWalletDB(strWalletFile, "cr+").ZapSelectTx(this, vHashIn, vHashOut);
+        CWalletDB(strWalletFile, "cr+").ZapSelectTx(vHashIn, vHashOut);
+    for (uint256 hash : vHashOut) {
+        mapWallet.erase(hash);
+    }
+
     if (nZapSelectTxRet == DB_NEED_REWRITE) {
         if (CDB::Rewrite(strWalletFile, "\x04pool")) {
-            LOCK(cs_wallet);
             setKeyPool.clear();
             // Note: can't top-up keypool here, because wallet is locked. User
             // will be prompted to unlock wallet the next operation that
@@ -3192,8 +3197,9 @@
         return DB_LOAD_OK;
     }
 
+    vchDefaultKey = CPubKey();
     DBErrors nZapWalletTxRet =
-        CWalletDB(strWalletFile, "cr+").ZapWalletTx(this, vWtx);
+        CWalletDB(strWalletFile, "cr+").ZapWalletTx(vWtx);
     if (nZapWalletTxRet == DB_NEED_REWRITE) {
         if (CDB::Rewrite(strWalletFile, "\x04pool")) {
             LOCK(cs_wallet);
diff --git a/src/wallet/walletdb.h b/src/wallet/walletdb.h
--- a/src/wallet/walletdb.h
+++ b/src/wallet/walletdb.h
@@ -169,10 +169,10 @@
                                 std::list<CAccountingEntry> &acentries);
 
     DBErrors LoadWallet(CWallet *pwallet);
-    DBErrors FindWalletTx(CWallet *pwallet, std::vector<uint256> &vTxHash,
+    DBErrors FindWalletTx(std::vector<uint256> &vTxHash,
                           std::vector<CWalletTx> &vWtx);
-    DBErrors ZapWalletTx(CWallet *pwallet, std::vector<CWalletTx> &vWtx);
-    DBErrors ZapSelectTx(CWallet *pwallet, std::vector<uint256> &vHashIn,
+    DBErrors ZapWalletTx(std::vector<CWalletTx> &vWtx);
+    DBErrors ZapSelectTx(std::vector<uint256> &vHashIn,
                          std::vector<uint256> &vHashOut);
     static bool Recover(CDBEnv &dbenv, const std::string &filename,
                         bool fOnlyKeys);
diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp
--- a/src/wallet/walletdb.cpp
+++ b/src/wallet/walletdb.cpp
@@ -667,21 +667,17 @@
     return result;
 }
 
-DBErrors CWalletDB::FindWalletTx(CWallet *pwallet,
-                                 std::vector<uint256> &vTxHash,
+DBErrors CWalletDB::FindWalletTx(std::vector<uint256> &vTxHash,
                                  std::vector<CWalletTx> &vWtx) {
-    pwallet->vchDefaultKey = CPubKey();
     bool fNoncriticalErrors = false;
     DBErrors result = DB_LOAD_OK;
 
     try {
-        LOCK(pwallet->cs_wallet);
         int nMinVersion = 0;
         if (Read(std::string("minversion"), nMinVersion)) {
             if (nMinVersion > CLIENT_VERSION) {
                 return DB_TOO_NEW;
             }
-            pwallet->LoadMinVersion(nMinVersion);
         }
 
         // Get cursor
@@ -732,13 +728,12 @@
     return result;
 }
 
-DBErrors CWalletDB::ZapSelectTx(CWallet *pwallet,
-                                std::vector<uint256> &vTxHashIn,
+DBErrors CWalletDB::ZapSelectTx(std::vector<uint256> &vTxHashIn,
                                 std::vector<uint256> &vTxHashOut) {
     // Build list of wallet TXs and hashes.
     std::vector<uint256> vTxHash;
     std::vector<CWalletTx> vWtx;
-    DBErrors err = FindWalletTx(pwallet, vTxHash, vWtx);
+    DBErrors err = FindWalletTx(vTxHash, vWtx);
     if (err != DB_LOAD_OK) {
         return err;
     }
@@ -758,7 +753,6 @@
         }
 
         if ((*it) == hash) {
-            pwallet->mapWallet.erase(hash);
             if (!EraseTx(hash)) {
                 LogPrint(BCLog::DB, "Transaction was found for deletion but "
                                     "returned database error: %s\n",
@@ -775,11 +769,10 @@
     return DB_LOAD_OK;
 }
 
-DBErrors CWalletDB::ZapWalletTx(CWallet *pwallet,
-                                std::vector<CWalletTx> &vWtx) {
+DBErrors CWalletDB::ZapWalletTx(std::vector<CWalletTx> &vWtx) {
     // Build list of wallet TXs.
     std::vector<uint256> vTxHash;
-    DBErrors err = FindWalletTx(pwallet, vTxHash, vWtx);
+    DBErrors err = FindWalletTx(vTxHash, vWtx);
     if (err != DB_LOAD_OK) {
         return err;
     }