This library provides basic functionality and model representation for using the Cashu protocol via its V1 API.
FakeWallet
ecash.
Implemented NUTs:
# | 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 |
# | 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 | N/A |
17 | WebSocket subscriptions | 🚧 |
Most methods on Mint
have additional parameters for customizing their behaviour (e.g. preferredDistribution
, seed
for deterministic secret generation)
let mintURL = URL(string: "https://testmint.macadamia.cash")!
let mint = try await Mint(with: mintURL)
let quote = try await mint.getQuote(quoteRequest: Bolt11.RequestMintQuote(unit: "sat",
amount: 21))
let proofs = try await mint.issue(for: quote)
let (token, change) = try await mint.send(proofs: proofs, amount: 15)
// The token object can be serialized to a string (currently only V3 format supported)
let tokenString = try token.serialize(.V3)
let token = try "cashuAey...".deserializeToken()
// This will swap the ecash contained in the token and return your new proofs
let proofs = try await mint.receive(token: token)
let meltQuoteRequest = Bolt11.RequestMeltQuote(unit: "sat", request: q2.request, options: nil)
let meltQ = try await mint.getQuote(quoteRequest: meltQuoteRequest)
let result = try await mint.melt(quote: meltQ, proofs: proofs)
// result.paid == true if the Bolt11 lightning payment successful