Commit graph

2298 commits

Author SHA1 Message Date
Peter Neuroth
2971f5d956 lightningd: add channel_id filter to listpeerchannels
Sometimes we don't know the short_channel_id yet (e.g the channel has
not been broadcasted), but we still know the channel_id from the funding
transaction. Add a channel_id filter to listpeerchannels and clarify
that id, short_channel_id and channel_id are mutually exclusive.

Changelog-Added: `listpeerchannels` now accepts a `channel_id` filter,
for cases where the `short_channel_id` is not known yet.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2026-02-24 16:51:59 +01:00
Rusty Russell
b1031e5637 Makefile: support overriding of CC and CARGO for catching unintended builds.
For CI we want to make sure we don't rebuild.  CC=false doesn't work because
we reply on the output of "$CC -dumpmachine" for the external build directory.

So we would use:

	make CC=devtools/cc-nobuild CARGO=false

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-02-24 11:54:04 +10:30
Rusty Russell
e9a7c942a2 plugins: neaten rust plugins, make them intermediate objects.
This keeps it simpler for future expansion, and also means we won't
rebuild them as much.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-02-24 11:54:04 +10:30
Rusty Russell
9fa7c937ea offers: only use blinded path nodes from offers when creating invoice for invoice_request.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-02-23 19:05:37 +10:30
Rusty Russell
64e4519288 offers: allow explicit fronting nodes for an offer.
The next commit makes us honor these when issuing a payment.

Changelog-Added: JSON-RPC: `offer` now has a `fronting_nodes` option to specify neighbors for payer to use to fetch invoices and make payments.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-02-23 19:05:37 +10:30
Rusty Russell
cff488d406 offers: honor payment-fronting-nodes when creating invoice_requests.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-02-23 19:05:37 +10:30
Rusty Russell
ae21089a77 offers: honor payment-fronting-nodes when creating invoices.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-02-23 19:05:37 +10:30
Rusty Russell
25e2374f76 offers: modify find_best_peer() to only select from fronting nodes if set.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-02-23 19:05:37 +10:30
Rusty Russell
9eee744df3 lightningd: honor payment-fronting-node when making bolt12 offers.
We use all the fronting nodes when creating offers.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-02-23 19:05:37 +10:30
Rusty Russell
572d4db8fc offers: encapsulate globals in plugin_get_data()
This is how modern plugins do it, and it has the benefit of not
requiring extra code for memleak tracking.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-02-23 19:05:37 +10:30
Rusty Russell
c168f6a7fe libplugin: support multi options.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: libplugin: support for options which accumulate if specified more than once ("multi": true).
2026-02-23 19:05:37 +10:30
Lagrang3
580c2f7854 renepay: refactor and bugfixes
We remove the auxiliary RPC renesenday (only used internally) in favor
of a function that builds the onion, stores the shared secrets
needed to recover the onion reply, and calls sendonion/injectpaymentonion.

This solves a concurrency race
```
**BROKEN** plugin-cln-renepay: Unable to parse sendpay_failure
```
in which we are waiting for renesenday to return in order to record the shared
secrets but we get the a sendpay_failure notification with an onionreply
before we have secrets to decode it.

It also solves a missing JSON id seen in the logs
```
DEBUG   plugin-cln-renepay: JSON reply with unknown id
```
because renesendpay was using his command variable to issue an RPC
to sendonion/injecpaymentonion and would fail or succeed the command
before those RPCs were done. This also meant that the callback
functions were silently being ignored.

Changelog-Fixed: renepay: fixes a race condition that leads to **BROKEN** plugin-cln-renepay: Unable to parse sendpay_failure

Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
2026-02-23 14:32:56 +10:30
Rusty Russell
d5c2c486f1 askrene: close files in child to isolate against bugs.
This makes sure it cannot interfere with the parent askrene's
connection to lightningd, for example.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-02-19 17:04:35 +10:30
Rusty Russell
6903cf2efb askrene: make "child.c" to be the explicit child entry point.
The fork logic itself is pretty simple, so do that directly in
askrene.c, and then call into "run_child()" almost as soon as
we do the fork.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-02-19 17:04:35 +10:30
Rusty Russell
3c6504a99e askrene: limit how many children we have.
Queue them before we query local channels, so they don't use stale
information.

Changelog-Added: Config: `askrene-max-threads` to control how many CPUs we use for routing (default 4).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-02-19 17:04:35 +10:30
Rusty Russell
fb4232dff8 askrene: actually run children in parallel.
Changelog-Changed: Plugins: `askrene` now runs routing in parallel.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-02-19 17:04:35 +10:30
Rusty Russell
68b30b1e5d askrene: have child make struct route_query internally.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-02-19 17:04:35 +10:30
Rusty Russell
b002824217 askrene: move route_query definition and functions into child/.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-02-19 17:04:35 +10:30
Rusty Russell
85c9179f77 askrene: expose additional_costs htable so child can access it.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-02-19 17:04:35 +10:30
Rusty Russell
0f575ac85a askrene: remove non child-friendly fields from struct route_query.
Notably no access to the struct command and struct plugin.

