Skip to content

Support parameter override #271

Open

Description

@nymius

Describe the enhancement
The config setup forces users to parse toml files or manually modify them to change things like rpc credentials.
Some users might not need modification of these, but in some setups these change continuously, forcing the user to use other tools to modify these files, adding additional dependencies to the setup.

Use case
I'm using bdk-cli mainly for testing. Maybe there is a good reason to not give too much freedom to the user to change parameters of their configuration, but I think at least RPC parameters are certainly prone to change, even more if the node is using cookie authentication.

Additional context
I updated the bdk-cli in the bdk-sp nix environment, and it broke most of the commands I was using to wrap bdk-cli. Some of the changes are useful, like writing keys into file, but some others are not, like rpc credentials. I'm starting and stopping this node very frequently and the rpc cookie changes each time. I had to add a tool like dasel to modify the parameters I need in the file.

Activity

  1. added
    enhancement
    on Apr 13, 2026
  2. emma31-dev commented on Sep 10, 2026

    @emma31-dev
    Contributor

    what change do you suggest? Default values for those that just want to get started or simpler setup

  3. nymius commented on Sep 10, 2026

    @nymius
    ContributorAuthor

    To allow multiple options to read configuration parameters, more flexible than just a file: flags or environment variables.

  4. emma31-dev commented on Sep 10, 2026

    @emma31-dev
    Contributor

    This can be done. I'll Open a PR on this tomorrow to add support for configuration via flags then the default from environmental variables

  5. emma31-dev commented on Sep 12, 2026

    @emma31-dev
    Contributor

    The environmental variable has already been built-in in recent. maybe ill take my time to document the environmental variables names

  6. Musab1258 commented on Nov 2, 2026

    @Musab1258
    Contributor

    6. The environmental variable has already been built-in in recent. maybe ill take my time to document the environmental variables names

    @emma31-dev, are you still working on this?

  7. emma31-dev commented on Nov 2, 2026

    @emma31-dev
    Contributor

    @Musab1258 @tvpeter explicit stated that he didn't want other options. I would advise you to confirm from him before opening a PR.

  8. Musab1258 commented on Nov 11, 2026

    @Musab1258
    Contributor

    @tvpeter, I'd like to take this. I checked the existing codebase first and found:

    • The flags and env vars (--url, --basic-auth, SERVER_URL, RPC_BASIC_AUTH, COOKIE) exist only on wallet -w <name> config, which writes config.toml.
    • Runtime commands (sync, full_scan, broadcast, ...) load through WalletRuntime::load from the file alone, so credentials and the cookie can't be overridden per run. That is still the gap this issue describes.
    • cookie has no named flag (it is positional), the env var names aren't documented, and the README still lists --rpc-user / --rpc-password, which don't exist.

    I propose that we have optional overrides for URL, basic auth, and cookie on the wallet subcommand (flag > env > config file), applied when the config is loaded, plus the docs fix. No change to the config file format.

    @emma31-dev mentioned that you didn't want other options for configuration. Does that apply to runtime overrides? If it does, I'll limit this to the docs fix.

  9. tvpeter commented on Nov 13, 2026

    @tvpeter
    Collaborator

    Additional context I updated the bdk-cli in the bdk-sp nix environment, and it broke most of the commands I was using to wrap bdk-cli. Some of the changes are useful, like writing keys into file, but some others are not, like rpc credentials. I'm starting and stopping this node very frequently and the rpc cookie changes each time. I had to add a tool like dasel to modify the parameters I need in the file.

    Hi @nymius, thanks for raising this. Could you confirm whether the cookie path changes between restarts, or its content? We opted to save the path rather than the cookie itself because we assumed the path will not change consistently. The file is read each time a command runs, so a restart that keeps the same datadir should already work. It would only break if the datadir changes, e.g. a temp dir per run.

    I would like config.toml to stay the single source of truth, so we won’t add runtime flags or env overrides on the wallet commands; that would give two places to look for a wallet’s settings. Making config --force update only the passed fields would mean making most of its required options optional. A separate wallet config update (or similar) that loads the existing entry and changes only the given fields might be the cleaner route. Open to thoughts.

    @Musab1258, that answers your question: no runtime overrides. #387 (the docs fix) is still welcome. Let’s agree on the update idea here before any code.

  10. nymius commented on Nov 17, 2026

    @nymius
    ContributorAuthor

    Hi @nymius, thanks for raising this. Could you confirm whether the cookie path changes between restarts, or its content? We opted to save the path rather than the cookie itself because we assumed the path will not change consistently. The file is read each time a command runs, so a restart that keeps the same datadir should already work. It would only break if the datadir changes, e.g. a temp dir per run.

    Yes, what I was doing is spawn a temporal environment for testing, so the value of the cookie and keys was recreated each time. I think your assumption is correct if you're using bdk-cli for non-testing purposes, but in a throw away testing environment, it doesn't hold.

    I would like config.toml to stay the single source of truth, so we won’t add runtime flags or env overrides on the wallet commands; that would give two places to look for a wallet’s settings. Making config --force update only the passed fields would mean making most of its required options optional. A separate wallet config update (or similar) that loads the existing entry and changes only the given fields might be the cleaner route. Open to thoughts.

    I agree with the single source of truth approach. I rely on this sparsely, so it's not something I cannot workaround each time. But if you go on with implementation, maybe a --env flag that enables this secondary config might avoid the double source of truth issue. `

  11. Musab1258 commented on Nov 19, 2026

    @Musab1258
    Contributor

    Thanks, @nymius, that clarifies the use case.

    I have one question to help determine the right solution: when you say the keys are recreated on every run, is the bdk-cli wallet also configured afresh each time, or do its datadir and config.toml persist between runs?

    If the wallet is configured afresh each time, the existing wallet config command should already support this workflow. If an entry with the same wallet name already exists, --force can overwrite it with the new descriptors and backend settings, provided the required configuration is supplied. In that case, I think we can just document this workflow.

    However, if the wallet configuration persists and only the Bitcoin Core connection details change (for example, the cookie path), I think a dedicated update command could be useful.

    So, @tvpeter, if it is the second use case, I'd propose adding:

    bdk-cli wallets update <WALLET_NAME> [--url ...] [--basic-auth ...] [--cookie ...]

    This would sit alongside the existing wallets list and wallets delete commands. It would load an existing wallet configuration, update only the supplied backend settings, and save the changes to config.toml, preserving the wallet's descriptors, network, database type, and client type.

    The command would fail if the wallet has no saved entry or if no update field is supplied. It would also validate that the supplied options are supported by the wallet's configured client type. When switching to basic authentication, it would clear the saved cookie to avoid the existing cookie taking precedence.

    @nymius, on the --env suggestion: I think it would create a second source of configuration, and @tvpeter wants config.toml to stay the single source of truth. I might probably be misunderstanding the intended behavior, though.

    If we don't want to add another command, I'd leave the implementation unchanged and improve the documentation of the wallet config command instead.

    What do you think?

  12. emma31-dev commented on Nov 19, 2026

    @emma31-dev
    Contributor

    Thanks, @nymius, that clarifies the use case.

    I have one question to help determine the right solution: when you say the keys are recreated on every run, is the bdk-cli wallet also configured afresh each time, or do its datadir and config.toml persist between runs?

    If the wallet is configured afresh each time, the existing wallet config command should already support this workflow. If an entry with the same wallet name already exists, --force can overwrite it with the new descriptors and backend settings, provided the required configuration is supplied. In that case, I think we can just document this workflow.

    However, if the wallet configuration persists and only the Bitcoin Core connection details change (for example, the cookie path), I think a dedicated update command could be useful.

    So, @tvpeter, if it is the second use case, I'd propose adding:

    bdk-cli wallets update <WALLET_NAME> [--url ...] [--basic-auth ...] [--cookie ...]

    This would sit alongside the existing wallets list and wallets delete commands. It would load an existing wallet configuration, update only the supplied backend settings, and save the changes to config.toml, preserving the wallet's descriptors, network, database type, and client type.

    The command would fail if the wallet has no saved entry or if no update field is supplied. It would also validate that the supplied options are supported by the wallet's configured client type. When switching to basic authentication, it would clear the saved cookie to avoid the existing cookie taking precedence.

    @nymius, on the --env suggestion: I think it would create a second source of configuration, and @tvpeter wants config.toml to stay the single source of truth. I might probably be misunderstanding the intended behavior, though.

    If we don't want to add another command, I'd leave the implementation unchanged and improve the documentation of the wallet config command instead.

    What do you think?

    I like the idea of a wallets update subcommand. I was just concerned of whether this should land in wallets update or wallet --wallet <WALLET_NAME> update since the wallet config is a wallet subcommand. Another concern is if this is really necessary since a single wallet can be configured with different wallet names and different configs for testing.

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

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

  • Status
    No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions