Add command to delete saved wallet config - #312
Conversation
9c25d3d to
e987877
Compare
wallets --delete to remove saved wallet config
So |
tvpeter
left a comment
There was a problem hiding this comment.
I agree with the approach of the delete operation but the returned type of WalletList is unnecesary. If returning a message is not possible, then it is better to split the wallets into something like wallets list and wallets --delete <name>. So WalletsSubcommand will be the top-level.
| #[derive(Args, Debug, Clone, PartialEq)] | ||
| pub struct ListWalletsCommand; | ||
| pub struct WalletsCommand { | ||
| /// Delete the saved configuration for the given wallet instead of listing. |
There was a problem hiding this comment.
| /// Delete the saved configuration for the given wallet instead of listing. | |
| /// Delete the saved configuration for the given wallet. |
|
|
||
| /// List all saved wallet configurations. | ||
| Wallets(ListWalletsCommand), | ||
| /// List all saved wallet configurations, or delete one with `--delete`. |
There was a problem hiding this comment.
| /// List all saved wallet configurations, or delete one with `--delete`. | |
| /// Saved wallet configuration operations. |
| "Wallet '{wallet_name}' not found in config" | ||
| ))); | ||
| } | ||
| config.save(&ctx.datadir)?; |
There was a problem hiding this comment.
Non-blocking: deleting the last wallet leaves config.toml with an empty wallets table, a state that was unreachable before --delete. WalletConfig::load returns None only when the file is missing, so wallets then prints {} and exits 0, while the same situation on a fresh datadir fails with "No wallets configured yet." and a non-zero exit (test_list_wallets_empty).
Probably worth folding into the wallets list / wallets delete split you are doing anyway.
| WalletConfigInner { | ||
| wallet: name.to_string(), | ||
| network: "testnet".to_string(), | ||
| ext_descriptor: EXT_DESCRIPTOR.to_string(), | ||
| int_descriptor: Some(INT_DESCRIPTOR.to_string()), | ||
| #[cfg(any(feature = "sqlite", feature = "redb"))] | ||
| database_type: "sqlite".to_string(), | ||
| #[cfg(any( | ||
| feature = "electrum", | ||
| feature = "esplora", | ||
| feature = "rpc", | ||
| feature = "cbf" | ||
| ))] | ||
| client_type: Some("rpc".to_string()), | ||
| #[cfg(any(feature = "electrum", feature = "esplora", feature = "rpc"))] | ||
| server_url: Some("http://localhost:18443".to_string()), | ||
| #[cfg(feature = "electrum")] | ||
| batch_size: None, | ||
| #[cfg(feature = "esplora")] | ||
| parallel_requests: None, | ||
| #[cfg(feature = "rpc")] | ||
| rpc_user: None, | ||
| #[cfg(feature = "rpc")] | ||
| rpc_password: None, | ||
| #[cfg(feature = "rpc")] | ||
| cookie: None, | ||
| #[cfg(any(feature = "electrum", feature = "esplora"))] | ||
| proxy: None, | ||
| #[cfg(any(feature = "electrum", feature = "esplora"))] | ||
| proxy_auth: None, | ||
| #[cfg(any(feature = "electrum", feature = "esplora"))] | ||
| proxy_retries: None, | ||
| #[cfg(any(feature = "electrum", feature = "esplora"))] | ||
| proxy_timeout: None, | ||
| #[cfg(feature = "cbf")] | ||
| conn_count: None, | ||
| } |
There was a problem hiding this comment.
Nit: test_wallet_config_inner_to_opts_conversion and test_invalid_client_type_fails still build WalletConfigInner by hand, repeating the same ~20 cfg-gated fields as the new helper.
Since you are adding a helper anyway, consider turning it into a small builder and reusing it there too - those two only differ in a few values. Fine to leave for a follow-up.
There was a problem hiding this comment.
The helper is gone in the updated version. The delete path is covered by the
integration tests instead.
|
@tvpeter, that makes sense. Splitting the operations would also fix the return type issue. Just to confirm, should this become |
Yes. We both said the same thing. |
e987877 to
011390e
Compare
wallets --delete to remove saved wallet config011390e to
f2a7e8f
Compare
Description
Adds
wallets delete <wallet_name>to remove a saved wallet configuration.Saved configurations can be listed with
wallets list.Resolves #310.
Notes to the reviewers
List and delete use separate handlers and outputs.
Delete only removes the entry from
config.toml.Wallet database files arenot removed.
Changelog notice
wallets deleteto remove a saved wallet configurationChecklists
All Submissions:
cargo fmtandcargo clippybefore committingNew Features:
CHANGELOG.md