]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Work around lnd sending invalid messages
authorMatt Corallo <git@bluematt.me>
Sat, 16 Jun 2018 23:20:50 +0000 (19:20 -0400)
committerMatt Corallo <git@bluematt.me>
Sat, 16 Jun 2018 23:45:32 +0000 (19:45 -0400)
src/ln/peer_handler.rs

index bccfe5a03b0256b365b6ad5f6d65ecbedf500db8..3c4196519c5cca1700e8c008e2af97f5d76cb81d 100644 (file)
@@ -307,6 +307,18 @@ impl<Descriptor: SocketDescriptor> PeerManager<Descriptor> {
                                                                }
                                                        }
 
+                                                       macro_rules! try_ignore_potential_decodeerror {
+                                                               ($thing: expr) => {
+                                                                       match $thing {
+                                                                               Ok(x) => x,
+                                                                               Err(_e) => {
+                                                                                       println!("Error decoding message, ignoring due to lnd spec incompatibility. See https://github.com/lightningnetwork/lnd/issues/1407");
+                                                                                       continue;
+                                                                               }
+                                                                       };
+                                                               }
+                                                       }
+
                                                        let next_step = peer.channel_encryptor.get_noise_step();
                                                        match next_step {
                                                                NextNoiseStep::ActOne => {
@@ -495,7 +507,7 @@ impl<Descriptor: SocketDescriptor> PeerManager<Descriptor> {
                                                                                                }
                                                                                        },
                                                                                        257 => {
-                                                                                               let msg = try_potential_decodeerror!(msgs::NodeAnnouncement::decode(&msg_data[2..]));
+                                                                                               let msg = try_ignore_potential_decodeerror!(msgs::NodeAnnouncement::decode(&msg_data[2..]));
                                                                                                try_potential_handleerror!(self.message_handler.route_handler.handle_node_announcement(&msg));
                                                                                        },
                                                                                        258 => {