Commit Graph

4781 Commits

Author SHA1 Message Date
Sangbida Chaudhuri
0269d0c0c9 jsonrpc: fix recover command for BIP86 wallets
The recover command checks if a node has already issued bitcoin
addresses before allowing recovery. This check only looked at
bip32_max_index, but with BIP86 wallets, newaddr() increments
bip86_max_index instead.

Also, the recover test asserted on hex but now it's asserting on codex32 instead. We should probably go in and fix the end point. @rustyrussell what do you think?
2026-01-14 17:18:56 +10:30
Sangbida Chaudhuri
c17590379e lightningd: use BIP86 derivation in p2wpkh_for_keyidx when available
When a peer doesn't support OPT_SHUTDOWN_ANYSEGWIT, we fall back to P2WPKH for the shutdown script. For BIP86 wallets, we need to use bip86_pubkey for derivation (matching p2tr_for_keyidx), otherwise the resulting script won't be recognized after restart.
2026-01-14 17:18:56 +10:30
Sangbida Chaudhuri
4106a212ec lightningd: add p2wpkh script for bip86 base
A bech32 address can be generated from a bip86 base so we should add both script types (p2wpkh, p2tr) to the txfilter for bip86 bases.
2026-01-14 17:18:56 +10:30
Sangbida Chaudhuri
4b1f2a079e lightningd: use BIP86 derivation for P2TR in HTLC rebroadcast change outputs 2026-01-14 17:18:56 +10:30
Sangbida Chaudhuri
fa96b60113 lightningd: use bip86 derivation for anchor spend change outputs 2026-01-14 17:18:56 +10:30
Sangbida Chaudhuri
bf43fbb7cc lightningd: Fix penalty tx output derivation for BIP86 wallets
When using the new BIP39 mnemonic HSM secret format, the wallet uses
BIP86 derivation for taproot addresses. However, onchaind_tx_unsigned() was always using bip32_pubkey() to derive the final key for penalty transaction outputs.
2026-01-14 17:18:56 +10:30
Rusty Russell
3be25d48d3 pytest: don't rely on sleep to ensure wait commands have been submitted.
Seems like sleep(1) isn't always enough.  Give in and put a log
message there, and use that:

