AgentSkillsCN

agicash-wallet-documentation

Agicash 钱包交易流程与实体的文档化说明。适用于修改收付款功能、处理 Quote/Swap/Transaction 实体,或深入了解支付状态机。

SKILL.md
--- frontmatter
name: agicash-wallet-documentation
description: Documentation for Agicash wallet transaction flows and entities. Use when modifying send/receive features, working with Quote/Swap/Transaction entities, or understanding payment state machines.

Agicash Wallet Documentation

Transaction Types

TypeDirectionEntityFlow
Cashu LightningSendCashuSendQuoteMelt proofs → pay Lightning invoice
Cashu LightningReceiveCashuReceiveQuotePay Lightning invoice → mint proofs
Cashu TokenSendCashuSendSwapSwap proofs → encode token → share
Cashu TokenReceiveCashuReceiveSwapParse token → swap proofs into account
Cashu TokenReceive (cross-account)CashuReceiveQuote or SparkReceiveQuoteMelt from source → Lightning → mint/receive on LN payment completed
Spark LightningSendSparkSendQuotePay Lightning invoice directly
Spark LightningReceiveSparkReceiveQuoteGenerate invoice → receive payment
Lightning AddressReceiveCashuReceiveQuote or SparkReceiveQuoteServer-side: LNURL discovery → invoice → payment

All operations create a corresponding Transaction entity for UI display.

Core Concepts

Entities

  • Quote = Payment request lifecycle (Lightning operations with Cashu mints or Spark)
  • Swap = Peer-to-peer proof exchange (Cashu tokens)
  • Transaction = User-facing record (1:1 with Quote or Swap via transactionId)
  • Proof = Cryptographic ecash token with amount, id, secret, C

Cashu Protocol Terms

  • Proof/Input = Ecash token sent to mint for swap/melt
  • BlindedMessage/Output = Blinded secret sent to mint for signing
  • BlindSignature/Promise = Mint's signature, unblinded to get Proof
  • Mint = Create proofs by paying Lightning
  • Melt = Spend proofs to pay Lightning
  • Swap = Exchange proofs for new proofs

Reference Files

FlowReference
Entity relationships & cross-cutting patternsreferences/entities.md
Cashu Lightning Send (melt)references/cashu-lightning-send.md
Cashu Lightning Receive (mint)references/cashu-lightning-receive.md
Cashu Token Sendreferences/cashu-send-swap.md
Cashu Token Receivereferences/cashu-receive-swap.md
Spark Lightning (send/receive)references/spark-operations.md
Cross-account token claimreferences/cross-account-claim.md
Public token receive (unauthenticated)references/public-token-receive.md
Lightning Address (LNURL-pay)references/lightning-address.md
Background task processingreferences/task-processing.md

File Structure

code
app/features/{send|receive}/
├── {entity}.ts              # Type definitions (discriminated unions)
├── {entity}-service.ts      # Business logic, state transitions
├── {entity}-repository.ts   # Database access, encryption
└── {entity}-hooks.ts        # TanStack Query hooks

Import hierarchy (never reverse): lib/componentsfeaturesroutes

Key Invariants

  1. All state transitions are idempotent - safe to retry
  2. All Quote/Swap entities have version - check before updates (optimistic locking). Transaction does not have a version field.
  3. All sensitive data encrypted - handled transparently by repository
  4. Proofs are RESERVED when quote/swap created - released on failure/expiry
  5. Only one client runs background tasks - leader election via take_lead RPC