Commit graph

16022 commits

Author SHA1 Message Date
Rusty Russell
da793e66b9 xpay: rename payment_failed to payment_give_up
Eduardo points out that payment_failed kind of over-promises: it may
actually not fail the payment now (with slow mode).

It's more an indiciation that we're not trying any more payment parts,
so rename it to payment_give_up.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-02-20 20:22:54 -06:00
Rusty Russell
43e59a6774 pytest: test xpay gracefully handles failure after success.
We can create this scenario by having one path force close.  We take
the opportunity to log this, even in non-slow-mode, since it's interesting
(not our bug, but someone just lost money!).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-02-20 20:22:54 -06:00
Rusty Russell
f168cb5949 xpay: add xpay-slow-mode to force waiting for all parts before returning.
This was requested by Michael of Boltz; it's mainly useful if you plan to
try failed payments on a *different* node.  In that case, there's a
theoretical possibility that slow parts of this payment could combine with
that from a different node and overpay.

We don't allow this from the same node, already.

Changelog-Added: xpay: `xpay-slow-mode` makes xpay wait for all parts of a payment to complete before returning success or failure.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-02-20 20:22:54 -06:00
Rusty Russell
db1e26eb67 xpay: refactor payment_succeeded.
1. Don't rely on the current attempt, make caller calculate total.
2. Save preimage inside attempt, for slow mode.
3. Hoist it higher in the file.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-02-20 20:22:54 -06:00
Alex Myers
a79dd4ae5f pyln-client: test dev version
Changelog-Changed: pyln-testing is now compatible with older versions of Core Lightning.
2025-02-20 19:40:07 -06:00
Erik De Smedt
dac51930e8 Use check_output instead of run
This is shorter and more readable

Suggested-By: @cdecker
2025-02-20 19:40:07 -06:00
Erik De Smedt
98ac15249e NodeVersion: Fix comparision in CI
When tests CI on occur the version number has the following shape "1a86e50-modded".
We will always assume this is the latest version to make the version
checks pass
2025-02-20 19:40:07 -06:00
Erik De Smedt
752a92130e Print proper error when version comparision fail 2025-02-20 19:40:07 -06:00
Erik De Smedt
50c9dc3095 pyln-testing: Fix compatiblity with old versions 2025-02-20 19:40:07 -06:00
Erik De Smedt
df5d081ed2 Refactor: Provide lightningd in constructor
The fixtures in `tests/fixtures.py` modifies the path to
`lightningd/lightningd`.

I've adapted `pyln-testing` to accept an executable in the constructor.
This approach is more transparant and allows us to use the executable
path to query the version in the constructor.
2025-02-20 19:40:07 -06:00
Erik De Smedt
8e16cb1a16 Support to query version in pyln-client
Introduce a `NodeVersion`-class into `pyln.client`.
This can be used to test if `lighningd` supports the required
functionality
2025-02-20 19:40:07 -06:00
fanquake
e8c8fd4195 docs: update bitcoin core install docs
Changelog-None

Signed-off-by: fanquake <fanquake@gmail.com>
2025-02-20 19:04:22 -06:00
Rusty Russell
d15f5a9b3b lightningd: don't even transiently try to connect to private nodes if --dev-no-reconnect-private.
Christian reported that this flag doesn't work on restart.

Indeed, it made us attempt *transient* rather than *persistent*
connections, but we still told connectd to connect.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: connectd: `dev-no-reconnect-private` is respected on restart.
2025-02-21 11:24:35 +10:30
Rusty Russell
a4e64fac58 pytest: write a test for --dev-no-reconnect-private.
Indeed it fails.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-02-21 11:24:35 +10:30
Rusty Russell
6d142dfad2 pytest: add multiline help test.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-02-20 14:37:28 +10:30
Rusty Russell
44093f09c3 lightning-cli: use human_readable for help messages (unescapes \n for us).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Changed: lightning-cli: `help` messages using new-lines is now printed properly, enhancing readability and consistency.
2025-02-20 14:37:28 +10:30
Rusty Russell
ca0c9e63ad lightningd: insert "raw" (unescaped) help messages from commands.
So if they want a \n in usage, they can have it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-02-20 14:37:28 +10:30
Nishant Bansal
f524f1172f pyln-client: use \n as line separator in lightning-cli help
Changelog-Changed: Interpret \n as the line separator in plugins to enhance the readability of lightning-cli help.

Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
[ Modified to use \n not | --RR ]
2025-02-20 14:37:28 +10:30
Nishant Bansal
eafb6d8c63 pyln-client: remove unused doc variable from plugin.
The `doc` variable was being initialised and processed but not used anywhere.
Changelog-None

Signed-off-by: Nishant Bansal <nishant.bansal.282003@gmail.com>
2025-02-20 14:37:28 +10:30
Lagrang3
f5c8934e22 xpay: reduce log entries on rpc_command hook
Don't print unnecessary log entries every time we receive an rpc_command
hook event. Only log when `pay` is called.

