X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fln%2Fpeer_handler.rs;h=30900cab499a8407fb4c7029c76a2de75517276d;hb=05e2a7dc48f11a7f258f59acd769e4874c022a87;hp=7b140b0797284f04ca55d993b75a45f53be5069a;hpb=3cf262c137a660c694d37529bd48be6d3fe7900e;p=rust-lightning diff --git a/src/ln/peer_handler.rs b/src/ln/peer_handler.rs index 7b140b07..30900cab 100644 --- a/src/ln/peer_handler.rs +++ b/src/ln/peer_handler.rs @@ -272,16 +272,19 @@ impl PeerManager { match $thing { Ok(x) => x, Err(e) => { - // TODO: Log e.err + println!("Got error handling message: {}!", e.err); if let Some(action) = e.msg { match action { msgs::ErrorAction::UpdateFailHTLC { msg } => { encode_and_send_msg!(msg, 131); continue; }, - msgs::ErrorAction::DisconnectPeer {} => { + msgs::ErrorAction::DisconnectPeer => { return Err(PeerHandleError{ no_connection_possible: false }); }, + msgs::ErrorAction::IgnoreError => { + continue; + }, } } else { return Err(PeerHandleError{ no_connection_possible: false }); @@ -296,6 +299,7 @@ impl PeerManager { match $thing { Ok(x) => x, Err(_e) => { + println!("Error decoding message"); //TODO: Handle e? return Err(PeerHandleError{ no_connection_possible: false }); } @@ -303,6 +307,18 @@ impl PeerManager { } } + 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 => { @@ -374,8 +390,15 @@ impl PeerManager { 17 => { // Error msg }, - 18 => { }, // ping - 19 => { }, // pong + + 18 => { + let msg = try_potential_decodeerror!(msgs::Ping::decode(&msg_data[2..])); + let resp = msgs::Pong { byteslen: msg.ponglen }; + encode_and_send_msg!(resp, 19); + }, + 19 => { + try_potential_decodeerror!(msgs::Pong::decode(&msg_data[2..])); + }, // Channel control: 32 => { @@ -491,7 +514,7 @@ impl PeerManager { } }, 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 => {