Skip to content

Commit db165ad

Browse files
authored
Merge pull request #3810 from tnull/2025-05-fix-new-bolt11-payment-interface
Various BOLT11 payment interface fixes
2 parents f22ffbb + 4e0b599 commit db165ad

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ use crate::ln::our_peer_storage::EncryptedOurPeerStorage;
8282
#[cfg(test)]
8383
use crate::ln::outbound_payment;
8484
use crate::ln::outbound_payment::{
85-
Bolt11PaymentError, OutboundPayments, PendingOutboundPayment, RetryableInvoiceRequest,
86-
SendAlongPathArgs, StaleExpiration,
85+
OutboundPayments, PendingOutboundPayment, RetryableInvoiceRequest, SendAlongPathArgs,
86+
StaleExpiration,
8787
};
8888
use crate::ln::types::ChannelId;
8989
use crate::offers::flow::OffersMessageFlow;
@@ -187,7 +187,8 @@ use core::{cmp, mem};
187187
#[cfg(any(test, feature = "_externalize_tests"))]
188188
pub(crate) use crate::ln::outbound_payment::PaymentSendFailure;
189189
pub use crate::ln::outbound_payment::{
190-
Bolt12PaymentError, ProbeSendFailure, RecipientOnionFields, Retry, RetryableSendFailure,
190+
Bolt11PaymentError, Bolt12PaymentError, ProbeSendFailure, RecipientOnionFields, Retry,
191+
RetryableSendFailure,
191192
};
192193
use crate::ln::script::ShutdownScript;
193194

@@ -5142,10 +5143,11 @@ where
51425143
///
51435144
/// # Handling Invoice Amounts
51445145
/// Some invoices include a specific amount, while others require you to specify one.
5145-
/// - If the invoice **includes** an amount, user must not provide `amount_msats`.
5146+
/// - If the invoice **includes** an amount, user may provide an amount greater or equal to it
5147+
/// to allow for overpayments.
51465148
/// - If the invoice **doesn't include** an amount, you'll need to specify `amount_msats`.
51475149
///
5148-
/// If these conditions aren’t met, the function will return `Bolt11PaymentError::InvalidAmount`.
5150+
/// If these conditions aren’t met, the function will return [`Bolt11PaymentError::InvalidAmount`].
51495151
///
51505152
/// # Custom Routing Parameters
51515153
/// Users can customize routing parameters via [`RouteParametersConfig`].

lightning/src/ln/outbound_payment.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -603,8 +603,7 @@ pub(crate) enum PaymentSendFailure {
603603
#[derive(Debug)]
604604
pub enum Bolt11PaymentError {
605605
/// Incorrect amount was provided to [`ChannelManager::pay_for_bolt11_invoice`].
606-
/// This happens when an amount is specified when [`Bolt11Invoice`] already contains
607-
/// an amount, or vice versa.
606+
/// This happens when the user-provided amount is less than an amount specified in the [`Bolt11Invoice`].
608607
///
609608
/// [`Bolt11Invoice`]: lightning_invoice::Bolt11Invoice
610609
/// [`ChannelManager::pay_for_bolt11_invoice`]: crate::ln::channelmanager::ChannelManager::pay_for_bolt11_invoice
@@ -917,7 +916,9 @@ impl OutboundPayments {
917916

918917
let amount = match (invoice.amount_milli_satoshis(), amount_msats) {
919918
(Some(amt), None) | (None, Some(amt)) => amt,
920-
(None, None) | (Some(_), Some(_)) => return Err(Bolt11PaymentError::InvalidAmount),
919+
(Some(inv_amt), Some(user_amt)) if user_amt < inv_amt => return Err(Bolt11PaymentError::InvalidAmount),
920+
(Some(_), Some(user_amt)) => user_amt,
921+
(None, None) => return Err(Bolt11PaymentError::InvalidAmount),
921922
};
922923

923924
let mut recipient_onion = RecipientOnionFields::secret_only(*invoice.payment_secret());

lightning/src/routing/router.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,7 @@ impl PaymentParameters {
11421142
}
11431143

11441144
/// A struct for configuring parameters for routing the payment.
1145-
#[derive(Clone, Copy)]
1145+
#[derive(Clone, Copy, Debug)]
11461146
pub struct RouteParametersConfig {
11471147
/// The maximum total fees, in millisatoshi, that may accrue during route finding.
11481148
///

0 commit comments

Comments
 (0)