@@ -242,7 +242,7 @@ type ShutdownResult = (Option<(OutPoint, ChannelMonitorUpdate)>, Vec<(HTLCSource
242242
243243struct MsgHandleErrInternal {
244244 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
246246 shutdown_finish : Option < ( ShutdownResult , Option < msgs:: ChannelUpdate > ) > ,
247247}
248248impl MsgHandleErrInternal {
@@ -278,7 +278,7 @@ impl MsgHandleErrInternal {
278278 Self { err, chan_id : None , shutdown_finish : None }
279279 }
280280 #[ 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 {
282282 Self {
283283 err : LightningError {
284284 err : err. clone ( ) ,
@@ -289,7 +289,7 @@ impl MsgHandleErrInternal {
289289 } ,
290290 } ,
291291 } ,
292- chan_id : Some ( channel_id) ,
292+ chan_id : Some ( ( channel_id, user_channel_id ) ) ,
293293 shutdown_finish : Some ( ( shutdown_res, channel_update) ) ,
294294 }
295295 }
@@ -894,8 +894,11 @@ macro_rules! handle_error {
894894 msg: update
895895 } ) ;
896896 }
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+ } ) ;
899902 }
900903 }
901904
@@ -937,15 +940,17 @@ macro_rules! convert_chan_err {
937940 $short_to_id. remove( & short_id) ;
938941 }
939942 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( ) ) )
941945 } ,
942946 ChannelError :: CloseDelayBroadcast ( msg) => {
943947 log_error!( $self. logger, "Channel {} need to be shutdown but closing transactions not broadcast due to {}" , log_bytes!( $channel_id[ ..] ) , msg) ;
944948 if let Some ( short_id) = $channel. get_short_channel_id( ) {
945949 $short_to_id. remove( & short_id) ;
946950 }
947951 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( ) ) )
949954 }
950955 }
951956 }
@@ -1013,7 +1018,7 @@ macro_rules! handle_monitor_err {
10131018 // splitting hairs we'd prefer to claim payments that were to us, but we haven't
10141019 // given up the preimage yet, so might as well just wait until the payment is
10151020 // 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 ( ) ,
10171022 $chan. force_shutdown( true ) , $self. get_channel_update_for_broadcast( & $chan) . ok( ) ) ) ;
10181023 ( res, true )
10191024 } ,
@@ -1402,7 +1407,11 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
14021407 } ,
14031408 None => { } ,
14041409 }
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+ } ) ;
14061415 }
14071416
14081417 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
22372246
22382247 ( chan. get_outbound_funding_created ( funding_transaction, funding_txo, & self . logger )
22392248 . 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 )
22412250 } else { unreachable ! ( ) ; } )
22422251 , chan)
22432252 } ,
@@ -2579,7 +2588,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
25792588 channel_state. short_to_id . remove ( & short_id) ;
25802589 }
25812590 // 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 ( ) ) )
25832592 } ,
25842593 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" ) ; }
25852594 } ;
@@ -5618,6 +5627,7 @@ impl<'a, Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref>
56185627 monitor. broadcast_latest_holder_commitment_txn ( & args. tx_broadcaster , & args. logger ) ;
56195628 channel_closures. push ( events:: Event :: ChannelClosed {
56205629 channel_id : channel. channel_id ( ) ,
5630+ user_channel_id : channel. get_user_id ( ) ,
56215631 reason : ClosureReason :: OutdatedChannelManager
56225632 } ) ;
56235633 } else {
0 commit comments