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. |
|
@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
|
Thanks for the first review! |
vadim-anfv
left a comment
There was a problem hiding this comment.
tACK f2a7e8f
Both of my earlier comments are addressed. I can't resolve the threads myself - could you close them?
Added two non-blocking notes inline.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #312 +/- ##
==========================================
+ Coverage 59.06% 59.82% +0.76%
==========================================
Files 22 22
Lines 3857 3968 +111
==========================================
+ Hits 2278 2374 +96
- Misses 1579 1594 +15
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
tvpeter
left a comment
There was a problem hiding this comment.
Thank you @yan-pi for working on this issue.
So having reconsidered the approach I suggested earlier, I think it may not be a good idea to delete saved configurations that have wallet data already persisted. So it will be better to handle it in such a way that, if the wallet data exists, return an error that wallet data exist for that configuration and do not delete the config. While it is possible to recreate the same config, the user might have lost the descriptors to do so. Also, if at all further down the line, we decide to consider deleting, it should also wipe the db file (for sqlite and much harder to even consider for redb) with a --force flag.
Aside that, kindly address the minor failing checks and review earlier by Vadim.
Thank you
|
The failing checks are unrelated to this PR. use payjoin::persist::SessionPersister as _;This file is not modified by this PR, and no Payjoin tests are executed. The default/no-default feature checks and formatting pass. |
f2a7e8f to
987c2e7
Compare
987c2e7 to
5196d96
Compare
|
Rebased onto the latest upstream/master and addressed the requested changes. I believe it’s ready for another round of review. |
vadim-anfv
left a comment
There was a problem hiding this comment.
Tested this locally and it looks good:
- an unused saved configuration is deleted, a wallet with persisted data is refused and keeps both its config entry and its data
- deleting one of two configurations leaves the other working
- deleting a name that is not in the config, and deleting with no config at all, both fail with a clear message
- redb: with two wallets in the shared store, the unused one is deleted while the store and the other wallet stay untouched
- builds clean with default features,
--no-default-featuresand--all-features
Added one small suggestion inline, on the message shown when the shared redb store cannot be opened.
The branch conflicts with master in CHANGELOG.md though, could you rebase? I already ran all of the above against this head, so I'll tACK as soon as the conflict is gone.
| let database = bdk_redb::redb::Database::open(&db_path).map_err(|error| { | ||
| Error::Generic(format!( | ||
| "Failed to open Redb database at {db_path:?}: {error}" | ||
| )) | ||
| })?; |
There was a problem hiding this comment.
The wallet being deleted may be sqlite-backed, so "failed to open Redb database" does not tell the user why the delete was refused.
| let database = bdk_redb::redb::Database::open(&db_path).map_err(|error| { | |
| Error::Generic(format!( | |
| "Failed to open Redb database at {db_path:?}: {error}" | |
| )) | |
| })?; | |
| let database = bdk_redb::redb::Database::open(&db_path).map_err(|error| { | |
| Error::Generic(format!( | |
| "Cannot inspect the shared Redb store at {db_path:?} to tell whether '{wallet_name}' has data: {error}" | |
| )) | |
| })?; |
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