Overview
Sovran implements the Cashu ecash protocol through thecoco-cashu-core and coco-cashu-react libraries. Ecash tokens are digital bearer instruments that can be sent, received, and validated cryptographically.
Token Validation
Thehelper/coco/utils.ts module provides token validation utilities:
Validate Token Format
helper/coco/utils.ts:55-62.
Decode Token
Tokens are decoded usingcoco-cashu-core:
Send Operations
TheuseSendWithHistory hook manages ecash token creation:
Two-Step Send Flow
hooks/coco/useSendWithHistory.ts:38-113.
Automatic Rollback
Failed send operations are automatically rolled back:hooks/coco/useSendWithHistory.ts:114-138.
Receive Operations
Build Receive History Entry
Centralized receive entry construction:helper/coco/utils.ts:334-349.
Sum Proof Amounts
Utility to calculate total token value:helper/coco/utils.ts:319-323.
Token Processing
TheuseProcessPaymentString hook handles token detection and routing:
Regular Ecash Tokens
hooks/coco/useProcessPaymentString.ts:203-212.
UR-Encoded Tokens
Support for animated QR codes (UR codes):hooks/coco/useProcessPaymentString.ts:153-199.
NUT-18 Payment Requests
Support for Nostr-transported payment requests:Detection
hooks/coco/useProcessPaymentString.ts:29-45.
Routing Logic
Payment requests are routed based on available data:
From
hooks/coco/useProcessPaymentString.ts:231-240.
Mint Validation
hooks/coco/useProcessPaymentString.ts:113-133.
Token Encoding
Tokens can be encoded in multiple versions:V4 Encoding (NFC)
hooks/useNfcEcashPayment.tsx:133.
Standard Encoding
Token State Management
Pending Tokens
Tokens in pending state:Reserved Proofs
Proofs locked during operations:Recovery Operations
components/blocks/PrimaryBalance.tsx:188-222.
Coco-Cashu Integration
Core Principles
Manager Usage
Event Subscription
hooks/coco/useSendWithHistory.ts:65-73.
Key Features
Token Validation
Cryptographic validation of ecash tokens before receive
Two-Step Send
Prepare and execute pattern with automatic rollback on failure
UR Code Support
Animated QR codes for large tokens with progress tracking
Payment Requests
NUT-18 payment requests with Nostr transport
Related Documentation
- Lightning Payments - Lightning Network integration
- Multi-Account - Account management
- NFC Payments - NFC token transfers