wallet: Always rewrite tx records during migration #32985

pull achow101 wants to merge 1 commits into bitcoin:master from achow101:migratewallet-rewrite-txs changing 1 files +3 −1
  1. achow101 commented at 0:01 am on July 16, 2025: member

    Since loading a wallet may change some parts of tx records (e.g. adding nOrderPos), we should rewrite the records instead of copying them so that the automatic upgrade does not need to be performed again when the wallet is loaded.

    This is useful for future PRs I’m working on where we need to be sure about what data exists in a tx record in descriptor wallets.

  2. DrahtBot added the label Wallet on Jul 16, 2025
  3. DrahtBot commented at 0:01 am on July 16, 2025: 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/32985.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK rkrux

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #33034 (wallet: Store transactions in a separate sqlite table by achow101)

    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.

  4. wallet: Always rewrite tx records during migration
    Since loading a wallet may change some parts of tx records (e.g. adding
    nOrderPos), we should rewrite the records instead of copying them so
    that the automatic upgrade does not need to be performed again when the
    wallet is loaded.
    af041c4057
  5. achow101 force-pushed on Jul 21, 2025
  6. achow101 requested review from laanwj on Oct 22, 2025
  7. achow101 requested review from Eunovo on Oct 22, 2025
  8. rkrux commented at 12:06 pm on October 28, 2025: contributor

    lgtm ACK af041c405756d3b8bb04cb2ebd8c32cf237ac2a9

    This appears to be a preparatory commit for the latter PR #33034 where transaction is written in the SQLite transactions table as well during migration. This appears fine also because during wallet loading, the transaction is rewritten if it needs to be reordered based on an updated nOrderPos.

    I don’t suppose there is an easy way to test this in the wallet_migration functional test because the wallet is loaded right after migration is done and this subsequent load would also rewrite the transaction if needed. There is an inspect_sqlite_db function in the functional tests that can query the wallet data before the post-migration load but I don’t know if it’d be trivial to generate a specific test that causes the transaction data to change after pre-migration load. Thus, not suggesting to add a functional test for this.

  9. Eunovo commented at 2:02 pm on October 29, 2025: contributor
    I’m assuming the PR description is referring to the changes ReorderTransactions() makes during LoadWallet(). If this is the case, these changes are persisted during ReorderTransactions(), so copying the records to the SQLite DB when we do MigrateToSQLite should already transfer the changes to the new DB. Why do we need to rewrite the TX records? What in-memory changes are we trying to persist to the new DB?

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: 2025-11-02 18:12 UTC

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