Cashu eCash Integration
SatSigner implements the Cashu protocol for privacy-preserving electronic cash (eCash). Connect to Cashu mints to issue, send, receive, and redeem eCash tokens backed by Bitcoin Lightning payments.What is Cashu?
Cashu is a free and open-source eCash protocol built on Bitcoin and Lightning Network. It provides:- Privacy: Blind signatures prevent mints from tracking spending
- Instant settlements: Lightning-backed payments
- Offline transactions: Transfer tokens without internet
- Interoperability: Standard protocol across implementations
Core Concepts
Mints
Cashu mints are servers that issue eCash tokens:Proofs
eCash tokens are cryptographic proofs:Tokens
Proofs are encoded into shareable tokens:Implementation
SatSigner uses the@cashu/cashu-ts library for Cashu operations.
Wallet Management
Wallet Cache: Maintains persistent connections to mintsConnecting to Mints
Adding a Mint
Fetching Keysets
Keysets are cryptographic key sets used by the mint:Minting eCash (Receiving)
Flow: Lightning → eCash
Step 1: Create Mint Quote Request invoice from mint:Sending eCash
Creating Tokens
Receiving eCash
Redeeming Tokens
Melting eCash (Spending)
Flow: eCash → Lightning
Step 1: Create Melt QuoteProof Validation
Check if proofs are still valid (unspent):UNSPENT: Proof is valid and spendablePENDING: Proof is being processedSPENT: Proof has already been redeemed
Token Validation
Validate encoded tokens:Balance Management
Calculate balance from proofs:Privacy Features
Blind Signatures
Cashu uses blind signatures to ensure privacy:- Client: Creates blinded secret
- Mint: Signs blinded secret (cannot see original)
- Client: Unblinds signature to get valid proof
- Mint: Cannot link signature to original request
No Tracking
- Mints cannot track how tokens are spent
- Tokens can be split and combined freely
- No transaction graph like Bitcoin
- Offline transfers possible
Multi-Mint Strategy
For enhanced privacy:- Use multiple mints simultaneously
- Swap between mints periodically
- Split large amounts across mints
- Diversify custodial risk
Security Considerations
Custodial Risk
eCash is custodial - the mint holds the Bitcoin:- Only use trusted mints
- Don’t store large amounts
- Monitor mint reputation
- Diversify across multiple mints
Proof Management
- Never share proofs - they are bearer assets
- Backup proofs securely
- Track spent vs unspent proofs
- Validate tokens before accepting
Token Security
- Tokens are like cash - anyone with the token can spend it
- Send tokens through secure channels
- Verify mint URL before redeeming
- Be cautious with public tokens
Error Handling
Common errors and solutions: “Token already spent”- Proofs in token have been redeemed
- Double-spend attempt detected
- Cannot recover - proofs are spent
- Not enough valid proofs for amount
- Check proof states
- Mint more tokens or receive from others
- Token is from a different mint
- Cannot redeem at current mint
- Connect to correct mint first
Implementation Reference
Core API:apps/mobile/api/ecash.ts:1
Type Definitions: apps/mobile/types/models/Ecash.ts:1
UI Component: apps/mobile/components/SSEcashTransactionCard.tsx:1
Cashu Protocol Versions
SatSigner supports:- Token v4: Current standard with memo support
- Keyset Fetching: Dynamic keyset discovery
- Proof States: UNSPENT, PENDING, SPENT tracking