Skip to content

Commit e998a4f

Browse files
committed
Add PaymentFailureReason::InvoiceRequestExpired
Now that Event::PaymentFailed is generated when an InvoiceRequest times out, define a new PaymentFailureReason for this situation.
1 parent d2dcc14 commit e998a4f

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

lightning/src/events/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,12 +530,15 @@ pub enum PaymentFailureReason {
530530
UnexpectedError,
531531
/// An invoice was received that required unknown features.
532532
UnknownRequiredFeatures,
533+
/// A [`Bolt12Invoice`] was not received in a reasonable amount of time.
534+
InvoiceRequestExpired,
533535
}
534536

535537
impl_writeable_tlv_based_enum!(PaymentFailureReason,
536538
(0, RecipientRejected) => {},
537539
(1, UnknownRequiredFeatures) => {},
538540
(2, UserAbandoned) => {},
541+
(3, InvoiceRequestExpired) => {},
539542
(4, RetriesExhausted) => {},
540543
(6, PaymentExpired) => {},
541544
(8, RouteNotFound) => {},

lightning/src/ln/outbound_payment.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,7 +1711,7 @@ impl OutboundPayments {
17111711
let event = events::Event::PaymentFailed {
17121712
payment_id: *payment_id,
17131713
payment_hash: None,
1714-
reason: None,
1714+
reason: Some(PaymentFailureReason::InvoiceRequestExpired),
17151715
};
17161716
pending_events.push_back((event, None));
17171717
false
@@ -2205,7 +2205,11 @@ mod tests {
22052205
assert!(!pending_events.lock().unwrap().is_empty());
22062206
assert_eq!(
22072207
pending_events.lock().unwrap().pop_front(),
2208-
Some((Event::PaymentFailed { payment_id, payment_hash: None, reason: None }, None)),
2208+
Some((Event::PaymentFailed {
2209+
payment_id,
2210+
payment_hash: None,
2211+
reason: Some(PaymentFailureReason::InvoiceRequestExpired),
2212+
}, None)),
22092213
);
22102214
assert!(pending_events.lock().unwrap().is_empty());
22112215

@@ -2254,7 +2258,11 @@ mod tests {
22542258
assert!(!pending_events.lock().unwrap().is_empty());
22552259
assert_eq!(
22562260
pending_events.lock().unwrap().pop_front(),
2257-
Some((Event::PaymentFailed { payment_id, payment_hash: None, reason: None }, None)),
2261+
Some((Event::PaymentFailed {
2262+
payment_id,
2263+
payment_hash: None,
2264+
reason: Some(PaymentFailureReason::InvoiceRequestExpired),
2265+
}, None)),
22582266
);
22592267
assert!(pending_events.lock().unwrap().is_empty());
22602268

0 commit comments

Comments
 (0)