@@ -25,6 +25,8 @@ use crate::ln::channel::FUNDING_CONF_DEADLINE_BLOCKS;
25
25
use crate :: ln:: features:: ChannelTypeFeatures ;
26
26
use crate :: ln:: msgs;
27
27
use crate :: ln:: types:: { ChannelId , PaymentPreimage , PaymentHash , PaymentSecret } ;
28
+ use crate :: offers:: invoice:: Bolt12Invoice ;
29
+ use crate :: onion_message:: messenger:: Responder ;
28
30
use crate :: routing:: gossip:: NetworkUpdate ;
29
31
use crate :: routing:: router:: { BlindedTail , Path , RouteHop , RouteParameters } ;
30
32
use crate :: sign:: SpendableOutputDescriptor ;
@@ -715,6 +717,23 @@ pub enum Event {
715
717
/// The `payment_id` to have been associated with payment for the requested invoice.
716
718
payment_id : PaymentId ,
717
719
} ,
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
+ } ,
718
737
/// Indicates an outbound payment we made succeeded (i.e. it made it all the way to its target
719
738
/// and we got back the payment preimage for it).
720
739
///
@@ -1471,7 +1490,15 @@ impl Writeable for Event {
1471
1490
write_tlv_fields ! ( writer, {
1472
1491
( 0 , peer_node_id, required) ,
1473
1492
} ) ;
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
+ } ,
1475
1502
// Note that, going forward, all new events must only write data inside of
1476
1503
// `write_tlv_fields`. Versions 0.0.101+ will ignore odd-numbered events that write
1477
1504
// data via `write_tlv_fields`.
@@ -1908,6 +1935,21 @@ impl MaybeReadable for Event {
1908
1935
} ;
1909
1936
f ( )
1910
1937
} ,
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
+ } ,
1911
1953
// Versions prior to 0.0.100 did not ignore odd types, instead returning InvalidValue.
1912
1954
// Version 0.0.100 failed to properly ignore odd types, possibly resulting in corrupt
1913
1955
// reads.
0 commit comments