@@ -242,7 +242,7 @@ type ShutdownResult = (Option<(OutPoint, ChannelMonitorUpdate)>, Vec<(HTLCSource
242
242
243
243
struct MsgHandleErrInternal {
244
244
err : msgs:: LightningError ,
245
- chan_id : Option < [ u8 ; 32 ] > , // If Some a channel of ours has been closed
245
+ chan_id : Option < ( [ u8 ; 32 ] , u64 ) > , // If Some a channel of ours has been closed
246
246
shutdown_finish : Option < ( ShutdownResult , Option < msgs:: ChannelUpdate > ) > ,
247
247
}
248
248
impl MsgHandleErrInternal {
@@ -278,7 +278,7 @@ impl MsgHandleErrInternal {
278
278
Self { err, chan_id : None , shutdown_finish : None }
279
279
}
280
280
#[ inline]
281
- fn from_finish_shutdown ( err : String , channel_id : [ u8 ; 32 ] , shutdown_res : ShutdownResult , channel_update : Option < msgs:: ChannelUpdate > ) -> Self {
281
+ fn from_finish_shutdown ( err : String , channel_id : [ u8 ; 32 ] , user_channel_id : u64 , shutdown_res : ShutdownResult , channel_update : Option < msgs:: ChannelUpdate > ) -> Self {
282
282
Self {
283
283
err : LightningError {
284
284
err : err. clone ( ) ,
@@ -289,7 +289,7 @@ impl MsgHandleErrInternal {
289
289
} ,
290
290
} ,
291
291
} ,
292
- chan_id : Some ( channel_id) ,
292
+ chan_id : Some ( ( channel_id, user_channel_id ) ) ,
293
293
shutdown_finish : Some ( ( shutdown_res, channel_update) ) ,
294
294
}
295
295
}
@@ -894,8 +894,11 @@ macro_rules! handle_error {
894
894
msg: update
895
895
} ) ;
896
896
}
897
- if let Some ( channel_id) = chan_id {
898
- $self. pending_events. lock( ) . unwrap( ) . push( events:: Event :: ChannelClosed { channel_id, reason: ClosureReason :: ProcessingError { err: err. err. clone( ) } } ) ;
897
+ if let Some ( ( channel_id, user_channel_id) ) = chan_id {
898
+ $self. pending_events. lock( ) . unwrap( ) . push( events:: Event :: ChannelClosed {
899
+ channel_id, user_channel_id,
900
+ reason: ClosureReason :: ProcessingError { err: err. err. clone( ) }
901
+ } ) ;
899
902
}
900
903
}
901
904
@@ -937,15 +940,17 @@ macro_rules! convert_chan_err {
937
940
$short_to_id. remove( & short_id) ;
938
941
}
939
942
let shutdown_res = $channel. force_shutdown( true ) ;
940
- ( true , MsgHandleErrInternal :: from_finish_shutdown( msg, * $channel_id, shutdown_res, $self. get_channel_update_for_broadcast( & $channel) . ok( ) ) )
943
+ ( true , MsgHandleErrInternal :: from_finish_shutdown( msg, * $channel_id, $channel. get_user_id( ) ,
944
+ shutdown_res, $self. get_channel_update_for_broadcast( & $channel) . ok( ) ) )
941
945
} ,
942
946
ChannelError :: CloseDelayBroadcast ( msg) => {
943
947
log_error!( $self. logger, "Channel {} need to be shutdown but closing transactions not broadcast due to {}" , log_bytes!( $channel_id[ ..] ) , msg) ;
944
948
if let Some ( short_id) = $channel. get_short_channel_id( ) {
945
949
$short_to_id. remove( & short_id) ;
946
950
}
947
951
let shutdown_res = $channel. force_shutdown( false ) ;
948
- ( true , MsgHandleErrInternal :: from_finish_shutdown( msg, * $channel_id, shutdown_res, $self. get_channel_update_for_broadcast( & $channel) . ok( ) ) )
952
+ ( true , MsgHandleErrInternal :: from_finish_shutdown( msg, * $channel_id, $channel. get_user_id( ) ,
953
+ shutdown_res, $self. get_channel_update_for_broadcast( & $channel) . ok( ) ) )
949
954
}
950
955
}
951
956
}
@@ -1013,7 +1018,7 @@ macro_rules! handle_monitor_err {
1013
1018
// splitting hairs we'd prefer to claim payments that were to us, but we haven't
1014
1019
// given up the preimage yet, so might as well just wait until the payment is
1015
1020
// retried, avoiding the on-chain fees.
1016
- let res: Result <( ) , _> = Err ( MsgHandleErrInternal :: from_finish_shutdown( "ChannelMonitor storage failure" . to_owned( ) , * $chan_id,
1021
+ let res: Result <( ) , _> = Err ( MsgHandleErrInternal :: from_finish_shutdown( "ChannelMonitor storage failure" . to_owned( ) , * $chan_id, $chan . get_user_id ( ) ,
1017
1022
$chan. force_shutdown( true ) , $self. get_channel_update_for_broadcast( & $chan) . ok( ) ) ) ;
1018
1023
( res, true )
1019
1024
} ,
@@ -1402,7 +1407,11 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
1402
1407
} ,
1403
1408
None => { } ,
1404
1409
}
1405
- pending_events_lock. push ( events:: Event :: ChannelClosed { channel_id : channel. channel_id ( ) , reason : closure_reason } ) ;
1410
+ pending_events_lock. push ( events:: Event :: ChannelClosed {
1411
+ channel_id : channel. channel_id ( ) ,
1412
+ user_channel_id : channel. get_user_id ( ) ,
1413
+ reason : closure_reason
1414
+ } ) ;
1406
1415
}
1407
1416
1408
1417
fn close_channel_internal ( & self , channel_id : & [ u8 ; 32 ] , target_feerate_sats_per_1000_weight : Option < u32 > ) -> Result < ( ) , APIError > {
@@ -2237,7 +2246,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
2237
2246
2238
2247
( chan. get_outbound_funding_created ( funding_transaction, funding_txo, & self . logger )
2239
2248
. map_err ( |e| if let ChannelError :: Close ( msg) = e {
2240
- MsgHandleErrInternal :: from_finish_shutdown ( msg, chan. channel_id ( ) , chan. force_shutdown ( true ) , None )
2249
+ MsgHandleErrInternal :: from_finish_shutdown ( msg, chan. channel_id ( ) , chan. get_user_id ( ) , chan . force_shutdown ( true ) , None )
2241
2250
} else { unreachable ! ( ) ; } )
2242
2251
, chan)
2243
2252
} ,
@@ -2579,7 +2588,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
2579
2588
channel_state. short_to_id . remove ( & short_id) ;
2580
2589
}
2581
2590
// ChannelClosed event is generated by handle_error for us.
2582
- Err ( MsgHandleErrInternal :: from_finish_shutdown ( msg, channel_id, channel. force_shutdown ( true ) , self . get_channel_update_for_broadcast ( & channel) . ok ( ) ) )
2591
+ Err ( MsgHandleErrInternal :: from_finish_shutdown ( msg, channel_id, channel. get_user_id ( ) , channel . force_shutdown ( true ) , self . get_channel_update_for_broadcast ( & channel) . ok ( ) ) )
2583
2592
} ,
2584
2593
ChannelError :: CloseDelayBroadcast ( _) => { panic ! ( "Wait is only generated on receipt of channel_reestablish, which is handled by try_chan_entry, we don't bother to support it here" ) ; }
2585
2594
} ;
@@ -5618,6 +5627,7 @@ impl<'a, Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
5618
5627
monitor. broadcast_latest_holder_commitment_txn ( & args. tx_broadcaster , & args. logger ) ;
5619
5628
channel_closures. push ( events:: Event :: ChannelClosed {
5620
5629
channel_id : channel. channel_id ( ) ,
5630
+ user_channel_id : channel. get_user_id ( ) ,
5621
5631
reason : ClosureReason :: OutdatedChannelManager
5622
5632
} ) ;
5623
5633
} else {
0 commit comments