@@ -546,8 +546,10 @@ impl Into<u16> for FailureCode {
546546struct MsgHandleErrInternal {
547547	err: msgs::LightningError,
548548	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>)>,
550551	channel_capacity: Option<u64>,
552+ 	channel_funding_txo: Option<OutPoint>,
551553}
552554impl MsgHandleErrInternal {
553555	#[inline]
@@ -565,14 +567,15 @@ impl MsgHandleErrInternal {
565567			chan_id: None,
566568			shutdown_finish: None,
567569			channel_capacity: None,
570+ 			channel_funding_txo: None,
568571		}
569572	}
570573	#[inline]
571574	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  }
573576	}
574577	#[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 {
576579		let err_msg = msgs::ErrorMessage { channel_id, data: err.clone() };
577580		let action = if shutdown_res.monitor_update.is_some() {
578581			// We have a closing `ChannelMonitorUpdate`, which means the channel was funded and we
@@ -586,7 +589,8 @@ impl MsgHandleErrInternal {
586589			err: LightningError { err, action },
587590			chan_id: Some((channel_id, user_channel_id)),
588591			shutdown_finish: Some((shutdown_res, channel_update)),
589- 			channel_capacity: Some(channel_capacity)
592+ 			channel_capacity: Some(channel_capacity),
593+ 			channel_funding_txo,
590594		}
591595	}
592596	#[inline]
@@ -620,6 +624,7 @@ impl MsgHandleErrInternal {
620624			chan_id: None,
621625			shutdown_finish: None,
622626			channel_capacity: None,
627+ 			channel_funding_txo: None,
623628		}
624629	}
625630
@@ -1956,7 +1961,7 @@ macro_rules! handle_error {
19561961
19571962		match $internal {
19581963			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  }) => {
19601965				let mut msg_events = Vec::with_capacity(2);
19611966
19621967				if let Some((shutdown_res, update_option)) = shutdown_finish {
@@ -1972,6 +1977,7 @@ macro_rules! handle_error {
19721977							reason: ClosureReason::ProcessingError { err: err.err.clone() },
19731978							counterparty_node_id: Some($counterparty_node_id),
19741979							channel_capacity_sats: channel_capacity,
1980+ 							channel_funding_txo,
19751981						}, None));
19761982					}
19771983				}
@@ -2042,9 +2048,10 @@ macro_rules! convert_chan_phase_err {
20422048				let shutdown_res = $channel.context.force_shutdown(true);
20432049				let user_id = $channel.context.get_user_id();
20442050				let channel_capacity_satoshis = $channel.context.get_value_satoshis();
2051+ 				let channel_funding_txo = $channel.context.get_funding_txo();
20452052
20462053				(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 ))
20482055			},
20492056		}
20502057	};
@@ -2718,6 +2725,7 @@ where
27182725			reason: closure_reason,
27192726			counterparty_node_id: Some(context.get_counterparty_node_id()),
27202727			channel_capacity_sats: Some(context.get_value_satoshis()),
2728+ 			channel_funding_txo: context.get_funding_txo(),
27212729		}, None));
27222730	}
27232731
@@ -3761,7 +3769,8 @@ where
37613769						let user_id = chan.context.get_user_id();
37623770						let shutdown_res = chan.context.force_shutdown(false);
37633771						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))
37653774					} else { unreachable!(); });
37663775				match funding_res {
37673776					Ok(funding_msg) => (chan, funding_msg),
@@ -10308,6 +10317,7 @@ where
1030810317						reason: ClosureReason::OutdatedChannelManager,
1030910318						counterparty_node_id: Some(channel.context.get_counterparty_node_id()),
1031010319						channel_capacity_sats: Some(channel.context.get_value_satoshis()),
10320+ 						channel_funding_txo: channel.context.get_funding_txo(),
1031110321					}, None));
1031210322					for (channel_htlc_source, payment_hash) in channel.inflight_htlc_sources() {
1031310323						let mut found_htlc = false;
@@ -10361,6 +10371,7 @@ where
1036110371					reason: ClosureReason::DisconnectedPeer,
1036210372					counterparty_node_id: Some(channel.context.get_counterparty_node_id()),
1036310373					channel_capacity_sats: Some(channel.context.get_value_satoshis()),
10374+ 					channel_funding_txo: channel.context.get_funding_txo(),
1036410375				}, None));
1036510376			} else {
1036610377				log_error!(logger, "Missing ChannelMonitor for channel {} needed by ChannelManager.", &channel.context.channel_id());
0 commit comments