Note: we actually *do* mess with askrene->reserves, but the previous code
used cmd to get to it.  Now we need to include a non-const pointer in
struct route_query.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-02-19 17:04:35 +10:30
Rusty Russell
ac9aa975ad askrene: make children use child_log() instead of rq_log.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-02-19 17:04:35 +10:30
Rusty Russell
33e2f0a47b askrene: move fork() entry point into its own file.
Now there's only one file clearly shared by both parent and child.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-02-19 17:04:35 +10:30
Rusty Russell
395261fc30 askrene: move fmt_flow_full from askrene.c into flow.c.
Weird that it was in askrene.c

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-02-19 17:04:35 +10:30
Rusty Russell
8775b62871 askrene: move routines only accessed by the child process into child/.
We want to make it clear when future generations edit the code, which
routines are called in the child (i.e. all the routing), and which in
the parent.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-02-19 17:04:35 +10:30
Rusty Russell
da2f77767c askrene: add child_log function so child can do logging.
We just shim rq_log for now, but we'll be weaning the child process off
that soon.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-02-19 17:04:35 +10:30
Rusty Russell
0ede29b81f askrene: fork before calling the route solver.
This is fairly simple.  We do all the prep work, fire off the child,
and it continues all the way to producing JSON output (or an error).
The parent then forwards it.

Limitations (fixed in successive patches):

1. Child logging currently gets lost.
2. We wait for the child, so this code is not a speedup.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-02-19 17:04:35 +10:30
Rusty Russell
e397b12282 askrene: make minflow() static, and remove unused linear_flow_cost.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-02-19 17:04:35 +10:30
Rusty Russell
d9774e73dc bitcoin: hash_scid and hash_scidd public functions.
We reimplemented this redundantly: hash_scid was called
short_channel_id_hash, so I obviously missed it.

