* Here's a commit message for this change: refactor: Move mint tests to fake_wallet.rs and add descriptive comments refactor: pure wallet/mint does not need arc refactor: Consolidate NUT-06 test into single function and remove redundant module docs: Add comments explaining test purposes in integration tests file refactor: Remove anyhow and replace with expect for error handling refactor: use expect in pure tests feat: Add configurable database type via environment variable for test mint and wallet refactor: Update database initialization in test mint and wallet creation feat: Add temporary directory support for redb and sqlite databases in tests feat: Add database type argument to test commands in justfile ci: Add build matrix for pure-itest with memory, sqlite, and redb databases refactor: use expect in pure tests refactor: Move and refactor `test_swap_unbalanced` from mint to integration tests pure refactor: move mint tests to pure tests docs: Add detailed comments explaining test file purposes for mint and integration tests refactor: Extract keyset ID retrieval into a reusable function test: Add concurrent double-spend test with 3 swap transactions refactor: Simplify concurrent swap request processing and error handling test: Add check to verify all proofs are marked as spent in concurrent double-spend test refactor: Optimize proof state retrieval in concurrent double-spend test feat: Add test for concurrent melt race condition with same proofs fix: Update concurrent melt test to use melt quote and handle errors refactor: melt concurrrent refactor: Rename test function for clarity in concurrent double-spend scenario refactor: Modify test_concurrent_double_spend_melt to manually create melt requests in mint tasks feat: con melt test refactor: Optimize proof state handling and error recovery in check_spendable refactor: Extract helper method to reset proofs to original state fix: reset y states fix: reset y states * fix: acces of priv feilds * fix: add extra migrate
Warning
This project is in early development, it does however work with real sats! Always use amounts you don't mind losing.
Cashu Development Kit
CDK is a collection of rust crates for Cashu wallets and mints written in Rust.
ALPHA This library is in early development, the api will change and should be used with caution.
Project structure
The project is split up into several crates in the crates/ directory:
- Libraries:
- cdk: Rust implementation of Cashu protocol.
- cdk-sqlite: SQLite Storage backend.
- cdk-redb: Redb Storage backend.
- cdk-rexie: Rexie Storage backend for browsers.
- cdk-axum: Axum webserver for mint.
- cdk-cln: CLN Lightning backend for mint.
- cdk-lnd: Lnd Lightning backend for mint.
- cdk-lnbits: LNbits Lightning backend for mint.
- cdk-fake-wallet: Fake Lightning backend for mint. To be used only for testing, quotes are automatically filled.
- cdk-mint-rpc: Mint management gRPC server and cli.
- Binaries:
- cdk-cli: Cashu wallet CLI.
- cdk-mintd: Cashu Mint Binary.
- cdk-mint-cli: Cashu Mint managemtn gRPC client cli.
Development
For a guide to settings up a development environment see DEVELOPMENT.md
Code Style Guidelines
-
Large Enum Variants: When an enum variant contains a large type (>100 bytes), box it using
Box<T>to reduce the overall enum size. This improves memory efficiency, especially for error types.// Instead of this: enum Error { SomeLargeError(LargeType), // LargeType is >100 bytes } // Do this: enum Error { SomeLargeError(Box<LargeType>), }
Implemented NUTs:
Mandatory
| NUT # | Description |
|---|---|
| 00 | Cryptography and Models |
| 01 | Mint public keys |
| 02 | Keysets and fees |
| 03 | Swapping tokens |
| 04 | Minting tokens |
| 05 | Melting tokens |
| 06 | Mint info |
Optional
| # | Description | Status |
|---|---|---|
| 07 | Token state check | ✔️ |
| 08 | Overpaid Lightning fees | ✔️ |
| 09 | Signature restore | ✔️ |
| 10 | Spending conditions | ✔️ |
| 11 | Pay-To-Pubkey (P2PK) | ✔️ |
| 12 | DLEQ proofs | ✔️ |
| 13 | Deterministic secrets | ✔️ |
| 14 | Hashed Timelock Contracts (HTLCs) | ✔️ |
| 15 | Partial multi-path payments (MPP) | ✔️ |
| 16 | Animated QR codes | ❌ |
| 17 | WebSocket subscriptions | ✔️ |
| 18 | Payment Requests | ✔️ |
| 19 | Cached responses | ✔️ |
| 20 | Signature on Mint Quote | ✔️ |
Bindings
Experimental JS bindings can be found in the bindings repository.
License
Code is under the MIT License
Contribution
All contributions are welcome.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, shall be licensed as above, without any additional terms or conditions.
Please see the development guide.