@@ -545,9 +545,8 @@ impl Into<u16> for FailureCode {
545
545
546
546
struct MsgHandleErrInternal {
547
547
err: msgs::LightningError,
548
- chan_id: Option<(ChannelId, u128)>, // If Some a channel of ours has been closed
548
+ closes_channel: bool,
549
549
shutdown_finish: Option<(ShutdownResult, Option<msgs::ChannelUpdate>)>,
550
- channel_capacity: Option<u64>,
551
550
}
552
551
impl MsgHandleErrInternal {
553
552
#[inline]
@@ -562,17 +561,16 @@ impl MsgHandleErrInternal {
562
561
},
563
562
},
564
563
},
565
- chan_id: None ,
564
+ closes_channel: false ,
566
565
shutdown_finish: None,
567
- channel_capacity: None,
568
566
}
569
567
}
570
568
#[inline]
571
569
fn from_no_close(err: msgs::LightningError) -> Self {
572
- Self { err, chan_id: None , shutdown_finish: None, channel_capacity : None }
570
+ Self { err, closes_channel: false , shutdown_finish: None }
573
571
}
574
572
#[inline]
575
- fn from_finish_shutdown(err: String, channel_id: ChannelId, user_channel_id: u128, shutdown_res: ShutdownResult, channel_update: Option<msgs::ChannelUpdate>, channel_capacity: u64 ) -> Self {
573
+ fn from_finish_shutdown(err: String, channel_id: ChannelId, shutdown_res: ShutdownResult, channel_update: Option<msgs::ChannelUpdate>) -> Self {
576
574
let err_msg = msgs::ErrorMessage { channel_id, data: err.clone() };
577
575
let action = if shutdown_res.monitor_update.is_some() {
578
576
// We have a closing `ChannelMonitorUpdate`, which means the channel was funded and we
@@ -584,9 +582,8 @@ impl MsgHandleErrInternal {
584
582
};
585
583
Self {
586
584
err: LightningError { err, action },
587
- chan_id: Some((channel_id, user_channel_id)) ,
585
+ closes_channel: true ,
588
586
shutdown_finish: Some((shutdown_res, channel_update)),
589
- channel_capacity: Some(channel_capacity)
590
587
}
591
588
}
592
589
#[inline]
@@ -617,14 +614,13 @@ impl MsgHandleErrInternal {
617
614
},
618
615
},
619
616
},
620
- chan_id: None ,
617
+ closes_channel: false ,
621
618
shutdown_finish: None,
622
- channel_capacity: None,
623
619
}
624
620
}
625
621
626
622
fn closes_channel(&self) -> bool {
627
- self.chan_id.is_some()
623
+ self.closes_channel
628
624
}
629
625
}
630
626
@@ -1956,22 +1952,27 @@ macro_rules! handle_error {
1956
1952
1957
1953
match $internal {
1958
1954
Ok(msg) => Ok(msg),
1959
- Err(MsgHandleErrInternal { err, chan_id, shutdown_finish, channel_capacity }) => {
1955
+ Err(MsgHandleErrInternal { err, shutdown_finish, .. }) => {
1960
1956
let mut msg_events = Vec::with_capacity(2);
1961
1957
1962
1958
if let Some((shutdown_res, update_option)) = shutdown_finish {
1959
+ let counterparty_node_id = shutdown_res.counterparty_node_id;
1960
+ let channel_id = shutdown_res.channel_id;
1961
+ let logger = WithContext::from(
1962
+ &$self.logger, Some(counterparty_node_id), Some(channel_id),
1963
+ );
1964
+ log_error!(logger, "Force-closing channel: {}", err.err);
1965
+
1963
1966
$self.finish_close_channel(shutdown_res);
1964
1967
if let Some(update) = update_option {
1965
1968
msg_events.push(events::MessageSendEvent::BroadcastChannelUpdate {
1966
1969
msg: update
1967
1970
});
1968
1971
}
1972
+ } else {
1973
+ log_error!($self.logger, "Got non-closing error: {}", err.err);
1969
1974
}
1970
1975
1971
- let logger = WithContext::from(
1972
- &$self.logger, Some($counterparty_node_id), chan_id.map(|(chan_id, _)| chan_id)
1973
- );
1974
- log_error!(logger, "{}", err.err);
1975
1976
if let msgs::ErrorAction::IgnoreError = err.action {
1976
1977
} else {
1977
1978
msg_events.push(events::MessageSendEvent::HandleError {
@@ -2033,11 +2034,9 @@ macro_rules! convert_chan_phase_err {
2033
2034
update_maps_on_chan_removal!($self, $channel.context);
2034
2035
let reason = ClosureReason::ProcessingError { err: msg.clone() };
2035
2036
let shutdown_res = $channel.context.force_shutdown(true, reason);
2036
- let user_id = $channel.context.get_user_id();
2037
- let channel_capacity_satoshis = $channel.context.get_value_satoshis();
2038
-
2039
- (true, MsgHandleErrInternal::from_finish_shutdown(msg, *$channel_id, user_id,
2040
- shutdown_res, $channel_update, channel_capacity_satoshis))
2037
+ let err =
2038
+ MsgHandleErrInternal::from_finish_shutdown(msg, *$channel_id, shutdown_res, $channel_update);
2039
+ (true, err)
2041
2040
},
2042
2041
}
2043
2042
};
@@ -2834,7 +2833,8 @@ where
2834
2833
&self.logger, Some(shutdown_res.counterparty_node_id), Some(shutdown_res.channel_id),
2835
2834
);
2836
2835
2837
- log_debug!(logger, "Finishing closure of channel with {} HTLCs to fail", shutdown_res.dropped_outbound_htlcs.len());
2836
+ log_debug!(logger, "Finishing closure of channel due to {} with {} HTLCs to fail",
2837
+ shutdown_res.closure_reason, shutdown_res.dropped_outbound_htlcs.len());
2838
2838
for htlc_source in shutdown_res.dropped_outbound_htlcs.drain(..) {
2839
2839
let (source, payment_hash, counterparty_node_id, channel_id) = htlc_source;
2840
2840
let reason = HTLCFailReason::from_failure_code(0x4000 | 8);
@@ -3746,11 +3746,9 @@ where
3746
3746
let funding_res = chan.get_funding_created(funding_transaction, funding_txo, is_batch_funding, &&logger)
3747
3747
.map_err(|(mut chan, e)| if let ChannelError::Close(msg) = e {
3748
3748
let channel_id = chan.context.channel_id();
3749
- let user_id = chan.context.get_user_id();
3750
3749
let reason = ClosureReason::ProcessingError { err: msg.clone() };
3751
3750
let shutdown_res = chan.context.force_shutdown(false, reason);
3752
- let channel_capacity = chan.context.get_value_satoshis();
3753
- (chan, MsgHandleErrInternal::from_finish_shutdown(msg, channel_id, user_id, shutdown_res, None, channel_capacity))
3751
+ (chan, MsgHandleErrInternal::from_finish_shutdown(msg, channel_id, shutdown_res, None))
3754
3752
} else { unreachable!(); });
3755
3753
match funding_res {
3756
3754
Ok(funding_msg) => (chan, funding_msg),
0 commit comments