bdk_turso
An experimental persistence backend for bdk_wallet that stores wallet state in Turso.
Project status
bdk_turso is early-stage and experimental. It currently implements async wallet persistence, and its API may change.
What is bdk_turso?
bdk_turso is a standalone persistence backend for bdk_wallet, storing wallet state in Turso, an in-process, SQLite-compatible database written in Rust. It implements the AsyncWalletPersister trait behind the wallet feature, without changes to bdk_wallet or bdk_persist.
bdk_turso is forked from bdk_sqlite, with its persistence implementation adapted for Turso's async-first API. Its persistence tests are adapted from the test suite in bdk_redb.
Why Turso?
Native async persistence
Turso's async-first design allows bdk_turso to implement AsyncWalletPersister natively rather than wrapping blocking database operations in spawn_blocking. Turso is designed to support concurrent write scaling; this project makes no benchmark claims.
SQLite compatibility
bdk_turso stays within Turso's SQLite-compatible feature subset and avoids Turso-only extensions. Unencrypted database files remain readable by bdk_sqlite; Turso-encrypted files require Turso to open.
Usage
The API is not finalized; this illustrative example shows the intended shape:
use Store;
use ;
let mut store = new?;
let wallet = new_or_load?;
Examples
cargo run --example walletsyncs a wallet with a local Bitcoin Core regtest node.cargo run --features psbt --example transactionsyncs a regtest wallet, stores and reloads an unsigned PSBT, confirms it matches, signs and broadcasts it, and persists the resulting wallet changeset. It requiresPOLAR_RPC_USER,POLAR_RPC_PASS, and a regtestRECIPIENT_ADDRESS. If the wallet has no spendable funds, it prints a receive address; fund it and mine 101 blocks before rerunning.
Both examples requires Polar.
Remote Turso
Enable the remote feature to connect to Turso Cloud through Turso's local sync engine. The store keeps a local cache at the supplied path, pulls remote changes before reads, and pushes committed writes. A push can fail after the local commit, in which case the local cache retains the change and the persistence operation returns an error; retry the same changeset to retry the upload. The cache is not encrypted by Turso Cloud encryption; configure Options::with_remote_encryption for Turso Cloud database encryption and protect the local cache separately.
use Store;
let store = new_remote.await?;
store.migrate.await?;
Local at-rest encryption and MVCC passive checkpointing are not supported by Turso's remote sync builder and return an error if requested. The ignored sync integration test can target a disposable Turso Cloud database or a local Turso sync server. Set BDK_TURSO_REMOTE_URL and BDK_TURSO_AUTH_TOKEN to the endpoint and token accepted by that server, then run cargo test --features remote --test persistence remote_store_syncs_changesets_between_local_caches -- --ignored.
Feature flags
Store::migrate() always creates the core block and transaction tables. Wallet-specific and PSBT tables are created only when their respective features are enabled.
| Feature | Description |
|---|---|
wallet |
Enables wallet-specific tables and the AsyncWalletPersister implementation. |
psbt |
Enables the PSBT table and storage methods; independent of wallet. |
remote |
Enables Turso Cloud sync with a local cache. |
Minimum Supported Rust Version (MSRV)
The MSRV is 1.88.0, based on the current resolved dependency graph.
License
Licensed under either of MIT or Apache License, Version 2.0, at your option.
Contribution
Contributions are welcome. Please read the contribution guide, the BDK contributing guidelines, and the BDK community standards.