@@ -546,8 +546,10 @@ impl Into<u16> for FailureCode {
546
546
struct MsgHandleErrInternal {
547
547
err: msgs::LightningError,
548
548
chan_id: Option<(ChannelId, u128)>, // If Some a channel of ours has been closed
549
- shutdown_finish: Option<(ShutdownResult, Option<msgs::ChannelUpdate>)>,
549
+ shutdown_finish: Option<(ShutdownResult,
550
+ Option<msgs::ChannelUpdate>)>,
550
551
channel_capacity: Option<u64>,
552
+ channel_funding_txo: Option<OutPoint>,
551
553
}
552
554
impl MsgHandleErrInternal {
553
555
#[inline]
@@ -565,14 +567,15 @@ impl MsgHandleErrInternal {
565
567
chan_id: None,
566
568
shutdown_finish: None,
567
569
channel_capacity: None,
570
+ channel_funding_txo: None,
568
571
}
569
572
}
570
573
#[inline]
571
574
fn from_no_close(err: msgs::LightningError) -> Self {
572
- Self { err, chan_id: None, shutdown_finish: None, channel_capacity: None }
575
+ Self { err, chan_id: None, shutdown_finish: None, channel_capacity: None, channel_funding_txo: None }
573
576
}
574
577
#[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 {
578
+ 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 {
576
579
let err_msg = msgs::ErrorMessage { channel_id, data: err.clone() };
577
580
let action = if shutdown_res.monitor_update.is_some() {
578
581
// We have a closing `ChannelMonitorUpdate`, which means the channel was funded and we
@@ -586,7 +589,8 @@ impl MsgHandleErrInternal {
586
589
err: LightningError { err, action },
587
590
chan_id: Some((channel_id, user_channel_id)),
588
591
shutdown_finish: Some((shutdown_res, channel_update)),
589
- channel_capacity: Some(channel_capacity)
592
+ channel_capacity: Some(channel_capacity),
593
+ channel_funding_txo,
590
594
}
591
595
}
592
596
#[inline]
@@ -620,6 +624,7 @@ impl MsgHandleErrInternal {
620
624
chan_id: None,
621
625
shutdown_finish: None,
622
626
channel_capacity: None,
627
+ channel_funding_txo: None,
623
628
}
624
629
}
625
630
@@ -1956,7 +1961,7 @@ macro_rules! handle_error {
1956
1961
1957
1962
match $internal {
1958
1963
Ok(msg) => Ok(msg),
1959
- Err(MsgHandleErrInternal { err, chan_id, shutdown_finish, channel_capacity }) => {
1964
+ Err(MsgHandleErrInternal { err, chan_id, shutdown_finish, channel_capacity, channel_funding_txo }) => {
1960
1965
let mut msg_events = Vec::with_capacity(2);
1961
1966
1962
1967
if let Some((shutdown_res, update_option)) = shutdown_finish {
@@ -1972,6 +1977,7 @@ macro_rules! handle_error {
1972
1977
reason: ClosureReason::ProcessingError { err: err.err.clone() },
1973
1978
counterparty_node_id: Some($counterparty_node_id),
1974
1979
channel_capacity_sats: channel_capacity,
1980
+ channel_funding_txo,
1975
1981
}, None));
1976
1982
}
1977
1983
}
@@ -2042,9 +2048,10 @@ macro_rules! convert_chan_phase_err {
2042
2048
let shutdown_res = $channel.context.force_shutdown(true);
2043
2049
let user_id = $channel.context.get_user_id();
2044
2050
let channel_capacity_satoshis = $channel.context.get_value_satoshis();
2051
+ let channel_funding_txo = $channel.context.get_funding_txo();
2045
2052
2046
2053
(true, MsgHandleErrInternal::from_finish_shutdown(msg, *$channel_id, user_id,
2047
- shutdown_res, $channel_update, channel_capacity_satoshis))
2054
+ shutdown_res, $channel_update, channel_capacity_satoshis, channel_funding_txo ))
2048
2055
},
2049
2056
}
2050
2057
};
@@ -2718,6 +2725,7 @@ where
2718
2725
reason: closure_reason,
2719
2726
counterparty_node_id: Some(context.get_counterparty_node_id()),
2720
2727
channel_capacity_sats: Some(context.get_value_satoshis()),
2728
+ channel_funding_txo: context.get_funding_txo(),
2721
2729
}, None));
2722
2730
}
2723
2731
@@ -3761,7 +3769,8 @@ where
3761
3769
let user_id = chan.context.get_user_id();
3762
3770
let shutdown_res = chan.context.force_shutdown(false);
3763
3771
let channel_capacity = chan.context.get_value_satoshis();
3764
- (chan, MsgHandleErrInternal::from_finish_shutdown(msg, channel_id, user_id, shutdown_res, None, channel_capacity))
3772
+ let channel_funding_txo = chan.context.get_funding_txo();
3773
+ (chan, MsgHandleErrInternal::from_finish_shutdown(msg, channel_id, user_id, shutdown_res, None, channel_capacity, channel_funding_txo))
3765
3774
} else { unreachable!(); });
3766
3775
match funding_res {
3767
3776
Ok(funding_msg) => (chan, funding_msg),
@@ -10308,6 +10317,7 @@ where
10308
10317
reason: ClosureReason::OutdatedChannelManager,
10309
10318
counterparty_node_id: Some(channel.context.get_counterparty_node_id()),
10310
10319
channel_capacity_sats: Some(channel.context.get_value_satoshis()),
10320
+ channel_funding_txo: channel.context.get_funding_txo(),
10311
10321
}, None));
10312
10322
for (channel_htlc_source, payment_hash) in channel.inflight_htlc_sources() {
10313
10323
let mut found_htlc = false;
@@ -10361,6 +10371,7 @@ where
10361
10371
reason: ClosureReason::DisconnectedPeer,
10362
10372
counterparty_node_id: Some(channel.context.get_counterparty_node_id()),
10363
10373
channel_capacity_sats: Some(channel.context.get_value_satoshis()),
10374
+ channel_funding_txo: channel.context.get_funding_txo(),
10364
10375
}, None));
10365
10376
} else {
10366
10377
log_error!(logger, "Missing ChannelMonitor for channel {} needed by ChannelManager.", &channel.context.channel_id());
0 commit comments