@@ -25,6 +25,8 @@ use crate::ln::channel::FUNDING_CONF_DEADLINE_BLOCKS;
2525use crate :: ln:: features:: ChannelTypeFeatures ;
2626use crate :: ln:: msgs;
2727use crate :: ln:: types:: { ChannelId , PaymentPreimage , PaymentHash , PaymentSecret } ;
28+ use crate :: offers:: invoice:: Bolt12Invoice ;
29+ use crate :: onion_message:: messenger:: Responder ;
2830use crate :: routing:: gossip:: NetworkUpdate ;
2931use crate :: routing:: router:: { BlindedTail , Path , RouteHop , RouteParameters } ;
3032use crate :: sign:: SpendableOutputDescriptor ;
@@ -715,6 +717,23 @@ pub enum Event {
715717 /// The `payment_id` to have been associated with payment for the requested invoice.
716718 payment_id : PaymentId ,
717719 } ,
720+ /// Indicates a [`Bolt12Invoice`] in response to an [`InvoiceRequest`] or a [`Refund`] was
721+ /// received.
722+ ///
723+ /// [`InvoiceRequest`]: crate::offers::invoice_request::InvoiceRequest
724+ /// [`Refund`]: crate::offers::refund::Refund
725+ InvoiceReceived {
726+ /// The `payment_id` associated with payment for the invoice.
727+ payment_id : PaymentId ,
728+ /// The invoice to pay.
729+ invoice : Bolt12Invoice ,
730+ /// A responder for replying with an [`InvoiceError`] if needed.
731+ ///
732+ /// `None` if the invoice wasn't sent with a reply path.
733+ ///
734+ /// [`InvoiceError`]: crate::offers::invoice_error::InvoiceError
735+ responder : Option < Responder > ,
736+ } ,
718737 /// Indicates an outbound payment we made succeeded (i.e. it made it all the way to its target
719738 /// and we got back the payment preimage for it).
720739 ///
@@ -1471,7 +1490,15 @@ impl Writeable for Event {
14711490 write_tlv_fields ! ( writer, {
14721491 ( 0 , peer_node_id, required) ,
14731492 } ) ;
1474- }
1493+ } ,
1494+ & Event :: InvoiceReceived { ref payment_id, ref invoice, ref responder } => {
1495+ 41u8 . write ( writer) ?;
1496+ write_tlv_fields ! ( writer, {
1497+ ( 0 , payment_id, required) ,
1498+ ( 2 , invoice, required) ,
1499+ ( 4 , responder, option) ,
1500+ } )
1501+ } ,
14751502 // Note that, going forward, all new events must only write data inside of
14761503 // `write_tlv_fields`. Versions 0.0.101+ will ignore odd-numbered events that write
14771504 // data via `write_tlv_fields`.
@@ -1908,6 +1935,21 @@ impl MaybeReadable for Event {
19081935 } ;
19091936 f ( )
19101937 } ,
1938+ 41u8 => {
1939+ let mut f = || {
1940+ _init_and_read_len_prefixed_tlv_fields ! ( reader, {
1941+ ( 0 , payment_id, required) ,
1942+ ( 2 , invoice, required) ,
1943+ ( 4 , responder, option) ,
1944+ } ) ;
1945+ Ok ( Some ( Event :: InvoiceReceived {
1946+ payment_id : payment_id. 0 . unwrap ( ) ,
1947+ invoice : invoice. 0 . unwrap ( ) ,
1948+ responder,
1949+ } ) )
1950+ } ;
1951+ f ( )
1952+ } ,
19111953 // Versions prior to 0.0.100 did not ignore odd types, instead returning InvalidValue.
19121954 // Version 0.0.100 failed to properly ignore odd types, possibly resulting in corrupt
19131955 // reads.
0 commit comments