Skip to content

refactor(config): remove redundant wallet field from WalletConfigInner - #350

Open
Jennycj wants to merge 1 commit into
bitcoindevkit:masterfrom
Jennycj:refactor/remove-wallet-config-field
Open

Jennycj wants to merge 1 commit into
bitcoindevkit:masterfrom
Jennycj:refactor/remove-wallet-config-field

Conversation

@Jennycj

@Jennycj Jennycj commented Oct 12, 2026 •

Copy link
Copy Markdown

Description

Removes the redundant wallet field from WalletConfigInner. The wallet name was being stored twice: once as the key in WalletConfig::wallets, and once inside each entry as wallet: String. The wallets command's JSON/TOML output showed both.
For example:

{
  "my_wallet": {
    "wallet": "my_wallet",
    "network": "testnet",
    ...
  }
}

The "wallet" field inside the entry is gone and the name is still available as the map key.

Fixes #332

Notes to the reviewers

  • TryFrom<&WalletConfigInner> for WalletOpts needed to be removed because it only receives the struct. It is now replaced with a private try_to_wallet_opts(&self, wallet_name: &str) that takes the name from the caller instead.

  • Backward compatible: old config.toml files with the stray wallet = "..." line still load (serde ignores unknown fields). This is covered bytest_load_tolerates_legacy_wallet_field.

  • CHANGELOG updated under [Unreleased].

Checklists

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing

@codecov

codecov Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.83%. Comparing base (4445a26) to head (bc050c7).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #350      +/-   ##
==========================================
+ Coverage   58.74%   58.83%   +0.08%     
==========================================
  Files          25       25              
  Lines        4608     4618      +10     
==========================================
+ Hits         2707     2717      +10     
  Misses       1901     1901              
Flag Coverage Δ
rust 58.83% <100.00%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Jennycj
Jennycj force-pushed the refactor/remove-wallet-config-field branch from b5a675e to d3ec317 Compare October 20, 2026 10:35

@vadim-anfv vadim-anfv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up, @Jennycj.
I left one note inline on the new test. Happy to test once it is rebased.

Comment thread tests/integration/init.rs Outdated
// as a `"wallet"` field inside each entry.
#[cfg(feature = "rpc")]
#[test]
fn test_list_wallets_entry_has_no_redundant_wallet_field() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure a test for an absent field is needed at all: the field is gone from WalletConfigInner, so serde cannot emit it either way, and the type already guarantees that.

If you would rather keep the check, maybe move it into test_list_wallets_with_entries just above, which already does the same setup.

@Jennycj Jennycj Oct 25, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review @vadim-anfv . I agree, and have removed the test.

@tvpeter tvpeter left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @Jennycj for working on this.

A few quick things before we merge:

  • Please rebase as #312 introduced updates to the wallets command.
  • Address Vadim's feedback regarding the test comment.
  • Squash your commits to a single commit.

Comment thread src/config.rs Outdated

fn try_from(config: &WalletConfigInner) -> Result<Self, Self::Error> {
impl WalletConfigInner {
fn try_to_wallet_opts(&self, wallet_name: &str) -> Result<WalletOpts, Error> {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to_wallet_opts name as the method does not implement TryFrom trait and there is no infallible to_wallet_opts here

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out. I have renamed to to_wallet_opts, and also dropped the leftover let config = self; binding.

`WalletConfigInner` duplicated its own wallet name in a `wallet` field,
even though it's already the key in `WalletConfig::wallets` - this
showed up as a redundant `"wallet"` entry in `wallets list` output.

`TryFrom<&WalletConfigInner> for WalletOpts` relied on that field, so
it's replaced with a private `to_wallet_opts(&self, wallet_name: &str)`
that takes the name from the caller's map lookup instead. Old config.toml
files still load fine; serde ignores the now-unknown `wallet` key.

Fixes bitcoindevkit#332
@Jennycj
Jennycj force-pushed the refactor/remove-wallet-config-field branch from d3ec317 to bc050c7 Compare October 25, 2026 22:55
@Jennycj

Jennycj commented Oct 25, 2026

Copy link
Copy Markdown
Author

Thank you @Jennycj for working on this.

A few quick things before we merge:

I have now rebased on master, addressed both review comments, and squashed my commits into a single signed commit.

This branch has not been deployed

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

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Remove "wallet" field from WalletConfigInner

3 participants