@@ -513,6 +513,25 @@ 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+ /// The node id for the node needing a connection.
531+ node_id : PublicKey ,
532+ /// Sockets for connecting to the node.
533+ addresses : Vec < msgs:: SocketAddress > ,
534+ } ,
516535 /// Indicates a request for an invoice failed to yield a response in a reasonable amount of time
517536 /// or was explicitly abandoned by [`ChannelManager::abandon_payment`]. This may be for an
518537 /// [`InvoiceRequest`] sent for an [`Offer`] or for a [`Refund`] that hasn't been redeemed.
@@ -1173,6 +1192,13 @@ impl Writeable for Event {
11731192 ( 0 , payment_id, required) ,
11741193 } )
11751194 } ,
1195+ & Event :: ConnectionNeeded { ref node_id, ref addresses } => {
1196+ 35u8 . write ( writer) ?;
1197+ write_tlv_fields ! ( writer, {
1198+ ( 0 , node_id, required) ,
1199+ ( 2 , * addresses, required_vec) ,
1200+ } )
1201+ } ,
11761202 // Note that, going forward, all new events must only write data inside of
11771203 // `write_tlv_fields`. Versions 0.0.101+ will ignore odd-numbered events that write
11781204 // data via `write_tlv_fields`.
@@ -1571,6 +1597,19 @@ impl MaybeReadable for Event {
15711597 } ;
15721598 f ( )
15731599 } ,
1600+ 35u8 => {
1601+ let f = || {
1602+ _init_and_read_len_prefixed_tlv_fields ! ( reader, {
1603+ ( 0 , node_id, required) ,
1604+ ( 2 , addresses, required_vec) ,
1605+ } ) ;
1606+ Ok ( Some ( Event :: ConnectionNeeded {
1607+ node_id : node_id. 0 . unwrap ( ) ,
1608+ addresses,
1609+ } ) )
1610+ } ;
1611+ f ( )
1612+ } ,
15741613 // Versions prior to 0.0.100 did not ignore odd types, instead returning InvalidValue.
15751614 // Version 0.0.100 failed to properly ignore odd types, possibly resulting in corrupt
15761615 // reads.
0 commit comments