wallet: fix ancient wallets migration #34198

pull furszy wants to merge 2 commits into bitcoin:master from furszy:2026_wallet_migration_ancient_wallets changing 2 files +33 −3
  1. furszy commented at 8:03 pm on January 3, 2026: member

    We currently fail migration if the wallet does not contain the best block locator. This is a problem for wallets created before #152, which are not storing such record.

    Missing this record is not an error. it simply means the wallet will scan the chain prior to finish migration.

    Note: Originally I wrote the test using a BDB library (bsddb3) but I wasn’t happy with the new dependency, and ended up zeroing the record length manually. I’m not sure this will work on every platform. If it doesn’t, we can just just drop the test as this can be tested manually on any ancient wallet too.

  2. wallet: fix ancient wallets migration
    The best block locator was introduced in #152, previously created
    wallets do not have these record.
    f73e694a65
  3. test: add coverage for migrating ancient wallets
    Pre-#152 wallets have no best block stored. Test we
    can migrate them.
    63a079e776
  4. DrahtBot added the label Wallet on Jan 3, 2026
  5. DrahtBot commented at 8:03 pm on January 3, 2026: contributor

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

    Code Coverage & Benchmarks

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

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK bensig

    If your review is incorrectly listed, please copy-paste <!–meta-tag:bot-skip–> into the comment that the bot should ignore.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #34156 (wallet: fix unnamed legacy wallet migration failure by furszy)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

    LLM Linter (✨ experimental)

    Possible places where comparison-specific test macros should replace generic comparisons:

    • test/functional/wallet_migration.py: assert idx != -1, f"{key!r} not found in wallet.dat" -> recommendation: use assert_not_equal(idx, -1, f"{key!r} not found in wallet.dat")
    • test/functional/wallet_migration.py: assert self.old_node.getblockcount() == 0 -> recommendation: use assert_equal(self.old_node.getblockcount(), 0)

    2026-01-03

  6. bensig commented at 0:45 am on January 5, 2026: contributor

    ACK 63a079e7761e8ef94e706eb2103ece4e2a117e50

    Code review ACK. The fix makes sense - ancient pre-#152 wallets shouldn’t fail migration just because they lack the bestblock record.

    Couldn’t run the test locally (requires previous releases for BDB wallet support), but the logic is straightforward.


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-01-07 03:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me