```
	waitfut = executor.submit(l2.rpc.wait, subsystem='forwards', indexname='deleted', nextvalue=1)
        time.sleep(1)
    
        l2.rpc.delforward(scid12, 1, 'failed')
    
        waitres = waitfut.result(TIMEOUT)
>       assert waitres == {'subsystem': 'forwards',
                           'deleted': 1,
                           'forwards': {'in_channel': scid12,
                                        'in_htlc_id': 1,
                                        'status': 'failed'}}
E       AssertionError: assert {'subsystem': 'forwards', 'deleted': 1} == {'subsystem': 'forwards', 'deleted': 1, 'forwards': {'in_channel': '103x2x0', 'in_htlc_id': 1, 'status': 'failed'}}
E         
E         Common items:
E         {'deleted': 1, 'subsystem': 'forwards'}
E         Right contains 1 more item:
E         {'forwards': {'in_channel': '103x2x0', 'in_htlc_id': 1, 'status': 'failed'}}
E         
E         Full diff:
E           {
E               'deleted': 1,
E         -     'forwards': {
E         -         'in_channel': '103x2x0',
E         -         'in_htlc_id': 1,
E         -         'status': 'failed',
E         -     },
E               'subsystem': 'forwards',
E           }

tests/test_misc.py:3599: AssertionError
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-01-14 15:41:45 +10:30
Rusty Russell
fd64bb114b lightningd: fix bogus memleak report.
We do our own leak detection on a reply from a subd, but the reply
code set subd->conn to NULL (saving it temporarily, in case the subd
is freed), resulting in it being seen as a leak:

```
lightningd-2 2026-01-12T14:11:12.677Z DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-channeld-chan#1: billboard perm: Reconnected, and reestablished.
lightningd-2 2026-01-12T14:11:12.677Z DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-channeld-chan#1: billboard: Channel ready for use. Shutdown messages exchanged.
lightningd-1 2026-01-12T14:11:12.705Z DEBUG   022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-closingd-chan#1: pid 100718, msgfd 87
lightningd-1 2026-01-12T14:11:12.705Z DEBUG   022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-channeld-chan#1: Status closed, but not exited. Killing
...
lightningd-1 2026-01-12T14:11:32.546Z **BROKEN** lightningd: MEMLEAK: 0x55f61eb4d848
lightningd-1 2026-01-12T14:11:32.546Z **BROKEN** lightningd:   label=ccan/ccan/io/io.c:92:struct io_conn
lightningd-1 2026-01-12T14:11:32.546Z **BROKEN** lightningd:   alloc:
lightningd-1 2026-01-12T14:11:32.840Z **BROKEN** lightningd:     ccan/ccan/tal/tal.c:488 (tal_alloc_)
lightningd-1 2026-01-12T14:11:32.845Z **BROKEN** lightningd:     ccan/ccan/io/io.c:92 (io_new_conn_)
lightningd-1 2026-01-12T14:11:32.845Z **BROKEN** lightningd:     lightningd/subd.c:785 (new_subd)
lightningd-1 2026-01-12T14:11:32.845Z **BROKEN** lightningd:     lightningd/subd.c:839 (new_channel_subd_)
lightningd-1 2026-01-12T14:11:32.846Z **BROKEN** lightningd:     lightningd/channel_control.c:1714 (peer_start_channeld)
lightningd-1 2026-01-12T14:11:32.847Z **BROKEN** lightningd:     lightningd/peer_control.c:1390 (connect_activate_subd)
lightningd-1 2026-01-12T14:11:32.847Z **BROKEN** lightningd:     lightningd/peer_control.c:1516 (peer_connected_hook_final)
lightningd-1 2026-01-12T14:11:32.847Z **BROKEN** lightningd:     lightningd/plugin_hook.c:243 (hook_done)
lightningd-1 2026-01-12T14:11:32.847Z **BROKEN** lightningd:     lightningd/plugin_hook.c:343 (plugin_hook_call_next)
lightningd-1 2026-01-12T14:11:32.847Z **BROKEN** lightningd:     lightningd/plugin_hook.c:299 (plugin_hook_callback)
lightningd-1 2026-01-12T14:11:32.851Z **BROKEN** lightningd:     lightningd/plugin.c:701 (plugin_response_handle)
lightningd-1 2026-01-12T14:11:32.851Z **BROKEN** lightningd:     lightningd/plugin.c:790 (plugin_read_json)
lightningd-1 2026-01-12T14:11:32.851Z **BROKEN** lightningd:     ccan/ccan/io/io.c:60 (next_plan)
lightningd-1 2026-01-12T14:11:32.851Z **BROKEN** lightningd:     ccan/ccan/io/io.c:422 (do_plan)
lightningd-1 2026-01-12T14:11:32.851Z **BROKEN** lightningd:     ccan/ccan/io/io.c:439 (io_ready)
lightningd-1 2026-01-12T14:11:32.851Z **BROKEN** lightningd:     ccan/ccan/io/poll.c:470 (io_loop)
lightningd-1 2026-01-12T14:11:32.851Z **BROKEN** lightningd:     lightningd/io_loop_with_timers.c:22 (io_loop_with_timers)
lightningd-1 2026-01-12T14:11:32.851Z **BROKEN** lightningd:     lightningd/lightningd.c:1492 (main)
lightningd-1 2026-01-12T14:11:32.852Z **BROKEN** lightningd:     ../sysdeps/nptl/libc_start_call_main.h:58 (__libc_start_call_main)
lightningd-1 2026-01-12T14:11:32.852Z **BROKEN** lightningd:     ../csu/libc-start.c:360 (__libc_start_main_impl)
lightningd-1 2026-01-12T14:11:32.852Z **BROKEN** lightningd:   parents:
lightningd-1 2026-01-12T14:11:32.852Z **BROKEN** lightningd:     lightningd/lightningd.c:108:struct lightningd
lightningd-1 2026-01-12T14:11:32.853Z DEBUG   lightningd: channel_gossip: no longer in startup mode
lightningd-1 2026-01-12T14:11:32.856Z DEBUG   hsmd: new_client: 1
```

The workaround is to do our own leak detection on a timer (making the
conn notleak() would leave us open to a real leak in future!).

We also move the `struct leak_detect` definition inside the C file
where it belongs.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-01-14 15:41:45 +10:30
Rusty Russell
779a478437 lightningd: allow --recover / recover JSON RPC to take mnemonic.
In fact, you *must* use mnemonic to successfully recover a modern node!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: JSON-RPC: `recover` takes a 12-word mnemonic for nodes created by v25.12 or later.
2026-01-13 22:36:01 +10:30
Rusty Russell
eb19862894 lightningd: don't complain if gossipd tells us about dead channel on startup.
This can happen if gossipd hasn't processed the blocks yet:

```
lightningd-2 2026-01-07T06:05:19.430Z **BROKEN** 0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-chan#3: gossipd gave channel_update in CGOSSIP_CHANNEL_ANNOUNCED_DEAD? update=010240d5d1b653118c047218802d8c5d6bda49124fc9e1cb30ceff72e24c44e6a20d0b6b6fbe5465def31a01c8ff49dc171542a64a1a69d5149698f31e1ba4e721c106226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f00006f0000010000695df63a010200060000000000000000000000010000000a000000003b023380
```

It does catch up later, so ignore this.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-01-08 22:33:19 +10:30
Rusty Russell
bb4d8cdb06 lightningd: fix error code on waitsendpay on old errors.
We don't explicitly save the return code in db, so we need to reconstruct it.

We didn't cover the "peer told us our onion was bad" corner case.  But it's hardly
worth a changelog message, since users will never see this.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-01-08 22:33:19 +10:30
Rusty Russell
1741e166a6 lightningd: fix occasional memleak when we detach subd from channel.
Do this by setting notleak when we do the detach!

```
**BROKEN** lightningd: MEMLEAK: 0x60f0000bbb38
**BROKEN** lightningd:   label=ccan/ccan/io/io.c:92:struct io_conn
**BROKEN** lightningd:   alloc:
**BROKEN** lightningd:     /home/runner/work/lightning/lightning/ccan/ccan/tal/tal.c:488 (tal_alloc_)
**BROKEN** lightningd:     /home/runner/work/lightning/lightning/ccan/ccan/io/io.c:92 (io_new_conn_)
**BROKEN** lightningd:     /home/runner/work/lightning/lightning/lightningd/subd.c:781 (new_subd)
**BROKEN** lightningd:     /home/runner/work/lightning/lightning/lightningd/subd.c:835 (new_channel_subd_)
**BROKEN** lightningd:     /home/runner/work/lightning/lightning/lightningd/channel_control.c:1715 (peer_start_channeld)
**BROKEN** lightningd:     /home/runner/work/lightning/lightning/lightningd/peer_control.c:1390 (connect_activate_subd)
**BROKEN** lightningd:     /home/runner/work/lightning/lightning/lightningd/peer_control.c:1516 (peer_connected_hook_final)
**BROKEN** lightningd:     /home/runner/work/lightning/lightning/lightningd/plugin_hook.c:243 (hook_done)
**BROKEN** lightningd:     /home/runner/work/lightning/lightning/lightningd/plugin_hook.c:343 (plugin_hook_call_next)
**BROKEN** lightningd:     /home/runner/work/lightning/lightning/lightningd/plugin_hook.c:299 (plugin_hook_callback)
**BROKEN** lightningd:     /home/runner/work/lightning/lightning/lightningd/plugin.c:701 (plugin_response_handle)
**BROKEN** lightningd:     /home/runner/work/lightning/lightning/lightningd/plugin.c:790 (plugin_read_json)
**BROKEN** lightningd:     /home/runner/work/lightning/lightning/ccan/ccan/io/io.c:60 (next_plan)
**BROKEN** lightningd:     /home/runner/work/lightning/lightning/ccan/ccan/io/io.c:422 (do_plan)
**BROKEN** lightningd:     /home/runner/work/lightning/lightning/ccan/ccan/io/io.c:439 (io_ready)
**BROKEN** lightningd:     /home/runner/work/lightning/lightning/ccan/ccan/io/poll.c:470 (io_loop)
**BROKEN** lightningd:     /home/runner/work/lightning/lightning/lightningd/io_loop_with_timers.c:22 (io_loop_with_timers)
**BROKEN** lightningd:     /home/runner/work/lightning/lightning/lightningd/lightningd.c:1492 (main)
**BROKEN** lightningd:     ../sysdeps/nptl/libc_start_call_main.h:58 (__libc_start_call_main)
**BROKEN** lightningd:     ../csu/libc-start.c:392 (__libc_start_main_impl)
**BROKEN** lightningd:   parents:
**BROKEN** lightningd:     lightningd/lightningd.c:108:struct lightningd
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-01-08 22:33:19 +10:30
Rusty Russell
25fb75e4be pytest: restore and fix disabled test test_excluded_adjacent_routehint.
1. It was flaky, probably because it didn't wait for the remote update_channel.
2. Rusty applied a fix in 5f664dac77, not clear if it worked.
3. Christian disabled it altogether in 23ce9a947d.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-01-08 22:33:19 +10:30
Rusty Russell
97e58e41f6 connectd: fix race when we supply a new address.
This shows up as a flake in test_route_by_old_scid:


```
        # Now restart l2, make sure it remembers the original!
        l2.restart()
>       l2.rpc.connect(l1.info['id'], 'localhost', l1.port)

tests/test_splicing.py:554: 
...
>           raise RpcError(method, payload, resp['error'])
E           pyln.client.lightning.RpcError: RPC call failed: method: connect, payload: {'id': '0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518', 'host': 'localhost', 'port': 33837}, error: {'code': 400, 'message': 'Unable to connect, no address known for peer'}
```

This is because it's already (auto)connecting, and fails.  This
failure is reported, before we've added the new address (once we add
the new address, we connect fine, but it's too late!):

```
lightningd-2 2025-12-08T02:39:18.241Z DEBUG   gossipd: REPLY WIRE_GOSSIPD_NEW_BLOCKHEIGHT_REPLY with 0 fds
lightningd-2 2025-12-08T02:39:18.320Z DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-connectd: Initializing important peer with 0 addresses
lightningd-2 2025-12-08T02:39:18.320Z DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-connectd: Failed connected out: Unable to connect, no address known for peer
lightningd-2 2025-12-08T02:39:18.344Z DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-connectd: Will try reconnect in 1 seconds
lightningd-2 2025-12-08T02:39:18.344Z DEBUG   035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d-connectd: Initializing important peer with 1 addresses
lightningd-2 2025-12-08T02:39:18.344Z DEBUG   035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d-connectd: Connected out, starting crypto
lightningd-2 2025-12-08T02:39:18.344Z DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-connectd: Adding 1 addresses to important peer
lightningd-2 2025-12-08T02:39:18.345Z DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-connectd: Connected out, starting crypto
{'run_id': 256236335046680576, 'github_repository': 'ElementsProject/lightning', 'github_sha': '555f1ac461d151064aad6fc83b94a0290e2e9d5d', 'github_ref': 'refs/pull/8767/merge', 'github_ref_name': 'HEAD', 'github_run_id': 20013689862, 'github_head_ref': 'fixup-backfill-bug', 'github_run_number': 14774, 'github_base_ref': 'master', 'github_run_attempt': '1', 'testname': 'test_route_by_old_scid', 'start_time': 1765161493, 'end_time': 1765161558, 'outcome': 'fail'}
lightningd-2 2025-12-08T02:39:18.421Z DEBUG   022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-hsmd: Got WIRE_HSMD_ECDH_REQ
lightningd-2 2025-12-08T02:39:18.421Z DEBUG   hsmd: Client: Received message 1 from client
lightningd-2 2025-12-08T02:39:18.453Z DEBUG   022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-hsmd: Got WIRE_HSMD_ECDH_REQ
lightningd-2 2025-12-08T02:39:18.453Z DEBUG   hsmd: Client: Received message 1 from client
--------------------------- Captured stdout teardown ---------------------------
```
2026-01-08 22:33:19 +10:30
dovgopoly
a1a4affe81 lightningd: fix segfault when parse_filter fails
We need to initialize ->json_cmd *before* complaining about malformed
filters.

