Skip to content

fix(rusqlite): fix get_pre_1_wallet_keychains migration helper - #411

Merged
ValuedMammal merged 1 commit into
bitcoindevkit:masterfrom
notmandatory:fix/sqlite_pre1_migration_helper
Mar 23, 2026
Merged

ValuedMammal merged 1 commit into
bitcoindevkit:masterfrom
notmandatory:fix/sqlite_pre1_migration_helper

Conversation

@notmandatory

@notmandatory notmandatory commented Mar 19, 2026 •

Copy link
Copy Markdown
Contributor

Description

While working on bitcoindevkit/book-of-bdk#141 I found some very rough edges with how I'd implemented the Pre1WalletKeychain struct. I've fixed these and added a new Pre1MigrationError type to cover new possible errors when parsing keychain name and checksum bytes.

Notes to the reviewers

  • rename public function to get_pre_v1_wallet_keychains
  • rename returned structure to PreV1WalletKeychain
  • added PreV1MigrationError
  • changed PreV1WalletKeychain::keychain to KeychainKind
  • changed PreV1WalletKeychain::checksum to String

Changelog notice

Replace changelog notice from #364 to:

Add get_pre_v1_wallet_keychains to assist migration from pre-1.0 bdk wallets.

Checklists

All Submissions:

Bugfixes:

  • This pull request breaks the existing API
  • I've added tests to reproduce the issue which are now passing
  • I'm linking the issue being fixed by this PR

@notmandatory notmandatory self-assigned this Mar 19, 2026
@notmandatory notmandatory added the bug Something isn't working label Mar 19, 2026
@codecov

codecov Bot commented Mar 19, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.53488% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.04%. Comparing base (fca6523) to head (c730973).
⚠️ Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
src/wallet/migration.rs 89.53% 8 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #411      +/-   ##
==========================================
+ Coverage   79.77%   80.04%   +0.26%     
==========================================
  Files          24       24              
  Lines        5266     5336      +70     
  Branches      241      242       +1     
==========================================
+ Hits         4201     4271      +70     
+ Misses        988      987       -1     
- Partials       77       78       +1     
Flag Coverage Δ
rust 80.04% <89.53%> (+0.26%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@notmandatory
notmandatory force-pushed the fix/sqlite_pre1_migration_helper branch from 69b3b27 to 6fc319d Compare March 19, 2026 04:18
@notmandatory

notmandatory commented Mar 19, 2026 •

Copy link
Copy Markdown
Contributor Author

I'd like to get this into the 3.0 release and then I'll back port the patch to the release/2.x branch.

@notmandatory
notmandatory force-pushed the fix/sqlite_pre1_migration_helper branch from 6fc319d to fc18db5 Compare March 19, 2026 04:21
@notmandatory notmandatory moved this to Needs Review in BDK Wallet Mar 19, 2026
@notmandatory notmandatory added this to the Wallet 3.0.0 milestone Mar 19, 2026
@notmandatory

notmandatory commented Mar 19, 2026 •

Copy link
Copy Markdown
Contributor Author

@notmandatory

notmandatory commented Mar 19, 2026 •

Copy link
Copy Markdown
Contributor Author

I re-pushed my commit with refactored and expanded test coverage, compliments of 🤖 LLM helper.

@oleonardolima oleonardolima left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK 849f88f

Overall looks good! I'll try to test it following bitcoindevkit/book-of-bdk#147

@ValuedMammal

Copy link
Copy Markdown
Contributor

You're using a lot of cfg attributes for the same reason. Is it possible to refactor those to apply to the module instead?

@oleonardolima

oleonardolima commented Mar 23, 2026 •

Copy link
Copy Markdown
Contributor

@notmandatory I updated it to apply the rusqlite feature configuration to the module, and also renamed it from Pre1... to PreV1... instead. If you'd like you can cherry-pick those from here: https://github.com/oleonardolima/bdk_wallet/commits/fix/sqlite_pre1_migration_helper/

@notmandatory

notmandatory commented Mar 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks @oleonardolima I cherry-picked your commits, these are good improvements addressing @ValuedMammal's comment.

@notmandatory notmandatory added the api A breaking API change label Mar 23, 2026
@notmandatory

Copy link
Copy Markdown
Contributor Author

I added #415 as a back port of this PR to the release/2.x branch.

@ValuedMammal

Copy link
Copy Markdown
Contributor

In 849f88f: fix(rusqlite): fix get_pre_1_wallet_keychains migration helper

Can you include a newline before the body of the commit message?

@notmandatory
notmandatory force-pushed the fix/sqlite_pre1_migration_helper branch 2 times, most recently from 5712f03 to 870393e Compare March 23, 2026 20:11

@oleonardolima oleonardolima left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK a399408

I've tested it by using bdk-cli v0.27.1 importing and syncing the same testnet4 descriptors we have in examples.

I used the code from bitcoindevkit/book-of-bdk#147 and it created the new database as expected, and I did a sync with it's initial state.

@oleonardolima

Copy link
Copy Markdown
Contributor

nit: it could probably be squashed into a single commit, though it's not a blocker.

@notmandatory

Copy link
Copy Markdown
Contributor Author

I'll squash it.

- add PreV1MigrationError
- rename Pre1WalletKeychain to PreV1WalletKeychain
- rename get_pre_1_wallet_keychains to get_pre_v1_wallet_keychains
- change PreV1WalletKeychain::keychain to KeychainKind
- change PreV1WalletKeychain::checksum to String
- refactored and expanded migration tests with LLM 🤖
- style: require `rusqlite` feature in migration mod
- apply `[cfg(feature = "rusqlite")] for `migration` module instead of
  having multiple ones in `migration.rs`.
@notmandatory
notmandatory force-pushed the fix/sqlite_pre1_migration_helper branch from 870393e to c730973 Compare March 23, 2026 20:37

@oleonardolima oleonardolima left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK c730973

I ran the test on the new commit.

@ValuedMammal

Copy link
Copy Markdown
Contributor

ACK c730973

@ValuedMammal
ValuedMammal merged commit cb2c7ed into bitcoindevkit:master Mar 23, 2026
17 checks passed
@github-project-automation github-project-automation Bot moved this from Needs Review to Done in BDK Wallet Mar 23, 2026
@ValuedMammal ValuedMammal mentioned this pull request Mar 24, 2026
1 task done
ValuedMammal added a commit that referenced this pull request Mar 30, 2026
fc233b2 fix(rusqlite): fix get_pre_v1_wallet_keychains migration helper (Steve Myers)

Pull request description:

  ### Description

  Backports #411 to the `release/2.x` branch.

  ### Notes to the reviewers

  No changes to the original PR.

  ### Changelog notice

  Add get_pre_v1_wallet_keychains to assist migration from pre-1.0 bdk wallets.

  ### Checklists

  #### All Submissions:

  * [x] I've signed all my commits
  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
  * [x] I ran `just p` before pushing

  #### New Features:

  * [x] I've added tests for the new feature
  * [x] I've added docs for the new feature

ACKs for top commit:
  ValuedMammal:
    ACK fc233b2

Tree-SHA512: eb78a965b7e170fce19896a65f3a26707555adb0743aaa31fe8423218409ddc884c465ced700c059b1a327cbc9d2953774c156f904472965362b8f8f5775331e
@notmandatory
notmandatory deleted the fix/sqlite_pre1_migration_helper branch November 18, 2026 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api A breaking API change bug Something isn't working

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants