wallet: remove unused code #36127

pull jeanpablojp wants to merge 6 commits into bitcoin:master from jeanpablojp:wallet-remove-unused changing 9 files +3 −33
  1. jeanpablojp commented at 1:04 PM on August 31, 2026: contributor

    Six unused items in src/wallet, one per commit.

    DescriptorScriptPubKeyMan::AddDescriptorKey, a private wrapper that lost its caller in #28333.

    COutput::ToString, no callers. It was used by COutput::print(), which went away with the other print() methods in wallet.

    The two CHDChain keypool index members, whose last uses went away with LegacySPKM in #28710.

    WalletDatabase::m_refcount. Only BDB ever maintained it, and BDB went away in #28710.

    The warnings parameter of CreateFromDump, never written, along with the loop that printed it in wallet-tool. The push_back went away with the -format option in #31250.

    The two BDB-only members of DatabaseOptions, use_shared_memory and max_log_mb. Their last readers went away with BDB in #28710, along with the -privdb and -dblogsize options that set them.

  2. wallet: remove unused DescriptorScriptPubKeyMan::AddDescriptorKey
    The private method has no callers. It opened a `WalletBatch` and
    forwarded to `AddDescriptorKeyWithDB`, which is still called from two
    other places.
    
    Its last caller, in `CWallet::AddWalletDescriptor`, was replaced in
    aa4f7823aa ("wallet: include keys when constructing DescriptorSPKM
    during import"), which builds the manager with `CreateFromMigration`
    instead of adding the key afterwards.
    a0e9aac428
  3. wallet: remove unused COutput::ToString
    No callers. It was used by `COutput::print()`, which was removed in
    3802224110 ("Remove all other print() methods").
    4afc7bc40d
  4. wallet: remove unused CHDChain keypool index members
    `m_next_external_index` and `m_next_internal_index` are declared and
    initialized and never read or written afterwards. Their last uses were
    removed in 83af1a3cca ("wallet: Delete LegacySPKM"). Neither appears in
    `SERIALIZE_METHODS` or in `SetNull`.
    f64b3fa70f
  5. wallet: remove unused WalletDatabase::m_refcount
    The counter is never incremented. Only the BDB implementation ever
    maintained it, and that went away in 04a7a7a28c ("build, wallet, doc:
    Remove BDB"). `AddRef()` and `RemoveRef()`, which the comment above the
    member describes as maintaining it, were removed in c0f3f3264f
    ("wallet: Remove unused db functions"), leaving the member behind.
    2f6aa41d3d
  6. wallet: remove unused warnings parameter from CreateFromDump
    `CreateFromDump` never writes to the vector, so the loop that prints it
    in wallet-tool cannot produce output. `tool_wallet.py` already asserts
    empty output for `createfromdump`.
    
    The only `warnings.push_back()` was removed in 7a41c939f0 ("wallet:
    Remove -format and bdb from wallet tool's createfromdump").
    bbed824a64
  7. DrahtBot added the label Wallet on Aug 31, 2026
  8. DrahtBot commented at 1:04 PM on August 31, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/36127.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    ACK pablomartin4btc, vicjuma
    Stale ACK Eunovo

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  9. pablomartin4btc commented at 6:10 PM on August 31, 2026: member

    ACK bbed824a64f0a5335442261b3abd63db22453cd6

    Clean removal, verified every symbol's references.

    Found one more piece of unused code that would make a natural 6th commit for the PR — these 2 data members in struct DatabaseOptions:

    bool use_shared_memory = false; //!< Let other processes access the database.
    int64_t max_log_mb = 100;       //!< Max log size to allow before consolidating.
    

    Both use_shared_memory and max_log_mb were last actually consumed in 04a7a7a28c — part of the merge for PR #28710, the same PR the existing commits already cite for the m_next_* and m_refcount removals.

  10. vicjuma commented at 11:26 AM on September 1, 2026: contributor

    ACK bbed824a64f0a5335442261b3abd63db22453cd6

  11. wallet: remove unused DatabaseOptions members
    `use_shared_memory` and `max_log_mb` are never read or written; they
    only ever hold their initializers. Their last readers, in
    `GetBerkeleyEnv()` and the `BerkeleyDatabase` constructor, were removed
    in 04a7a7a28c ("build, wallet, doc: Remove BDB"), along with the
    `-privdb` and `-dblogsize` options that set them.
    
    Co-authored-by: pablomartin4btc <pablomartin4btc@gmail.com>
    9f0543d69a
  12. jeanpablojp commented at 12:51 PM on September 1, 2026: contributor

    Pushed a sixth commit taking @pablomartin4btc's suggestion, use_shared_memory and max_log_mb in DatabaseOptions. Their last readers went with BDB in #28710, same as m_refcount, along with the -privdb and -dblogsize options that set them. Credited on the commit.

  13. pablomartin4btc commented at 1:21 PM on September 1, 2026: member

    ACK 9f0543d69a1357371017c8289d9addc457b6f132

  14. DrahtBot requested review from Eunovo on Sep 1, 2026
  15. vicjuma commented at 1:29 PM on September 1, 2026: contributor

    ACK 9f0543d69a1357371017c8289d9addc457b6f132

  16. pablomartin4btc commented at 4:06 PM on September 1, 2026: member

    reACK

    Mmm... I think the @DrahtBot hasn't properly counted @vicjuma's ACK...

    | Type | Reviewers | | ---------| ---------| | ACK | pablomartin4btc | | Concept ACK | vicjuma | | Stale ACK | Eunovo |

  17. maflcko commented at 5:34 PM on September 1, 2026: member

    Mmm... I think the @DrahtBot hasn't properly counted @vicjuma's ACK...

    You can find more details on code review in https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review. (Without a hash, no one can know what the comment is referring to)

  18. vicjuma commented at 5:41 PM on September 1, 2026: contributor

    Mmm... I think the @DrahtBot hasn't properly counted @vicjuma's ACK...

    You can find more details on code

    thanks @maflcko and @pablomartin4btc

  19. in src/wallet/wallettool.cpp:165 in 9f0543d69a
     161 | @@ -162,11 +162,7 @@ bool ExecuteWalletToolFunc(const ArgsManager& args, const std::string& command)
     162 |          return ret;
     163 |      } else if (command == "createfromdump") {
     164 |          bilingual_str error;
     165 | -        std::vector<bilingual_str> warnings;
     166 | -        bool ret = CreateFromDump(args, name, path, error, warnings);
     167 | -        for (const auto& warning : warnings) {
     168 | -            tfm::format(std::cout, "%s\n", warning.original);
     169 | -        }
     170 | +        bool ret = CreateFromDump(args, name, path, error);
    


    fanquake commented at 1:08 PM on September 7, 2026:

    Looks like the last use of warnings in CreateFromDrump was removed in 7a41c939f05f2208c33e8f09eecbbfd579fb4023.

  20. fanquake merged this on Sep 7, 2026
  21. fanquake closed this on Sep 7, 2026

  22. jeanpablojp deleted the branch on Sep 8, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-09-09 07:56 UTC