WIP: feat: add wallet trait #1581

Draft
crodas wants to merge 1 commit from crodas/feature/wallet-trait into main
crodas commented 2026-01-28 03:28:54 +00:00 (Migrated from github.com)

Description

Introduce a modular trait system for wallet implementations that enables flexible composition of wallet capabilities. This allows different wallet implementations to share a common interface while supporting selective trait implementation.

The trait hierarchy consists of:

  • WalletTypes: Base trait defining associated types (Amount, Proofs, etc.)
  • WalletBalance: Balance query operations
  • WalletMintInfo: Mint information and keyset operations
  • WalletMint: Minting operations (payment -> tokens)
  • WalletMelt: Melting operations (tokens -> payment)
  • WalletReceive: Token receiving
  • WalletProofs: Proof state management
  • Wallet: Super-trait combining all capabilities with blanket impl

Implements all traits for both cdk::Wallet and cdk-ffi::Wallet, enabling generic code that works with any wallet implementation.


Notes to the reviewers


Suggested CHANGELOG Updates

CHANGED

ADDED

REMOVED

FIXED


Checklist

### Description Introduce a modular trait system for wallet implementations that enables flexible composition of wallet capabilities. This allows different wallet implementations to share a common interface while supporting selective trait implementation. The trait hierarchy consists of: - WalletTypes: Base trait defining associated types (Amount, Proofs, etc.) - WalletBalance: Balance query operations - WalletMintInfo: Mint information and keyset operations - WalletMint: Minting operations (payment -> tokens) - WalletMelt: Melting operations (tokens -> payment) - WalletReceive: Token receiving - WalletProofs: Proof state management - Wallet: Super-trait combining all capabilities with blanket impl Implements all traits for both cdk::Wallet and cdk-ffi::Wallet, enabling generic code that works with any wallet implementation. ----- ### Notes to the reviewers <!-- In this section you can include notes directed to the reviewers, like explaining why some parts of the PR were done in a specific way --> ----- ### 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 #### REMOVED #### FIXED ---- ### Checklist * [ ] I followed the [code style guidelines](https://github.com/cashubtc/cdk/blob/main/CODE_STYLE.md) * [ ] I ran `just final-check` before committing
davidcaseria (Migrated from github.com) reviewed 2026-01-28 03:28:54 +00:00
thesimplekid (Migrated from github.com) reviewed 2026-01-28 17:42:17 +00:00
thesimplekid (Migrated from github.com) commented 2026-01-28 17:42:17 +00:00

Do we see a use case where we would want multiple traits to implement only part of the api? I don't think I see one and one trait would be simpler.

Do we see a use case where we would want multiple traits to implement only part of the api? I don't think I see one and one trait would be simpler.
crodas (Migrated from github.com) reviewed 2026-01-30 06:22:01 +00:00
crodas (Migrated from github.com) commented 2026-01-30 06:22:01 +00:00

Is it any better at 1a2fd1fcd960696fd5fb3beb0ac60921b9d4bf32?

Is it any better at 1a2fd1fcd960696fd5fb3beb0ac60921b9d4bf32?
thesimplekid (Migrated from github.com) reviewed 2026-01-30 11:41:04 +00:00
thesimplekid (Migrated from github.com) commented 2026-01-30 11:41:04 +00:00

i don't see how this change addresses the comment of 1 wallet trait vs the multiple it still has multiple. To be clear I not strongly against having multiple traits if there is a reason for it, just one trait would be simpler but if others see a use case for the multiple I'm okay with that.

i don't see how this change addresses the comment of 1 wallet trait vs the multiple it still has multiple. To be clear I not strongly against having multiple traits if there is a reason for it, just one trait would be simpler but if others see a use case for the multiple I'm okay with that.
thesimplekid commented 2026-02-24 12:24:00 +00:00 (Migrated from github.com)

@crodas Now that we have released 0.15 I think we should turn our attention back to this and get it merged. Looks like it needs a rebase is there anything else that is outstanding with it?

cc @ye0man

@crodas Now that we have released 0.15 I think we should turn our attention back to this and get it merged. Looks like it needs a rebase is there anything else that is outstanding with it? cc @ye0man
crodas commented 2026-02-24 12:40:42 +00:00 (Migrated from github.com)

Rebasing, I am on it now.

Rebasing, I am on it now.
This pull request is marked as a work in progress.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin crodas/feature/wallet-trait:crodas/feature/wallet-trait
git switch crodas/feature/wallet-trait

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 crodas/feature/wallet-trait
git switch crodas/feature/wallet-trait
git rebase main
git switch main
git merge --ff-only crodas/feature/wallet-trait
git switch crodas/feature/wallet-trait
git rebase main
git switch main
git merge --no-ff crodas/feature/wallet-trait
git switch main
git merge --squash crodas/feature/wallet-trait
git switch main
git merge --ff-only crodas/feature/wallet-trait
git switch main
git merge crodas/feature/wallet-trait
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!1581
No description provided.