123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- //! Types for `cashu-crab`
- use serde::{Deserialize, Serialize};
- use uuid::Uuid;
- use crate::nuts::{CurrencyUnit, Proofs};
- use crate::Amount;
- #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
- pub struct ProofsStatus {
- pub spendable: Proofs,
- pub spent: Proofs,
- }
- /// Melt response with proofs
- #[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
- pub struct Melted {
- pub paid: bool,
- pub preimage: Option<String>,
- pub change: Option<Proofs>,
- }
- /// Possible states of an invoice
- #[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
- pub enum InvoiceStatus {
- Unpaid,
- Paid,
- Expired,
- InFlight,
- }
- /// Mint Quote Info
- #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
- pub struct MintQuote {
- pub id: String,
- pub amount: Amount,
- pub unit: CurrencyUnit,
- pub request: String,
- pub paid: bool,
- pub expiry: u64,
- }
- impl MintQuote {
- pub fn new(request: String, unit: CurrencyUnit, amount: Amount, expiry: u64) -> Self {
- let id = Uuid::new_v4();
- Self {
- id: id.to_string(),
- amount,
- unit,
- request,
- paid: false,
- expiry,
- }
- }
- }
- /// Melt Quote Info
- #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
- pub struct MeltQuote {
- pub id: String,
- pub unit: CurrencyUnit,
- pub amount: Amount,
- pub request: String,
- pub fee_reserve: Amount,
- pub paid: bool,
- pub expiry: u64,
- }
- impl MeltQuote {
- pub fn new(
- request: String,
- unit: CurrencyUnit,
- amount: Amount,
- fee_reserve: Amount,
- expiry: u64,
- ) -> Self {
- let id = Uuid::new_v4();
- Self {
- id: id.to_string(),
- amount,
- unit,
- request,
- fee_reserve,
- paid: false,
- expiry,
- }
- }
- }
|