Commit graph

2421 commits

Author SHA1 Message Date
Lagrang3
03e5d22a95 libplugin: add helpers for multi-string options
Changelog-None

Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
2026-05-11 15:43:30 +09:30
Rusty Russell
6eb7dc0428 renepay: deprecate.
I think Eduardo and I stole all the best bits to make xpay and askrene.

I simply enabled deprecations on all the renepay tests.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-05-11 13:51:52 +09:30
Rusty Russell
ed42adc9e4 plugins: move listpays from pay plugin to xpay plugin.
This will make life easier when we remove the pay plugin, but also fixes
an issue where `listpays` can indicate ongoing payments are failed,
even though xpay is still working on it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-05-11 13:51:52 +09:30
Rusty Russell
560b016584 xpay: keep track of ongoing payments, to implement attempt_ongoing()
This will help when we implement listpays (next) to be xpay-aware.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-05-11 13:51:52 +09:30
Rusty Russell
98315531fa keysend: deprecate in favor of xkeysend.
Changelog-Deprecated: JSON-RPC: `keysend` (use `xkeysend`).  `xkeysend` will take over `keysend` in v27.03.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-05-11 13:51:52 +09:30
Rusty Russell
e657552058 getroute: deprecate in favor of getroutes
Changelog-Deprecated: JSON-RPC: `getroute` (use `getroutes` with layers `["auto.localchans","auto.sourcefree"]` and `maxparts=1`) (since v25.09).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-05-11 13:51:52 +09:30
Rusty Russell
eebc6eea00 pay: deprecate pay and paystatus.
Use xpay and listpays.

