@@ -46,6 +46,12 @@ use core::time::Duration;
46
46
use core:: ops:: Deref ;
47
47
use crate :: sync:: Arc ;
48
48
49
+ #[ cfg( async_payments) ] use {
50
+ crate :: blinded_path:: message:: BlindedMessagePath ,
51
+ crate :: offers:: nonce:: Nonce ,
52
+ crate :: offers:: static_invoice:: StaticInvoice ,
53
+ } ;
54
+
49
55
#[ allow( unused_imports) ]
50
56
use crate :: prelude:: * ;
51
57
@@ -1494,7 +1500,32 @@ pub enum Event {
1494
1500
/// The node id of the peer we just connected to, who advertises support for
1495
1501
/// onion messages.
1496
1502
peer_node_id : PublicKey ,
1497
- }
1503
+ } ,
1504
+ /// We received a [`StaticInvoice`] from an async recipient that wants us to serve the invoice to
1505
+ /// payers on their behalf when they are offline. This event will only be generated if we
1506
+ /// previously created paths using [`ChannelManager::blinded_paths_for_async_recipient`] and
1507
+ /// configured the recipient with them via [`UserConfig::paths_to_static_invoice_server`].
1508
+ ///
1509
+ /// [`ChannelManager::blinded_paths_for_async_recipient`]: crate::ln::channelmanager::ChannelManager::blinded_paths_for_async_recipient
1510
+ /// [`UserConfig::paths_to_static_invoice_server`]: crate::util::config::UserConfig::paths_to_static_invoice_server
1511
+ #[ cfg( async_payments) ]
1512
+ PersistStaticInvoice {
1513
+ /// The invoice that should be persisted and later provided to payers when handling a future
1514
+ /// `Event::StaticInvoiceRequested`.
1515
+ invoice : StaticInvoice ,
1516
+ /// An identifier for the recipient, originally surfaced in
1517
+ /// [`ChannelManager::blinded_paths_for_async_recipient`]. When an
1518
+ /// `Event::StaticInvoiceRequested` comes in for this invoice, this id will be surfaced so the
1519
+ /// persisted invoice can be retrieved from the database.
1520
+ recipient_id_nonce : Nonce ,
1521
+ /// Once the [`StaticInvoice`] is persisted, [`ChannelManager::static_invoice_persisted`] should
1522
+ /// be called with these paths to confirm to the recipient that their [`Offer`] is ready to be used
1523
+ /// for async payments.
1524
+ ///
1525
+ /// [`ChannelManager::static_invoice_persisted`]: crate::ln::channelmanager::ChannelManager::static_invoice_persisted
1526
+ /// [`Offer`]: crate::offers::offer::Offer
1527
+ invoice_persisted_paths : Vec < BlindedMessagePath > ,
1528
+ } ,
1498
1529
}
1499
1530
1500
1531
impl Writeable for Event {
@@ -1828,6 +1859,15 @@ impl Writeable for Event {
1828
1859
( 8 , former_temporary_channel_id, required) ,
1829
1860
} ) ;
1830
1861
} ,
1862
+ #[ cfg( async_payments) ]
1863
+ & Event :: PersistStaticInvoice { ref invoice, ref recipient_id_nonce, ref invoice_persisted_paths } => {
1864
+ 45u8 . write ( writer) ?;
1865
+ write_tlv_fields ! ( writer, {
1866
+ ( 0 , invoice, required) ,
1867
+ ( 2 , recipient_id_nonce, required) ,
1868
+ ( 4 , invoice_persisted_paths, required) ,
1869
+ } ) ;
1870
+ } ,
1831
1871
// Note that, going forward, all new events must only write data inside of
1832
1872
// `write_tlv_fields`. Versions 0.0.101+ will ignore odd-numbered events that write
1833
1873
// data via `write_tlv_fields`.
@@ -2341,6 +2381,22 @@ impl MaybeReadable for Event {
2341
2381
former_temporary_channel_id : former_temporary_channel_id. 0 . unwrap ( ) ,
2342
2382
} ) )
2343
2383
} ,
2384
+ #[ cfg( async_payments) ]
2385
+ 45u8 => {
2386
+ let mut f = || {
2387
+ _init_and_read_len_prefixed_tlv_fields ! ( reader, {
2388
+ ( 0 , invoice, required) ,
2389
+ ( 2 , recipient_id_nonce, required) ,
2390
+ ( 4 , invoice_persisted_paths, required) ,
2391
+ } ) ;
2392
+ Ok ( Some ( Event :: PersistStaticInvoice {
2393
+ invoice : _init_tlv_based_struct_field ! ( invoice, required) ,
2394
+ recipient_id_nonce : _init_tlv_based_struct_field ! ( recipient_id_nonce, required) ,
2395
+ invoice_persisted_paths : _init_tlv_based_struct_field ! ( invoice_persisted_paths, required) ,
2396
+ } ) )
2397
+ } ;
2398
+ f ( )
2399
+ } ,
2344
2400
// Versions prior to 0.0.100 did not ignore odd types, instead returning InvalidValue.
2345
2401
// Version 0.0.100 failed to properly ignore odd types, possibly resulting in corrupt
2346
2402
// reads.
0 commit comments