@@ -4796,11 +4796,14 @@ macro_rules! handle_chan_reestablish_msgs {
4796
4796
None
4797
4797
} ;
4798
4798
4799
- if let Some ( & MessageSendEvent :: SendAnnouncementSignatures { ref node_id, msg: _ } ) =
4799
+ let mut announcement_sigs = None ; // May be now or later
4800
+ if let Some ( & MessageSendEvent :: SendAnnouncementSignatures { ref node_id, ref msg } ) =
4800
4801
msg_events. get( idx)
4801
4802
{
4802
4803
idx += 1 ;
4803
4804
assert_eq!( * node_id, $dst_node. node. get_our_node_id( ) ) ;
4805
+ assert!( announcement_sigs. is_none( ) ) ;
4806
+ announcement_sigs = Some ( msg. clone( ) ) ;
4804
4807
}
4805
4808
4806
4809
let mut had_channel_update = false ; // ChannelUpdate may be now or later, but not both
@@ -4859,23 +4862,33 @@ macro_rules! handle_chan_reestablish_msgs {
4859
4862
}
4860
4863
}
4861
4864
4865
+ if let Some ( & MessageSendEvent :: SendAnnouncementSignatures { ref node_id, ref msg } ) =
4866
+ msg_events. get( idx)
4867
+ {
4868
+ idx += 1 ;
4869
+ assert_eq!( * node_id, $dst_node. node. get_our_node_id( ) ) ;
4870
+ assert!( announcement_sigs. is_none( ) ) ;
4871
+ announcement_sigs = Some ( msg. clone( ) ) ;
4872
+ }
4873
+
4862
4874
if let Some ( & MessageSendEvent :: SendChannelUpdate { ref node_id, .. } ) = msg_events. get( idx)
4863
4875
{
4864
4876
assert_eq!( * node_id, $dst_node. node. get_our_node_id( ) ) ;
4865
4877
idx += 1 ;
4866
4878
assert!( !had_channel_update) ;
4867
4879
}
4868
4880
4869
- assert_eq!( msg_events. len( ) , idx) ;
4881
+ assert_eq!( msg_events. len( ) , idx, "{msg_events:?}" ) ;
4870
4882
4871
- ( channel_ready, revoke_and_ack, commitment_update, order)
4883
+ ( channel_ready, revoke_and_ack, commitment_update, order, announcement_sigs )
4872
4884
} } ;
4873
4885
}
4874
4886
4875
4887
pub struct ReconnectArgs < ' a , ' b , ' c , ' d > {
4876
4888
pub node_a : & ' a Node < ' b , ' c , ' d > ,
4877
4889
pub node_b : & ' a Node < ' b , ' c , ' d > ,
4878
4890
pub send_channel_ready : ( bool , bool ) ,
4891
+ pub send_announcement_sigs : ( bool , bool ) ,
4879
4892
pub pending_responding_commitment_signed : ( bool , bool ) ,
4880
4893
/// Indicates that the pending responding commitment signed will be a dup for the recipient,
4881
4894
/// and no monitor update is expected
@@ -4894,6 +4907,7 @@ impl<'a, 'b, 'c, 'd> ReconnectArgs<'a, 'b, 'c, 'd> {
4894
4907
node_a,
4895
4908
node_b,
4896
4909
send_channel_ready : ( false , false ) ,
4910
+ send_announcement_sigs : ( false , false ) ,
4897
4911
pending_responding_commitment_signed : ( false , false ) ,
4898
4912
pending_responding_commitment_signed_dup_monitor : ( false , false ) ,
4899
4913
pending_htlc_adds : ( 0 , 0 ) ,
@@ -4913,6 +4927,7 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
4913
4927
node_a,
4914
4928
node_b,
4915
4929
send_channel_ready,
4930
+ send_announcement_sigs,
4916
4931
pending_htlc_adds,
4917
4932
pending_htlc_claims,
4918
4933
pending_htlc_fails,
@@ -4994,7 +5009,7 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
4994
5009
&& pending_cell_htlc_fails. 1 == 0 )
4995
5010
) ;
4996
5011
4997
- for chan_msgs in resp_1. drain ( ..) {
5012
+ for mut chan_msgs in resp_1. drain ( ..) {
4998
5013
if send_channel_ready. 0 {
4999
5014
node_a. node . handle_channel_ready ( node_b_id, & chan_msgs. 0 . unwrap ( ) ) ;
5000
5015
let announcement_event = node_a. node . get_and_clear_pending_msg_events ( ) ;
@@ -5009,6 +5024,18 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
5009
5024
} else {
5010
5025
assert ! ( chan_msgs. 0 . is_none( ) ) ;
5011
5026
}
5027
+ if send_announcement_sigs. 0 {
5028
+ let announcement_sigs = chan_msgs. 4 . take ( ) . unwrap ( ) ;
5029
+ node_a. node . handle_announcement_signatures ( node_b_id, & announcement_sigs) ;
5030
+ let msg_events = node_a. node . get_and_clear_pending_msg_events ( ) ;
5031
+ assert_eq ! ( msg_events. len( ) , 1 , "{msg_events:?}" ) ;
5032
+ if let MessageSendEvent :: BroadcastChannelAnnouncement { .. } = msg_events[ 0 ] {
5033
+ } else {
5034
+ panic ! ( "Unexpected event! {:?}" , msg_events[ 0 ] ) ;
5035
+ }
5036
+ } else {
5037
+ assert ! ( chan_msgs. 4 . is_none( ) ) ;
5038
+ }
5012
5039
if pending_raa. 0 {
5013
5040
assert ! ( chan_msgs. 3 == RAACommitmentOrder :: RevokeAndACKFirst ) ;
5014
5041
node_a. node . handle_revoke_and_ack ( node_b_id, & chan_msgs. 1 . unwrap ( ) ) ;
@@ -5073,7 +5100,7 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
5073
5100
}
5074
5101
}
5075
5102
5076
- for chan_msgs in resp_2. drain ( ..) {
5103
+ for mut chan_msgs in resp_2. drain ( ..) {
5077
5104
if send_channel_ready. 1 {
5078
5105
node_b. node . handle_channel_ready ( node_a_id, & chan_msgs. 0 . unwrap ( ) ) ;
5079
5106
let announcement_event = node_b. node . get_and_clear_pending_msg_events ( ) ;
@@ -5088,6 +5115,18 @@ pub fn reconnect_nodes<'a, 'b, 'c, 'd>(args: ReconnectArgs<'a, 'b, 'c, 'd>) {
5088
5115
} else {
5089
5116
assert ! ( chan_msgs. 0 . is_none( ) ) ;
5090
5117
}
5118
+ if send_announcement_sigs. 1 {
5119
+ let announcement_sigs = chan_msgs. 4 . take ( ) . unwrap ( ) ;
5120
+ node_b. node . handle_announcement_signatures ( node_a_id, & announcement_sigs) ;
5121
+ let mut msg_events = node_b. node . get_and_clear_pending_msg_events ( ) ;
5122
+ assert_eq ! ( msg_events. len( ) , 1 , "{msg_events:?}" ) ;
5123
+ if let MessageSendEvent :: BroadcastChannelAnnouncement { .. } = msg_events. remove ( 0 ) {
5124
+ } else {
5125
+ panic ! ( ) ;
5126
+ }
5127
+ } else {
5128
+ assert ! ( chan_msgs. 4 . is_none( ) ) ;
5129
+ }
5091
5130
if pending_raa. 1 {
5092
5131
assert ! ( chan_msgs. 3 == RAACommitmentOrder :: RevokeAndACKFirst ) ;
5093
5132
node_b. node . handle_revoke_and_ack ( node_a_id, & chan_msgs. 1 . unwrap ( ) ) ;
0 commit comments