Skip to content

Commit 3880e98

Browse files
committed
Introduce RetryableSendFailure::InvalidAmount
Some upcoming changes require a new `PaymentFailure` variant to handle cases where a Bolt11 invoice specifies an invalid amount. This commit introduces the variant, setting the stage for its usage in subsequent commits.
1 parent 1610854 commit 3880e98

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lightning/src/events/mod.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,10 @@ pub enum PaymentFailureReason {
598598
///
599599
/// [`HeldHtlcAvailable`]: crate::onion_message::async_payments::HeldHtlcAvailable
600600
BlindedPathCreationFailed,
601+
/// Incorrect amount was provided to ChannelManager::pay_for_bolt11_invoice.
602+
/// This happens when an amount is specified when Bolt11Invoice already contains
603+
/// an amount, or vice versa.
604+
InvalidAmount,
601605
}
602606

603607
impl_writeable_tlv_based_enum_upgradable!(PaymentFailureReason,
@@ -610,6 +614,7 @@ impl_writeable_tlv_based_enum_upgradable!(PaymentFailureReason,
610614
(6, PaymentExpired) => {},
611615
(7, BlindedPathCreationFailed) => {},
612616
(8, RouteNotFound) => {},
617+
(9, InvalidAmount) => {},
613618
(10, UnexpectedError) => {},
614619
);
615620

@@ -1702,7 +1707,9 @@ impl Writeable for Event {
17021707
Some(PaymentFailureReason::InvoiceRequestRejected) =>
17031708
&Some(PaymentFailureReason::RecipientRejected),
17041709
Some(PaymentFailureReason::BlindedPathCreationFailed) =>
1705-
&Some(PaymentFailureReason::RouteNotFound)
1710+
&Some(PaymentFailureReason::RouteNotFound),
1711+
Some(PaymentFailureReason::InvalidAmount) =>
1712+
&Some(PaymentFailureReason::InvalidAmount)
17061713
};
17071714
write_tlv_fields!(writer, {
17081715
(0, payment_id, required),

lightning/src/ln/outbound_payment.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,10 @@ pub enum RetryableSendFailure {
500500
///
501501
/// [`BlindedPaymentPath`]: crate::blinded_path::payment::BlindedPaymentPath
502502
OnionPacketSizeExceeded,
503+
/// Incorrect amount was provided to ChannelManager::pay_for_bolt11_invoice.
504+
/// This happens when an amount is specified when Bolt11Invoice already contains
505+
/// an amount, or vice versa.
506+
InvalidAmount,
503507
}
504508

505509
/// If a payment fails to send to a route, it can be in one of several states. This enum is returned
@@ -959,6 +963,7 @@ impl OutboundPayments {
959963
RetryableSendFailure::RouteNotFound => PaymentFailureReason::RouteNotFound,
960964
RetryableSendFailure::DuplicatePayment => PaymentFailureReason::UnexpectedError,
961965
RetryableSendFailure::OnionPacketSizeExceeded => PaymentFailureReason::UnexpectedError,
966+
RetryableSendFailure::InvalidAmount => PaymentFailureReason::InvalidAmount,
962967
};
963968
self.abandon_payment(payment_id, reason, pending_events);
964969
return Err(Bolt12PaymentError::SendingFailed(e));

0 commit comments

Comments
 (0)