@@ -730,6 +730,9 @@ pub(super) struct Channel<Signer: ChannelSigner> {
730
730
// blinded paths instead of simple scid+node_id aliases.
731
731
outbound_scid_alias : u64 ,
732
732
733
+ // We track whether we already emitted a `ChannelPending` event.
734
+ channel_pending_event_emitted : bool ,
735
+
733
736
// We track whether we already emitted a `ChannelReady` event.
734
737
channel_ready_event_emitted : bool ,
735
738
@@ -1107,6 +1110,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
1107
1110
latest_inbound_scid_alias : None ,
1108
1111
outbound_scid_alias,
1109
1112
1113
+ channel_pending_event_emitted : false ,
1110
1114
channel_ready_event_emitted : false ,
1111
1115
1112
1116
#[ cfg( any( test, fuzzing) ) ]
@@ -1456,6 +1460,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
1456
1460
latest_inbound_scid_alias : None ,
1457
1461
outbound_scid_alias,
1458
1462
1463
+ channel_pending_event_emitted : false ,
1459
1464
channel_ready_event_emitted : false ,
1460
1465
1461
1466
#[ cfg( any( test, fuzzing) ) ]
@@ -4706,6 +4711,16 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
4706
4711
self . prev_config . map ( |prev_config| prev_config. 0 )
4707
4712
}
4708
4713
4714
+ // Checks whether we should emit a `ChannelPending` event.
4715
+ pub ( crate ) fn should_emit_channel_pending_event ( & mut self ) -> bool {
4716
+ self . is_funding_initiated ( ) && !self . channel_pending_event_emitted
4717
+ }
4718
+
4719
+ // Remembers that we already emitted a `ChannelPending` event.
4720
+ pub ( crate ) fn set_channel_pending_event_emitted ( & mut self ) {
4721
+ self . channel_pending_event_emitted = true ;
4722
+ }
4723
+
4709
4724
// Checks whether we should emit a `ChannelReady` event.
4710
4725
pub ( crate ) fn should_emit_channel_ready_event ( & mut self ) -> bool {
4711
4726
self . is_usable ( ) && !self . channel_ready_event_emitted
@@ -6432,6 +6447,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Writeable for Channel<Signer> {
6432
6447
if self . holder_max_htlc_value_in_flight_msat != Self :: get_holder_max_htlc_value_in_flight_msat ( self . channel_value_satoshis , & old_max_in_flight_percent_config)
6433
6448
{ Some ( self . holder_max_htlc_value_in_flight_msat ) } else { None } ;
6434
6449
6450
+ let channel_pending_event_emitted = Some ( self . channel_pending_event_emitted ) ;
6435
6451
let channel_ready_event_emitted = Some ( self . channel_ready_event_emitted ) ;
6436
6452
6437
6453
// `user_id` used to be a single u64 value. In order to remain backwards compatible with
@@ -6465,6 +6481,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Writeable for Channel<Signer> {
6465
6481
( 25 , user_id_high_opt, option) ,
6466
6482
( 27 , self . channel_keys_id, required) ,
6467
6483
( 29 , self . temporary_channel_id, option) ,
6484
+ ( 31 , channel_pending_event_emitted, option) ,
6468
6485
} ) ;
6469
6486
6470
6487
Ok ( ( ) )
@@ -6732,6 +6749,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
6732
6749
let mut announcement_sigs_state = Some ( AnnouncementSigsState :: NotSent ) ;
6733
6750
let mut latest_inbound_scid_alias = None ;
6734
6751
let mut outbound_scid_alias = None ;
6752
+ let mut channel_pending_event_emitted = None ;
6735
6753
let mut channel_ready_event_emitted = None ;
6736
6754
6737
6755
let mut user_id_high_opt: Option < u64 > = None ;
@@ -6758,6 +6776,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
6758
6776
( 25 , user_id_high_opt, option) ,
6759
6777
( 27 , channel_keys_id, option) ,
6760
6778
( 29 , temporary_channel_id, option) ,
6779
+ ( 31 , channel_pending_event_emitted, option) ,
6761
6780
} ) ;
6762
6781
6763
6782
let ( channel_keys_id, holder_signer) = if let Some ( channel_keys_id) = channel_keys_id {
@@ -6915,6 +6934,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
6915
6934
// Later in the ChannelManager deserialization phase we scan for channels and assign scid aliases if its missing
6916
6935
outbound_scid_alias : outbound_scid_alias. unwrap_or ( 0 ) ,
6917
6936
6937
+ channel_pending_event_emitted : channel_pending_event_emitted. unwrap_or ( true ) ,
6918
6938
channel_ready_event_emitted : channel_ready_event_emitted. unwrap_or ( true ) ,
6919
6939
6920
6940
#[ cfg( any( test, fuzzing) ) ]
0 commit comments