Skip to content

refactor!: replace sqlx with sqlite-thin - #22

Draft
notmandatory wants to merge 10 commits into
bitcoindevkit:masterfrom
notmandatory:refact/use_sqlite-thin
Draft

notmandatory wants to merge 10 commits into
bitcoindevkit:masterfrom
notmandatory:refact/use_sqlite-thin

Conversation

@notmandatory

@notmandatory notmandatory commented Dec 4, 2026 •

Copy link
Copy Markdown

Description

Add a blocking Store (enabled by default) and an AsyncStore backed by a dedicated worker thread. Both features can be enabled at the same time. Migrations are embedded and tracked in a schema_migrations table; databases created by earlier sqlx-based releases are imported once from _sqlx_migrations so existing wallets are never re-migrated. Remove the sqlx dependency and all sqlx types from the public API.

Notes to the reviewers

When the chain 0.24 based bdk_testutils release it includes persist_test_utils from it. For now the code is copy pasted into this repo from bitcoindevkit/bdk#2012.

My goal is to publish this refactor in a bdk_sqlite v0.7.0 release.

Add a blocking Store (enabled by default) and an AsyncStore backed by a dedicated worker thread. Both features can be enabled at the same time. Migrations are embedded and tracked in a schema_migrations table; databases created by earlier sqlx-based releases are imported once from _sqlx_migrations so existing wallets are never re-migrated. Remove the sqlx dependency and all sqlx types from the public API.
Describe the new feature flags, the blocking Store default, the AsyncStore worker thread, and the one-time import of the legacy sqlx migration ledger. Add the 0.7.0 changelog entries.
Build every supported feature combination (blocking, async, wallet, and both stores together) and fail if sqlx references reappear.
Database failures now surface as Error::Database(DatabaseError), whose inner backend error is opaque. Internal conversions use a private InternalError type, so there is no public From<sqlite_thin::Error> impl. Remove Store::from_connection and Store::connection, and turn the public methods that took a &Connection into instance methods. AsyncStore::from_connection becomes internal. sqlite-thin can now change without altering bdk_sqlite's public type signatures.
The blocking example is now wallet (Store) and the async example is wallet_async (AsyncStore), matching the src module layout.
Adopt the same dual-license layout as bdk: a LICENSE pointer plus LICENSE-APACHE and LICENSE-MIT, matching the Cargo.toml license field.
Vendor bdk_testenv's persist_test_utils harness until it is published, and run its tx_graph, local_chain, and keychain_txout changeset checks against both Store and AsyncStore. Wallet-level cases (network, descriptors, full changesets) run through bdk_wallet's persist_test_utils. The multi-wallet case is omitted because this store holds a single wallet.
Replace the git dependency on sqlite-thin with the published
0.1.0-rc.0 release from crates.io, and point the README and
CHANGELOG links at the crates.io page instead of the old CDK
workspace path.
Document that sqlite-thin accepts any libsqlite3-sys >=0.28 and
adopts whichever version the dependency graph selects, so bdk_sqlite
can coexist with rusqlite (including bdk_wallet's rusqlite feature).
Also describe how bundled vs. system SQLite is chosen and how to
enable other libsqlite3-sys features such as SQLCipher.
@notmandatory notmandatory self-assigned this Dec 4, 2026
@notmandatory notmandatory added the enhancement New feature or request label Dec 4, 2026
@notmandatory
notmandatory marked this pull request as ready for review December 4, 2026 03:47
@notmandatory
notmandatory marked this pull request as draft December 4, 2026 04:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant