Commit Graph

17363 Commits

Author SHA1 Message Date
Rusty Russell
9ad505acec pytest: remove test_lockup_drain.
Since this was written, we now test if remote side would get into this situation and stop
it from happening, so the test doesn't work any more.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-01-08 22:33:19 +10:30
Rusty Russell
81a45b194b pytest: fix real reason for warning issue in test_route_by_old_scid.
We can still get a warning:
	lightningd-1 2025-12-10T01:11:07.232Z DEBUG   022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-connectd: Received WIRE_WARNING: WARNING: channel_announcement: no unspent txout 109x1x1

This has nothing to do with l1 talking about the original channel
(which would be 103x1x): it's because l2's gossipd (being the node
which does the splice) immediately forgets the pre-splice id.  If l1
sends some gossip, it will get a warning message.

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
Rusty Russell
2beeab6fa2 CI: remove reruns on all failures.
This is covering up real bugs; we need to fix CI instead.

From https://pypi.org/project/pytest-rerunfailures/#re-run-all-failures:

```
To re-run all test failures, use the --reruns command line option with the maximum number of times you’d like the tests to run:

$ pytest --reruns 5
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-01-08 22:33:19 +10:30
Rusty Russell
98a19df413 pytest: don't run tests marked slow_test at all if VALGRIND and SLOW_MACHINE.
We used to just run these without valgrind, but we already run them in
CI (which sets SLOW_MACHINE) without valgrind, so this just doubles
up.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-01-08 22:33:19 +10:30
Rusty Russell
8f09f0c154 common: fix ubsan trigger in param test.
```
common/test/run-param.c:381:8: runtime error: applying zero offset to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior common/test/run-param.c:381:8
```

Probably because CI now on 24.04, so more recent clang.  But the test really does
want to see what happens when the callback is NULL, so workaround.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-01-07 09:42:11 +10:30
ShahanaFarooqui
2bba6f0d3a ci: Increase timeout
Increased it to 120 since prebuild check is taking 97 minutes locally.
2025-12-22 12:23:06 -08:00
ShahanaFarooqui
8d37299953 ci: Update GitHub Actions runner to Ubuntu 24.04 due to timeout reports on 22.04
Changelog-None: CI fixes only.
2025-12-22 12:23:06 -08:00
Sangbida Chaudhuri
767ece8f9c contrib: add Sangbida's signing key 2025-12-22 14:28:10 +01:00
dovgopoly
dcaa529a31 tests: added *non-developer mode* test for invalid filtering 2025-12-22 13:13:57 +01:00
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
bb5b8d7019 test: test_sql: fix missing description field 2025-12-19 15:28:46 -08:00
ShahanaFarooqui
1887ed4ae5 test: Add tests to confirm that description is added to RPCs 2025-12-19 15:28:46 -08:00
ShahanaFarooqui
54af71c5b3 doc: Added doc schemas with description and update proto 2025-12-19 15:28:46 -08: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
ShahanaFarooqui
a05150bd18 tools: Fixed shellcheck error from promote-stable script
Changelog-None: Fixed script.
2025-12-19 14:54:50 -08:00
wqxoxo
bc3b9b4f11 pay: Enforce maxdelay for direct channel payments
When paying through a direct channel, direct_pay_override() creates a
route bypassing the normal routing path, which skips the CLTV budget
check in payment_getroute(). This allows payments to succeed even when
maxdelay is set below the required min_final_cltv_expiry.

Add a check in direct_pay_override() to verify the required CLTV
doesn't exceed cltv_budget before using the direct channel shortcut.
If it exceeds, skip the direct channel and let normal routing handle
the failure with a proper error message.

Fixes: #8609

Changelog-Fixed: pay: `maxdelay` parameter now enforced for direct channel payments
2025-12-19 12:41:17 +01:00
Rusty Russell
d6f6d46c3b gossipd: move timestamp_reasonable into gossmap_manage.c.
It's only used in there anyway.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-12-19 12:37:36 +01: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
nazarevsky
d065d3692d tests: add payer_note case for xpay 2025-12-18 12:47:06 -08:00
nazarevsky
bcdce8f40d cln-rpc: update schema, update proto for xpay payer_note field 2025-12-18 12:47:06 -08:00
nazarevsky
66ce41d584 xpay: add payer_note field
Changelog-Added: Add 'payer-note' field to the 'xpay' RPC call.
2025-12-18 12:47:06 -08:00
nazarevsky
071656970c readme: change links for 'Useful commands' from local to a web doc
Changelog-None
2025-12-18 12:05:38 -08:00
ShahanaFarooqui
611e262099 script: Update sync RPC documentation script to check if the page was renderable for Readme
- ReadMe API v2 now requires category.uri instead of category.id.

- ReadMe v2 page responses include a renderable field indicating whether the document is MDX-compatible and can be rendered successfully. The script now checks this field and prints detailed compilation errors if rendering fails.
2025-12-18 10:27:15 +10:30
ShahanaFarooqui
3e841b358e docs: Updated schema for mdx compatibility
Changelog-Fixed: Ensure documentation renders correctly when adding/updating new RPCs by detecting non-MDX-compatible pages.
2025-12-18 10:27:15 +10:30
Rusty Russell
f0e9547661 gossipd: make sure we correctly move node announcement when *no* channel preceeds it in the gossip store.
We had the test backwards, so we moved it *all the time*.  This bloats our gossip store, as well as
not moving it in the case where we need to.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: gossipd: we would occasionally not show a node announcement in listnodes().
2025-12-17 11:56:42 +10:30
Rusty Russell
d1857fff91 pytest: add test to demonstrate gossip_store misordering node announcements.
We usually lose the node announcement on restart, because the
node_announcement message is ignored by gossmap, as it doesn't (yet!) know of the node, since the
channel_announcement does not precede the node_announcement.

This is supposed to be detected and fixed by gossipd, but this simple test shows that it is not!

```
FAILED tests/test_gossip.py::test_gossmap_lost_node - AssertionError: assert {'nodes': [{'nodeid': '022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59', 'alias': 'SILENTARTIST-v25.12-2-g703851b', 'color': '022d22', 'last_timestamp': 1765172273, 'features': '8898880a8a59a1', 'addresses': []}, {'nodeid': '0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518', 'alias': 'JUNIORBEAM-v25.12-2-g703851b', 'color': '0266e4', 'last_timestamp': 1765172273, 'features': '8898880a8a59a1', 'addresses': []}, {'nodeid': '035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d'}, {'nodeid': '0382ce59ebf18be7d84677c2e35f23294b9992ceca95491fcf8a56c6cb2d9de199', 'alias': 'JUNIORFELONY-v25.12-2-g703851b', 'color': '0382ce', 'last_timestamp': 1765172273, 'features': '8898880a8a59a1', 'addresses': []}]} == {'nodes': [{'nodeid': '022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59', 'alias': 'SILENTARTIST-v25.12-2-g703851b', 'color': '022d22', 'last_timestamp': 1765172273, 'features': '8898880a8a59a1', 'addresses': []}, {'nodeid': '0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518', 'alias': 'JUNIORBEAM-v25.12-2-g703851b', 'color': '0266e4', 'last_timestamp': 1765172273, 'features': '8898880a8a59a1', 'addresses': []}, {'nodeid': '035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d', 'alias': 'HOPPINGFIRE-v25.12-2-g703851b', 'color': '035d2b', 'last_timestamp': 1765172273, 'features': '8898880a8a59a1', 'addresses': []}, {'nodeid': '0382ce59ebf18be7d84677c2e35f23294b9992ceca95491fcf8a56c6cb2d9de199', 'alias': 'JUNIORFELONY-v25.12-2-g703851b', 'color': '0382ce', 'last_timestamp': 1765172273, 'features': '8898880a8a59a1', 'addresses': []}]}
  
  Differing items:
  {'nodes': [{'addresses': [], 'alias': 'SILENTARTIST-v25.12-2-g703851b', 'color': '022d22', 'features': '8898880a8a59a1...}, {'addresses': [], 'alias': 'JUNIORFELONY-v25.12-2-g703851b', 'color': '0382ce', 'features': '8898880a8a59a1', ...}]} != {'nodes': [{'addresses': [], 'alias': 'SILENTARTIST-v25.12-2-g703851b', 'color': '022d22', 'features': '8898880a8a59a1...}, {'addresses': [], 'alias': 'JUNIORFELONY-v25.12-2-g703851b', 'color': '0382ce', 'features': '8898880a8a59a1', ...}]}
  
  Full diff:
    {
        'nodes': [
            {
                'addresses': [],
                'alias': 'SILENTARTIST-v25.12-2-g703851b',
                'color': '022d22',
                'features': '8898880a8a59a1',
                'last_timestamp': 1765172273,
                'nodeid': '022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59',
            },
            {
                'addresses': [],
                'alias': 'JUNIORBEAM-v25.12-2-g703851b',
                'color': '0266e4',
                'features': '8898880a8a59a1',
                'last_timestamp': 1765172273,
                'nodeid': '0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518',
            },
            {
  -             'addresses': [],
  -             'alias': 'HOPPINGFIRE-v25.12-2-g703851b',
  -             'color': '035d2b',
  -             'features': '8898880a8a59a1',
  -             'last_timestamp': 1765172273,
                'nodeid': '035d2b1192dfba134e10e540875d366ebc8bc353d5aa766b80c090b39c3a5d885d',
            },
            {
                'addresses': [],
                'alias': 'JUNIORFELONY-v25.12-2-g703851b',
                'color': '0382ce',
                'features': '8898880a8a59a1',
                'last_timestamp': 1765172273,
                'nodeid': '0382ce59ebf18be7d84677c2e35f23294b9992ceca95491fcf8a56c6cb2d9de199',
            },
        ],
    }

