Skip to content

Commit 16a4596

Browse files
committed
Allow for BOLT11 overpayments again
Previously, we refactored our BOLT11 payment API which made invoice-provided and user-provided amounts mutually exclusive. Here, we restore the original behavior that allows overpaying for invoices, even if they specify a (default) amount.
1 parent 864271c commit 16a4596

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

lightning-background-processor/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,8 @@ impl<
238238
G,
239239
&'a (dyn UtxoLookup + Send + Sync),
240240
L,
241-
> where
241+
>
242+
where
242243
L::Target: Logger,
243244
{
244245
/// Initializes a new [`GossipSync::Rapid`] variant.
@@ -255,7 +256,8 @@ impl<'a, L: Deref>
255256
&'a NetworkGraph<L>,
256257
&'a (dyn UtxoLookup + Send + Sync),
257258
L,
258-
> where
259+
>
260+
where
259261
L::Target: Logger,
260262
{
261263
/// Initializes a new [`GossipSync::None`] variant.

lightning/src/ln/channelmanager.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4864,10 +4864,11 @@ where
48644864
///
48654865
/// # Handling Invoice Amounts
48664866
/// Some invoices include a specific amount, while others require you to specify one.
4867-
/// - If the invoice **includes** an amount, user must not provide `amount_msats`.
4867+
/// - If the invoice **includes** an amount, user may provide an amount greater or equal to it
4868+
/// to allow for overpayments.
48684869
/// - If the invoice **doesn't include** an amount, you'll need to specify `amount_msats`.
48694870
///
4870-
/// If these conditions aren’t met, the function will return `Bolt11PaymentError::InvalidAmount`.
4871+
/// If these conditions aren’t met, the function will return [`Bolt11PaymentError::InvalidAmount`].
48714872
///
48724873
/// # Custom Routing Parameters
48734874
/// 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
@@ -588,8 +588,7 @@ pub(crate) enum PaymentSendFailure {
588588
#[derive(Debug)]
589589
pub enum Bolt11PaymentError {
590590
/// Incorrect amount was provided to [`ChannelManager::pay_for_bolt11_invoice`].
591-
/// This happens when an amount is specified when [`Bolt11Invoice`] already contains
592-
/// an amount, or vice versa.
591+
/// This happens when the user-provided amount is less than an amount specified in the [`Bolt11Invoice`].
593592
///
594593
/// [`Bolt11Invoice`]: lightning_invoice::Bolt11Invoice
595594
/// [`ChannelManager::pay_for_bolt11_invoice`]: crate::ln::channelmanager::ChannelManager::pay_for_bolt11_invoice
@@ -894,7 +893,9 @@ impl OutboundPayments {
894893

895894
let amount = match (invoice.amount_milli_satoshis(), amount_msats) {
896895
(Some(amt), None) | (None, Some(amt)) => amt,
897-
(None, None) | (Some(_), Some(_)) => return Err(Bolt11PaymentError::InvalidAmount),
896+
(Some(inv_amt), Some(user_amt)) if user_amt < inv_amt => return Err(Bolt11PaymentError::InvalidAmount),
897+
(Some(_), Some(user_amt)) => user_amt,
898+
(None, None) => return Err(Bolt11PaymentError::InvalidAmount),
898899
};
899900

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

0 commit comments

Comments
 (0)