types.rs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //! Types for `cashu-crab`
  2. use serde::{Deserialize, Serialize};
  3. use crate::nuts::{CurrencyUnit, Proofs};
  4. use crate::Bolt11Invoice;
  5. #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
  6. pub struct ProofsStatus {
  7. pub spendable: Proofs,
  8. pub spent: Proofs,
  9. }
  10. #[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
  11. pub struct SendProofs {
  12. pub change_proofs: Proofs,
  13. pub send_proofs: Proofs,
  14. }
  15. /// Melt response with proofs
  16. #[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
  17. pub struct Melted {
  18. pub paid: bool,
  19. pub preimage: Option<String>,
  20. pub change: Option<Proofs>,
  21. }
  22. /// Possible states of an invoice
  23. #[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
  24. pub enum InvoiceStatus {
  25. Unpaid,
  26. Paid,
  27. Expired,
  28. InFlight,
  29. }
  30. /// Quote
  31. #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
  32. pub struct Quote {
  33. pub id: String,
  34. pub amount: u64,
  35. pub request: Bolt11Invoice,
  36. pub unit: CurrencyUnit,
  37. pub fee_reserve: u64,
  38. pub paid: bool,
  39. pub expiry: u64,
  40. }