Selaa lähdekoodia

feat: add unit to `PayInvoiceResponse`

thesimplekid 7 kuukautta sitten
vanhempi
säilyke
fba609f28a

+ 1 - 1
crates/cdk-axum/src/router_handlers.rs

@@ -375,7 +375,7 @@ pub async fn post_melt_bolt11(
                 }
             };
 
-            let amount_spent = to_unit(pre.total_spent, &ln.get_settings().unit, &quote.unit)
+            let amount_spent = to_unit(pre.total_spent, &pre.unit, &quote.unit)
                 .map_err(|_| into_response(Error::UnitUnsupported))?;
 
             (pre.payment_preimage, amount_spent)

+ 1 - 0
crates/cdk-cln/src/lib.rs

@@ -226,6 +226,7 @@ impl MintLightning for Cln {
                         &CurrencyUnit::Msat,
                         &melt_quote.unit,
                     )?,
+                    unit: melt_quote.unit,
                 }
             }
             _ => {

+ 1 - 0
crates/cdk-fake-wallet/src/lib.rs

@@ -129,6 +129,7 @@ impl MintLightning for FakeWallet {
             payment_hash: "".to_string(),
             status: MeltQuoteState::Paid,
             total_spent: melt_quote.amount,
+            unit: melt_quote.unit,
         })
     }
 

+ 1 - 0
crates/cdk-lnbits/src/lib.rs

@@ -193,6 +193,7 @@ impl MintLightning for LNbits {
             payment_preimage: Some(invoice_info.payment_hash),
             status,
             total_spent,
+            unit: CurrencyUnit::Sat,
         })
     }
 

+ 2 - 1
crates/cdk-lnd/src/lib.rs

@@ -200,8 +200,9 @@ impl MintLightning for Lnd {
         Ok(PayInvoiceResponse {
             payment_hash: hex::encode(payment_response.payment_hash),
             payment_preimage: Some(hex::encode(payment_response.payment_preimage)),
-            status: MeltQuoteState::Pending,
+            status: MeltQuoteState::Paid,
             total_spent: total_spent.into(),
+            unit: CurrencyUnit::Sat,
         })
     }
 

+ 1 - 0
crates/cdk-phoenixd/src/lib.rs

@@ -193,6 +193,7 @@ impl MintLightning for Phoenixd {
             payment_preimage: Some(pay_response.payment_preimage),
             status: MeltQuoteState::Paid,
             total_spent: total_spent_sats,
+            unit: CurrencyUnit::Sat,
         })
     }
 

+ 1 - 0
crates/cdk-strike/src/lib.rs

@@ -178,6 +178,7 @@ impl MintLightning for Strike {
             payment_preimage: None,
             status: state,
             total_spent,
+            unit: melt_quote.unit,
         })
     }
 

+ 3 - 1
crates/cdk/src/cdk_lightning/mod.rs

@@ -106,8 +106,10 @@ pub struct PayInvoiceResponse {
     pub payment_preimage: Option<String>,
     /// Status
     pub status: MeltQuoteState,
-    /// Totoal Amount Spent
+    /// Total Amount Spent
     pub total_spent: Amount,
+    /// Unit of total spent
+    pub unit: CurrencyUnit,
 }
 
 /// Payment quote response