From 8f36386bee87294d1df9bcb4740724cc9785fbca Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sat, 25 Aug 2018 14:32:02 -0400 Subject: [PATCH] Ensure we never send messages prior to Init for BOLT 1 compliance --- src/ln/peer_handler.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ln/peer_handler.rs b/src/ln/peer_handler.rs index 4ab039741..53788b3f2 100644 --- a/src/ln/peer_handler.rs +++ b/src/ln/peer_handler.rs @@ -621,6 +621,10 @@ impl PeerManager { }; match peers.peers.get_mut(&descriptor) { Some(peer) => { + if peer.their_global_features.is_none() { + $handle_no_such_peer; + continue; + } (descriptor, peer) }, None => panic!("Inconsistent peers set state!"), @@ -717,7 +721,7 @@ impl PeerManager { let encoded_update_msg = encode_msg!(update_msg, 258); for (ref descriptor, ref mut peer) in peers.peers.iter_mut() { - if !peer.channel_encryptor.is_ready_for_encryption() { + if !peer.channel_encryptor.is_ready_for_encryption() || peer.their_global_features.is_none() { continue } match peer.their_node_id { @@ -741,7 +745,7 @@ impl PeerManager { let encoded_msg = encode_msg!(msg, 258); for (ref descriptor, ref mut peer) in peers.peers.iter_mut() { - if !peer.channel_encryptor.is_ready_for_encryption() { + if !peer.channel_encryptor.is_ready_for_encryption() || peer.their_global_features.is_none() { continue } peer.pending_outbound_buffer.push_back(peer.channel_encryptor.encrypt_message(&encoded_msg[..])); -- 2.39.5