Skip to content

Commit e97bfc2

Browse files
committed
Log the errors before we return them from ChannelManager::do_accept_inbound_channel #2754
1 parent 15b7f66 commit e97bfc2

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6008,7 +6008,12 @@ where
60086008
self.peers_without_funded_channels(|peer| { peer.total_channel_count() > 0 });
60096009
let per_peer_state = self.per_peer_state.read().unwrap();
60106010
let peer_state_mutex = per_peer_state.get(counterparty_node_id)
6011-
.ok_or_else(|| APIError::ChannelUnavailable { err: format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id) })?;
6011+
.ok_or_else(|| {
6012+
let err_str = format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id);
6013+
log_error!(self.logger, "{}", err_str);
6014+
6015+
APIError::ChannelUnavailable { err: err_str }
6016+
})?;
60126017
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
60136018
let peer_state = &mut *peer_state_lock;
60146019
let is_only_peer_channel = peer_state.total_channel_count() == 1;
@@ -6023,9 +6028,19 @@ where
60236028
InboundV1Channel::new(&self.fee_estimator, &self.entropy_source, &self.signer_provider,
60246029
counterparty_node_id.clone(), &self.channel_type_features(), &peer_state.latest_features,
60256030
&unaccepted_channel.open_channel_msg, user_channel_id, &self.default_configuration, best_block_height,
6026-
&self.logger, accept_0conf).map_err(|e| APIError::ChannelUnavailable { err: e.to_string() })
6031+
&self.logger, accept_0conf).map_err(|e| {
6032+
let err_str = e.to_string();
6033+
log_error!(self.logger,e);
6034+
6035+
APIError::ChannelUnavailable { err: err_str }
6036+
})
6037+
}
6038+
_ => {
6039+
let err_str = "No such channel awaiting to be accepted.".to_owned();
6040+
log_error!(self.logger, "{}", err_str);
6041+
6042+
Err(APIError::APIMisuseError { err: err_str })
60276043
}
6028-
_ => Err(APIError::APIMisuseError { err: "No such channel awaiting to be accepted.".to_owned() })
60296044
}?;
60306045

60316046
if accept_0conf {
@@ -6039,7 +6054,10 @@ where
60396054
}
60406055
};
60416056
peer_state.pending_msg_events.push(send_msg_err_event);
6042-
return Err(APIError::APIMisuseError { err: "Please use accept_inbound_channel_from_trusted_peer_0conf to accept channels with zero confirmations.".to_owned() });
6057+
let err_str = "Please use accept_inbound_channel_from_trusted_peer_0conf to accept channels with zero confirmations.".to_owned();
6058+
log_error!(self.logger, "{}", err_str);
6059+
6060+
return Err(APIError::APIMisuseError { err: err_str });
60436061
} else {
60446062
// If this peer already has some channels, a new channel won't increase our number of peers
60456063
// with unfunded channels, so as long as we aren't over the maximum number of unfunded
@@ -6052,7 +6070,10 @@ where
60526070
}
60536071
};
60546072
peer_state.pending_msg_events.push(send_msg_err_event);
6055-
return Err(APIError::APIMisuseError { err: "Too many peers with unfunded channels, refusing to accept new ones".to_owned() });
6073+
let err_str = "Too many peers with unfunded channels, refusing to accept new ones".to_owned();
6074+
log_error!(self.logger, "{}", err_str);
6075+
6076+
return Err(APIError::APIMisuseError { err: err_str });
60566077
}
60576078
}
60586079

0 commit comments

Comments
 (0)