lightning/wallet
Rusty Russell 5e4c1b7839 lightningd: redo closing negotiation even if we consider channel closed.
This corner case started triggering on my machine with latest Bitcoind.

This test sabotages the closing negotiation, and as a result l1
doesn't see l2's CLOSING_SIGNED.  l2 is happy, however, and it is in
CLOSINGD_COMPLETE.  When l1 reconnects, it gets an error, and this causes
it to drop the unilateral tx to chain.

This unilateral tx from l1 replaces or races the mutual close tx from
l2, causing a unilateral close, which breaks our test.

Though this is a corner case, it's much friendlier to allow the
closing negotiation again until we actually see the close onchain.
This fixes the tests here, too.

```
    def test_closing_negotiation_reconnect(node_factory, bitcoind):
        disconnects = ['-WIRE_CLOSING_SIGNED',
                       '+WIRE_CLOSING_SIGNED']
        l1, l2 = node_factory.line_graph(2, opts=[{'disconnect': disconnects,
                                                   'may_reconnect': True},
                                                  {'may_reconnect': True}])
        l1.pay(l2, 200000000)
    
        assert bitcoind.rpc.getmempoolinfo()['size'] == 0
    
        l1.rpc.close(l2.info['id'])
        l1.daemon.wait_for_log(r'State changed from CHANNELD_NORMAL to CHANNELD_SHUTTING_DOWN')
        l2.daemon.wait_for_log(r'State changed from CHANNELD_NORMAL to CHANNELD_SHUTTING_DOWN')
    
        # Now verify that the closing tx is in the mempool.
        bitcoind.generate_block(6, wait_for_mempool=1)
        sync_blockheight(bitcoind, [l1, l2])
        for n in [l1, l2]:
            # Ensure we actually got a mutual close.
>           n.daemon.wait_for_log(r'Resolved FUNDING_TRANSACTION/FUNDING_OUTPUT by MUTUAL_CLOSE')

tests/test_closing.py:275: 
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: Protocol: We now renegotiate an interrupted close, even if we don't need it, instead of sending an error.
2025-02-26 10:22:03 -06:00
..
test lightningd: redo closing negotiation even if we consider channel closed. 2025-02-26 10:22:03 -06:00
.gitignore reorganize .gitignore entries across subdirs. 2021-05-18 09:43:50 +09:30
db.c lightningd: remember when we started closing channel. 2024-11-26 14:49:36 +10:30
db.h db: migrate old runes table to fix up id fields. 2023-08-31 05:33:15 +09:30
invoices.c lightningd: remove delexpiredinvoice 2024-03-25 15:02:35 +10:30
invoices.h lightningd: remove delexpiredinvoice 2024-03-25 15:02:35 +10:30
Makefile wallet/psbt_fixup: routine to fix invalid PBSTs which modern libwally won't load. 2023-03-31 09:16:25 +10:30
psbt_fixup.c wallet/psbt_fixup: routine to fix invalid PBSTs which modern libwally won't load. 2023-03-31 09:16:25 +10:30
psbt_fixup.h wallet/psbt_fixup: routine to fix invalid PBSTs which modern libwally won't load. 2023-03-31 09:16:25 +10:30
reservation.c wallet: save keytype when issuing new address. 2024-11-17 20:27:13 +10:30
txfilter.c wallet: create htable to store scriptpubkeys for issued indexes. 2025-02-13 15:42:51 -06:00
txfilter.h wallet: create htable to store scriptpubkeys for issued indexes. 2025-02-13 15:42:51 -06:00
wallet.c wallet: Add 'wallet_stub_shachain_init' to persist shachain 2025-02-22 11:51:54 -06:00
wallet.h wallet: create htable to store scriptpubkeys for issued indexes. 2025-02-13 15:42:51 -06:00
walletrpc.c wallet: re-add ADDR_P2SH_SEGWIT type to enum addrtype 2025-02-13 15:42:51 -06:00
walletrpc.h wallet: save keytype when issuing new address. 2024-11-17 20:27:13 +10:30