@@ -1009,3 +1009,38 @@ fn test_connect_before_funding() {
1009
1009
connect_blocks ( & nodes[ 0 ] , 1 ) ;
1010
1010
connect_blocks ( & nodes[ 1 ] , 1 ) ;
1011
1011
}
1012
+
1013
+ #[ test]
1014
+ fn test_0conf_ann_sigs_racing_conf ( ) {
1015
+ // Previously we had a bug where we'd panic when receiving a counterparty's
1016
+ // announcement_signatures message for a 0conf channel pending confirmation on-chain. Here we
1017
+ // check that we just error out, ignore the announcement_signatures message, and proceed
1018
+ // instead.
1019
+ let chanmon_cfgs = create_chanmon_cfgs ( 2 ) ;
1020
+ let node_cfgs = create_node_cfgs ( 2 , & chanmon_cfgs) ;
1021
+ let mut chan_config = test_default_channel_config ( ) ;
1022
+ chan_config. manually_accept_inbound_channels = true ;
1023
+
1024
+ let node_chanmgrs = create_node_chanmgrs ( 2 , & node_cfgs, & [ None , Some ( chan_config) ] ) ;
1025
+ let nodes = create_network ( 2 , & node_cfgs, & node_chanmgrs) ;
1026
+
1027
+ // This is the default but we force it on anyway
1028
+ chan_config. channel_handshake_config . announced_channel = true ;
1029
+ let ( tx, ..) = open_zero_conf_channel ( & nodes[ 0 ] , & nodes[ 1 ] , Some ( chan_config) ) ;
1030
+
1031
+ // We can use the channel immediately, but we can't announce it until we get 6+ confirmations
1032
+ send_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 100_000 ) ;
1033
+
1034
+ let scid = confirm_transaction ( & nodes[ 0 ] , & tx) ;
1035
+ let as_announcement_sigs = get_event_msg ! ( nodes[ 0 ] , MessageSendEvent :: SendAnnouncementSignatures , nodes[ 1 ] . node. get_our_node_id( ) ) ;
1036
+
1037
+ // Handling the announcement_signatures prior to the first confirmation would panic before.
1038
+ nodes[ 1 ] . node . handle_announcement_signatures ( & nodes[ 0 ] . node . get_our_node_id ( ) , & as_announcement_sigs) ;
1039
+
1040
+ assert_eq ! ( confirm_transaction( & nodes[ 1 ] , & tx) , scid) ;
1041
+ let bs_announcement_sigs = get_event_msg ! ( nodes[ 1 ] , MessageSendEvent :: SendAnnouncementSignatures , nodes[ 0 ] . node. get_our_node_id( ) ) ;
1042
+
1043
+ nodes[ 0 ] . node . handle_announcement_signatures ( & nodes[ 1 ] . node . get_our_node_id ( ) , & bs_announcement_sigs) ;
1044
+ let as_announcement = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
1045
+ assert_eq ! ( as_announcement. len( ) , 1 ) ;
1046
+ }
0 commit comments