@@ -397,6 +397,7 @@ struct MsgHandleErrInternal {
397397 err: msgs::LightningError,
398398 chan_id: Option<([u8; 32], u128)>, // If Some a channel of ours has been closed
399399 shutdown_finish: Option<(ShutdownResult, Option<msgs::ChannelUpdate>)>,
400+ channel_capacity: Option<u64>,
400401}
401402impl MsgHandleErrInternal {
402403 #[inline]
@@ -413,14 +414,15 @@ impl MsgHandleErrInternal {
413414 },
414415 chan_id: None,
415416 shutdown_finish: None,
417+ channel_capacity: None,
416418 }
417419 }
418420 #[inline]
419421 fn from_no_close(err: msgs::LightningError) -> Self {
420- Self { err, chan_id: None, shutdown_finish: None }
422+ Self { err, chan_id: None, shutdown_finish: None, channel_capacity: None }
421423 }
422424 #[inline]
423- fn from_finish_shutdown(err: String, channel_id: [u8; 32], user_channel_id: u128, shutdown_res: ShutdownResult, channel_update: Option<msgs::ChannelUpdate>) -> Self {
425+ fn from_finish_shutdown(err: String, channel_id: [u8; 32], user_channel_id: u128, shutdown_res: ShutdownResult, channel_update: Option<msgs::ChannelUpdate>, channel_capacity: u64 ) -> Self {
424426 Self {
425427 err: LightningError {
426428 err: err.clone(),
@@ -433,6 +435,7 @@ impl MsgHandleErrInternal {
433435 },
434436 chan_id: Some((channel_id, user_channel_id)),
435437 shutdown_finish: Some((shutdown_res, channel_update)),
438+ channel_capacity: Some(channel_capacity)
436439 }
437440 }
438441 #[inline]
@@ -465,6 +468,7 @@ impl MsgHandleErrInternal {
465468 },
466469 chan_id: None,
467470 shutdown_finish: None,
471+ channel_capacity: None,
468472 }
469473 }
470474}
@@ -1680,7 +1684,7 @@ macro_rules! handle_error {
16801684
16811685 match $internal {
16821686 Ok(msg) => Ok(msg),
1683- Err(MsgHandleErrInternal { err, chan_id, shutdown_finish }) => {
1687+ Err(MsgHandleErrInternal { err, chan_id, shutdown_finish, channel_capacity }) => {
16841688 let mut msg_events = Vec::with_capacity(2);
16851689
16861690 if let Some((shutdown_res, update_option)) = shutdown_finish {
@@ -1693,7 +1697,9 @@ macro_rules! handle_error {
16931697 if let Some((channel_id, user_channel_id)) = chan_id {
16941698 $self.pending_events.lock().unwrap().push_back((events::Event::ChannelClosed {
16951699 channel_id, user_channel_id,
1696- reason: ClosureReason::ProcessingError { err: err.err.clone() }
1700+ reason: ClosureReason::ProcessingError { err: err.err.clone() },
1701+ counterparty_node_id: Some($counterparty_node_id),
1702+ channel_capacity_sats: channel_capacity,
16971703 }, None));
16981704 }
16991705 }
@@ -1766,7 +1772,7 @@ macro_rules! convert_chan_err {
17661772 update_maps_on_chan_removal!($self, &$channel.context);
17671773 let shutdown_res = $channel.context.force_shutdown(true);
17681774 (true, MsgHandleErrInternal::from_finish_shutdown(msg, *$channel_id, $channel.context.get_user_id(),
1769- shutdown_res, $self.get_channel_update_for_broadcast(&$channel).ok()))
1775+ shutdown_res, $self.get_channel_update_for_broadcast(&$channel).ok(), $channel.context.get_value_satoshis() ))
17701776 },
17711777 }
17721778 };
@@ -1779,7 +1785,7 @@ macro_rules! convert_chan_err {
17791785 update_maps_on_chan_removal!($self, &$channel_context);
17801786 let shutdown_res = $channel_context.force_shutdown(false);
17811787 (true, MsgHandleErrInternal::from_finish_shutdown(msg, *$channel_id, $channel_context.get_user_id(),
1782- shutdown_res, None))
1788+ shutdown_res, None, $channel_context.get_value_satoshis() ))
17831789 },
17841790 }
17851791 }
@@ -1958,7 +1964,7 @@ macro_rules! handle_new_monitor_update {
19581964 let res = Err(MsgHandleErrInternal::from_finish_shutdown(
19591965 "ChannelMonitor storage failure".to_owned(), $chan.context.channel_id(),
19601966 $chan.context.get_user_id(), $chan.context.force_shutdown(false),
1961- $self.get_channel_update_for_broadcast(&$chan).ok()));
1967+ $self.get_channel_update_for_broadcast(&$chan).ok(), $chan.context.get_value_satoshis() ));
19621968 $remove;
19631969 res
19641970 },
@@ -2392,7 +2398,9 @@ where
23922398 pending_events_lock.push_back((events::Event::ChannelClosed {
23932399 channel_id: context.channel_id(),
23942400 user_channel_id: context.get_user_id(),
2395- reason: closure_reason
2401+ reason: closure_reason,
2402+ counterparty_node_id: Some(context.get_counterparty_node_id()),
2403+ channel_capacity_sats: Some(context.get_value_satoshis()),
23962404 }, None));
23972405 }
23982406
@@ -3408,7 +3416,8 @@ where
34083416 let channel_id = chan.context.channel_id();
34093417 let user_id = chan.context.get_user_id();
34103418 let shutdown_res = chan.context.force_shutdown(false);
3411- (chan, MsgHandleErrInternal::from_finish_shutdown(msg, channel_id, user_id, shutdown_res, None))
3419+ let channel_capacity = chan.context.get_value_satoshis();
3420+ (chan, MsgHandleErrInternal::from_finish_shutdown(msg, channel_id, user_id, shutdown_res, None, channel_capacity))
34123421 } else { unreachable!(); });
34133422 match funding_res {
34143423 Ok((chan, funding_msg)) => (chan, funding_msg),
@@ -5492,7 +5501,7 @@ where
54925501 let user_id = inbound_chan.context.get_user_id();
54935502 let shutdown_res = inbound_chan.context.force_shutdown(false);
54945503 return Err(MsgHandleErrInternal::from_finish_shutdown(format!("{}", err),
5495- msg.temporary_channel_id, user_id, shutdown_res, None));
5504+ msg.temporary_channel_id, user_id, shutdown_res, None, inbound_chan.context.get_value_satoshis() ));
54965505 },
54975506 }
54985507 },
@@ -8442,7 +8451,9 @@ where
84428451 channel_closures.push_back((events::Event::ChannelClosed {
84438452 channel_id: channel.context.channel_id(),
84448453 user_channel_id: channel.context.get_user_id(),
8445- reason: ClosureReason::OutdatedChannelManager
8454+ reason: ClosureReason::OutdatedChannelManager,
8455+ counterparty_node_id: Some(channel.context.get_counterparty_node_id()),
8456+ channel_capacity_sats: Some(channel.context.get_value_satoshis()),
84468457 }, None));
84478458 for (channel_htlc_source, payment_hash) in channel.inflight_htlc_sources() {
84488459 let mut found_htlc = false;
@@ -8494,6 +8505,8 @@ where
84948505 channel_id: channel.context.channel_id(),
84958506 user_channel_id: channel.context.get_user_id(),
84968507 reason: ClosureReason::DisconnectedPeer,
8508+ counterparty_node_id: Some(channel.context.get_counterparty_node_id()),
8509+ channel_capacity_sats: Some(channel.context.get_value_satoshis()),
84978510 }, None));
84988511 } else {
84998512 log_error!(args.logger, "Missing ChannelMonitor for channel {} needed by ChannelManager.", log_bytes!(channel.context.channel_id()));
@@ -9710,7 +9723,7 @@ mod tests {
97109723 nodes[0].node.force_close_broadcasting_latest_txn(&chan.2, &nodes[1].node.get_our_node_id()).unwrap();
97119724 check_closed_broadcast!(nodes[0], true);
97129725 check_added_monitors!(nodes[0], 1);
9713- check_closed_event!(nodes[0], 1, ClosureReason::HolderForceClosed);
9726+ check_closed_event!(nodes[0], 1, ClosureReason::HolderForceClosed, [nodes[1].node.get_our_node_id()], 100000 );
97149727
97159728 {
97169729 // Assert that nodes[1] is awaiting removal for nodes[0] once nodes[1] has been
@@ -9873,8 +9886,8 @@ mod tests {
98739886 }
98749887 let (_nodes_1_update, _none) = get_closing_signed_broadcast!(nodes[1].node, nodes[0].node.get_our_node_id());
98759888
9876- check_closed_event!(nodes[0], 1, ClosureReason::CooperativeClosure);
9877- check_closed_event!(nodes[1], 1, ClosureReason::CooperativeClosure);
9889+ check_closed_event!(nodes[0], 1, ClosureReason::CooperativeClosure, [nodes[1].node.get_our_node_id()], 1000000 );
9890+ check_closed_event!(nodes[1], 1, ClosureReason::CooperativeClosure, [nodes[0].node.get_our_node_id()], 1000000 );
98789891 }
98799892
98809893 fn check_not_connected_to_peer_error<T>(res_err: Result<T, APIError>, expected_public_key: PublicKey) {
@@ -10267,7 +10280,7 @@ mod tests {
1026710280 let open_channel_msg = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id());
1026810281 assert!(!open_channel_msg.channel_type.unwrap().supports_anchors_zero_fee_htlc_tx());
1026910282
10270- check_closed_event!(nodes[1], 1, ClosureReason::HolderForceClosed);
10283+ check_closed_event!(nodes[1], 1, ClosureReason::HolderForceClosed, [nodes[0].node.get_our_node_id()], 100000 );
1027110284 }
1027210285
1027310286 #[test]
0 commit comments