```
lightningd: FATAL SIGNAL 11 (version v25.12-21-g3851187-modded)
0x1042d2023 ???
        send_backtrace+0x4f:0
0x1042d20cb ???
        crashdump+0x43:0
0x19fe3b743 ???
        ???:0
0x104180173 command_log
        lightningd/jsonrpc.c:1406
0x10420d8f7 command_fail_badparam
        common/json_command.c:25
0x104181a07 parse_request
        lightningd/jsonrpc.c:1075
0x104181a07 read_json
        lightningd/jsonrpc.c:1216
0x10424c65b next_plan
        ccan/ccan/io/io.c:60
0x10424c65b do_plan
        ccan/ccan/io/io.c:422
0x10424c587 io_ready
        ccan/ccan/io/io.c:439
0x10424dd9b io_loop
        ccan/ccan/io/poll.c:470
0x10417ede7 io_loop_with_timers
        lightningd/io_loop_with_timers.c:22
0x104183a33 main
        lightningd/lightningd.c:1492
```

Co-authored-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: JSON-RPC: malformed filters no longer crash lightningd.
2025-12-22 13:13:57 +01:00
erdoganishe
1f302cd270 lightningd: add description field to offer related responces
Changelog-Added: Expose decoded offer description in `offer` and `listoffers` RPC responses.
2025-12-19 15:28:46 -08:00
Rusty Russell
4c8d656f77 gossipd: don't need hsm fd any more.
gossipd no longer makes gossip messages, and hasn't since v24.02, so it
doesn't actually need to talk to the hsm daemon.

Also, various comments were out of date, so fix those too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-12-19 12:37:36 +01:00
Rusty Russell
cef11ea361 lightningd: fix db constraint error when fixing up old blocks.
It's very hard to reproduce, since we only consider UTXOs we are watching, but scanning
from the first block we know about is wrong, because we don't care about blocks which
we only put in the db in response to old gossip queries.

I'm not sure how Sjors got into the state where they see their own UTXO spend in a block
they don't have in the database, but we shouldn't crash:

```
2025-12-07T11:25:18.163Z **BROKEN** lightningd: Error executing statement: wallet/wallet.c:4913: UPDATE outputs SET spend_height = ?,  status = ? WHERE prev_out_tx = ? AND prev_out_index = ?: FOREIGN KEY constraint failed
2025-12-07T11:25:18.163Z **BROKEN** lightningd: Error executing statement: wallet/wallet.c:4913: UPDATE outputs SET spend_height = ?,  status = ? WHERE prev_out_tx = ? AND prev_out_index = ?: FOREIGN KEY constraint failed
2025-12-07T11:25:18.179Z **BROKEN** lightningd: FATAL SIGNAL 6 (version v25.12)
2025-12-07T11:25:18.180Z **BROKEN** lightningd: backtrace: common/daemon.c:46 (send_backtrace) 0x5e263feb9292
2025-12-07T11:25:18.180Z **BROKEN** lightningd: backtrace: common/daemon.c:83 (crashdump) 0x5e263feb92e1
2025-12-07T11:25:18.180Z **BROKEN** lightningd: backtrace: (null):0 ((null)) 0x70ee6f64532f
2025-12-07T11:25:18.180Z **BROKEN** lightningd: backtrace: (null):0 ((null)) 0x70ee6f69eb2c
2025-12-07T11:25:18.180Z **BROKEN** lightningd: backtrace: (null):0 ((null)) 0x70ee6f64527d
2025-12-07T11:25:18.180Z **BROKEN** lightningd: backtrace: (null):0 ((null)) 0x70ee6f6288fe
2025-12-07T11:25:18.180Z **BROKEN** lightningd: backtrace: lightningd/log.c:1054 (fatal_vfmt) 0x5e263fe38e10
2025-12-07T11:25:18.180Z **BROKEN** lightningd: backtrace: wallet/db.c:95 (db_error) 0x5e263fe6f7ef
2025-12-07T11:25:18.180Z **BROKEN** lightningd: backtrace: db/utils.c:326 (db_fatal) 0x5e263feaa797
2025-12-07T11:25:18.180Z **BROKEN** lightningd: backtrace: db/utils.c:200 (db_exec_prepared_v2) 0x5e263feaab85
2025-12-07T11:25:18.180Z **BROKEN** lightningd: backtrace: wallet/wallet.c:4924 (wallet_outpoint_spend) 0x5e263fe7de2f
2025-12-07T11:25:18.180Z **BROKEN** lightningd: backtrace: lightningd/chaintopology.c:929 (topo_update_spends) 0x5e263fe0af81
2025-12-07T11:25:18.180Z **BROKEN** lightningd: backtrace: lightningd/chaintopology.c:1532 (fixup_scan_block) 0x5e263fe0c268
2025-12-07T11:25:18.180Z **BROKEN** lightningd: backtrace: lightningd/bitcoind.c:503 (getrawblockbyheight_callback) 0x5e263fe09280
2025-12-07T11:25:18.180Z **BROKEN** lightningd: backtrace: lightningd/plugin.c:701 (plugin_response_handle) 0x5e263fe5bf2b
2025-12-07T11:25:18.180Z **BROKEN** lightningd: backtrace: lightningd/plugin.c:790 (plugin_read_json) 0x5e263fe610e7
2025-12-07T11:25:18.180Z **BROKEN** lightningd: backtrace: ccan/ccan/io/io.c:60 (next_plan) 0x5e263fef3629
2025-12-07T11:25:18.180Z **BROKEN** lightningd: backtrace: ccan/ccan/io/io.c:422 (do_plan) 0x5e263fef3afa
2025-12-07T11:25:18.180Z **BROKEN** lightningd: backtrace: ccan/ccan/io/io.c:439 (io_ready) 0x5e263fef3bb7
2025-12-07T11:25:18.180Z **BROKEN** lightningd: backtrace: ccan/ccan/io/poll.c:470 (io_loop) 0x5e263fef55c5
2025-12-07T11:25:18.180Z **BROKEN** lightningd: backtrace: lightningd/io_loop_with_timers.c:22 (io_loop_with_timers) 0x5e263fe308e9
2025-12-07T11:25:18.180Z **BROKEN** lightningd: backtrace: lightningd/lightningd.c:1492 (main) 0x5e263fe363ce
2025-12-07T11:25:18.180Z **BROKEN** lightningd: backtrace: (null):0 ((null)) 0x70ee6f62a1c9
2025-12-07T11:25:18.180Z **BROKEN** lightningd: backtrace: (null):0 ((null)) 0x70ee6f62a28a
2025-12-07T11:25:18.180Z **BROKEN** lightningd: backtrace: (null):0 ((null)) 0x5e263fe06bf4
2025-12-07T11:25:18.180Z **BROKEN** lightningd: backtrace: (null):0 ((null)) 0xffffffffffffffff
```