Changelog-None

Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
2025-02-19 16:17:44 -06:00
ShahanaFarooqui
3649a54f04 docs: Lock example values to avoid unnecessary updates in schemas
Changelog-None.
2025-02-19 15:51:44 -06:00
Alex Myers
26359e4c8c pytest: address flakes from blinded paths in bolt12 offers
Following 6e4ff6a, nodes now check for their public address and
generate a blinded path for invoices if the address is not advertized.
This breaks several of the tests where the blinded path is expected
to have the entrypoint be the node itself.

Changelog-None
2025-02-19 10:25:51 -06:00
Rusty Russell
8fedb26e6e pytest: fix test_xpay_bolt12_no_mpp
When we merged blinded paths for nodes with no address
(6e4ff6a7d2), this test
broke.  We need to prevent that, otherwise:

```
>       assert ret['successful_parts'] == 2
E       assert 1 == 2

tests/test_xpay.py:677: AssertionError
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-02-17 17:12:19 +10:30
Erick λ
38b9cb94d3 docs: fix JSON indentation in 'connect' example Changelog-None 2025-02-17 15:59:12 +10:30
daywalker90
5e0a25bca9 cln-grpc, clnrest: workaround for logging before shutdown
Changelog-Fixed: cln-grpc and clnrest errors that cause them to stop will now log
2025-02-14 14:58:00 -06:00
Rusty Russell
4bb7b49f0a pytest: test that we indeed do MPP even if not advertized.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-02-14 22:17:21 +10:30
Rusty Russell
d881c3cf3e offers: fix incorrect name for field.
It wasn't documented, and hopefully nobody was using it.

Changelog-Fixed: `decode` for bolt12 invoices "features" field renamed to "invoice_features" (as documentation said)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-02-14 22:17:21 +10:30
Rusty Russell
e2be010cbb offers: correctly advertize MPP in invoice features.
Turns out we weren't wiring them through!  And libplugin wasn't reading them anyway.

Changelog-Fixed: lightningd: tell plugins our bolt12 features (so our bolt12 invoices explicitly allow MPP).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-02-14 22:17:21 +10:30
Rusty Russell
c718e35359 xpay: in future, don't MPP to pay bolt12 invoices unless invoice explicitly says so.
We don't want to enable this yet, since we only just fixed CLN this release!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-02-14 22:17:21 +10:30
Rusty Russell
7577af0d59 common: if something isn't deprecated yet, it's always ok.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-02-14 22:17:21 +10:30
Rusty Russell
731aa497c3 offers: don't call create_invoicereq twice.
We ignored the second one, but still it's unnecessary.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-02-14 22:17:21 +10:30
Rusty Russell
4ed709f9ec xpay: avoid MPP if invoice does not allow it.
This is deeply annoying, and we may have to support this properly
(using a separate algorithm entirely) if other implementations don't
fix their crap.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: Plugins: xpay: suppress multi-part payment if invoice doesn't allow it (please, fix your nodes!)
2025-02-14 22:17:21 +10:30
Rusty Russell
461eb2eddb askrene: remove all small channels if there's no MPP support.
This is an inefficient hack.  Can you tell I really didn't want to
implement this?  MPP was finalized in 2018 FFS.

We do this by adding another "auto" layer, which removes all too-small
channels, and then makes our MPP node pile all the funds into the largest
channel it chooses.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-02-14 22:17:21 +10:30
Rusty Russell
5b74e98201 pytest: test that xpay doesn't use MPP if invoice doesn't permit it.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-02-14 22:17:21 +10:30
Rusty Russell
6d961f6b13 devtools: allow encode with 9 flag (for features).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-02-14 22:17:21 +10:30
Rusty Russell
91d7394175 askrene: don't include impossible channels in the MCF graph.
In particular, if the total amount we're sending is less than the minimum amount
the channel insists on, we can eliminate it.

This fixes the problem that we're really trying to send a de-minumus
amount (rather than the more obscure case where we divide the amount
and then it is below the minimum).

After trying several other approaches, this was by far the cleanest!

Reported-by: https://github.com/JssDWt
Fixes: https://github.com/ElementsProject/lightning/issues/8045
Changelog-Fixed: xpay: don't simply give up if our total amount is less than htlc_minimum_msat on some channel.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-02-14 15:18:48 +10:30
Rusty Russell
38b9df44b2 pytest: test that askrene doesn't simply give up if we are below htlc_minimum.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-02-14 15:18:48 +10:30
Rusty Russell
6e4ff6a7d2 offers: add a blinded path if we have no advertized address.
Suggested-by: Matt Corallo
Fixes: https://github.com/ElementsProject/lightning/issues/7806
Changelog-Changed: Offers: we will use a blinded path if we have no advertized address (so payers wouldn't be able to connect directly).
2025-02-14 14:18:29 +10:30
Rusty Russell
f806b26734 Makefile: update CLN_NEXT_VERSION.
I should have done this immediately after last release :(.

This turns various things off by default, even if deprecated APIs are enabled.

We remove the test of the to-be-removed params.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Deprecated: Config: `rest-port`, `rest-protocol`, `rest-host` and `rest-certs` disabled by default (use clnrest-*, or `i-promise-to-fix-broken-api-user=rest-port.clnrest-prefix` etc and PLEASE REPORT if you need this!)
Changelog-Deprecated: Config: `max-locktime-blocks` disabled by default (use `i-promise-to-fix-broken-api-user=max-locktime-blocks` and PLEASE REPORT if you need this!)
2025-02-13 21:15:45 -06:00
Rusty Russell
2ffe07b0df lightningd: make i-promise-to-fix-broken-api-user an early option.
Otherwise it doesn't work to fix up other options!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-02-13 21:15:45 -06:00
Rusty Russell
e3c36988ea pytest: add override options to prepare for default removal of rest-port/rest-host options.
Otherwise this test breaks when we change CLN_NEXT_VERSION.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-02-13 21:15:45 -06:00
Rusty Russell
2b3b7fde2c pytest: expect complaints when we use deprecated commando-runes commands.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-02-13 21:15:45 -06:00
Rusty Russell
d18f564324 pytest: stop using deprecated commando_rune commands.
These are about to start logging warnings, so use modern versions for tests
which aren't explicitly about testing obsolete ones.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-02-13 21:15:45 -06:00
Rusty Russell
e81a50e551 pytest: fix change in error msg from latest bitcoind master.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-02-13 21:15:45 -06:00
Rusty Russell
4e568e4f0d testing: don't try to valgrind clnrest, it's Rust.
This happened in CI:

```
algrind error file: valgrind-errors.16800
==16800== Thread 4 tokio-runtime-w:
==16800== Conditional jump or move depends on uninitialised value(s)
==16800==    at 0x2466BF: _ZN175_$LT$axum..middleware..from_fn..FromFn$LT$F$C$S$C$I$C$$LP$T1$C$T2$C$T3$RP$$GT$$u20$as$u20$tower_service..Service$LT$http..request..Request$LT$axum_core..body..Body$GT$$GT$$GT$4call28_$u7b$$u7b$closure$u7d$$u7d$17h4cc36de5dd56d9feE.llvm.119371497468325184 (in /home/runner/work/lightning/lightning/plugins/clnrest)
==16800==    by 0x57BFFA: <axum::middleware::from_fn::ResponseFuture as core::future::future::Future>::poll (in /home/runner/work/lightning/lightning/plugins/clnrest)
==16800==    by 0x37312B: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll (in /home/runner/work/lightning/lightning/plugins/clnrest)
==16800==    by 0x372D8D: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll (in /home/runner/work/lightning/lightning/plugins/clnrest)
==16800==    by 0x372F59: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll (in /home/runner/work/lightning/lightning/plugins/clnrest)
==16800==    by 0x373A88: <tower::util::map_response::MapResponseFuture<F,N> as core::future::future::Future>::poll (in /home/runner/work/lightning/lightning/plugins/clnrest)
==16800==    by 0x32100D: <tower::util::oneshot::Oneshot<S,Req> as core::future::future::Future>::poll (in /home/runner/work/lightning/lightning/plugins/clnrest)
==16800==    by 0x38E326: _ZN91_$LT$axum..routing..route..RouteFuture$LT$E$GT$$u20$as$u20$core..future..future..Future$GT$4poll17h3f11114fc5dd51f8E.llvm.194396656150191000 (in /home/runner/work/lightning/lightning/plugins/clnrest)
==16800==    by 0x372315: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll (in /home/runner/work/lightning/lightning/plugins/clnrest)
==16800==    by 0x372C05: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll (in /home/runner/work/lightning/lightning/plugins/clnrest)
==16800==    by 0x371A15: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll (in /home/runner/work/lightning/lightning/plugins/clnrest)
==16800==    by 0x373A48: <tower::util::map_response::MapResponseFuture<F,N> as core::future::future::Future>::poll (in /home/runner/work/lightning/lightning/plugins/clnrest)
==16800==
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-02-13 20:46:11 -06:00
Lagrang3
a2a186ff29 renepay: change the groupid selection
Searches the first unused groupid and uses that number for the current
payment attempt.
We previously used the highest value of used groupid + 1, which breaks
in a few corner cases.

Changelog-None

Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
2025-02-13 19:16:21 -06:00
Lagrang3
0e98426f02 renepay: names by convention
Change functions json_pay and json_paystatus to json_renepay
and json_renepaystatus to match the conventional naming.
This is helpful for grep searches.

Changelog-None

Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
2025-02-13 19:16:21 -06:00
Lagrang3
ddb62a1114 renepay: bugfix: read groupids as u64
Changelog-Fixed: renepay: read groupids as u64 integers.

Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
2025-02-13 19:16:21 -06:00
Rusty Russell
df24568143 pytest: remove test_slow_startup_many_addresses
As I suspected, benchmark tests like this are too unreliable under CI.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-02-13 15:42:51 -06:00
Rusty Russell
645b202222 wallet: use htable in wallet_add_onchaind_utxo.
On lookup, we update the htable if any new addresses have been added.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: lightningd: startup time vastly improved for large nodes with pending closes and many bitcoin addresses.
2025-02-13 15:42:51 -06:00