diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index 50ef6d70464..8179e35a395 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -82,8 +82,8 @@ use crate::ln::our_peer_storage::EncryptedOurPeerStorage; #[cfg(test)] use crate::ln::outbound_payment; use crate::ln::outbound_payment::{ - Bolt11PaymentError, OutboundPayments, PendingOutboundPayment, RetryableInvoiceRequest, - SendAlongPathArgs, StaleExpiration, + OutboundPayments, PendingOutboundPayment, RetryableInvoiceRequest, SendAlongPathArgs, + StaleExpiration, }; use crate::ln::types::ChannelId; use crate::offers::flow::OffersMessageFlow; @@ -187,7 +187,8 @@ use core::{cmp, mem}; #[cfg(any(test, feature = "_externalize_tests"))] pub(crate) use crate::ln::outbound_payment::PaymentSendFailure; pub use crate::ln::outbound_payment::{ - Bolt12PaymentError, ProbeSendFailure, RecipientOnionFields, Retry, RetryableSendFailure, + Bolt11PaymentError, Bolt12PaymentError, ProbeSendFailure, RecipientOnionFields, Retry, + RetryableSendFailure, }; use crate::ln::script::ShutdownScript; @@ -5055,10 +5056,11 @@ where /// /// # Handling Invoice Amounts /// Some invoices include a specific amount, while others require you to specify one. - /// - If the invoice **includes** an amount, user must not provide `amount_msats`. + /// - If the invoice **includes** an amount, user may provide an amount greater or equal to it + /// to allow for overpayments. /// - If the invoice **doesn't include** an amount, you'll need to specify `amount_msats`. /// - /// If these conditions aren’t met, the function will return `Bolt11PaymentError::InvalidAmount`. + /// If these conditions aren’t met, the function will return [`Bolt11PaymentError::InvalidAmount`]. /// /// # Custom Routing Parameters /// Users can customize routing parameters via [`RouteParametersConfig`]. diff --git a/lightning/src/ln/outbound_payment.rs b/lightning/src/ln/outbound_payment.rs index 1beeb3574db..62bd535d5d4 100644 --- a/lightning/src/ln/outbound_payment.rs +++ b/lightning/src/ln/outbound_payment.rs @@ -589,8 +589,7 @@ pub(crate) enum PaymentSendFailure { #[derive(Debug)] pub enum Bolt11PaymentError { /// Incorrect amount was provided to [`ChannelManager::pay_for_bolt11_invoice`]. - /// This happens when an amount is specified when [`Bolt11Invoice`] already contains - /// an amount, or vice versa. + /// This happens when the user-provided amount is less than an amount specified in the [`Bolt11Invoice`]. /// /// [`Bolt11Invoice`]: lightning_invoice::Bolt11Invoice /// [`ChannelManager::pay_for_bolt11_invoice`]: crate::ln::channelmanager::ChannelManager::pay_for_bolt11_invoice @@ -895,7 +894,9 @@ impl OutboundPayments { let amount = match (invoice.amount_milli_satoshis(), amount_msats) { (Some(amt), None) | (None, Some(amt)) => amt, - (None, None) | (Some(_), Some(_)) => return Err(Bolt11PaymentError::InvalidAmount), + (Some(inv_amt), Some(user_amt)) if user_amt < inv_amt => return Err(Bolt11PaymentError::InvalidAmount), + (Some(_), Some(user_amt)) => user_amt, + (None, None) => return Err(Bolt11PaymentError::InvalidAmount), }; let mut recipient_onion = RecipientOnionFields::secret_only(*invoice.payment_secret()); diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index 1a76e682668..d27fe1db2f7 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -1075,7 +1075,7 @@ impl PaymentParameters { } /// A struct for configuring parameters for routing the payment. -#[derive(Clone, Copy)] +#[derive(Clone, Copy, Debug)] pub struct RouteParametersConfig { /// The maximum total fees, in millisatoshi, that may accrue during route finding. ///