@@ -397,6 +397,7 @@ struct MsgHandleErrInternal {
397
397
err: msgs::LightningError,
398
398
chan_id: Option<([u8; 32], u128)>, // If Some a channel of ours has been closed
399
399
shutdown_finish: Option<(ShutdownResult, Option<msgs::ChannelUpdate>)>,
400
+ channel_capacity: Option<u64>,
400
401
}
401
402
impl MsgHandleErrInternal {
402
403
#[inline]
@@ -413,14 +414,15 @@ impl MsgHandleErrInternal {
413
414
},
414
415
chan_id: None,
415
416
shutdown_finish: None,
417
+ channel_capacity: None,
416
418
}
417
419
}
418
420
#[inline]
419
421
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 }
421
423
}
422
424
#[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 {
424
426
Self {
425
427
err: LightningError {
426
428
err: err.clone(),
@@ -433,6 +435,7 @@ impl MsgHandleErrInternal {
433
435
},
434
436
chan_id: Some((channel_id, user_channel_id)),
435
437
shutdown_finish: Some((shutdown_res, channel_update)),
438
+ channel_capacity: Some(channel_capacity)
436
439
}
437
440
}
438
441
#[inline]
@@ -465,6 +468,7 @@ impl MsgHandleErrInternal {
465
468
},
466
469
chan_id: None,
467
470
shutdown_finish: None,
471
+ channel_capacity: None,
468
472
}
469
473
}
470
474
}
@@ -1680,7 +1684,7 @@ macro_rules! handle_error {
1680
1684
1681
1685
match $internal {
1682
1686
Ok(msg) => Ok(msg),
1683
- Err(MsgHandleErrInternal { err, chan_id, shutdown_finish }) => {
1687
+ Err(MsgHandleErrInternal { err, chan_id, shutdown_finish, channel_capacity }) => {
1684
1688
let mut msg_events = Vec::with_capacity(2);
1685
1689
1686
1690
if let Some((shutdown_res, update_option)) = shutdown_finish {
@@ -1693,7 +1697,9 @@ macro_rules! handle_error {
1693
1697
if let Some((channel_id, user_channel_id)) = chan_id {
1694
1698
$self.pending_events.lock().unwrap().push_back((events::Event::ChannelClosed {
1695
1699
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,
1697
1703
}, None));
1698
1704
}
1699
1705
}
@@ -1766,7 +1772,7 @@ macro_rules! convert_chan_err {
1766
1772
update_maps_on_chan_removal!($self, &$channel.context);
1767
1773
let shutdown_res = $channel.context.force_shutdown(true);
1768
1774
(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() ))
1770
1776
},
1771
1777
}
1772
1778
};
@@ -1779,7 +1785,7 @@ macro_rules! convert_chan_err {
1779
1785
update_maps_on_chan_removal!($self, &$channel_context);
1780
1786
let shutdown_res = $channel_context.force_shutdown(false);
1781
1787
(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() ))
1783
1789
},
1784
1790
}
1785
1791
}
@@ -1958,7 +1964,7 @@ macro_rules! handle_new_monitor_update {
1958
1964
let res = Err(MsgHandleErrInternal::from_finish_shutdown(
1959
1965
"ChannelMonitor storage failure".to_owned(), $chan.context.channel_id(),
1960
1966
$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() ));
1962
1968
$remove;
1963
1969
res
1964
1970
},
@@ -2392,7 +2398,9 @@ where
2392
2398
pending_events_lock.push_back((events::Event::ChannelClosed {
2393
2399
channel_id: context.channel_id(),
2394
2400
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()),
2396
2404
}, None));
2397
2405
}
2398
2406
@@ -3408,7 +3416,8 @@ where
3408
3416
let channel_id = chan.context.channel_id();
3409
3417
let user_id = chan.context.get_user_id();
3410
3418
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))
3412
3421
} else { unreachable!(); });
3413
3422
match funding_res {
3414
3423
Ok((chan, funding_msg)) => (chan, funding_msg),
@@ -5492,7 +5501,7 @@ where
5492
5501
let user_id = inbound_chan.context.get_user_id();
5493
5502
let shutdown_res = inbound_chan.context.force_shutdown(false);
5494
5503
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() ));
5496
5505
},
5497
5506
}
5498
5507
},
@@ -8442,7 +8451,9 @@ where
8442
8451
channel_closures.push_back((events::Event::ChannelClosed {
8443
8452
channel_id: channel.context.channel_id(),
8444
8453
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()),
8446
8457
}, None));
8447
8458
for (channel_htlc_source, payment_hash) in channel.inflight_htlc_sources() {
8448
8459
let mut found_htlc = false;
@@ -8494,6 +8505,8 @@ where
8494
8505
channel_id: channel.context.channel_id(),
8495
8506
user_channel_id: channel.context.get_user_id(),
8496
8507
reason: ClosureReason::DisconnectedPeer,
8508
+ counterparty_node_id: Some(channel.context.get_counterparty_node_id()),
8509
+ channel_capacity_sats: Some(channel.context.get_value_satoshis()),
8497
8510
}, None));
8498
8511
} else {
8499
8512
log_error!(args.logger, "Missing ChannelMonitor for channel {} needed by ChannelManager.", log_bytes!(channel.context.channel_id()));
@@ -9710,7 +9723,7 @@ mod tests {
9710
9723
nodes[0].node.force_close_broadcasting_latest_txn(&chan.2, &nodes[1].node.get_our_node_id()).unwrap();
9711
9724
check_closed_broadcast!(nodes[0], true);
9712
9725
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 );
9714
9727
9715
9728
{
9716
9729
// Assert that nodes[1] is awaiting removal for nodes[0] once nodes[1] has been
@@ -9873,8 +9886,8 @@ mod tests {
9873
9886
}
9874
9887
let (_nodes_1_update, _none) = get_closing_signed_broadcast!(nodes[1].node, nodes[0].node.get_our_node_id());
9875
9888
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 );
9878
9891
}
9879
9892
9880
9893
fn check_not_connected_to_peer_error<T>(res_err: Result<T, APIError>, expected_public_key: PublicKey) {
@@ -10267,7 +10280,7 @@ mod tests {
10267
10280
let open_channel_msg = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id());
10268
10281
assert!(!open_channel_msg.channel_type.unwrap().supports_anchors_zero_fee_htlc_tx());
10269
10282
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 );
10271
10284
}
10272
10285
10273
10286
#[test]
0 commit comments