Skip to content

Commit 52c2253

Browse files
authored
Merge pull request #2807 from Jossec101/log-errors-do-accept-inbound-channel
Log the errors before we return them from ChannelManager::do_accept_inbound_channel
2 parents 0d513fd + dbe69ba commit 52c2253

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6002,13 +6002,20 @@ where
60026002
}
60036003

60046004
fn do_accept_inbound_channel(&self, temporary_channel_id: &ChannelId, counterparty_node_id: &PublicKey, accept_0conf: bool, user_channel_id: u128) -> Result<(), APIError> {
6005+
6006+
let logger = WithContext::from(&self.logger, Some(*counterparty_node_id), Some(*temporary_channel_id));
60056007
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
60066008

60076009
let peers_without_funded_channels =
60086010
self.peers_without_funded_channels(|peer| { peer.total_channel_count() > 0 });
60096011
let per_peer_state = self.per_peer_state.read().unwrap();
60106012
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) })?;
6013+
.ok_or_else(|| {
6014+
let err_str = format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id);
6015+
log_error!(logger, "{}", err_str);
6016+
6017+
APIError::ChannelUnavailable { err: err_str }
6018+
})?;
60126019
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
60136020
let peer_state = &mut *peer_state_lock;
60146021
let is_only_peer_channel = peer_state.total_channel_count() == 1;
@@ -6023,9 +6030,19 @@ where
60236030
InboundV1Channel::new(&self.fee_estimator, &self.entropy_source, &self.signer_provider,
60246031
counterparty_node_id.clone(), &self.channel_type_features(), &peer_state.latest_features,
60256032
&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() })
6033+
&self.logger, accept_0conf).map_err(|e| {
6034+
let err_str = e.to_string();
6035+
log_error!(logger, "{}", err_str);
6036+
6037+
APIError::ChannelUnavailable { err: err_str }
6038+
})
6039+
}
6040+
_ => {
6041+
let err_str = "No such channel awaiting to be accepted.".to_owned();
6042+
log_error!(logger, "{}", err_str);
6043+
6044+
Err(APIError::APIMisuseError { err: err_str })
60276045
}
6028-
_ => Err(APIError::APIMisuseError { err: "No such channel awaiting to be accepted.".to_owned() })
60296046
}?;
60306047

60316048
if accept_0conf {
@@ -6039,7 +6056,10 @@ where
60396056
}
60406057
};
60416058
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() });
6059+
let err_str = "Please use accept_inbound_channel_from_trusted_peer_0conf to accept channels with zero confirmations.".to_owned();
6060+
log_error!(logger, "{}", err_str);
6061+
6062+
return Err(APIError::APIMisuseError { err: err_str });
60436063
} else {
60446064
// If this peer already has some channels, a new channel won't increase our number of peers
60456065
// with unfunded channels, so as long as we aren't over the maximum number of unfunded
@@ -6052,7 +6072,10 @@ where
60526072
}
60536073
};
60546074
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() });
6075+
let err_str = "Too many peers with unfunded channels, refusing to accept new ones".to_owned();
6076+
log_error!(logger, "{}", err_str);
6077+
6078+
return Err(APIError::APIMisuseError { err: err_str });
60566079
}
60576080
}
60586081

0 commit comments

Comments
 (0)