@@ -530,6 +530,25 @@ pub enum Event {
530
530
/// serialized prior to LDK version 0.0.117.
531
531
sender_intended_total_msat : Option < u64 > ,
532
532
} ,
533
+ /// Indicates that a peer connection with a node is needed in order to send an [`OnionMessage`].
534
+ ///
535
+ /// Typically, this happens when a [`MessageRouter`] is unable to find a complete path to a
536
+ /// [`Destination`]. Once a connection is established, any messages buffered by an
537
+ /// [`OnionMessageHandler`] may be sent.
538
+ ///
539
+ /// This event will not be generated for onion message forwards; only for sends including
540
+ /// replies. Handlers should connect to the node otherwise any buffered messages may be lost.
541
+ ///
542
+ /// [`OnionMessage`]: msgs::OnionMessage
543
+ /// [`MessageRouter`]: crate::onion_message::MessageRouter
544
+ /// [`Destination`]: crate::onion_message::Destination
545
+ /// [`OnionMessageHandler`]: crate::ln::msgs::OnionMessageHandler
546
+ ConnectionNeeded {
547
+ /// The node id for the node needing a connection.
548
+ node_id : PublicKey ,
549
+ /// Sockets for connecting to the node.
550
+ addresses : Vec < msgs:: SocketAddress > ,
551
+ } ,
533
552
/// Indicates a request for an invoice failed to yield a response in a reasonable amount of time
534
553
/// or was explicitly abandoned by [`ChannelManager::abandon_payment`]. This may be for an
535
554
/// [`InvoiceRequest`] sent for an [`Offer`] or for a [`Refund`] that hasn't been redeemed.
@@ -1190,6 +1209,10 @@ impl Writeable for Event {
1190
1209
( 0 , payment_id, required) ,
1191
1210
} )
1192
1211
} ,
1212
+ & Event :: ConnectionNeeded { .. } => {
1213
+ 35u8 . write ( writer) ?;
1214
+ // Never write ConnectionNeeded events as buffered onion messages aren't serialized.
1215
+ } ,
1193
1216
// Note that, going forward, all new events must only write data inside of
1194
1217
// `write_tlv_fields`. Versions 0.0.101+ will ignore odd-numbered events that write
1195
1218
// data via `write_tlv_fields`.
@@ -1200,8 +1223,7 @@ impl Writeable for Event {
1200
1223
impl MaybeReadable for Event {
1201
1224
fn read < R : io:: Read > ( reader : & mut R ) -> Result < Option < Self > , msgs:: DecodeError > {
1202
1225
match Readable :: read ( reader) ? {
1203
- // Note that we do not write a length-prefixed TLV for FundingGenerationReady events,
1204
- // unlike all other events, thus we return immediately here.
1226
+ // Note that we do not write a length-prefixed TLV for FundingGenerationReady events.
1205
1227
0u8 => Ok ( None ) ,
1206
1228
1u8 => {
1207
1229
let f = || {
@@ -1588,6 +1610,8 @@ impl MaybeReadable for Event {
1588
1610
} ;
1589
1611
f ( )
1590
1612
} ,
1613
+ // Note that we do not write a length-prefixed TLV for ConnectionNeeded events.
1614
+ 35u8 => Ok ( None ) ,
1591
1615
// Versions prior to 0.0.100 did not ignore odd types, instead returning InvalidValue.
1592
1616
// Version 0.0.100 failed to properly ignore odd types, possibly resulting in corrupt
1593
1617
// reads.
0 commit comments