Skip to content

Conversation

@crodas
Copy link
Collaborator

@crodas crodas commented Jan 28, 2026

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

@crodas crodas self-assigned this Jan 28, 2026
@github-project-automation github-project-automation bot moved this to Backlog in CDK Jan 28, 2026
@crodas crodas force-pushed the feature/wallet-trait branch from 497aa6d to 85ffb8b Compare January 28, 2026 04:33
@crodas crodas marked this pull request as ready for review January 28, 2026 05:28

#[cfg_attr(target_arch = "wasm32", async_trait::async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)]
impl WalletMintInfo for Wallet {
Copy link
Collaborator

Choose a reason for hiding this comment

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

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.

Copy link
Collaborator Author

@crodas crodas Jan 30, 2026

Choose a reason for hiding this comment

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

Is it any better at 1a2fd1f?

Copy link
Collaborator

Choose a reason for hiding this comment

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

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.

@crodas crodas force-pushed the feature/wallet-trait branch 2 times, most recently from 1a2fd1f to b535f81 Compare January 30, 2026 06:23
@ye0man ye0man moved this from Backlog to In Review in CDK Feb 4, 2026
@crodas crodas force-pushed the feature/wallet-trait branch from b535f81 to 84528dd Compare February 5, 2026 20:07
@crodas crodas marked this pull request as draft February 5, 2026 21:15
@crodas crodas force-pushed the feature/wallet-trait branch 3 times, most recently from 3dbcb17 to 60280ad Compare February 10, 2026 19:48
Add a new `Wallet` trait in cdk-common that provides a comprehensive interface
for all wallet operations with associated types. This enables trait-based
polymorphism for different wallet implementations, better FFI support, and
cleaner separation between interface and implementation.

The `mint_quote` method now accepts a `PaymentMethod` parameter and routes to
Bolt11, Bolt12, or Custom payment backends — matching the existing `melt_quote`
pattern.

Key changes:
- Define `Wallet` trait in cdk-common with associated types for Amount, Proofs,
  MintQuote, MeltQuote, Token, PaymentMethod, etc.
- Implement the trait for the concrete `Wallet` struct in cdk
- Route `mint_quote` by PaymentMethod (Bolt11/Bolt12/Custom)
- Add wallet_trait.rs to cdk-ffi for FFI support
- Update CLI, multi-mint wallet, examples, and integration tests
- Refactor balance, keyset, and issue modules to use the trait
@crodas crodas force-pushed the feature/wallet-trait branch from 60280ad to ee94ebb Compare February 10, 2026 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

2 participants