Skip to content

Commit 714eb64

Browse files
committed
Add an InvoiceRequestFailed event
When an invoice is requested but either receives an error or never receives a response, surface an event to indicate to the user that the corresponding future payment has failed.
1 parent 3c4bce7 commit 714eb64

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

lightning/src/events/mod.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,11 @@ pub enum Event {
452452
/// spontaneous payment.
453453
purpose: PaymentPurpose,
454454
},
455+
/// Indicates a request for invoice failed to yield a response in a reasonable amount of time.
456+
InvoiceRequestFailed {
457+
/// The `payment_id` to have been associated with payment for the requested invoice.
458+
payment_id: PaymentId,
459+
},
455460
/// Indicates an outbound payment we made succeeded (i.e. it made it all the way to its target
456461
/// and we got back the payment preimage for it).
457462
///
@@ -1059,6 +1064,12 @@ impl Writeable for Event {
10591064
(8, funding_txo, required),
10601065
});
10611066
},
1067+
&Event::InvoiceRequestFailed { ref payment_id } => {
1068+
33u8.write(writer)?;
1069+
write_tlv_fields!(writer, {
1070+
(0, payment_id, required),
1071+
})
1072+
},
10621073
// Note that, going forward, all new events must only write data inside of
10631074
// `write_tlv_fields`. Versions 0.0.101+ will ignore odd-numbered events that write
10641075
// data via `write_tlv_fields`.
@@ -1431,6 +1442,17 @@ impl MaybeReadable for Event {
14311442
};
14321443
f()
14331444
},
1445+
33u8 => {
1446+
let f = || {
1447+
_init_and_read_tlv_fields!(reader, {
1448+
(0, payment_id, required),
1449+
});
1450+
Ok(Some(Event::InvoiceRequestFailed {
1451+
payment_id: payment_id.0.unwrap(),
1452+
}))
1453+
};
1454+
f()
1455+
},
14341456
// Versions prior to 0.0.100 did not ignore odd types, instead returning InvalidValue.
14351457
// Version 0.0.100 failed to properly ignore odd types, possibly resulting in corrupt
14361458
// reads.

0 commit comments

Comments
 (0)