Skip to content

Commit

Permalink
Simplify parameters of
Browse files Browse the repository at this point in the history
  • Loading branch information
optout21 committed Dec 19, 2023
1 parent 7c176b3 commit c570853
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,9 @@ impl MsgHandleErrInternal {
Self { err, chan_id: None, shutdown_finish: None, channel_capacity: None, channel_funding_txo: None }
}
#[inline]
fn from_finish_shutdown(err: String, channel_id: ChannelId, user_channel_id: u128, shutdown_res: ShutdownResult, channel_update: Option<msgs::ChannelUpdate>, channel_capacity: u64, channel_funding_txo: Option<OutPoint>) -> Self {
fn from_finish_shutdown<SP: Deref>(err: String, channel_id: ChannelId, shutdown_res: ShutdownResult, channel_update: Option<msgs::ChannelUpdate>, channel_context: &ChannelContext<SP>) -> Self
where SP::Target: SignerProvider
{
let err_msg = msgs::ErrorMessage { channel_id, data: err.clone() };
let action = if shutdown_res.monitor_update.is_some() {
// We have a closing `ChannelMonitorUpdate`, which means the channel was funded and we
Expand All @@ -586,10 +588,10 @@ impl MsgHandleErrInternal {
};
Self {
err: LightningError { err, action },
chan_id: Some((channel_id, user_channel_id)),
chan_id: Some((channel_id, channel_context.get_user_id())),
shutdown_finish: Some((shutdown_res, channel_update)),
channel_capacity: Some(channel_capacity),
channel_funding_txo: channel_funding_txo,
channel_capacity: Some(channel_context.get_value_satoshis()),
channel_funding_txo: channel_context.get_funding_txo(),
}
}
#[inline]
Expand Down Expand Up @@ -2045,12 +2047,9 @@ macro_rules! convert_chan_phase_err {
log_error!(logger, "Closing channel {} due to close-required error: {}", $channel_id, msg);
update_maps_on_chan_removal!($self, $channel.context);
let shutdown_res = $channel.context.force_shutdown(true);
let user_id = $channel.context.get_user_id();
let channel_capacity_satoshis = $channel.context.get_value_satoshis();
let channel_funding_txo = $channel.context.get_funding_txo();

(true, MsgHandleErrInternal::from_finish_shutdown(msg, *$channel_id, user_id,
shutdown_res, $channel_update, channel_capacity_satoshis, channel_funding_txo))
(true, MsgHandleErrInternal::from_finish_shutdown(msg, *$channel_id,
shutdown_res, $channel_update, &$channel.context))
},
}
};
Expand Down Expand Up @@ -3764,12 +3763,9 @@ where
let logger = WithChannelContext::from(&self.logger, &chan.context);
let funding_res = chan.get_funding_created(funding_transaction, funding_txo, is_batch_funding, &&logger)
.map_err(|(mut chan, e)| if let ChannelError::Close(msg) = e {
let channel_id = chan.context.channel_id();
let user_id = chan.context.get_user_id();
let shutdown_res = chan.context.force_shutdown(false);
let channel_capacity = chan.context.get_value_satoshis();
let channel_funding_txo = chan.context.get_funding_txo();
(chan, MsgHandleErrInternal::from_finish_shutdown(msg, channel_id, user_id, shutdown_res, None, channel_capacity, channel_funding_txo))
let err_msg = MsgHandleErrInternal::from_finish_shutdown(msg, chan.context.channel_id(), shutdown_res, None, &chan.context);
(chan, err_msg)
} else { unreachable!(); });
match funding_res {
Ok(funding_msg) => (chan, funding_msg),
Expand Down

0 comments on commit c570853

Please sign in to comment.