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).
The library defines basic types like Mint
, Proof
etc., that conform to corresponding protocols. This allows a library user to either reuse these types or define their own in accordance with these protocols.
let mintURL = URL(string: "https://testmint.macadamia.cash")!
let mint = try await Mint(with: mintURL)
let amount = 511
let quote = try await CashuSwift.getQuote(mint: mint,
quoteRequest: CashuSwift.Bolt11.RequestMintQuote(unit: "sat",
amount: amount))
let proofs = try await CashuSwift.issue(for: quote, on: mint) as! [CashuSwift.Proof]
let (token, change) = try await CashuSwift.send(mint: mint, 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 CashuSwift.receive(mint: mint, token: token)
let quoteRequest = CashuSwift.Bolt11.RequestMeltQuote(unit: "sat", request: q2.request, options: nil)
let quote = try await CashuSwift.getQuote(mint:mint, quoteRequest: quoteRequest)
let result = try await CashuSwift.melt(mint: mint, quote: quote, proofs: proofs)
// result.paid == true if the Bolt11 lightning payment successful