Repository navigation
Description
Summary
Every BDK application currently invents its own wallet configuration. bdk-cli has config.toml with a [wallets.<name>] table, and any other BDK app (desktop, TUI, scripts) has to reimplement the same schema, validation, and storage conventions. As a result, a wallet configured in one BDK application cannot be opened by another with the same state: the same descriptors, network, chain backend, and persistence backend.
I'd like to propose a reusable bdk_config crate (name TBD) that defines a common, versioned wallet-config schema plus a storage abstraction, so bdk-cli, a BDK desktop app, and a TUI like bdk_tui can share one configurable state. It should support SQLite (bdk_sqlite), Redb (bdk_redb), and optionally Turso (bdk_turso).
A parallel proposal is open in the core repo: bitcoindevkit/bdk#2476
Current situation
bdk-cli stores per-wallet config at <datadir>/config.toml (default ~/.bdk-bitcoin), keyed by wallet name. Each entry contains:
- network and external/internal descriptors
database_type(sqliteorredb)client_type(electrum,esplora,rpc,cbf),server_url, RPC user/password/cookie- proxy options,
batch_size,parallel_requests,conn_count
That logic lives only in bdk-cli (src/config.rs, src/handlers/config.rs). Rules that are easy to get wrong are implemented once, in one app:
- network is immutable after creation (Make wallet network immutable after creation, or document and validate it explicitly #359)
- config permissions are 0700/0600 on Unix (Wallet config file is saved with default permissions #331)
- unknown fields must survive edits (Add command to delete saved wallet config #310, Remove "wallet" field from
WalletConfigInner#332) - flags vs config precedence (Support parameter override #271)
A second BDK app that wants the same behaviour has to copy all of it, and there is no way for the two apps to agree on where a wallet lives or what "the same wallet" means.
Proposal
Create a bdk_config crate providing:
- A versioned schema with
schema_versionand explicit migrations. - A shared model for a wallet entry: name, network, descriptors, chain backend and endpoint/credentials, persistence backend and location, proxy, and scan options.
- A
ConfigStoretrait withload,save,list, anddelete, so the storage mechanism is pluggable. - Backends: TOML file (default, compatible with today's
bdk-cliformat), SQLite viabdk_sqlite, Redb viabdk_redb, and an optional Turso backend viabdk_tursobehind a feature flag. - Shared validation: network/descriptor matching, network immutability, and clear mismatch errors in one place.
- Shared path and permission conventions, so applications agree on the default directory and file modes.
- Secret hygiene: never log descriptors or credentials; support redacted display; leave OS keyring/encrypted storage as a follow-up.
Illustrative shape (TOML backend):
schema_version = 1
[wallets.alice]
network = "regtest"
ext_descriptor = "..."
int_descriptor = "..."
[wallets.alice.database]
backend = "sqlite"
path = "alice/wallet.sqlite"
[wallets.alice.client]
backend = "rpc"
url = "http://127.0.0.1:18443"
rpc_user = "user"
rpc_password = "password"Use cases
- Create/configure a wallet in
bdk-cli, then open the same wallet in a BDK desktop app or TUI without re-entering descriptors or backend settings. - Start work in a TUI and automate the same wallet with
bdk-cli. - Change the persistence backend between SQLite, Redb, and Turso without changing the application-facing config.
- Implement network-mismatch handling, permissions, migrations, and validation once instead of per app.
Non-goals
- Not replacing
bdk_walletpersistence or moving wallet data between backends. - Not making
bdk-clidepend on a GUI or TUI. - Not removing CLI flags; config would still act as defaults, with flags overriding.
Open questions
- Where should the crate live: a new
bitcoindevkit/bdk-configrepository, a workspace member ofbdk-cli, or underbdk? - Final name:
bdk_config,bdk-wallet-config, something else? - Should the config store the database path explicitly, or keep deriving it from the wallet name as
bdk-clidoes today? - Is Turso best kept as an optional in-tree feature, or as an external implementation of the
ConfigStoretrait? - Secret storage: keep plaintext with 0600 permissions for now, or design for keyring/encryption from the start?
- Migration path for existing
bdk-cliconfig.tomlfiles and backward compatibility guarantees.
References
bdk-cli: Consider enabling a config file for each wallet #209, Support parameter override #271, Add command to delete saved wallet config #310, Wallet config file is saved with default permissions #331, Remove "wallet" field fromWalletConfigInner#332, Make wallet network immutable after creation, or document and validate it explicitly #359- Backends:
bdk_sqlite,bdk_redb,bdk_turso - Consumer example:
emma31-dev/bdk_tui
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTodo
Activity
emma31-dev commentedon Nov 20, 2026
Opened a broader organisation-level discussion for this: https://github.com/orgs/bitcoindevkit/discussions/127. Keeping this issue open for tracking.