+ peer.pending_read_buffer_pos = 0;
+
+ macro_rules! encode_and_send_msg {
+ ($msg: expr, $msg_code: expr) => {
+ peer.pending_outbound_buffer.push_back(peer.channel_encryptor.encrypt_message(&encode_msg!($msg, $msg_code)[..]));
+ }
+ }
+
+ macro_rules! try_potential_handleerror {
+ ($thing: expr) => {
+ match $thing {
+ Ok(x) => x,
+ Err(e) => {
+ 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 => {
+ return Err(PeerHandleError{ no_connection_possible: false });
+ },
+ msgs::ErrorAction::IgnoreError => {
+ continue;
+ },
+ }
+ } else {
+ return Err(PeerHandleError{ no_connection_possible: false });
+ }
+ }
+ };
+ }
+ }
+
+ macro_rules! try_potential_decodeerror {
+ ($thing: expr) => {
+ match $thing {
+ Ok(x) => x,
+ Err(_e) => {
+ println!("Error decoding message");
+ //TODO: Handle e?
+ return Err(PeerHandleError{ no_connection_possible: false });
+ }
+ };
+ }
+ }
+
+ 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;
+ }
+ };
+ }
+ }
+