Changelog-Fixes: lightningd: crash on fixup scan with old blocks.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-12-11 12:16:42 +10:30
Rusty Russell
22f7a620e6 lightningd: fix crash on fixup scan if block unavailable.
```
lightningd: FATAL SIGNAL 11 (version v25.12rc3-1-g498c5b6)
0x5cc2f620ce4c send_backtrace
        common/daemon.c:38
0x5cc2f620cee8 crashdump
        common/daemon.c:83
0x7e3ac1e4532f ???
        ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0x5cc2f615f186 fixup_scan_block
        lightningd/chaintopology.c:1531
0x5cc2f615c22c getrawblockbyheight_callback
        lightningd/bitcoind.c:484
0x5cc2f61aee87 plugin_response_handle
        lightningd/plugin.c:701
0x5cc2f61b4043 plugin_read_json
        lightningd/plugin.c:790
0x5cc2f6248d8b next_plan
        ccan/ccan/io/io.c:60
0x5cc2f624925c do_plan
        ccan/ccan/io/io.c:422
0x5cc2f6249319 io_ready
        ccan/ccan/io/io.c:439
0x5cc2f624ad24 io_loop
        ccan/ccan/io/poll.c:470
0x5cc2f618381a io_loop_with_timers
        lightningd/io_loop_with_timers.c:22
0x5cc2f61892ff main
```

This happens intermittantly on in a few tests:

tests/test_invoices.py::test_invoice_botched_migration
tests/test_pay.py::test_pay_bolt11_metadata
tests/test_runes.py::test_id_migration

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: lightningd: potential crash on startup if bitcoind isn't up-to-date.
2025-12-10 14:43:45 +10:30
Rusty Russell
6c60375651 lightningd: scan back to seek missing UTXOs.
We only do this once, and not on new nodes.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-11-29 08:18:20 +10:30
Rusty Russell
6dcf4e7bdd wallet: separate migration table into its own source file.
This will make it easier to share with the downgrade tool.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-11-28 09:16:53 +10:30
Rusty Russell
fc23b538cd lightningd: print UNUSUAL log message if a command is very slow.
We don't expect an internal command to take 5 seconds to service
without explicitly pausing: if it does, log at a higher level.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-11-27 15:04:20 +10:30
Rusty Russell
87324103de lightningd: print last method we called if we abort processing loop.
We are seeing this in the CI logs, eg tests/test_connection.py::test_reconnect_sender_add1:

   lightningd-1 2025-11-17T05:48:00.665Z DEBUG   jsonrpc#84: Pausing parsing after 1 requests

followed by:

   lightningd-1 2025-11-17T05:48:02.068Z **BROKEN** 022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-connectd: wake delay for WIRE_CHANNEL_REESTABLISH: 8512msec

So, what is consuming lightningd for 8 or so seconds?

This message helped diagnose that the issue was dev-memleak: fixed in a different branch.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-11-20 16:30:50 +10:30
Rusty Russell
98bd95cb2e lightningd: optimize find_cmd.
We have a reasonable number of commands now, and we *already* keep a
strmap for the usage strings.  So simply keep the usage and the command
in the map, and skip the array.

tests/test_coinmoves.py::test_generate_coinmoves (2,000,000, sqlite3):
	Time (from start to end of l2 node):	 95 seconds (was 102)
	Worst latency:				 4.5 seconds

tests/test_coinmoves.py::test_generate_coinmoves (2,000,000, Postgres):
	Time (from start to end of l2 node):	 231 seconds
	Worst latency:				 4.8 seconds

Note the values compare against 25.09.2 (Postgres):

	sqlite3:
	Time (from start to end of l2 node):	 403 seconds

	Postgres:
	Time (from start to end of l2 node):	 671 seconds

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-11-20 16:30:50 +10:30
Rusty Russell
94d582f24e lightningd: don't process more than 100 commands from a plugin at once.
Now that ccan/io rotates through callbacks, we can call io_always() to
yield.

