Sfoglia il codice sorgente

feat(nut04/nut05): mint and melt settings as objects

thesimplekid 1 anno fa
parent
commit
69a0792e01

+ 14 - 1
crates/cashu/src/nuts/nut04.rs

@@ -64,9 +64,22 @@ pub struct MintBolt11Response {
     pub signatures: Vec<BlindedSignature>,
 }
 
+/// Mint Method Settings
+#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
+pub struct MintMethodSettings {
+    /// Payment Method e.g. bolt11
+    method: PaymentMethod,
+    /// Currency Unit e.g. sat
+    unit: CurrencyUnit,
+    /// Min Amount
+    min_amount: Amount,
+    /// Max Amount
+    max_amount: Amount,
+}
+
 /// Mint Settings
 #[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
 pub struct Settings {
-    methods: Vec<(PaymentMethod, CurrencyUnit)>,
+    methods: Vec<MintMethodSettings>,
     disabled: bool,
 }

+ 15 - 2
crates/cashu/src/nuts/nut05.rs

@@ -3,7 +3,7 @@
 
 use serde::{Deserialize, Serialize};
 
-use super::CurrencyUnit;
+use super::{CurrencyUnit, PaymentMethod};
 use crate::nuts::Proofs;
 use crate::types::MeltQuote;
 use crate::{Amount, Bolt11Invoice};
@@ -68,8 +68,21 @@ pub struct MeltBolt11Response {
     pub payment_preimage: Option<String>,
 }
 
+/// Melt Method Settings
+#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
+pub struct MeltMethodSettings {
+    /// Payment Method e.g. bolt11
+    method: PaymentMethod,
+    /// Currency Unit e.g. sat
+    unit: CurrencyUnit,
+    /// Min Amount
+    min_amount: Amount,
+    /// Max Amount
+    max_amount: Amount,
+}
+
 /// Melt Settings
 #[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
 pub struct Settings {
-    methods: Vec<(String, CurrencyUnit)>,
+    methods: Vec<MeltMethodSettings>,
 }

+ 12 - 2
crates/cashu/src/nuts/nut06.rs

@@ -142,13 +142,23 @@ mod tests {
   "nuts": {
     "4": {
       "methods": [
-        ["bolt11", "sat"]
+        {
+        "method": "bolt11",
+        "unit": "sat",
+        "min_amount": 0,
+        "max_amount": 10000
+        }
       ],
       "disabled": false
     },
     "5": {
       "methods": [
-        ["bolt11", "sat"]
+        {
+        "method": "bolt11",
+        "unit": "sat",
+        "min_amount": 0,
+        "max_amount": 10000
+        }
       ]
     },
     "7": {"supported": true},