@@ -1582,6 +1582,47 @@ pub enum Event {
1582
1582
/// onion messages.
1583
1583
peer_node_id : PublicKey ,
1584
1584
} ,
1585
+ /// As a static invoice server, we received a [`StaticInvoice`] from an async recipient that wants
1586
+ /// us to serve the invoice to payers on their behalf when they are offline. This event will only
1587
+ /// be generated if we previously created paths using
1588
+ /// [`ChannelManager::blinded_paths_for_async_recipient`] and the recipient was configured with
1589
+ /// them via [`ChannelManager::set_paths_to_static_invoice_server`].
1590
+ ///
1591
+ /// [`ChannelManager::blinded_paths_for_async_recipient`]: crate::ln::channelmanager::ChannelManager::blinded_paths_for_async_recipient
1592
+ /// [`ChannelManager::set_paths_to_static_invoice_server`]: crate::ln::channelmanager::ChannelManager::set_paths_to_static_invoice_server
1593
+ #[ cfg( async_payments) ]
1594
+ PersistStaticInvoice {
1595
+ /// The invoice that should be persisted and later provided to payers when handling a future
1596
+ /// `Event::StaticInvoiceRequested`.
1597
+ invoice : StaticInvoice ,
1598
+ /// Useful for the recipient to replace a specific invoice stored by us as the static invoice
1599
+ /// server.
1600
+ ///
1601
+ /// When this invoice and its metadata are persisted, this slot number should be included so if
1602
+ /// we receive another [`Event::PersistStaticInvoice`] containing the same slot number we can
1603
+ /// swap the existing invoice out for the new one.
1604
+ invoice_slot : u16 ,
1605
+ /// An identifier for the recipient, originally provided to
1606
+ /// [`ChannelManager::blinded_paths_for_async_recipient`].
1607
+ ///
1608
+ /// When an `Event::StaticInvoiceRequested` comes in for the invoice, this id will be surfaced
1609
+ /// and can be used alongside the `invoice_id` to retrieve the invoice from the database.
1610
+ recipient_id : Vec < u8 > ,
1611
+ /// A random identifier for the invoice. When an `Event::StaticInvoiceRequested` comes in for
1612
+ /// the invoice, this id will be surfaced and can be used alongside the `recipient_id` to
1613
+ /// retrieve the invoice from the database.
1614
+ ///
1615
+ /// Note that this id will remain the same for all invoice updates corresponding to a particular
1616
+ /// offer that the recipient has cached.
1617
+ invoice_id : u128 ,
1618
+ /// Once the [`StaticInvoice`], `invoice_slot` and `invoice_id` are persisted,
1619
+ /// [`ChannelManager::static_invoice_persisted`] should be called with this responder to confirm
1620
+ /// to the recipient that their [`Offer`] is ready to be used for async payments.
1621
+ ///
1622
+ /// [`ChannelManager::static_invoice_persisted`]: crate::ln::channelmanager::ChannelManager::static_invoice_persisted
1623
+ /// [`Offer`]: crate::offers::offer::Offer
1624
+ invoice_persisted_path : Responder ,
1625
+ } ,
1585
1626
}
1586
1627
1587
1628
impl Writeable for Event {
@@ -2012,6 +2053,12 @@ impl Writeable for Event {
2012
2053
( 8 , former_temporary_channel_id, required) ,
2013
2054
} ) ;
2014
2055
} ,
2056
+ #[ cfg( async_payments) ]
2057
+ & Event :: PersistStaticInvoice { .. } => {
2058
+ 45u8 . write ( writer) ?;
2059
+ // No need to write these events because we can just restart the static invoice negotiation
2060
+ // on startup.
2061
+ } ,
2015
2062
// Note that, going forward, all new events must only write data inside of
2016
2063
// `write_tlv_fields`. Versions 0.0.101+ will ignore odd-numbered events that write
2017
2064
// data via `write_tlv_fields`.
@@ -2583,6 +2630,9 @@ impl MaybeReadable for Event {
2583
2630
former_temporary_channel_id : former_temporary_channel_id. 0 . unwrap ( ) ,
2584
2631
} ) )
2585
2632
} ,
2633
+ // Note that we do not write a length-prefixed TLV for PersistStaticInvoice events.
2634
+ #[ cfg( async_payments) ]
2635
+ 45u8 => Ok ( None ) ,
2586
2636
// Versions prior to 0.0.100 did not ignore odd types, instead returning InvalidValue.
2587
2637
// Version 0.0.100 failed to properly ignore odd types, possibly resulting in corrupt
2588
2638
// reads.
0 commit comments