Some tests which are pay/paystatus specific simply enabled deprecations.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Deprecated: JSON-RPC: `pay` and `paystatus`: use `xpay`, `listpays` (or `xpay`'s notifications for details of attempts).  `pay` will be replaced by `xpay` in v27.03.
2026-05-11 13:51:52 +09:30
Rusty Russell
68d700c609 pay: accept invstring as first parameter name.
If you don't use complex pay options, you can use `invstring` now and when xpay
becomes pay, there's no transition.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: JSON-RPC: `pay` now accepts `invstring` as a parameter name for `bolt11`, to ease transition when xpay takes over in v27.03.
2026-05-11 13:51:52 +09:30
Rusty Russell
afea38138d xpay: take over pay invocations by default.
The main change here is the error messages got better.  Where that was
the case, and the test was not completely redundant with existing xpay
tests, I explicitly converted to calls to xpay (meaning the tests
will be kept when `pay` is finally removed).

Test changes:
1. deschash checking is old-pay only, keep that there.
2. Add debug logs for checks for using forwarding via scid in injectpaymentonion.
3. Don't assert that not all sendpays should have the invoice string: xpay does not try to be clever there.
4. We no longer check if invoices are already paid before routing, since injectpaymentonion will catch that for us.
5. Removed `test_pay_get_error_with_update` which has xpay equiv.

Changelog-Changed: JSON-RPC: `xpay` now handles `pay` command by default (use `xpay-handle-pay=false` to prevent this)
Changelog-Removed: JSON-RPC: `exclude` parameter to `pay` (when `xpay-handle-pay` is True): craft a layer with desired modifications and pass it to `xpay` `layers`.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-05-11 13:51:52 +09:30
Rusty Russell
a488711de3 offers: use xpay.
Changelog-Changed: offers: we now use `xpay` not `pay` for paying invoices made with invoicerequest().
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-05-11 13:51:52 +09:30
Rusty Russell
78721c7fcb xpay: add xkeysend support.
This uses askrene, so it benefits from previous payment experience.

Changelog-Added: JSON-RPC: `xkeysend` command for keysend with modern routing support.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-05-11 13:51:52 +09:30
Rusty Russell
183e1a0e60 getroutes: deprecate old vaguely named fields.
Changelog-Deprecated: JSON-RPC: `getroutes` `route` fields `next_node_id`, `amount_msat` and `delay` (use `node_id_out`, `amount_in_msat` and `cltv_in`).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-05-11 13:51:52 +09:30
Rusty Russell
6206d02d7d getroutes: return more detailed fields in routes[].
This reflects a long-standing complaint from @lagrang3 when the API
was first implemented, and I should have listened.  In particular, the
impedance mismatch with the sendpay API is annoying.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: JSON-RPC: `getroutes` `route` explicit fields `node_id_in`, `node_id_out`, `amount_in_msat`, `amount_out_msat`, `cltv_in`, `cltv_out`.
2026-05-11 13:51:52 +09:30
Rusty Russell
26e8f346c9 askrene: populate struct route with more complete information.
Much of this is redundant, but now it's better labeleled and stands alone.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-05-11 13:51:52 +09:30
Rusty Russell
7c89e23ce8 xpay: ensure unique_id is always valid.
In implementing shadow, I added a call to payment_log in xpay_core,
which caused a valgrind error because we set unique_id later.  This
was a premature optimization, so we didn't assign unique_id for
payments which didn't even start, but it's a footgun, and there are
other (less common) calls to payment_log too early which make the same
mistake.

Simplify: unique_id is assigned at creation.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-05-11 13:51:52 +09:30
Rusty Russell
48b378694c xpay: when acting as pay, imitate its idempotent behavior.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-05-11 13:51:52 +09:30
Rusty Russell
d600fed04f xpay: correctly identify final node when using a dummy blinded path.
We would get WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS in this case if
the invoice was unknown, and think it weird because it came from an
intermediate node.  In practice the result is the same (as it would remove
the blinded path), but it was misleading.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-05-11 13:51:52 +09:30
Rusty Russell
69b9d22da5 xpay: return the correct (documented!) error code on repeat payments.
The man page says 219, but we didn't return that.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: JSON-RPC: `xpay` now correctly returns error code 219 on already paid invoices (not 218).
2026-05-11 13:51:52 +09:30
Rusty Russell
72f4cae866 xpay: add a CLTV shadow for single non-blinded paths.
BOLT 7 recommends this.  pay did it: in fact, pay would also add sats,
but that's much more difficult and fraught, so only do CLTV.

Changelog-Added: Protocol: `xpay` now uses shadow CLTV additions to help mask final destination as per BOLT 7.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-05-11 13:51:52 +09:30
Rusty Russell
1529b2b639 xpay: process channel_update from error for the current payment.
Applying it globally as `pay` did risks leaking information, but applying
it for retries doesn't really.  And doing that is fairly easy with layers.

Changelog-Added: Protocol: `xpay` will now update for the current payment if it gets a `channel_update` in an error message.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-05-11 13:51:52 +09:30
Rusty Russell
6da85381ff xpay: handle localinvreqid and label parameters when we're called as pay.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-05-11 13:51:52 +09:30
Rusty Russell
1a9631c59b xpay: add label and localinvreqid params
This bring us closer to pay parity, and `localinvreq` is needed for
invoicerequest payments.

Changelog-Added: JSON-RPC: `xpay` now accepts `label` and `localinvreqid` parameters (like `pay`).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-05-11 13:51:52 +09:30
Rusty Russell
09ff5ed657 xpay: add extra_tlvs support (unused for now).
This adds them to the final onion (but it's always NULL for now).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-05-11 13:51:52 +09:30
Rusty Russell
b70fd6e334 xpay: extract payment creation logic.
Simple refactor so we can use it for `xkeysend` too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-05-11 13:51:52 +09:30
Rusty Russell
f27b6d3f99 xpay: remove internal "disable_mpp" flag.
We already have `maxparts`: simply set that to 1 for the same effect.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-05-11 13:51:52 +09:30
Rusty Russell
052386abaf askrene: deprecate auto.no_mpp_support layer in favor of maxparts=1.
This layer predated the maxparts parameter.

Changelog-Deprecated: JSON-RPC: `getroutes` layer `auto.no_mpp_support`: use `maxparts=1` parameter instead (available since v25.09).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-05-11 13:51:52 +09:30
Rusty Russell
3e4af7de03 askrene: make failure messages clearer:
If all channels are disabled, say so clearly.  Also reword: it's not
the source or destination which have disabled the channels.  While
we're here, remove the double space, lest people think I'm Satoshi.

Before:
	Failed after 1 attempts.
	Unexpected error (invalid_onion_payload) from final node: disabling 103x1x0/1 for this payment.
	Then routing failed: We could not find a usable set of paths.  The source has disabled 1 of 1 channels, leaving capacity only 0msat of 1000000000msat.

After:
	Failed after 1 attempts.
	Unexpected error (invalid_onion_payload) from final node: disabling 103x1x0/1 for this payment.
	Then routing failed: We could not find a usable set of paths. All 1 channels to the source are disabled.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-05-11 13:51:52 +09:30
Rusty Russell
b74305b52b askrene: improve errors we return.
In particular, we can return PAY_ROUTE_TOO_EXPENSIVE.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-05-11 13:51:52 +09:30
Rusty Russell
a577e53097 askrene: all remove_small_channel_layer when maxparts=1.
We were doing it for "auto.no_mpp_support", but not maxparts=1.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-05-11 13:51:52 +09:30
Rusty Russell
427ee36dfd common: implement tal_arr_append and tal_arr_appendn, and use them.
These are useful for the common pattern of "append these bytes to this tal array".

As a bonus, we do memcheck() on all these callers, for extra checking
under valgrind.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-05-11 13:51:52 +09:30
Rusty Russell
86f459511f update-mocks: make handling of mocks in nested files deterministic.
update-mocks searches for prototypes, looking first in the local
directory, then in */*.h, and takes the first.  In the case of
plugins/bkpr/test/run-currencyrate_str.c referring to
jsonrpc_request_start_, this means it could get either the one in
libplugin (correct) or the one in lightningd (wrong!), depending on
directory order randomness.

Hack it a bit harder, to look one up from the local dir before */*.h.
This is redundant in most cases, but not for three-deep-nested dirs
like this.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-05-11 13:51:52 +09:30
Rusty Russell
9dda3eecb8 offers: add createproof API.
Changelog-EXPERIMENTAL: JSON-RPC: `createproof` to create a payment proof for a (successful) BOLT12 payment.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-05-11 11:13:55 +09:30
Vincenzo Palazzo
d477db45df common: add bolt12 payer proof support (decode)
[Adapted for my decode routines --RR]
Changelog-EXPERIMENTAL: JSON-RPC: `decode` now supports the `lnp` payer proof format.
2026-05-11 11:13:55 +09:30
Rusty Russell
1189175cbc common/bolt12: use a const char * for fail reason.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-05-11 11:13:55 +09:30
Rusty Russell
c23ee37567 decode: fix decode on recurring offers.
We no longer have offer_recurrence, we have
offer_recurrence_compulsory and offer_recurrence_optional.  Decode was
changed in v25.12, but we never properly tested it (recurrence is
experimental, after all).

I opted for simplicity over truth here, and simply modified decode to
match the schema, but add a "compulsory" flag.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-05-11 11:13:55 +09:30
Rusty Russell
bf55e580d6 decode / bolt12-cli: add missing invreq_recurrence_cancel field.
We missed this.  It's experimental, so no changelog needed.

Spotted-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-05-11 11:13:55 +09:30
Vincenzo Palazzo
16cf06b4ba txprepare: fix withdraw returning unsigned transaction
The withdraw command was returning an unsigned raw transaction in
its 'tx' response field. This happened because signpsbt_done() used
psbt_txid() to extract utx->tx, which internally calls
wally_psbt_extract() with WALLY_PSBT_EXTRACT_NON_FINAL — stripping
all signature and witness data.

The broadcast itself succeeded because sendpsbt internally finalizes
the PSBT via psbt_final_tx(), but the 'tx' field returned to the
user had empty scriptSigs and no witness data.

This is a regression from 908f834d6 ("Update libwally to 0.8.8,
support PSBTv2") which rewrote psbt_txid() from manually copying
final_scriptsig/redeem_script into the cloned tx, to using
wally_psbt_extract(WALLY_PSBT_EXTRACT_NON_FINAL) which strips all
signing data by design.

Fix by finalizing the signed PSBT in signpsbt_done() and extracting
the fully signed transaction via psbt_final_tx(). The txid
verification still uses psbt_txid() (which is correct for txid
computation since txids exclude witness data).

Fixes: https://github.com/ElementsProject/lightning/issues/8701
Changelog-Fixed: withdraw now returns a fully signed transaction in the `tx` response field.
Signed-off-by: Vincenzo Palazzo <vincenzopalazzo@member.fsf.org>

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-09 17:06:10 +09:30
Aditya Sharma
a1f907ce52 chanbackup: Store the latest recvd peer storage only
Node should not store SCB that is older than what we already have.

Changelog-Fixed: Protocol: we now only store the most recent peer backup when recovering from peers.
2026-05-07 12:36:26 +10:00
Aditya Sharma
98ba9eb23e chanbackup: make getemergencyrecoverdata rpc more verbose
Adding more information to geremergencyrecoverdata, to let users know if they are using
legacy file format and the list of all the backed up channel ids.

Key Changes:
 - Added:
   1. can_create_penalty: To let user know if they need to update the file.
   2. backed_up_channel_ids: List of all the backed up channels

Changelog-Changed: Made getemergencyrecoverdata more verbose.
2026-05-07 12:36:26 +10:00
Lagrang3
8c2821e8e8 xpay: fix reported value of amount_sent_msat
Changelog-None

Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
2026-05-07 12:00:10 +09:30
Rusty Russell
00ff0a0b26 bech32: check for invalid/unnecessary trailing bits.
There's a new test for bolt12 in commit 7153bed9705d7493 ("BOLT 12:
add test vector for invalid bech32 padding (#1312)") which requires us
to b stricter in decoding.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-04-30 20:09:31 +09:30
Rusty Russell
e37096494d xpay: don't use MPP for bolt12 unless the invoice explicitly supports it.
We actually changed this by default last release, and nobody noticed!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-04-30 20:09:31 +09:30
Rusty Russell
c6f18ff705 global: more missing BOLT quotes.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-04-30 12:17:43 +09:30
Rusty Russell
0759a3a495 global: add the "easy" missing quotes.
Claude messed up about half of these: putting them too far from the
appropriate code.  After this I did it myself.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-30 12:17:43 +09:30
Rusty Russell
de23003f80 Update outdated BOLT quotes in HTLC/closing handling.
Mose of these are from the stricter `...` which won't cross section
boundaries.  The listoffers_done doesn't actually need the ellipsis at
all.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-04-30 12:17:43 +09:30
Rusty Russell
69f1e72021 Fix C comments which will accidentally trigger Python BOLT quote checker.
We're going to get stricter, so "/* BOLT #N to-local output */" or "/* BOLT11 ... */"
will upset it.

Also remove a stray bare blank line in a BOLT comment block.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-04-30 12:17:43 +09:30
Dusty Daemon
30a6b4c41a splice-script: Round channel balances down
When getting channel balances, we round off the msats for splice script.

Changelog-Fixed: Fix for `splicein`, `spliceout`, and `dev-splice` commands where channel balances included partial sats.
2026-04-29 11:43:27 +09:30
Sangbida Chaudhuri
6f4fd1bd97 lightningd: fix format specifier for bitcoin_tx_weight
Replaces %lu in channeld and spender splice calc_weight output so
format matches size_t;

Changelog-Fixed: Builds on linux/amd64 to push to Dockerhub
2026-04-25 07:35:15 +10:00
Rusty Russell
93ff0fe99b bookkeeper: don't use int128.
32-bit ARM doesn't like it :(

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: Build: we now build on 32 bit systems again.
2026-04-25 07:33:42 +10:00
daywalker90
193afeb81b lsps: remove unmaintained crate paste
Instead we use a more verbose approach of requiring an additional name input

Changelog-None
2026-04-24 19:38:53 +02:00