@@ -548,6 +548,7 @@ struct MsgHandleErrInternal {
548
548
chan_id: Option<(ChannelId, u128)>, // If Some a channel of ours has been closed
549
549
shutdown_finish: Option<(ShutdownResult, Option<msgs::ChannelUpdate>)>,
550
550
channel_capacity: Option<u64>,
551
+ channel_funding_txo: Option<OutPoint>,
551
552
}
552
553
impl MsgHandleErrInternal {
553
554
#[inline]
@@ -565,14 +566,17 @@ impl MsgHandleErrInternal {
565
566
chan_id: None,
566
567
shutdown_finish: None,
567
568
channel_capacity: None,
569
+ channel_funding_txo: None,
568
570
}
569
571
}
570
572
#[inline]
571
573
fn from_no_close(err: msgs::LightningError) -> Self {
572
- Self { err, chan_id: None, shutdown_finish: None, channel_capacity: None }
574
+ Self { err, chan_id: None, shutdown_finish: None, channel_capacity: None, channel_funding_txo: None }
573
575
}
574
576
#[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 {
577
+ fn from_finish_shutdown<SP: Deref>(err: String, channel_id: ChannelId, shutdown_res: ShutdownResult, channel_update: Option<msgs::ChannelUpdate>, channel_context: &ChannelContext<SP>) -> Self
578
+ where SP::Target: SignerProvider
579
+ {
576
580
let err_msg = msgs::ErrorMessage { channel_id, data: err.clone() };
577
581
let action = if shutdown_res.monitor_update.is_some() {
578
582
// We have a closing `ChannelMonitorUpdate`, which means the channel was funded and we
@@ -584,9 +588,10 @@ impl MsgHandleErrInternal {
584
588
};
585
589
Self {
586
590
err: LightningError { err, action },
587
- chan_id: Some((channel_id, user_channel_id )),
591
+ chan_id: Some((channel_id, channel_context.get_user_id() )),
588
592
shutdown_finish: Some((shutdown_res, channel_update)),
589
- channel_capacity: Some(channel_capacity)
593
+ channel_capacity: Some(channel_context.get_value_satoshis()),
594
+ channel_funding_txo: channel_context.get_funding_txo(),
590
595
}
591
596
}
592
597
#[inline]
@@ -620,6 +625,7 @@ impl MsgHandleErrInternal {
620
625
chan_id: None,
621
626
shutdown_finish: None,
622
627
channel_capacity: None,
628
+ channel_funding_txo: None,
623
629
}
624
630
}
625
631
@@ -1956,7 +1962,7 @@ macro_rules! handle_error {
1956
1962
1957
1963
match $internal {
1958
1964
Ok(msg) => Ok(msg),
1959
- Err(MsgHandleErrInternal { err, chan_id, shutdown_finish, channel_capacity }) => {
1965
+ Err(MsgHandleErrInternal { err, chan_id, shutdown_finish, channel_capacity, channel_funding_txo }) => {
1960
1966
let mut msg_events = Vec::with_capacity(2);
1961
1967
1962
1968
if let Some((shutdown_res, update_option)) = shutdown_finish {
@@ -1972,6 +1978,7 @@ macro_rules! handle_error {
1972
1978
reason: ClosureReason::ProcessingError { err: err.err.clone() },
1973
1979
counterparty_node_id: Some($counterparty_node_id),
1974
1980
channel_capacity_sats: channel_capacity,
1981
+ channel_funding_txo: channel_funding_txo,
1975
1982
}, None));
1976
1983
}
1977
1984
}
@@ -2040,11 +2047,9 @@ macro_rules! convert_chan_phase_err {
2040
2047
log_error!(logger, "Closing channel {} due to close-required error: {}", $channel_id, msg);
2041
2048
update_maps_on_chan_removal!($self, $channel.context);
2042
2049
let shutdown_res = $channel.context.force_shutdown(true);
2043
- let user_id = $channel.context.get_user_id();
2044
- let channel_capacity_satoshis = $channel.context.get_value_satoshis();
2045
2050
2046
- (true, MsgHandleErrInternal::from_finish_shutdown(msg, *$channel_id, user_id,
2047
- shutdown_res, $channel_update, channel_capacity_satoshis ))
2051
+ (true, MsgHandleErrInternal::from_finish_shutdown(msg, *$channel_id,
2052
+ shutdown_res, $channel_update, &$channel.context ))
2048
2053
},
2049
2054
}
2050
2055
};
@@ -2718,6 +2723,7 @@ where
2718
2723
reason: closure_reason,
2719
2724
counterparty_node_id: Some(context.get_counterparty_node_id()),
2720
2725
channel_capacity_sats: Some(context.get_value_satoshis()),
2726
+ channel_funding_txo: context.get_funding_txo(),
2721
2727
}, None));
2722
2728
}
2723
2729
@@ -3757,11 +3763,9 @@ where
3757
3763
let logger = WithChannelContext::from(&self.logger, &chan.context);
3758
3764
let funding_res = chan.get_funding_created(funding_transaction, funding_txo, is_batch_funding, &&logger)
3759
3765
.map_err(|(mut chan, e)| if let ChannelError::Close(msg) = e {
3760
- let channel_id = chan.context.channel_id();
3761
- let user_id = chan.context.get_user_id();
3762
3766
let shutdown_res = chan.context.force_shutdown(false);
3763
- let channel_capacity = chan.context.get_value_satoshis( );
3764
- (chan, MsgHandleErrInternal::from_finish_shutdown(msg, channel_id, user_id, shutdown_res, None, channel_capacity) )
3767
+ let err_msg = MsgHandleErrInternal::from_finish_shutdown(msg, chan.context.channel_id(), shutdown_res, None, &chan.context );
3768
+ (chan, err_msg )
3765
3769
} else { unreachable!(); });
3766
3770
match funding_res {
3767
3771
Ok(funding_msg) => (chan, funding_msg),
@@ -10308,6 +10312,7 @@ where
10308
10312
reason: ClosureReason::OutdatedChannelManager,
10309
10313
counterparty_node_id: Some(channel.context.get_counterparty_node_id()),
10310
10314
channel_capacity_sats: Some(channel.context.get_value_satoshis()),
10315
+ channel_funding_txo: channel.context.get_funding_txo(),
10311
10316
}, None));
10312
10317
for (channel_htlc_source, payment_hash) in channel.inflight_htlc_sources() {
10313
10318
let mut found_htlc = false;
@@ -10361,6 +10366,7 @@ where
10361
10366
reason: ClosureReason::DisconnectedPeer,
10362
10367
counterparty_node_id: Some(channel.context.get_counterparty_node_id()),
10363
10368
channel_capacity_sats: Some(channel.context.get_value_satoshis()),
10369
+ channel_funding_txo: channel.context.get_funding_txo(),
10364
10370
}, None));
10365
10371
} else {
10366
10372
log_error!(logger, "Missing ChannelMonitor for channel {} needed by ChannelManager.", &channel.context.channel_id());
0 commit comments