```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-12-17 11:56:42 +10:30
Peter Neuroth
4a1c922017 plugins: lsps: remove anyhow from tlvs
Remove anyhow as a dependency from the tlv module. This allows for a
cleaner error handling

Changelog-None

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
c7bbf84c83 plugins: lsps: remove cln dependencies from core module and clean up service
The core module shouldn't depend on anything from the cln_adapters
module. This ensures that we can switch out interfaces in the future
(e.g a different database than cln's datastore).

This change made it necessary to refactor the service plugin which
allowed us to clean it up on the go

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
30268ad945 plugins: lsps: move feature helpers to core module
This removes the util.rs module and leaves us with proto, core and
cln_adapters

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
f678a70610 plugins: lsps: remove lsps2 module
Separate concerns of the lsps2 modules into their respective layers:
core for tlv, as it is lightning related, not specifically
core-lightning. cln_adapters for core-lightning related types.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
fa62c64de7 plugins: lsps: split up handlers
This commit separates the business logic from core-lighting behaviour
and moves the core-lightning related implementations into the
cln_adapters module.

Splits up tests as well

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
e001652ab1 plugins: lsps: add own trait for lightning provider
Clean up the CLN interface

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
a05c2c9c2c plugins: lsps: add own trait for datastore provider
This now only makes it easier to test, but also more modular. It allows
us to use any kind of storage, not only the datastore.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
38c84be25e plugins: lsps: add own trait for blockheight provider
The ClnApi trait is way overloaded. We break things down to make it more
modular on the service side.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
38b3d14eb9 plugins: lsps: add own trait for lsps offer provider
The cln api trait is really cluttered, we try to clean it up a little
bit.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
e50f5ee863 plugins: lsps: refactor service hook
We have some shared behavior and can use the MessageSender for the
service hook as well

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
462ca844dd plugins: lsps: replace heavy transport
We replace the legacy transport by a slim custommsg hook that makes use
of the lightweight multiplexed transport and avoids deserialization and
serialization through this extra layer

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
d5bcde09ae plugins: lsps: implement ClnSender for bolt8 transport
Implement the MessageSender trait for Bolt8 transport via core-lightning

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
3cf99c358b plugins: lsps: add slim multiplexing transport
We can separate concerns here by adding a lightweight multiplexing
transport client. This helps us to clean up any direct dependencies on
CLN

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
7401585088 plugins: lsps: move client transport to cln_adapters
cln_adapters is the layer that holds concrete implementations that are
related to core-lightning.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
9adc8cdfed plugins: lsps: slim down lsps service
This commit replaces the lsps service. Therefore we add the cln_adapters
module that handles the communication with core-lightning. We add a
lightweight LspsService that wraps the router and allows handlers to
register themselves to the service/router.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
461065aff7 plugins: lsps: add router compatible lsps2 service handler
This commit copys and adapts the lsps2 service handlers to match the
slim router handlers

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
ffc05ddcf0 plugins: lsps: add slim generic json-rpc router
This router is very lightweight and can handle routing for the lsps
service. It avoids allocations by just borrowing from the request. This
is much cleaner than what we have now and reduces the amount of
serializations by a lot.

Also it supports typed handlers which will remove serialization overhead
from the handlers in future commits

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
1159adb0e2 plugin: lsps: move json-rpc server to core module
This removes the jsonrpc module

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
b9172239d0 plugins: lsps: switch to typed transport
There is no need to communicate via a generic JsonRpcClient if all
messages are well defined and we can use the typed transport to remove a
whole lot of overhead and just pass the ResponseObjects directly to the
Transport layer

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
1bb76f84e2 plugins: lsps: add request to transport trait
Introducing "request" to the transport trait that uses the RequestObject
and JsonRpcResponse directly reduces some overhead and unnecessary
conversions. Why do we implement a generic transport over &str when we
already know that we are dealing with JSON-RPC 2.0 here.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
2546642c32 plugins: lsps: move id generation into jsonrpcrequest
There is no need to generate the id in some client when we can actually
generate it on a lower layer as we know by LSPS0 how we have to generate
it.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
5ed743e10d plugins: lsps: add lsps0 encoding and decoding
In order to seperate concerns, this adds the basic encoding of an lsps0
frame to the proto module.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
0927179fe1 plugins: lsps: replace owned types by references
Improves flexibility in transport implementations.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30