This commit is contained in:
thesimplekid
2025-01-05 14:42:44 +00:00
committed by GitHub
parent d6b7d49ea9
commit 6a8a5a7941
27 changed files with 222 additions and 145 deletions

View File

@@ -77,7 +77,7 @@ impl MintLightning for Lnd {
fn get_settings(&self) -> Settings {
Settings {
mpp: true,
mpp: false,
unit: CurrencyUnit::Msat,
invoice_description: true,
}
@@ -164,16 +164,9 @@ impl MintLightning for Lnd {
&self,
melt_quote_request: &MeltQuoteBolt11Request,
) -> Result<PaymentQuoteResponse, Self::Err> {
let invoice_amount_msat = melt_quote_request
.request
.amount_milli_satoshis()
.ok_or(Error::UnknownInvoiceAmount)?;
let amount = melt_quote_request.amount_msat()?;
let amount = to_unit(
invoice_amount_msat,
&CurrencyUnit::Msat,
&melt_quote_request.unit,
)?;
let amount = amount / MSAT_IN_SAT.into();
let relative_fee_reserve =
(self.fee_reserve.percent_fee_reserve * u64::from(amount) as f32) as u64;
@@ -196,11 +189,21 @@ impl MintLightning for Lnd {
async fn pay_invoice(
&self,
melt_quote: mint::MeltQuote,
partial_amount: Option<Amount>,
_partial_amount: Option<Amount>,
max_fee: Option<Amount>,
) -> Result<PayInvoiceResponse, Self::Err> {
let payment_request = melt_quote.request;
let amount_msat: u64 = match melt_quote.msat_to_pay {
Some(amount_msat) => amount_msat.into(),
None => {
let bolt11 = Bolt11Invoice::from_str(&payment_request)?;
bolt11
.amount_milli_satoshis()
.ok_or(Error::UnknownInvoiceAmount)?
}
};
let pay_req = fedimint_tonic_lnd::lnrpc::SendRequest {
payment_request,
fee_limit: max_fee.map(|f| {
@@ -208,13 +211,7 @@ impl MintLightning for Lnd {
FeeLimit { limit: Some(limit) }
}),
amt_msat: partial_amount
.map(|a| {
let msat = to_unit(a, &melt_quote.unit, &CurrencyUnit::Msat).unwrap();
u64::from(msat) as i64
})
.unwrap_or_default(),
amt_msat: amount_msat as i64,
..Default::default()
};