Skip to content

Commit c2227b6

Browse files
committed
Fix missing init message send upon connection initiation.
1 parent 6f4e76a commit c2227b6

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

lightning/src/ln/peer_handler.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,8 @@ impl<Descriptor: SocketDescriptor, CM: Deref> PeerManager<Descriptor, CM> where
480480
let mut conduit_option = None;
481481
let mut remote_pubkey_option = None;
482482

483+
let mut needs_to_send_init_message = false;
484+
483485
if let &mut PeerState::Authenticating(ref mut handshake) = &mut peer.encryptor {
484486
let (next_act, conduit) = handshake.process_act(&peer.pending_read_buffer).unwrap();
485487
peer.pending_read_buffer = Vec::new(); // empty the pending read buffer
@@ -488,11 +490,16 @@ impl<Descriptor: SocketDescriptor, CM: Deref> PeerManager<Descriptor, CM> where
488490
remote_pubkey_option = Some(key);
489491
}
490492

493+
let mut has_remaining_act = false;
491494
if let Some(act) = next_act {
495+
has_remaining_act = true;
492496
peer.pending_outbound_buffer.push_back(act.serialize());
493497
}
494498

495499
if let Some(conduit) = conduit {
500+
if has_remaining_act {
501+
needs_to_send_init_message = true;
502+
}
496503
conduit_option = Some(conduit);
497504
}
498505
}
@@ -557,6 +564,16 @@ impl<Descriptor: SocketDescriptor, CM: Deref> PeerManager<Descriptor, CM> where
557564
}
558565
}
559566

567+
if needs_to_send_init_message {
568+
let mut features = InitFeatures::supported();
569+
if self.message_handler.route_handler.should_request_full_sync(&peer.their_node_id.unwrap()) {
570+
features.set_initial_routing_sync();
571+
}
572+
573+
let resp = msgs::Init { features };
574+
encode_and_send_msg!(resp);
575+
}
576+
560577
let message_option = conduit.decrypt_single_message(Some(&peer.pending_read_buffer.clone()));
561578
peer.pending_read_buffer = Vec::new(); // empty the pending read buffer
562579
let msg_data = if let Some(message) = message_option {

0 commit comments

Comments
 (0)