We're now fast enough that this doesn't have any effect on this test,
bit it's still good to have.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-11-20 16:30:50 +10:30
Rusty Russell
b51e2827cd lightningd: don't process more than 100 commands from a JSONRPC at once.
Now that ccan/io rotates through callbacks, we can call io_always() to yield.

Though it doesn't fire on our benchmark, it's a good thing to do.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-11-20 16:30:50 +10:30
Rusty Russell
213cbba5bf lightningd: allow filtering on custommsg hook too.
Changelog-Added: Plugins: "filters" can be specified on the `custommsg` hook to limit what message types the hook will be called for.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-11-20 16:30:50 +10:30
Rusty Russell
d9d82ac5bd lightningd: add support for filters on "rpc_command" hook.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: Plugins: the `rpc_command` hook can now specify a "filter" on what commands it is interested in.
2025-11-20 16:30:50 +10:30
Rusty Russell
d76a9050ad lightningd: support "filters" in plugins manifest to restrict when hooks are called.
We're going to use this on the "rpc_command" hook, to allow xpay to specify that it
only wants to be called on "pay" commands.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-11-20 16:30:50 +10:30
Rusty Russell
8707b7312a lightningd: handle large numbers of command outputs gracefully.
Profiling shows us spending all our time in tal_arr_remove when dealing
with a giant number of output streams.  This applies both for RPC output
and plugin output.

Use linked list instead.

tests/test_coinmoves.py::test_generate_coinmoves (2,000,000, sqlite3):
	Time (from start to end of l2 node):	239 seconds **WAS 518**
	Worst latency:				56.9 seconds **WAS 353**

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-11-20 16:30:50 +10:30
Rusty Russell
cfa89f64e9 lightningd: don't loop through all commands every time one finishes.
When we have many commands, this is where we spend all our time, and it's
just for an old assertion.

tests/test_coinmoves.py::test_generate_coinmoves (100,000, sqlite3):
	Time (from start to end of l2 node):	13 seconds **WAS 34**
	Worst latency:				4.0 seconds **WAS 24*

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-11-20 16:30:50 +10:30
Rusty Russell
576f48cb74 lightningd: log when we have to defer hook registration.
If livelock ever *does* become an issue, we will see it in the logs.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-11-20 16:30:50 +10:30
Rusty Russell
a4f772efa7 lightningd: avoid race when runtime-added plugins register hooks.
If we add a new hook, not at the end, while hooks are getting called,
then iteration could be messed up (e.g. calling a plugin twice, or
skipping one).

The simplest thing is to defer updates until nobody is calling the
hook.  In theory this could livelock, in practice it won't.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-11-20 16:30:50 +10:30
Rusty Russell
6e5a5b0f75 lightningd: don't copy hooks array into hook request, simply don't shrink it.
We make a copy, then attach a destructor to the hook in case that plugin exits, so we
can NULL it out in the local copy.  When we have 300,000 requests pending, this means
we have 300,000 destructors, which don't scale (it's a single-linked list).

Simply NULL out (rather than shrink) the array in the `plugin_hook`.
Then we can keep using that.

tests/test_coinmoves.py::test_generate_coinmoves (100,000, sqlite3):
	Time (from start to end of l2 node):	34 seconds **WAS 85**
	Worst latency:				24 seconds **WAS 75**

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-11-20 16:30:50 +10:30
Rusty Russell
55d622bd0e lightningd: fix race with mutual connect.
65dccea5bd "pytest: fix flake in test_reconnect_signed" accidentally
introduced a bug, where the connect command may not return.

If we call "connect" while a connection is still being processed
through the peer_connected hooks, we would call peer_channels_cleanup(),
which (if the peer has no channels) would free the peer.

Then when the peer_connected hook returned, it would lookup the peer,
see it was gone, and silently return.  The connect_succeeded() function
was never called, and the connect command never woken.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-None: bug introduced this release.
2025-11-19 16:04:21 +10:30
Rusty Russell
79e609468a connectd: don't complain if lightningd is unresponsive while doing dev-memleak.
We had a flake of form:

```
2025-11-18T04:42:23.489Z **BROKEN** 022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-connectd: wake delay for WIRE_CHANNEL_REESTABLISH: 6789msec
```

Which happened as we're shutting down.  Some investigation revealed
the cause: `dev-memleak` can be extremely slow.  Fair enough.

So we change `dev-memleak` to call connectd first, and connectd uses
that as a trigger to stop complaining about delays.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-11-19 14:29:08 +10:30
Rusty Russell
215294bc2d lightningd: another gossip transition corner case.
If we see a close tx at the same time we see the channel reach announce depth (here, 104x1x0 confirms
and we process blocks 109 and 110), we see it go from:

	CGOSSIP_WAITING_FOR_ANNOUNCE_DEPTH->CGOSSIP_CHANNEL_UNANNOUNCED_DYING (Channel closing before 6 confirms)

Then:
	CGOSSIP_CHANNEL_UNANNOUNCED_DYING->CGOSSIP_CHANNEL_ANNOUNCED_DEAD

