Skip to content

Mark Keysets as Deleted.#797

Open
KvngMikey wants to merge 15 commits intocashubtc:mainfrom
KvngMikey:wallet-deleted-keysets
Open

Mark Keysets as Deleted.#797
KvngMikey wants to merge 15 commits intocashubtc:mainfrom
KvngMikey:wallet-deleted-keysets

Conversation

@KvngMikey
Copy link
Copy Markdown
Contributor

@KvngMikey KvngMikey commented Oct 5, 2025

Fixes #731

Summary

This PR fixes the wallet behavior when a keyset disappears from a mint's /keysets response.

Changes

  • Updated load_mint_keysets to mark missing keysets as deleted.
  • Added update_keyset_active in crud.py to use named SQL parameters for SQLAlchemy async compatibility.
  • Verified with pytest tests/wallet/test_wallet.py -k keyset (all keyset tests now pass).

Comment thread cashu/wallet/wallet.py Outdated
Comment thread cashu/wallet/wallet.py
Comment thread tests/wallet/test_wallet.py Outdated
Comment thread tests/wallet/test_wallet.py Outdated
Copy link
Copy Markdown
Collaborator

@callebtc callebtc left a comment

Choose a reason for hiding this comment

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

LGTM but one outstanding question regarding the removed line await self.load_keysets_from_db()

what's the justification for that?

@KvngMikey
Copy link
Copy Markdown
Contributor Author

KvngMikey commented Oct 8, 2025

LGTM but one outstanding question regarding the removed line await self.load_keysets_from_db()

what's the justification for that?

@callebtc I replaced "await self.load_keysets_from_db()" because we now build self.keysets inline with the already-fetched list (keysets_in_db) filtered by k.unit == self.unit and k.active.
That list is fresh (we re-fetch after marking inactive), so the old helper’s extra query + loop is redundant.
The trace message is still printed two lines below, so no observability is lost.

@KvngMikey KvngMikey requested a review from callebtc October 8, 2025 14:21
@callebtc
Copy link
Copy Markdown
Collaborator

Hi @KvngMikey, sorry for getting back to you late. We have a crud called update_keyset that supports setting the active flag (latest main also can update the fee, worth a merge of main into this branch). Why not use that directly?

@KvngMikey
Copy link
Copy Markdown
Contributor Author

Hi @KvngMikey, sorry for getting back to you late. We have a crud called update_keyset that supports setting the active flag (latest main also can update the fee, worth a merge of main into this branch). Why not use that directly?

hi @callebtc , thanks for checking my work, I have addressed your request now.

@callebtc
Copy link
Copy Markdown
Collaborator

we talked about this off band: there should probably be a boolean deleted column in the keyset table of the wallet and if we flip it to True, the keyset shouldn't be loaded from the db, when we use load_keysets(). wanna try that?

@KvngMikey
Copy link
Copy Markdown
Contributor Author

we talked about this off band: there should probably be a boolean deleted column in the keyset table of the wallet and if we flip it to True, the keyset shouldn't be loaded from the db, when we use load_keysets(). wanna try that?

yes, i remember and i'm working on it.

@KvngMikey KvngMikey force-pushed the wallet-deleted-keysets branch from 9a9688c to dfd79ed Compare December 18, 2025 21:28
@KvngMikey
Copy link
Copy Markdown
Contributor Author

@callebtc PR updated, ready for re-review, thank you.

@KvngMikey
Copy link
Copy Markdown
Contributor Author

question:
when this PR goes in, would we need to update NUT01 to show that keysets can now be marked as deleted ?

cc @callebtc @a1denvalu3

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.25%. Comparing base (03f6f56) to head (57394e4).
⚠️ Report is 44 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #797      +/-   ##
==========================================
+ Coverage   74.40%   75.25%   +0.85%     
==========================================
  Files          99       99              
  Lines       11599    11723     +124     
==========================================
+ Hits         8630     8822     +192     
+ Misses       2969     2901      -68     

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

@ye0man ye0man added this to nutshell Jan 21, 2026
@github-project-automation github-project-automation bot moved this to In progress in nutshell Jan 21, 2026
@callebtc
Copy link
Copy Markdown
Collaborator

question: when this PR goes in, would we need to update NUT01 to show that keysets can now be marked as deleted ?

cc @callebtc @a1denvalu3

nope, this is just for the wallet and not related to the API. the mint just deletes the keyset

@KvngMikey
Copy link
Copy Markdown
Contributor Author

question: when this PR goes in, would we need to update NUT01 to show that keysets can now be marked as deleted ?
cc @callebtc @a1denvalu3

nope, this is just for the wallet and not related to the API. the mint just deletes the keyset

great, thank you !

@KvngMikey KvngMikey force-pushed the wallet-deleted-keysets branch from d1aa49d to 6624071 Compare February 9, 2026 10:05
@KvngMikey
Copy link
Copy Markdown
Contributor Author

@callebtc - this has also been rebased and is ready.

cc @a1denvalu3

Comment thread cashu/core/base.py Outdated
Comment thread cashu/core/base.py Outdated
Comment thread cashu/core/base.py Outdated
@ye0man ye0man added this to the 0.20.0 milestone Mar 10, 2026
Copilot AI review requested due to automatic review settings March 27, 2026 10:13
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review is ineligible. To be eligible to request a review, you need a paid Copilot license, or your organization must enable Copilot code review.

Comment thread cashu/wallet/wallet.py Outdated
Comment thread cashu/wallet/wallet.py Outdated
@KvngMikey KvngMikey force-pushed the wallet-deleted-keysets branch from 4b4ccac to 5364262 Compare March 27, 2026 18:45
Comment thread cashu/wallet/wallet.py Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

Bug: Wallet should mark keysets as "deleted" if they disappear from the mint's keysets response

5 participants