From: Matt Corallo Date: Sat, 25 Aug 2018 18:32:02 +0000 (-0400) Subject: Ensure we never send messages prior to Init for BOLT 1 compliance X-Git-Tag: v0.0.12~338^2~2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=8f36386bee87294d1df9bcb4740724cc9785fbca;p=rust-lightning Ensure we never send messages prior to Init for BOLT 1 compliance --- 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[..]));