```
INFO    0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-chan#2: State changed from CHANNELD_NORMAL to CHANNELD_SHUTTING_DOWN
DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-chan#2: gossip state: CGOSSIP_WAITING_FOR_ANNOUNCE_DEPTH->CGOSSIP_CHANNEL_UNANNOUNCED_DYING (Channel closing before 6 confirms)
DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-channeld-chan#2: billboard: Channel ready for use. They've sent shutdown, waiting for ours
DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-channeld-chan#2: Trying commit
DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-channeld-chan#2: Can't send commit: nothing to send, feechange not wanted ({ RCVD_ADD_ACK_REVOCATION:3755 }) blockheight not wanted ({ RCVD_ADD_ACK_REVOCATION:109 })
DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-channeld-chan#2: peer_out WIRE_SHUTDOWN
DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-channeld-chan#2: billboard: Channel ready for use. Shutdown messages exchanged.
DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-closingd-chan#2: pid 35692, msgfd 86
DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-channeld-chan#2: Status closed, but not exited. Killing
INFO    0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-chan#2: State changed from CHANNELD_SHUTTING_DOWN to CLOSINGD_SIGEXCHANGE
DEBUG   hsmd: new_client: 2
DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-closingd-chan#2: Expected closing weight = 772, fee 2895sat (min 1447sat, max 1006268sat)
DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-closingd-chan#2: out = 506268sat/500000sat
DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-closingd-chan#2: dustlimit = 546sat
DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-closingd-chan#2: fee = 2895sat
DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-closingd-chan#2: fee negotiation step = 50%
DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-closingd-chan#2: billboard perm: Negotiating closing fee between 1447sat and 1006268sat satoshi (ideal 2895sat) using step 50%
DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-closingd-chan#2: billboard: Waiting for their initial closing fee offer
DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-closingd-chan#2: peer_in WIRE_CLOSING_SIGNED
DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-closingd-chan#2: Making close tx at = 506268sat/500000sat fee 2895sat
DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-closingd-chan#2: Received fee offer 2895sat
DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-closingd-chan#2: ...offer is reasonable
DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-chan#2: Their actual closing tx fee is 2895sat vs previous 4220sat: weight is 772
INFO    0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-closingd-chan#2: performing quickclose in range 1447sat-8492sat
DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-closingd-chan#2: Making close tx at = 506268sat/500000sat fee 2895sat
DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-hsmd: Got WIRE_HSMD_SIGN_MUTUAL_CLOSE_TX
DEBUG   hsmd: Client: Received message 21 from client
DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-closingd-chan#2: sending fee offer 2895sat
DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-closingd-chan#2: peer_out WIRE_CLOSING_SIGNED
DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-closingd-chan#2: billboard perm: We agreed on a closing fee of 2895 satoshi for tx:7685256e6e4632bd601f42bb85b6f22b7a0db8d55c468dfbb1703c3ab2e4d9ce
INFO    0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-chan#2: State changed from CLOSINGD_SIGEXCHANGE to CLOSINGD_COMPLETE
DEBUG   wallet: Owning output 1 506268sat (p2tr) txid 7685256e6e4632bd601f42bb85b6f22b7a0db8d55c468dfbb1703c3ab2e4d9ce
DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-chan#2: We have 1 anchor points to use
DEBUG   lightningd: Broadcasting txid 7685256e6e4632bd601f42bb85b6f22b7a0db8d55c468dfbb1703c3ab2e4d9ce
DEBUG   lightningd: sendrawtransaction: 020000000001016f50e5481abf2482ed719dde6014cf9da9b3076fe12af7c8bbccfb705150ffbe0000000000ffffffff02d195070000000000225120eed745804da9784cc203f563efa99ffa54fdf01b137bc964e63c3124070ffbe69cb90700000000002251208a73bb281433f2b5db5461c6778aa2afd28e011de6bd04799a5991662c61d7a80400473044022015af4ffc277e44ab701507e017194b1e3ab8598397efab02c59dbe72340790b50220762065e91ce0a2c73f36fdf3a4d54732ef91d075c0887cfb28580220e081e81a01473044022050730b9d051a3fdecb368750ecbd558d625a1acaa42e59586c7187407319dda402202f2f6e099b2e092698fe528260e2b56be8de325bc985a17945c724514fb65b9c014752210259b3cb48220dc2016f4d320bb8105cc2c92bd8c79fc25c2ad96f37b496e491c62103bbee60c395056b8a1201e06ed79e2914c11a61d7b1aa781846468d02489dba6952ae00000000
DEBUG   lightningd: Adding block 108: 4e6ba3059c6890797a29acd306e82d6f4e85ad62a6aa6d0ee5bc6ead3e6329cd
DEBUG   hsmd: Client: Received message 5 from client
DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-connectd: peer_downgrade
DEBUG   plugin-bcli: sendrawtx exit 0 (bitcoin-cli -regtest -datadir=/tmp/ltests-laf51vlg/test_buy_liquidity_ad_check_bookkeeping_1/lightning-2/ -rpcclienttimeout=60 -rpcport=41847 -rpcuser=... -stdinrpcpass sendrawtransaction 020000000001016f50e5481abf2482ed719dde6014cf9da9b3076fe12af7c8bbccfb705150ffbe0000000000ffffffff02d195070000000000225120eed745804da9784cc203f563efa99ffa54fdf01b137bc964e63c3124070ffbe69cb90700000000002251208a73bb281433f2b5db5461c6778aa2afd28e011de6bd04799a5991662c61d7a80400473044022015af4ffc277e44ab701507e017194b1e3ab8598397efab02c59dbe72340790b50220762065e91ce0a2c73f36fdf3a4d54732ef91d075c0887cfb28580220e081e81a01473044022050730b9d051a3fdecb368750ecbd558d625a1acaa42e59586c7187407319dda402202f2f6e099b2e092698fe528260e2b56be8de325bc985a17945c724514fb65b9c014752210259b3cb48220dc2016f4d320bb8105cc2c92bd8c79fc25c2ad96f37b496e491c62103bbee60c395056b8a1201e06ed79e2914c11a61d7b1aa781846468d02489dba6952ae00000000) 
DEBUG   lightningd: Adding block 109: 540a47d6b316aec8d1b56efca22ffb384403659e3b29cddd3d68f87df72065a6
DEBUG   lightningd: Adding block 110: 1931e9ea62324d0fb50188df525e84ee7021e1910cf3534b343db05cc4639851
DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-chan#2: Got UTXO spend for beff505170fbccbbc8f72ae16f07b3a99dcf1460de9d71ed8224bf1a48e5506f:0: 7685256e6e4632bd601f42bb85b6f22b7a0db8d55c468dfbb1703c3ab2e4d9ce
UNUSUAL 0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-chan#2: Peer permanent failure in CLOSINGD_COMPLETE: Funding transaction spent: onchain txid 7685256e6e4632bd601f42bb85b6f22b7a0db8d55c468dfbb1703c3ab2e4d9ce (reason=unknown)
UNUSUAL 0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-chan#2: Not dropping our unilateral close onchain since we already saw 7685256e6e4632bd601f42bb85b6f22b7a0db8d55c468dfbb1703c3ab2e4d9ce confirm.
INFO    0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-chan#2: State changed from CLOSINGD_COMPLETE to FUNDING_SPEND_SEEN
**BROKEN** 0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-chan#2: Illegal gossip state transition: CGOSSIP_CHANNEL_UNANNOUNCED_DYING->CGOSSIP_CHANNEL_ANNOUNCED_DEAD
DEBUG   0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-onchaind-chan#2: pid 35721, msgfd 86
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-11-19 14:29:08 +10:30
Rusty Russell
b74d32f6c4 lightningd: add withhold option to fundchannel_complete.
This is just a polite way of telling us that if we close, don't bother broadcasting
since we didn't broadcast the funding tx.

Changelog-Added: JSON-RPC: `fundchannel_complete` new parameter `withhold` (default false).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-11-19 07:23:39 +10:30
Rusty Russell
33e5876d29 lightningd: don't rebroadcast withheld channels' funding_psbt on restart.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-11-19 07:23:39 +10:30
Rusty Russell
8d99c5b839 lightningd: immediately close without broadcast whenever we close a withheld channel.
There's no funding tx to spend.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-11-19 07:23:39 +10:30
Rusty Russell
39349965a6 lightningd: add withheld flag to listpeerchannels and listclosedchannels.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: JSON-RPC: `listpeerchannels` `funding` object `withheld` flag, and `listclosedchannels` `funding_withheld` flags, indicating fundchannel_complete was called with the `withheld` parameter true.
2025-11-19 07:23:39 +10:30
Rusty Russell
ff433a17a8 lightningd: save funding PSBT to database if we're to withhold it.
Normally we don't care, but if we're withholding it, keep it around
so we can sign & broadcast later.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-11-19 07:23:39 +10:30
Rusty Russell
606aad07ed lightningd: expose funding PSBT (if we have it) in JSON API.
Changelog-Added: JSON-RPC: `psbt` field in `funding` in listpeerchannels, and `funding_psbt` in listclosedchannels.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-11-19 07:23:39 +10:30
Rusty Russell
d44fa2f3bd lightningd: re-xmit funding txs on startup.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: Protocol: we now re-transmit unseen funding transactions on startup, for more robustness.
2025-11-19 07:23:39 +10:30
Rusty Russell
ae9ecba375 sendpsbt: update channel psbts if this is a channel PSBT.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-11-19 07:23:39 +10:30
Rusty Russell
5cbab33dc4 lightningd: save funding_psbt in channel, database.
Interestingly, @niftynei added a funding_psbt column to the db in 2020,
but we don't use it (it was removed early 2021 with the "inflight"
architecture).  So we don't need to add a new column, just plumb it
back in.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-11-19 07:23:39 +10:30
Rusty Russell
c43206e463 lightningd: allow another gossip state transition.
This can definitely happen with zeroconf and the about-to-be-implemented withheld=True:

```
lightningd-1 2025-09-12T13:17:50.848Z **BROKEN** 022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-chan#1: Illegal gossip state transition: CGOSSIP_WAITING_FOR_SCID->CGOSSIP_CHANNEL_UNANNOUNCED_DYING
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-11-19 07:23:39 +10:30
Rusty Russell
f284489c96 common: don't abort() if wally_psbt_output_taproot_keypath_add() fails.
It fails on duplicates.  It would ideally succeed, but bug reported:

	https://github.com/ElementsProject/libwally-core/issues/509

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: JSON-RPC: `signpsbt` no longer crashes if asked to sign an already-signed PSBT with taproot paths.
2025-11-19 07:23:39 +10:30
Matt Whitlock
cbfe1a9996 lightningd: notify plugins when finalizing channel
Changelog-Added: Plugins now receive `channel_state_changed` notification upon final change to `CLOSED` state.
2025-11-18 14:28:22 +10:30
Rusty Russell
7c7f1e4235 lightningd: deprecate "message": null in channel_state_changed notifications.
Somehow I missed this when deprecating `short_channel_id` being null.

Changelog-Deprecated: Plugins: `channel_state_changed` notification `message` field being `null`: it will be omitted instead.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-11-18 14:28:22 +10:30