@@ -4771,11 +4771,14 @@ macro_rules! handle_chan_reestablish_msgs {
4771
4771
None
4772
4772
} ;
4773
4773
4774
- if let Some ( & MessageSendEvent :: SendAnnouncementSignatures { ref node_id, msg: _ } ) =
4774
+ let mut announcement_sigs = None ; // May be now or later
4775
+ if let Some ( & MessageSendEvent :: SendAnnouncementSignatures { ref node_id, ref msg } ) =
4775
4776
msg_events. get( idx)
4776
4777
{
4777
4778
idx += 1 ;
4778
4779
assert_eq!( * node_id, $dst_node. node. get_our_node_id( ) ) ;
4780
+ assert!( announcement_sigs. is_none( ) ) ;
4781
+ announcement_sigs = Some ( msg. clone( ) ) ;
4779
4782
}
4780
4783
4781
4784
let mut had_channel_update = false ; // ChannelUpdate may be now or later, but not both
@@ -4841,16 +4844,26 @@ macro_rules! handle_chan_reestablish_msgs {
4841
4844
assert!( !had_channel_update) ;
4842
4845
}
4843
4846
4844
- assert_eq!( msg_events. len( ) , idx) ;
4847
+ if let Some ( & MessageSendEvent :: SendAnnouncementSignatures { ref node_id, ref msg } ) =
4848
+ msg_events. get( idx)
4849
+ {
4850
+ idx += 1 ;
4851
+ assert_eq!( * node_id, $dst_node. node. get_our_node_id( ) ) ;
4852
+ assert!( announcement_sigs. is_none( ) ) ;
4853
+ announcement_sigs = Some ( msg. clone( ) ) ;
4854
+ }
4855
+
4856
+ assert_eq!( msg_events. len( ) , idx, "{msg_events:?}" ) ;
4845
4857
4846
- ( channel_ready, revoke_and_ack, commitment_update, order)
4858
+ ( channel_ready, revoke_and_ack, commitment_update, order, announcement_sigs )
4847
4859
} } ;
4848
4860
}
4849
4861
4850
4862
pub struct ReconnectArgs < ' a , ' b , ' c , ' d > {
4851
4863
pub node_a : & ' a Node < ' b , ' c , ' d > ,
4852
4864
pub node_b : & ' a Node < ' b , ' c , ' d > ,
4853
4865
pub send_channel_ready : ( bool , bool ) ,
4866
+ pub send_announcement_sigs : ( bool , bool ) ,
4854
4867
pub pending_responding_commitment_signed : ( bool , bool ) ,
4855
4868
/// Indicates that the pending responding commitment signed will be a dup for the recipient,
4856
4869
/// and no monitor update is expected
@@ -4869,6 +4882,7 @@ impl<'a, 'b, 'c, 'd> ReconnectArgs<'a, 'b, 'c, 'd> {
4869
4882
node_a,
4870
4883
node_b,
4871
4884
send_channel_ready : ( false , false ) ,
4885
+ send_announcement_sigs : ( false , false ) ,
4872
4886
pending_responding_commitment_signed : ( false , false ) ,
4873
4887
pending_responding_commitment_signed_dup_monitor : ( false , false ) ,
4874
4888
pending_htlc_adds : ( 0 , 0 ) ,
@@ -4888,6 +4902,7 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
4888
4902
node_a,
4889
4903
node_b,
4890
4904
send_channel_ready,
4905
+ send_announcement_sigs,
4891
4906
pending_htlc_adds,
4892
4907
pending_htlc_claims,
4893
4908
pending_htlc_fails,
@@ -4969,7 +4984,7 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
4969
4984
&& pending_cell_htlc_fails. 1 == 0 )
4970
4985
) ;
4971
4986
4972
- for chan_msgs in resp_1. drain ( ..) {
4987
+ for mut chan_msgs in resp_1. drain ( ..) {
4973
4988
if send_channel_ready. 0 {
4974
4989
node_a. node . handle_channel_ready ( node_b_id, & chan_msgs. 0 . unwrap ( ) ) ;
4975
4990
let announcement_event = node_a. node . get_and_clear_pending_msg_events ( ) ;
@@ -4984,6 +4999,18 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
4984
4999
} else {
4985
5000
assert ! ( chan_msgs. 0 . is_none( ) ) ;
4986
5001
}
5002
+ if send_announcement_sigs. 0 {
5003
+ let announcement_sigs = chan_msgs. 4 . take ( ) . unwrap ( ) ;
5004
+ node_a. node . handle_announcement_signatures ( node_b_id, & announcement_sigs) ;
5005
+ let msg_events = node_a. node . get_and_clear_pending_msg_events ( ) ;
5006
+ assert_eq ! ( msg_events. len( ) , 1 , "{msg_events:?}" ) ;
5007
+ if let MessageSendEvent :: BroadcastChannelAnnouncement { .. } = msg_events[ 0 ] {
5008
+ } else {
5009
+ panic ! ( "Unexpected event! {:?}" , msg_events[ 0 ] ) ;
5010
+ }
5011
+ } else {
5012
+ assert ! ( chan_msgs. 4 . is_none( ) ) ;
5013
+ }
4987
5014
if pending_raa. 0 {
4988
5015
assert ! ( chan_msgs. 3 == RAACommitmentOrder :: RevokeAndACKFirst ) ;
4989
5016
node_a. node . handle_revoke_and_ack ( node_b_id, & chan_msgs. 1 . unwrap ( ) ) ;
@@ -5048,7 +5075,7 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
5048
5075
}
5049
5076
}
5050
5077
5051
- for chan_msgs in resp_2. drain ( ..) {
5078
+ for mut chan_msgs in resp_2. drain ( ..) {
5052
5079
if send_channel_ready. 1 {
5053
5080
node_b. node . handle_channel_ready ( node_a_id, & chan_msgs. 0 . unwrap ( ) ) ;
5054
5081
let announcement_event = node_b. node . get_and_clear_pending_msg_events ( ) ;
@@ -5063,6 +5090,18 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
5063
5090
} else {
5064
5091
assert ! ( chan_msgs. 0 . is_none( ) ) ;
5065
5092
}
5093
+ if send_announcement_sigs. 1 {
5094
+ let announcement_sigs = chan_msgs. 4 . take ( ) . unwrap ( ) ;
5095
+ node_b. node . handle_announcement_signatures ( node_a_id, & announcement_sigs) ;
5096
+ let mut msg_events = node_b. node . get_and_clear_pending_msg_events ( ) ;
5097
+ assert_eq ! ( msg_events. len( ) , 1 , "{msg_events:?}" ) ;
5098
+ if let MessageSendEvent :: BroadcastChannelAnnouncement { .. } = msg_events. remove ( 0 ) {
5099
+ } else {
5100
+ panic ! ( ) ;
5101
+ }
5102
+ } else {
5103
+ assert ! ( chan_msgs. 4 . is_none( ) ) ;
5104
+ }
5066
5105
if pending_raa. 1 {
5067
5106
assert ! ( chan_msgs. 3 == RAACommitmentOrder :: RevokeAndACKFirst ) ;
5068
5107
node_b. node . handle_revoke_and_ack ( node_a_id, & chan_msgs. 1 . unwrap ( ) ) ;
0 commit comments