fix: use InvoiceRequest::amount_msats() when creating invoices

This commit is contained in:
Alex71btc 2026-06-11 20:48:59 +02:00
parent e0b23440a3
commit de2cf2f646
No known key found for this signature in database
GPG key ID: 0295D5E79F6FAE4F

View file

@ -1,7 +1,6 @@
use lightning::blinded_path::payment::BlindedPaymentPath;
use lightning::blinded_path::IntroductionNode;
use lightning::offers::invoice_request::InvoiceRequest;
use lightning::offers::offer::Amount;
use log::{error, trace};
use tonic::async_trait;
use tonic_lnd::lnrpc::{
@ -229,10 +228,11 @@ impl Bolt12InvoiceCreator for Client {
&mut self,
invoice_request: InvoiceRequest,
) -> Result<AddInvoiceResponse, Status> {
let amount = match invoice_request.amount() {
Some(Amount::Bitcoin { amount_msats }) => amount_msats as i64,
_ => 0,
};
// Use the request's amount (the payer's dynamic amount for amountless offers, or the
// offer amount times quantity for fixed-amount offers) rather than the offer's amount,
// which is None for amountless offers and would yield a 0-value invoice that LND cannot
// build blinded paths for.
let amount = invoice_request.amount_msats().unwrap_or(0) as i64;
let description = match invoice_request.description() {
Some(description) => description.to_string(),
None => "".to_string(),