@@ -513,6 +513,23 @@ pub enum Event {
513513 /// serialized prior to LDK version 0.0.117.
514514 sender_intended_total_msat : Option < u64 > ,
515515 } ,
516+ /// Indicates that a peer connection with a node is needed in order to send an [`OnionMessage`].
517+ ///
518+ /// Typically, this happens when a [`MessageRouter`] is unable to find a complete path to a
519+ /// [`Destination`]. Once a connection is established, any messages buffered by an
520+ /// [`OnionMessageHandler`] may be sent.
521+ ///
522+ /// This event will not be generated for onion message forwards; only for sends including
523+ /// replies. Handlers should connect to the node otherwise any buffered messages may be lost.
524+ ///
525+ /// [`OnionMessage`]: msgs::OnionMessage
526+ /// [`MessageRouter`]: crate::onion_message::MessageRouter
527+ /// [`Destination`]: crate::onion_message::Destination
528+ /// [`OnionMessageHandler`]: crate::ln::msgs::OnionMessageHandler
529+ ConnectionNeeded {
530+ /// Information needed to decide on whether to and how to connect to the node.
531+ node_announcement : msgs:: NodeAnnouncement ,
532+ } ,
516533 /// Indicates a request for an invoice failed to yield a response in a reasonable amount of time
517534 /// or was explicitly abandoned by [`ChannelManager::abandon_payment`]. This may be for an
518535 /// [`InvoiceRequest`] sent for an [`Offer`] or for a [`Refund`] that hasn't been redeemed.
@@ -1173,6 +1190,12 @@ impl Writeable for Event {
11731190 ( 0 , payment_id, required) ,
11741191 } )
11751192 } ,
1193+ & Event :: ConnectionNeeded { ref node_announcement } => {
1194+ 35u8 . write ( writer) ?;
1195+ write_tlv_fields ! ( writer, {
1196+ ( 0 , node_announcement, required) ,
1197+ } )
1198+ } ,
11761199 // Note that, going forward, all new events must only write data inside of
11771200 // `write_tlv_fields`. Versions 0.0.101+ will ignore odd-numbered events that write
11781201 // data via `write_tlv_fields`.
@@ -1571,6 +1594,17 @@ impl MaybeReadable for Event {
15711594 } ;
15721595 f ( )
15731596 } ,
1597+ 35u8 => {
1598+ let f = || {
1599+ _init_and_read_len_prefixed_tlv_fields ! ( reader, {
1600+ ( 0 , node_announcement, required) ,
1601+ } ) ;
1602+ Ok ( Some ( Event :: ConnectionNeeded {
1603+ node_announcement : node_announcement. 0 . unwrap ( ) ,
1604+ } ) )
1605+ } ;
1606+ f ( )
1607+ } ,
15741608 // Versions prior to 0.0.100 did not ignore odd types, instead returning InvalidValue.
15751609 // Version 0.0.100 failed to properly ignore odd types, possibly resulting in corrupt
15761610 // reads.
0 commit comments