feat: add unit to PayInvoiceResponse

This commit is contained in:
thesimplekid
2024-09-14 11:25:58 +01:00
parent eae57eae02
commit fba609f28a
8 changed files with 11 additions and 3 deletions

View File

@@ -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))?; .map_err(|_| into_response(Error::UnitUnsupported))?;
(pre.payment_preimage, amount_spent) (pre.payment_preimage, amount_spent)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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