Skip to content

feat: extract wallet configuration into a shared bdk_config crate #391

Open

Description

@emma31-dev

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 (sqlite or redb)
  • 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:

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:

  1. A versioned schema with schema_version and explicit migrations.
  2. A shared model for a wallet entry: name, network, descriptors, chain backend and endpoint/credentials, persistence backend and location, proxy, and scan options.
  3. A ConfigStore trait with load, save, list, and delete, so the storage mechanism is pluggable.
  4. Backends: TOML file (default, compatible with today's bdk-cli format), SQLite via bdk_sqlite, Redb via bdk_redb, and an optional Turso backend via bdk_turso behind a feature flag.
  5. Shared validation: network/descriptor matching, network immutability, and clear mismatch errors in one place.
  6. Shared path and permission conventions, so applications agree on the default directory and file modes.
  7. 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_wallet persistence or moving wallet data between backends.
  • Not making bdk-cli depend 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-config repository, a workspace member of bdk-cli, or under bdk?
  • 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-cli does today?
  • Is Turso best kept as an optional in-tree feature, or as an external implementation of the ConfigStore trait?
  • Secret storage: keep plaintext with 0600 permissions for now, or design for keyring/encryption from the start?
  • Migration path for existing bdk-cli config.toml files and backward compatibility guarantees.

References

Activity

  1. emma31-dev commented on Nov 20, 2026

    @emma31-dev
    ContributorAuthor

    Opened a broader organisation-level discussion for this: https://github.com/orgs/bitcoindevkit/discussions/127. Keeping this issue open for tracking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    • Status
      Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions