@@ -376,6 +376,7 @@ struct MsgHandleErrInternal {
376
376
err : msgs:: LightningError ,
377
377
chan_id : Option < ( [ u8 ; 32 ] , u128 ) > , // If Some a channel of ours has been closed
378
378
shutdown_finish : Option < ( ShutdownResult , Option < msgs:: ChannelUpdate > ) > ,
379
+ channel_capacity : Option < u64 > ,
379
380
}
380
381
impl MsgHandleErrInternal {
381
382
#[ inline]
@@ -392,14 +393,15 @@ impl MsgHandleErrInternal {
392
393
} ,
393
394
chan_id : None ,
394
395
shutdown_finish : None ,
396
+ channel_capacity : None ,
395
397
}
396
398
}
397
399
#[ inline]
398
400
fn from_no_close ( err : msgs:: LightningError ) -> Self {
399
- Self { err, chan_id : None , shutdown_finish : None }
401
+ Self { err, chan_id : None , shutdown_finish : None , channel_capacity : None }
400
402
}
401
403
#[ inline]
402
- fn from_finish_shutdown ( err : String , channel_id : [ u8 ; 32 ] , user_channel_id : u128 , shutdown_res : ShutdownResult , channel_update : Option < msgs:: ChannelUpdate > ) -> Self {
404
+ 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 {
403
405
Self {
404
406
err : LightningError {
405
407
err : err. clone ( ) ,
@@ -412,6 +414,7 @@ impl MsgHandleErrInternal {
412
414
} ,
413
415
chan_id : Some ( ( channel_id, user_channel_id) ) ,
414
416
shutdown_finish : Some ( ( shutdown_res, channel_update) ) ,
417
+ channel_capacity : Some ( channel_capacity)
415
418
}
416
419
}
417
420
#[ inline]
@@ -444,6 +447,7 @@ impl MsgHandleErrInternal {
444
447
} ,
445
448
chan_id : None ,
446
449
shutdown_finish : None ,
450
+ channel_capacity : None ,
447
451
}
448
452
}
449
453
}
@@ -1659,7 +1663,7 @@ macro_rules! handle_error {
1659
1663
1660
1664
match $internal {
1661
1665
Ok ( msg) => Ok ( msg) ,
1662
- Err ( MsgHandleErrInternal { err, chan_id, shutdown_finish } ) => {
1666
+ Err ( MsgHandleErrInternal { err, chan_id, shutdown_finish, channel_capacity } ) => {
1663
1667
let mut msg_events = Vec :: with_capacity( 2 ) ;
1664
1668
1665
1669
if let Some ( ( shutdown_res, update_option) ) = shutdown_finish {
@@ -1672,7 +1676,9 @@ macro_rules! handle_error {
1672
1676
if let Some ( ( channel_id, user_channel_id) ) = chan_id {
1673
1677
$self. pending_events. lock( ) . unwrap( ) . push_back( ( events:: Event :: ChannelClosed {
1674
1678
channel_id, user_channel_id,
1675
- reason: ClosureReason :: ProcessingError { err: err. err. clone( ) }
1679
+ reason: ClosureReason :: ProcessingError { err: err. err. clone( ) } ,
1680
+ counterparty_node_id: Some ( $counterparty_node_id) ,
1681
+ channel_capacity_sats: channel_capacity,
1676
1682
} , None ) ) ;
1677
1683
}
1678
1684
}
@@ -1745,7 +1751,7 @@ macro_rules! convert_chan_err {
1745
1751
update_maps_on_chan_removal!( $self, & $channel. context) ;
1746
1752
let shutdown_res = $channel. context. force_shutdown( true ) ;
1747
1753
( true , MsgHandleErrInternal :: from_finish_shutdown( msg, * $channel_id, $channel. context. get_user_id( ) ,
1748
- shutdown_res, $self. get_channel_update_for_broadcast( & $channel) . ok( ) ) )
1754
+ shutdown_res, $self. get_channel_update_for_broadcast( & $channel) . ok( ) , $channel . context . get_value_satoshis ( ) ) )
1749
1755
} ,
1750
1756
}
1751
1757
} ;
@@ -1758,7 +1764,7 @@ macro_rules! convert_chan_err {
1758
1764
update_maps_on_chan_removal!( $self, & $channel_context) ;
1759
1765
let shutdown_res = $channel_context. force_shutdown( false ) ;
1760
1766
( true , MsgHandleErrInternal :: from_finish_shutdown( msg, * $channel_id, $channel_context. get_user_id( ) ,
1761
- shutdown_res, None ) )
1767
+ shutdown_res, None , $channel_context . get_value_satoshis ( ) ) )
1762
1768
} ,
1763
1769
}
1764
1770
}
@@ -1937,7 +1943,7 @@ macro_rules! handle_new_monitor_update {
1937
1943
let res = Err ( MsgHandleErrInternal :: from_finish_shutdown(
1938
1944
"ChannelMonitor storage failure" . to_owned( ) , $chan. context. channel_id( ) ,
1939
1945
$chan. context. get_user_id( ) , $chan. context. force_shutdown( false ) ,
1940
- $self. get_channel_update_for_broadcast( & $chan) . ok( ) ) ) ;
1946
+ $self. get_channel_update_for_broadcast( & $chan) . ok( ) , $chan . context . get_value_satoshis ( ) ) ) ;
1941
1947
$remove;
1942
1948
res
1943
1949
} ,
@@ -2371,7 +2377,9 @@ where
2371
2377
pending_events_lock. push_back ( ( events:: Event :: ChannelClosed {
2372
2378
channel_id : context. channel_id ( ) ,
2373
2379
user_channel_id : context. get_user_id ( ) ,
2374
- reason : closure_reason
2380
+ reason : closure_reason,
2381
+ counterparty_node_id : Some ( context. get_counterparty_node_id ( ) ) ,
2382
+ channel_capacity_sats : Some ( context. get_value_satoshis ( ) ) ,
2375
2383
} , None ) ) ;
2376
2384
}
2377
2385
@@ -3371,7 +3379,8 @@ where
3371
3379
let channel_id = chan. context . channel_id ( ) ;
3372
3380
let user_id = chan. context . get_user_id ( ) ;
3373
3381
let shutdown_res = chan. context . force_shutdown ( false ) ;
3374
- ( chan, MsgHandleErrInternal :: from_finish_shutdown ( msg, channel_id, user_id, shutdown_res, None ) )
3382
+ let channel_capacity = chan. context . get_value_satoshis ( ) ;
3383
+ ( chan, MsgHandleErrInternal :: from_finish_shutdown ( msg, channel_id, user_id, shutdown_res, None , channel_capacity) )
3375
3384
} else { unreachable ! ( ) ; } ) ;
3376
3385
match funding_res {
3377
3386
Ok ( ( chan, funding_msg) ) => ( chan, funding_msg) ,
@@ -5408,7 +5417,7 @@ where
5408
5417
let user_id = inbound_chan. context . get_user_id ( ) ;
5409
5418
let shutdown_res = inbound_chan. context . force_shutdown ( false ) ;
5410
5419
return Err ( MsgHandleErrInternal :: from_finish_shutdown ( format ! ( "{}" , err) ,
5411
- msg. temporary_channel_id , user_id, shutdown_res, None ) ) ;
5420
+ msg. temporary_channel_id , user_id, shutdown_res, None , inbound_chan . context . get_value_satoshis ( ) ) ) ;
5412
5421
} ,
5413
5422
}
5414
5423
} ,
@@ -8356,7 +8365,9 @@ where
8356
8365
channel_closures. push_back ( ( events:: Event :: ChannelClosed {
8357
8366
channel_id : channel. context . channel_id ( ) ,
8358
8367
user_channel_id : channel. context . get_user_id ( ) ,
8359
- reason : ClosureReason :: OutdatedChannelManager
8368
+ reason : ClosureReason :: OutdatedChannelManager ,
8369
+ counterparty_node_id : Some ( channel. context . get_counterparty_node_id ( ) ) ,
8370
+ channel_capacity_sats : Some ( channel. context . get_value_satoshis ( ) ) ,
8360
8371
} , None ) ) ;
8361
8372
for ( channel_htlc_source, payment_hash) in channel. inflight_htlc_sources ( ) {
8362
8373
let mut found_htlc = false ;
@@ -8408,6 +8419,8 @@ where
8408
8419
channel_id : channel. context . channel_id ( ) ,
8409
8420
user_channel_id : channel. context . get_user_id ( ) ,
8410
8421
reason : ClosureReason :: DisconnectedPeer ,
8422
+ counterparty_node_id : Some ( channel. context . get_counterparty_node_id ( ) ) ,
8423
+ channel_capacity_sats : Some ( channel. context . get_value_satoshis ( ) ) ,
8411
8424
} , None ) ) ;
8412
8425
} else {
8413
8426
log_error ! ( args. logger, "Missing ChannelMonitor for channel {} needed by ChannelManager." , log_bytes!( channel. context. channel_id( ) ) ) ;
0 commit comments