Merge bitcoin/bitcoin#34301: wallet: remove outdated RewriteDB calls from SPKM & DBErrors::NEED_REWRITE enum value

c6a6435cedac01a6800cac9285e2c599290e2e0d wallet: remove `DBErrors::NEED_REWRITE` enum value (rkrux)
61039d72a5da443a254b3229748fc64eee613757 wallet: remove unimplemented `RewriteDB` calls from SPKM (rkrux)

Pull request description:

  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.

  Also remove `DBErrors::NEED_REWRITE` enum value as its usage is outdated now.

  <!--
  *** Please remove the following help text before submitting: ***

  Pull requests without a rationale and clear improvement may be closed
  immediately.

  GUI-related pull requests should be opened against
  https://github.com/bitcoin-core/gui
  first. See CONTRIBUTING.md
  -->

  <!--
  Please provide clear motivation for your patch and explain how it improves
  Bitcoin Core user experience or Bitcoin Core developer experience
  significantly:

  * Any test improvements or new tests that improve coverage are always welcome.
  * All other changes should have accompanying unit tests (see `src/test/`) or
    functional tests (see `test/`). Contributors should note which tests cover
    modified code. If no tests exist for a region of modified code, new tests
    should accompany the change.
  * Bug fixes are most welcome when they come with steps to reproduce or an
    explanation of the potential issue as well as reasoning for the way the bug
    was fixed.
  * Features are welcome, but might be rejected due to design or scope issues.
    If a feature is based on a lot of dependencies, contributors should first
    consider building the system outside of Bitcoin Core, if possible.
  * Refactoring changes are only accepted if they are required for a feature or
    bug fix or otherwise improve developer experience significantly. For example,
    most "code style" refactoring changes require a thorough explanation why they
    are useful, what downsides they have and why they *significantly* improve
    developer experience or avoid serious programming bugs. Note that code style
    is often a subjective matter. Unless they are explicitly mentioned to be
    preferred in the [developer notes](/doc/developer-notes.md), stylistic code
    changes are usually rejected.
  -->

  <!--
  Bitcoin Core has a thorough review process and even the most trivial change
  needs to pass a lot of eyes and requires non-zero or even substantial time
  effort to review. There is a huge lack of active reviewers on the project, so
  patches often sit for a long time.
  -->

ACKs for top commit:
  achow101:
    ACK c6a6435cedac01a6800cac9285e2c599290e2e0d
  furszy:
    ACK c6a6435cedac01a6800cac9285e2c599290e2e0d
  sedited:
    ACK c6a6435cedac01a6800cac9285e2c599290e2e0d

Tree-SHA512: 050d3115ad436eb7728716c897c8d23c6dd0c6cd7a018dc023896d301b126bae5ba89b684811226a0ca4045b393b612296aeab3b3b5dfb7ed0bf443fc1eaef41
This commit is contained in:
merge-script 2026-03-11 13:57:33 +01:00
commit 281c0cce73
No known key found for this signature in database
GPG Key ID: 9B79B45691DB4173
4 changed files with 0 additions and 22 deletions

View File

@ -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; }

View File

@ -2357,15 +2357,6 @@ DBErrors CWallet::PopulateWalletFromDB(bilingual_str& error, std::vector<bilingu
Assert(m_spk_managers.empty());
Assert(m_wallet_flags == 0);
DBErrors nLoadWalletRet = WalletBatch(GetDatabase()).LoadWallet(this);
if (nLoadWalletRet == DBErrors::NEED_REWRITE)
{
if (GetDatabase().Rewrite())
{
for (const auto& spk_man_pair : m_spk_managers) {
spk_man_pair.second->RewriteDB();
}
}
}
if (m_spk_managers.empty()) {
assert(m_external_spk_managers.empty());
@ -2394,9 +2385,6 @@ DBErrors CWallet::PopulateWalletFromDB(bilingual_str& error, std::vector<bilingu
case DBErrors::EXTERNAL_SIGNER_SUPPORT_REQUIRED:
error = strprintf(_("Error loading %s: External signer wallet being loaded without external signer support compiled"), wallet_file);
break;
case DBErrors::NEED_REWRITE:
error = strprintf(_("Wallet needed to be rewritten: restart %s to complete"), CLIENT_NAME);
break;
case DBErrors::UNKNOWN_DESCRIPTOR:
error = strprintf(_("Unrecognized descriptor found. Loading wallet %s\n\n"
"The wallet might have been created on a newer version.\n"

View File

@ -584,12 +584,6 @@ static DBErrors LoadLegacyWalletRecords(CWallet* pwallet, DatabaseBatch& batch,
});
result = std::max(result, script_res.m_result);
// Check whether rewrite is needed
if (ckey_res.m_records > 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<uint160, CHDChain> hd_chains;
LoadResult keymeta_res = LoadRecords(pwallet, batch, DBKeys::KEYMETA,

View File

@ -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,