@@ -216,6 +216,38 @@ def test_v2_open_sigs_reconnect_1(node_factory, bitcoind):
216216 l2 .daemon .wait_for_log (r'to CHANNELD_NORMAL' )
217217
218218
219+ @unittest .skipIf (TEST_NETWORK != 'regtest' , 'elementsd doesnt yet support PSBT features we need' )
220+ @pytest .mark .xfail
221+ @pytest .mark .openchannel ('v2' )
222+ def test_v2_open_sigs_out_of_order (node_factory , bitcoind ):
223+ """ Test what happens if the tx-sigs get sent "before" commitment signed """
224+ disconnects = ['$WIRE_COMMITMENT_SIGNED' ]
225+
226+ l1 , l2 = node_factory .get_nodes (2 ,
227+ opts = [{},
228+ {'disconnect' : disconnects }])
229+
230+ l1 .rpc .connect (l2 .info ['id' ], 'localhost' , l2 .port )
231+ amount = 2 ** 24
232+ chan_amount = 100000
233+ bitcoind .rpc .sendtoaddress (l1 .rpc .newaddr ()['bech32' ], amount / 10 ** 8 + 0.01 )
234+ bitcoind .generate_block (1 )
235+ # Wait for it to arrive.
236+ wait_for (lambda : len (l1 .rpc .listfunds ()['outputs' ]) > 0 )
237+
238+ # Fund the channel, should error because L2 doesn't see our commitment-signed
239+ # so they think we've sent things out of order
240+ with pytest .raises (RpcError , match = 'tx_signatures sent before commitment sigs' ):
241+ l1 .rpc .fundchannel (l2 .info ['id' ], chan_amount )
242+
243+ # L1 should remove the in-progress channel
244+ wait_for (lambda : l1 .rpc .listpeerchannels ()['channels' ] == [])
245+ # L2 should fail it to chain
246+ l2 .daemon .wait_for_logs ([r'to AWAITING_UNILATERAL' ,
247+ # We can't broadcast this, we don't have sigs for funding
248+ 'sendrawtx exit 25' ])
249+
250+
219251@pytest .mark .openchannel ('v2' )
220252def test_v2_fail_second (node_factory , bitcoind ):
221253 """ Open a channel succeeds; opening a second channel
0 commit comments