Skip to content

Commit d3c8613

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 9215242 commit d3c8613

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

lightning/src/events/mod.rs

+22
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,11 @@ pub enum Event {
455455
/// spontaneous payment.
456456
purpose: PaymentPurpose,
457457
},
458+
/// Indicates a request for invoice failed to yield a response in a reasonable amount of time.
459+
InvoiceRequestFailed {
460+
/// The `payment_id` to have been associated with payment for the requested invoice.
461+
payment_id: PaymentId,
462+
},
458463
/// Indicates an outbound payment we made succeeded (i.e. it made it all the way to its target
459464
/// and we got back the payment preimage for it).
460465
///
@@ -1063,6 +1068,12 @@ impl Writeable for Event {
10631068
(8, funding_txo, required),
10641069
});
10651070
},
1071+
&Event::InvoiceRequestFailed { ref payment_id } => {
1072+
33u8.write(writer)?;
1073+
write_tlv_fields!(writer, {
1074+
(0, payment_id, required),
1075+
})
1076+
},
10661077
// Note that, going forward, all new events must only write data inside of
10671078
// `write_tlv_fields`. Versions 0.0.101+ will ignore odd-numbered events that write
10681079
// data via `write_tlv_fields`.
@@ -1437,6 +1448,17 @@ impl MaybeReadable for Event {
14371448
};
14381449
f()
14391450
},
1451+
33u8 => {
1452+
let f = || {
1453+
_init_and_read_tlv_fields!(reader, {
1454+
(0, payment_id, required),
1455+
});
1456+
Ok(Some(Event::InvoiceRequestFailed {
1457+
payment_id: payment_id.0.unwrap(),
1458+
}))
1459+
};
1460+
f()
1461+
},
14401462
// Versions prior to 0.0.100 did not ignore odd types, instead returning InvalidValue.
14411463
// Version 0.0.100 failed to properly ignore odd types, possibly resulting in corrupt
14421464
// reads.

0 commit comments

Comments
 (0)