Split HTLC tracking into separate Inbound/Outbound types
[rust-lightning] / src / ln / peer_handler.rs
index d7a7553ed1b9da5b6c3e739f6a6f8cc0198003e4..8a4228851b7a7e3981e698ccc6cd05f3cb3e5d3b 100644 (file)
@@ -147,7 +147,12 @@ impl<Descriptor: SocketDescriptor> PeerManager<Descriptor> {
        /// completed and we are sure the remote peer has the private key for the given node_id.
        pub fn get_peer_node_ids(&self) -> Vec<PublicKey> {
                let peers = self.peers.lock().unwrap();
-               peers.peers.values().filter_map(|p| p.their_node_id).collect()
+               peers.peers.values().filter_map(|p| {
+                       if !p.channel_encryptor.is_ready_for_encryption() || p.their_global_features.is_none() {
+                               return None;
+                       }
+                       p.their_node_id
+               }).collect()
        }
 
        /// Indicates a new outbound connection has been established to a node with the given node_id.
@@ -440,6 +445,9 @@ impl<Descriptor: SocketDescriptor> PeerManager<Descriptor> {
                                                                                                if msg.local_features.requires_unknown_bits() {
                                                                                                        return Err(PeerHandleError{ no_connection_possible: true });
                                                                                                }
+                                                                                               if peer.their_global_features.is_some() {
+                                                                                                       return Err(PeerHandleError{ no_connection_possible: false });
+                                                                                               }
                                                                                                peer.their_global_features = Some(msg.global_features);
                                                                                                peer.their_local_features = Some(msg.local_features);