}
}
}
+
+ fn handle_error(&self, their_node_id: &PublicKey, msg: &msgs::ErrorMessage) {
+ if msg.channel_id == [0; 32] {
+ for chan in self.list_channels() {
+ if chan.remote_network_id == *their_node_id {
+ self.force_close_channel(&chan.channel_id);
+ }
+ }
+ } else {
+ self.force_close_channel(&msg.channel_id);
+ }
+ }
}
#[cfg(test)]
// Channel-to-announce:
fn handle_announcement_signatures(&self, their_node_id: &PublicKey, msg: &AnnouncementSignatures) -> Result<(), HandleError>;
- // Informational:
+ // Error conditions:
/// Indicates a connection to the peer failed/an existing connection was lost. If no connection
/// is believed to be possible in the future (eg they're sending us messages we don't
/// understand or indicate they require unknown feature bits), no_connection_possible is set
/// and any outstanding channels should be failed.
fn peer_disconnected(&self, their_node_id: &PublicKey, no_connection_possible: bool);
+
+ fn handle_error(&self, their_node_id: &PublicKey, msg: &ErrorMessage);
}
pub trait RoutingMessageHandler : Send + Sync {
}
},
17 => {
- // Error msg
+ let msg = try_potential_decodeerror!(msgs::ErrorMessage::decode(&msg_data[2..]));
+ let mut data_is_printable = true;
+ for b in msg.data.bytes() {
+ if b < 32 || b > 126 {
+ data_is_printable = false;
+ break;
+ }
+ }
+
+ if data_is_printable {
+ log_debug!(self, "Got Err message from {}: {}", log_pubkey!(peer.their_node_id.unwrap()), msg.data);
+ } else {
+ log_debug!(self, "Got Err message from {} with non-ASCII error message", log_pubkey!(peer.their_node_id.unwrap()));
+ }
+ self.message_handler.chan_handler.handle_error(&peer.their_node_id.unwrap(), &msg);
+ if msg.channel_id == [0; 32] {
+ return Err(PeerHandleError{ no_connection_possible: true });
+ }
},
18 => {
Err(HandleError { err: "", action: None })
}
fn peer_disconnected(&self, _their_node_id: &PublicKey, _no_connection_possible: bool) {}
+ fn handle_error(&self, _their_node_id: &PublicKey, _msg: &msgs::ErrorMessage) {}
}
impl events::EventsProvider for TestChannelMessageHandler {