l2<->l3 force closes while an HTLC is in flight from l1, but l2 can't timeout because the feerate has spiked. It should do so anyway.
(node_factory, bitcoind, anchors)
| 4324 | |
| 4325 | @pytest.mark.parametrize("anchors", [False, True]) |
| 4326 | def test_htlc_no_force_close(node_factory, bitcoind, anchors): |
| 4327 | """l2<->l3 force closes while an HTLC is in flight from l1, but l2 can't timeout because the feerate has spiked. It should do so anyway.""" |
| 4328 | opts = [{}, {}, {'disconnect': ['-WIRE_UPDATE_FULFILL_HTLC']}] |
| 4329 | if anchors is False: |
| 4330 | for opt in opts: |
| 4331 | opt['dev-force-features'] = "-23" |
| 4332 | |
| 4333 | l1, l2, l3 = node_factory.line_graph(3, opts=opts, wait_for_announce=True) |
| 4334 | |
| 4335 | MSATS = 12300000 |
| 4336 | inv = l3.rpc.invoice(MSATS, 'label', 'description') |
| 4337 | |
| 4338 | route = [{'amount_msat': MSATS + 1 + MSATS * 10 // 1000000, |
| 4339 | 'id': l2.info['id'], |
| 4340 | 'delay': 16, |
| 4341 | 'channel': first_scid(l1, l2)}, |
| 4342 | {'amount_msat': MSATS, |
| 4343 | 'id': l3.info['id'], |
| 4344 | 'delay': 10, |
| 4345 | 'channel': first_scid(l2, l3)}] |
| 4346 | l1.rpc.sendpay(route, inv['payment_hash'], |
| 4347 | payment_secret=inv['payment_secret']) |
| 4348 | l3.daemon.wait_for_log('dev_disconnect') |
| 4349 | |
| 4350 | htlc_txs = [] |
| 4351 | |
| 4352 | # l3 drops to chain, holding htlc (but we stop it xmitting txs) |
| 4353 | def censoring_sendrawtx(r): |
| 4354 | htlc_txs.append(r['params'][0]) |
| 4355 | return {'id': r['id'], 'result': {}} |
| 4356 | |
| 4357 | l3.daemon.rpcproxy.mock_rpc('sendrawtransaction', censoring_sendrawtx) |
| 4358 | |
| 4359 | # l3 gets upset, drops to chain when there are < 4 blocks remaining. |
| 4360 | # But tx doesn't get mined... |
| 4361 | bitcoind.generate_block(8) |
| 4362 | l3.daemon.wait_for_log("Peer permanent failure in CHANNELD_NORMAL: Fulfilled HTLC 0 SENT_REMOVE_.* cltv 119 hit deadline") |
| 4363 | |
| 4364 | # l2 closes drops the commitment tx at block 115 (one block after timeout) |
| 4365 | bitcoind.generate_block(4) |
| 4366 | l2.daemon.wait_for_log("Peer permanent failure in CHANNELD_NORMAL: Offered HTLC 0 SENT_ADD_ACK_REVOCATION cltv 119 hit deadline") |
| 4367 | l1.set_feerates((15000, 15000, 15000, 15000)) |
| 4368 | |
| 4369 | # Two more blocks, with no htlc tx. |
| 4370 | bitcoind.generate_block(1, wait_for_mempool=1) |
| 4371 | # Make sure l2 sees it onchain! |
| 4372 | wait_for(lambda: only_one(l2.rpc.listpeerchannels(l3.info['id'])['channels'])['state'] == 'ONCHAIN') |
| 4373 | # Don't let l2's htlc timeout tx get mined either! |
| 4374 | bitcoind.generate_block(1, needfeerate=9999999) |
| 4375 | |
| 4376 | # l2 will have abandoned l2->l3 HTLC to close l1->l2. |
| 4377 | l2.daemon.wait_for_log(r'Abandoning unresolved onchain HTLC at block 122 \(expired at 119\) to avoid peer closing incoming HTLC at block 125') |
| 4378 | |
| 4379 | # l1 should not have force-closed, htlc should be finished by l2. |
| 4380 | assert not l1.daemon.is_in_log('Peer permanent failure in CHANNELD_NORMAL') |
| 4381 | wait_for(lambda: only_one(l1.rpc.listpeerchannels()['channels'])['htlcs'] == []) |
| 4382 | |
| 4383 | # Now, surprise! l3 fulfills htlc (l2 loses out!) |
nothing calls this directly
no test coverage detected