Crate cashu

Source
Expand description

§Cashu

crates.io Documentation MIT licensed

A Rust implementation of the Cashu protocol, providing the core functionality for Cashu e-cash operations.

§Overview

This crate implements the core Cashu protocol as defined in the Cashu NUTs (Notation, Usage, and Terminology).

§Features

  • Cryptographic Operations: Secure blind signatures and verification
  • Token Management: Creation, validation, and manipulation of Cashu tokens
  • NUTs Implementation: Support for the core Cashu protocol specifications
  • Type-safe API: Strongly-typed interfaces for working with Cashu primitives

§Usage

Add this to your Cargo.toml:

[dependencies]
cashu = "*"

§Basic Example

use cashu::amount::Amount;
use cashu::nuts::nut00::Token;
use std::str::FromStr;

// Parse a Cashu token from a string
let token_str = "cashuBo2FteCJodHRwczovL25vZmVlcy50ZXN0bnV0LmNhc2h1LnNwYWNlYXVjc2F0YXSBomFpSAC0zSfYhhpEYXCCpGFhAmFzeEAzYzNlOWRhMDU3ZjQzNmExOTc2MmRhOWYyYTBjMzc5YzE5N2RlNDMzZDY5MWU1NDI0ZmRjODcxNjZjMmNlMjZmYWNYIQKKtwESLR-yn5rqNAL3_8_H5BtpwjSPs7uOJ18kPn2mV2Fko2FlWCCsMAK1xoLlwVRxpv8hfsxKYXlXTOomiVt3JCbzNgQpUmFzWCD9MfRUr0asiF_jUJMSylphLvKUd2SLz9oSpcvuLCXPp2FyWCA_1toQ_l158xW0zorqTBXvh76o-_D3e-Ru1Ea-51UrFaRhYQhhc3hAMTM5YWRjZDJlY2Q5MWQyNjNjMDhhMzdhNjBmODZjNDVkYWE3NjNmNjM4NTY0NzEyMmFiZjhlMDM3OGQ0NjA5OGFjWCECHZh5Qx9o-8PaY6t0d5hRTbWeez1dh3md7ehfE25f2N5hZKNhZVgg5MLkVzIw2tDzdUpYwFe-MLhIPJ4hkCpPGL0X7RxpPIRhc1ggyEtcsq3FX8wZOGpwTXOP7BsqfdYdMhGG1X8jVjncDcVhclggyLVOc2xy4m1_YeYGef2HQ8WyJX7LjZq403CS9Dt_eME=";
let token = Token::from_str(token_str).expect("Valid token");

// Get the total amount
let amount: Amount = token.value().expect("Value");
println!("Token amount: {}", amount);

§Implemented NUTs

§Mandatory

NUT #Description
00Cryptography and Models
01Mint public keys
02Keysets and fees
03Swapping tokens
04Minting tokens
05Melting tokens
06Mint info

§Optional

#DescriptionStatus
07Token state checkImplemented
08Overpaid Lightning feesImplemented
09Signature restoreImplemented
10Spending conditionsImplemented
11Pay-To-Pubkey (P2PK)Implemented
12DLEQ proofsImplemented
13Deterministic secretsImplemented
14Hashed Timelock Contracts (HTLCs)Implemented
15Partial multi-path payments (MPP)Implemented
16Animated QR codesNot implemented
17WebSocket subscriptionsImplemented
18Payment RequestsImplemented
19Cached responsesImplemented
20Signature on Mint QuoteImplemented

§License

This project is licensed under the MIT License.

Re-exports§

pub use self::amount::Amount;
pub use self::mint_url::MintUrl;
pub use self::util::SECP256K1;
pub use lightning_invoice;
pub use self::nuts::*;

Modules§

amount
CDK Amount
dhke
Diffie-Hellmann key exchange
mint_url
Url
nuts
Nuts
secret
Secret
util
Cashu utils

Structs§

Bolt11Invoice
Represents a syntactically and semantically correct lightning BOLT11 invoice.