Rename, and implement hash_scidd helper too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-02-19 17:04:35 +10:30
Rusty Russell
9bcac63414 libplugin: add command_finish_rawstr() for when we're simply repeating an entore response.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-02-19 17:04:35 +10:30
dovgopoly
2b39fc0cb4 bcli: replace magic numbers with constants 2026-02-18 14:16:29 +10:00
dovgopoly
4126f3b1fe bcli: refactor wait_and_check_bitcoind and run_bitcoin_cli to use shared execution
Extract `execute_bitcoin_cli` as shared function used by both `run_bitcoin_cli` and `wait_and_check_bitcoind`.
2026-02-18 14:16:29 +10:00
dovgopoly
d727946b14 bcli: return "not found" on any getblockhash exit status
Return "not found" on any `getblockhash` exit status. Previously, only exit code 8 (block height doesn't exist) returned "not found", while other exit codes returned an error. Now any non-zero exit status returns "not found" since any failure means the block is unavailable.
2026-02-18 14:16:29 +10:00
dovgopoly
57d60c025b bcli: remove unused async code after sync refactor
Remove the asynchronous execution infrastructure no longer needed after converting all bcli commands to synchronous execution. This includes removing the async callbacks, the pending request queue, etc.

Fix missing `close(from)` file descriptor leak in `run_bitcoin_cliv`.

Changelog-Changed: bcli plugin now uses synchronous execution, simplifying bitcoin backend communication and improving error handling reliability.
2026-02-18 14:16:29 +10:00
dovgopoly
b5c300a82b bcli: convert getrawblockbyheight to synchronous execution
Also rename command_err_badjson to generic command_err helper, since error messages aren't always about bad JSON (e.g., "command failed" for non-zero exit).
2026-02-18 14:16:29 +10:00
dovgopoly
d06024cef7 bcli: convert estimatefees to synchronous execution
Add `command_err_badjson` helper for sync error handling, mirroring the async `command_err_bcli_badjson`. Store args string in `bcli_result` for consistent error messages.
2026-02-18 14:16:29 +10:00
dovgopoly
0de1350706 bcli: convert sendrawtransaction to synchronous execution 2026-02-18 14:16:29 +10:00
dovgopoly
a3e07f4f3a bcli: convert getutxout to synchronous execution 2026-02-18 14:16:29 +10:00
dovgopoly
f8c7a20403 bcli: convert getchaininfo to synchronous execution 2026-02-18 14:16:29 +10:00
dovgopoly
fad05200eb bcli: add synchronous run_bitcoin_cli for future refactor 2026-02-18 14:16:29 +10:00
Rusty Russell
29e0a1ddfe bkpr: limp along if we lost our db.
We can't really do decent bookkeeping any more, but don't crash!

```
bookkeeper: plugins/bkpr/recorder.c:178: find_txo_chain: Assertion `acct->open_event_db_id' failed.
bookkeeper: FATAL SIGNAL 6 (version v25.12)
0xaaaab7d51a7f send_backtrace
	common/daemon.c:38
0xaaaab7d51b2b crashdump
	common/daemon.c:83
0xffff8c0b07cf ???
	???:0
0xffff8bdf7608 __pthread_kill_implementation
	./nptl/pthread_kill.c:44
0xffff8bdacb3b __GI_raise
	../sysdeps/posix/raise.c:26
0xffff8bd97dff __GI_abort
	./stdlib/abort.c:79
0xffff8bda5cbf __assert_fail_base
	./assert/assert.c:96
0xffff8bda5d2f __assert_fail
	./assert/assert.c:105
0xaaaab7d41fd7 find_txo_chain
	plugins/bkpr/recorder.c:178
0xaaaab7d421fb account_onchain_closeheight
	plugins/bkpr/recorder.c:291
0xaaaab7d37687 do_account_close_checks
	plugins/bkpr/bookkeeper.c:884
0xaaaab7d38203 parse_and_log_chain_move
	plugins/bkpr/bookkeeper.c:1261
0xaaaab7d3871f listchainmoves_done
	plugins/bkpr/bookkeeper.c:171
0xaaaab7d4811f handle_rpc_reply
	plugins/libplugin.c:1073
0xaaaab7d4827b rpc_conn_read_response
	plugins/libplugin.c:1377
0xaaaab7d889a7 next_plan
	ccan/ccan/io/io.c:60
0xaaaab7d88f7b do_plan
	ccan/ccan/io/io.c:422
0xaaaab7d89053 io_ready
	ccan/ccan/io/io.c:439
```

Fixes: https://github.com/ElementsProject/lightning/issues/8854
Changelog-Fixed: Plugins: `bkpr_listbalances` no longer crashes if we lost our db, then do emergencyrecover and close a channel.
Reported-by: https://github.com/enaples
2026-02-17 12:10:26 +10:30
Rusty Russell
e8fd235d4e common: move gossip_store_wire.csv into common/ from gossipd/
It's used by common/gossip_store.c, which is used by many things other than
gossipd.  This file belongs in common.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-02-16 17:23:33 +10:30
Rusty Russell
6a937307b1 decode: don't treat every failure as a rune.
If we can't decode something, and it decodes as a rune (and all bech32
strings do!), then we would usually just complain it was a malformed
rune.  Be a big more useful, when the parameter looks like somthing else.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: JSON-RPC: `decode` is now more informative with malformed strings (won't claim everything is a malformed rune!).
2026-02-03 13:05:23 +10:30
Lagrang3
f1bf66c91f askrene: fixed a timeout corner case
Changelog-Fixed: askrene: fixed a class of corner cases that cause askrene main loop to timeout instead of quickly failing, thus wasting runtime.

Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
2026-02-02 10:23:27 +10:30
Lagrang3
41a5c68aa8 askrene: consider fees during *explain failure*
We would try to explain a failure by simply finding a path between
source and destination and then checking the constraints.
However, we did not add fees.

Changelog-None

Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
2026-02-02 10:23:27 +10:30
Lagrang3
3822a67030 askrene: add auto.include_fees layer
Changelog-Added: askrene: add a new layer auto.include_fees thhat makes fees be deducted from the payment amount making in effect the receiver pay for routing fees.

Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
2026-01-29 15:20:25 +10:30
Rusty Russell
a3946663ec askrene: speed up when using large number of layers.
Simple bench.

Before:
   Creating 20,000 layers:  20 seconds
   Creating 50,000 layers:  107 seconds

After:
   Creating 20,000 layers:  7 seconds
   Creating 50,000 layers:  15 seconds
   Creating 100,000 layers: 29 seconds

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-01-27 13:59:36 +10:30
Se7enZ
70fe02513c build: Replace PLUGIN_RENEPAY_HDRS json.c with json.h in Makefile. 2026-01-24 09:40:49 +10:00
Rusty Russell
d5f66ceabc plugins: don't try to fetch max-locktime-blocks.
It was removed in v25.09, so this code is useless.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-01-20 19:32:42 +10:30
Rusty Russell
9081499b0e libplugin: fix 'i-promise-to-fix-broken-api-user' parsing.
This is important for the first xpay deprecation end-of-life!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-01-20 19:32:42 +10:30
daywalker90
d03cf820a8 clnrest: add clnrest-register-path method for dynamic paths
Changelog-Added: clnrest: add clnrest-register-path rpc method to register dynamic paths
2026-01-19 12:55:57 +10:30