From 61039d72a5da443a254b3229748fc64eee613757 Mon Sep 17 00:00:00 2001 From: rkrux Date: Thu, 15 Jan 2026 15:36:21 +0530 Subject: [PATCH 1/2] wallet: remove unimplemented `RewriteDB` calls from SPKM ISTM that there is no implementation left of the `RewriteDB` method in any of the SPKMs, and thus, its call sites can be removed safely. --- src/wallet/scriptpubkeyman.h | 3 --- src/wallet/wallet.cpp | 10 ++-------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h index 00dd6eed4d1..cf024294bf3 100644 --- a/src/wallet/scriptpubkeyman.h +++ b/src/wallet/scriptpubkeyman.h @@ -120,9 +120,6 @@ public: virtual bool HavePrivateKeys() const { return false; } virtual bool HaveCryptedKeys() const { return false; } - //! The action to do when the DB needs rewrite - virtual void RewriteDB() {} - virtual unsigned int GetKeyPoolSize() const { return 0; } virtual int64_t GetTimeFirstKey() const { return 0; } diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index b1562952257..e1e0d307ccc 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2357,14 +2357,8 @@ DBErrors CWallet::PopulateWalletFromDB(bilingual_str& error, std::vectorRewriteDB(); - } - } + if (nLoadWalletRet == DBErrors::NEED_REWRITE) { + GetDatabase().Rewrite(); } if (m_spk_managers.empty()) { From c6a6435cedac01a6800cac9285e2c599290e2e0d Mon Sep 17 00:00:00 2001 From: rkrux Date: Fri, 16 Jan 2026 16:25:51 +0530 Subject: [PATCH 2/2] wallet: remove `DBErrors::NEED_REWRITE` enum value As highlighted in the PR review comment, this enum seems no longer required as the specific issue it solves for involves BDB based wallets that can't be loaded anymore outside the context of wallet migration, which rewrites the database anyway. --- src/wallet/wallet.cpp | 6 ------ src/wallet/walletdb.cpp | 6 ------ src/wallet/walletdb.h | 1 - 3 files changed, 13 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index e1e0d307ccc..fe074a3a804 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2357,9 +2357,6 @@ DBErrors CWallet::PopulateWalletFromDB(bilingual_str& error, std::vector 0) { - // Rewrite encrypted wallets of versions 0.4.0 and 0.5.0rc: - if (last_client == 40000 || last_client == 50000) result = std::max(result, DBErrors::NEED_REWRITE); - } - // Load keymeta std::map hd_chains; LoadResult keymeta_res = LoadRecords(pwallet, batch, DBKeys::KEYMETA, diff --git a/src/wallet/walletdb.h b/src/wallet/walletdb.h index 65ff8c0b60f..455fc745571 100644 --- a/src/wallet/walletdb.h +++ b/src/wallet/walletdb.h @@ -44,7 +44,6 @@ enum class DBErrors : int { LOAD_OK = 0, NEED_RESCAN = 1, - NEED_REWRITE = 2, EXTERNAL_SIGNER_SUPPORT_REQUIRED = 3, NONCRITICAL_ERROR = 4, TOO_NEW = 5,