feat: add inactive/expired keysets to fake wallet via MintBuilder #1687

Open
Forte11Cuba wants to merge 4 commits from Forte11Cuba/feat/test-keysets-mint-builder into main
Forte11Cuba commented 2026-02-27 04:25:15 +00:00 (Migrated from github.com)

Description

Implements the MintBuilder-based approach for creating inactive/expired test keysets in the fake wallet mint, as requested in #1596 and the review feedback on #1681.

Changes:

  • Add final_expiry: Option<u64> parameter to Mint::rotate_keyset so callers can set an expiry on the rotated-out keyset
  • Introduce KeysetRotation struct and with_keyset_rotation() builder method on MintBuilder to configure extra keyset rotations at build time
  • Add create_test_keysets: bool config option to FakeWallet (configurable via CDK_MINTD_FAKE_WALLET__CREATE_TEST_KEYSETS=true`)
  • When enabled, creates a Sat V0 expired keyset and a Sat V1 rotation-deactivated keyset alongside the normal active keysets
  • Enable create_test_keysets in start_fake_mint binary for integration tests

Target keyset layout when create_test_keysets: true:

Keyset Status Notes
Sat V1 active current working keyset (from normal build)
Sat V0 inactive final_expiry in the past (expired)
Sat V1 inactive no final_expiry (rotation-deactivated)
USD V1 active non-sat keyset (from supported_units config)

Notes to the reviewers

  • The final_expiry bugfix is separate (PR #1686)
  • This uses the MintBuilder pattern as requested by @thesimplekid instead of splitting run_mintd_with_shutdown
  • All existing callers of rotate_keyset pass None for the new parameter (no behavior change)
  • The KeysetRotation struct is intentionally simple and mirrors RotateKeyArguments fields

Suggested CHANGELOG Updates

CHANGED

ADDED

  • Added final_expiry parameter to Mint::rotate_keyset to allow setting expiry on rotated keysets
  • Added KeysetRotation struct and MintBuilder::with_keyset_rotation() for configuring extra keyset rotations at build time
  • Added create_test_keysets config option to FakeWallet for creating inactive/expired test keysets

REMOVED

FIXED


Checklist

### Description Implements the MintBuilder-based approach for creating inactive/expired test keysets in the fake wallet mint, as requested in #1596 and the review feedback on #1681. **Changes:** - Add `final_expiry: Option<u64>` parameter to `Mint::rotate_keyset` so callers can set an expiry on the rotated-out keyset - Introduce `KeysetRotation` struct and `with_keyset_rotation()` builder method on `MintBuilder` to configure extra keyset rotations at build time - Add `create_test_keysets: bool` config option to `FakeWallet` (configurable via CDK_MINTD_FAKE_WALLET__CREATE_TEST_KEYSETS=true`) - When enabled, creates a Sat V0 expired keyset and a Sat V1 rotation-deactivated keyset alongside the normal active keysets - Enable `create_test_keysets` in `start_fake_mint` binary for integration tests **Target keyset layout when `create_test_keysets: true`:** | Keyset | Status | Notes | |---|---|---| | Sat V1 | active | current working keyset (from normal build) | | Sat V0 | inactive | `final_expiry` in the past (expired) | | Sat V1 | inactive | no `final_expiry` (rotation-deactivated) | | USD V1 | active | non-sat keyset (from supported_units config) | ----- ### Notes to the reviewers - The `final_expiry` bugfix is separate (PR #1686) - This uses the `MintBuilder` pattern as requested by @thesimplekid instead of splitting `run_mintd_with_shutdown` - All existing callers of `rotate_keyset` pass `None` for the new parameter (no behavior change) - The `KeysetRotation` struct is intentionally simple and mirrors `RotateKeyArguments` fields ----- ### Suggested [CHANGELOG](https://github.com/cashubtc/cdk/blob/main/CHANGELOG.md) Updates <!-- Please do not edit the actual changelog but note what you changed here. --> #### CHANGED #### ADDED - Added `final_expiry` parameter to `Mint::rotate_keyset` to allow setting expiry on rotated keysets - Added `KeysetRotation` struct and `MintBuilder::with_keyset_rotation()` for configuring extra keyset rotations at build time - Added `create_test_keysets` config option to `FakeWallet` for creating inactive/expired test keysets #### REMOVED #### FIXED ---- ### Checklist * [x] I followed the [code style guidelines](https://github.com/cashubtc/cdk/blob/main/CODE_STYLE.md) * [ ] I ran `just final-check` before committing
thesimplekid commented 2026-03-03 10:26:02 +00:00 (Migrated from github.com)

Can you rebase this on main now that https://github.com/cashubtc/cdk/pull/1686 is merged.

Can you rebase this on main now that https://github.com/cashubtc/cdk/pull/1686 is merged.
thesimplekid commented 2026-03-04 17:57:32 +00:00 (Migrated from github.com)

It would be nice if we could allow the user to configure what keysets they want instead of just a default test matrix like it is now. To do this we could add new env configs for the fake mint. I believe nutshell has something like this so we could mirror that.

It would be nice if we could allow the user to configure what keysets they want instead of just a default test matrix like it is now. To do this we could add new env configs for the fake mint. I believe nutshell has something like this so we could mirror that.
thesimplekid commented 2026-03-07 15:13:24 +00:00 (Migrated from github.com)

I think this looks good. Can you just fix the clippy warning. Another thing that might be useful is being able to set the denominations of the keyset but we can leave that for a follow up.

I think this looks good. Can you just fix the clippy warning. Another thing that might be useful is being able to set the denominations of the keyset but we can leave that for a follow up.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin Forte11Cuba/feat/test-keysets-mint-builder:Forte11Cuba/feat/test-keysets-mint-builder
git switch Forte11Cuba/feat/test-keysets-mint-builder

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff Forte11Cuba/feat/test-keysets-mint-builder
git switch Forte11Cuba/feat/test-keysets-mint-builder
git rebase main
git switch main
git merge --ff-only Forte11Cuba/feat/test-keysets-mint-builder
git switch Forte11Cuba/feat/test-keysets-mint-builder
git rebase main
git switch main
git merge --no-ff Forte11Cuba/feat/test-keysets-mint-builder
git switch main
git merge --squash Forte11Cuba/feat/test-keysets-mint-builder
git switch main
git merge --ff-only Forte11Cuba/feat/test-keysets-mint-builder
git switch main
git merge Forte11Cuba/feat/test-keysets-mint-builder
git push origin main
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cashubtc/cdk!1687
No description provided.