@@ -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,22 @@ 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. `None` if the invoice
731
+ /// wasn't sent with a reply path.
732
+ ///
733
+ /// [`InvoiceError`]: crate::offers::invoice_error::InvoiceError
734
+ responder : Option < Responder > ,
735
+ } ,
718
736
/// Indicates an outbound payment we made succeeded (i.e. it made it all the way to its target
719
737
/// and we got back the payment preimage for it).
720
738
///
@@ -1471,7 +1489,15 @@ impl Writeable for Event {
1471
1489
write_tlv_fields ! ( writer, {
1472
1490
( 0 , peer_node_id, required) ,
1473
1491
} ) ;
1474
- }
1492
+ } ,
1493
+ & Event :: InvoiceReceived { ref payment_id, ref invoice, ref responder } => {
1494
+ 41u8 . write ( writer) ?;
1495
+ write_tlv_fields ! ( writer, {
1496
+ ( 0 , payment_id, required) ,
1497
+ ( 2 , invoice, required) ,
1498
+ ( 4 , responder, option) ,
1499
+ } )
1500
+ } ,
1475
1501
// Note that, going forward, all new events must only write data inside of
1476
1502
// `write_tlv_fields`. Versions 0.0.101+ will ignore odd-numbered events that write
1477
1503
// data via `write_tlv_fields`.
@@ -1908,6 +1934,21 @@ impl MaybeReadable for Event {
1908
1934
} ;
1909
1935
f ( )
1910
1936
} ,
1937
+ 41u8 => {
1938
+ let mut f = || {
1939
+ _init_and_read_len_prefixed_tlv_fields ! ( reader, {
1940
+ ( 0 , payment_id, required) ,
1941
+ ( 2 , invoice, required) ,
1942
+ ( 4 , responder, option) ,
1943
+ } ) ;
1944
+ Ok ( Some ( Event :: InvoiceReceived {
1945
+ payment_id : payment_id. 0 . unwrap ( ) ,
1946
+ invoice : invoice. 0 . unwrap ( ) ,
1947
+ responder,
1948
+ } ) )
1949
+ } ;
1950
+ f ( )
1951
+ } ,
1911
1952
// Versions prior to 0.0.100 did not ignore odd types, instead returning InvalidValue.
1912
1953
// Version 0.0.100 failed to properly ignore odd types, possibly resulting in corrupt
1913
1954
// reads.
0 commit comments