types.rs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //! Types for `cashu-crab`
  2. use serde::{Deserialize, Serialize};
  3. use crate::nuts::{Id, KeySetInfo, Proofs};
  4. #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
  5. pub struct ProofsStatus {
  6. pub spendable: Proofs,
  7. pub spent: Proofs,
  8. }
  9. #[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
  10. pub struct SendProofs {
  11. pub change_proofs: Proofs,
  12. pub send_proofs: Proofs,
  13. }
  14. /// Melt response with proofs
  15. #[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
  16. pub struct Melted {
  17. pub paid: bool,
  18. pub preimage: Option<String>,
  19. pub change: Option<Proofs>,
  20. }
  21. /// Possible states of an invoice
  22. #[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
  23. pub enum InvoiceStatus {
  24. Unpaid,
  25. Paid,
  26. Expired,
  27. InFlight,
  28. }
  29. #[derive(Debug, Hash, Clone, PartialEq, Eq, Serialize, Deserialize)]
  30. pub struct KeysetInfo {
  31. pub id: Id,
  32. pub unit: String,
  33. pub active: bool,
  34. pub valid_from: u64,
  35. pub valid_to: Option<u64>,
  36. pub derivation_path: String,
  37. pub max_order: u8,
  38. }
  39. impl From<KeysetInfo> for KeySetInfo {
  40. fn from(keyset_info: KeysetInfo) -> Self {
  41. Self {
  42. id: keyset_info.id,
  43. unit: keyset_info.unit,
  44. }
  45. }
  46. }