Skip to content

Commit 3377119

Browse files
committed
Work around lnd sending invalid messages
1 parent d7b33fc commit 3377119

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/ln/peer_handler.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,18 @@ impl<Descriptor: SocketDescriptor> PeerManager<Descriptor> {
307307
}
308308
}
309309

310+
macro_rules! try_ignore_potential_decodeerror {
311+
($thing: expr) => {
312+
match $thing {
313+
Ok(x) => x,
314+
Err(_e) => {
315+
println!("Error decoding message, ignoring due to lnd spec incompatibility. See https://github.com/lightningnetwork/lnd/issues/1407");
316+
continue;
317+
}
318+
};
319+
}
320+
}
321+
310322
let next_step = peer.channel_encryptor.get_noise_step();
311323
match next_step {
312324
NextNoiseStep::ActOne => {
@@ -495,7 +507,7 @@ impl<Descriptor: SocketDescriptor> PeerManager<Descriptor> {
495507
}
496508
},
497509
257 => {
498-
let msg = try_potential_decodeerror!(msgs::NodeAnnouncement::decode(&msg_data[2..]));
510+
let msg = try_ignore_potential_decodeerror!(msgs::NodeAnnouncement::decode(&msg_data[2..]));
499511
try_potential_handleerror!(self.message_handler.route_handler.handle_node_announcement(&msg));
500512
},
501513
258 => {

0 commit comments

Comments
 (0)