Skip to content

Commit 1a3de89

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 4e38002 commit 1a3de89

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
@@ -508,6 +508,11 @@ pub enum Event {
508508
/// serialized prior to LDK version 0.0.117.
509509
sender_intended_total_msat: Option<u64>,
510510
},
511+
/// Indicates a request for invoice failed to yield a response in a reasonable amount of time.
512+
InvoiceRequestFailed {
513+
/// The `payment_id` to have been associated with payment for the requested invoice.
514+
payment_id: PaymentId,
515+
},
511516
/// Indicates an outbound payment we made succeeded (i.e. it made it all the way to its target
512517
/// and we got back the payment preimage for it).
513518
///
@@ -1148,6 +1153,12 @@ impl Writeable for Event {
11481153
(8, funding_txo, required),
11491154
});
11501155
},
1156+
&Event::InvoiceRequestFailed { ref payment_id } => {
1157+
33u8.write(writer)?;
1158+
write_tlv_fields!(writer, {
1159+
(0, payment_id, required),
1160+
})
1161+
},
11511162
// Note that, going forward, all new events must only write data inside of
11521163
// `write_tlv_fields`. Versions 0.0.101+ will ignore odd-numbered events that write
11531164
// data via `write_tlv_fields`.
@@ -1535,6 +1546,17 @@ impl MaybeReadable for Event {
15351546
};
15361547
f()
15371548
},
1549+
33u8 => {
1550+
let f = || {
1551+
_init_and_read_len_prefixed_tlv_fields!(reader, {
1552+
(0, payment_id, required),
1553+
});
1554+
Ok(Some(Event::InvoiceRequestFailed {
1555+
payment_id: payment_id.0.unwrap(),
1556+
}))
1557+
};
1558+
f()
1559+
},
15381560
// Versions prior to 0.0.100 did not ignore odd types, instead returning InvalidValue.
15391561
// Version 0.0.100 failed to properly ignore odd types, possibly resulting in corrupt
15401562
// reads.

0 commit comments

Comments
 (0)