Commit graph

1654 commits

Author SHA1 Message Date
Rusty Russell
cb2c4963f2 bolt12: allow first_node_id in blinded path to be a scid.
We don't actually support it yet, but this threads through the type change,
puts it in "decode" etc.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-12 19:11:43 -05:00
Rusty Russell
1b9b160108 common: move json_to_blinded_path into its own file.
It's fairly obscure, and let's not make everyone link it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-12 19:11:43 -05:00
Rusty Russell
7eb72c5924 plugins/fetchinvoice: remove "blindedpath" command altogether, since we're the only user.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-12 19:11:43 -05:00
Rusty Russell
3e37a755cd lightningd: move undocumented "blindedpath" command into fetchinvoice plugin.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-12 19:11:43 -05:00
Rusty Russell
e30c835f72 common: add sciddir_or_pubkey type.
This is proposed to be added to bolt 12, so we need a type to
represent it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-12 19:11:43 -05:00
Alex Myers
db3d9e9250 dualopend: remove min_witness_weight requirement
Also fix move on uninitialized value
2024-05-09 16:14:23 -05:00
Rusty Russell
68da238b31 multifundchannel: where does this minimum weight appear in the BOLTs?
I can't find such a quote, and I'm not sure if this is correct?

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-09 16:14:23 -05:00
Rusty Russell
cca784c9d0 BOLT: update to include 2016 for max_htlc_cltv.
And deprecate the --max-locktime-blocks which allows them to set it.

Hilariously, the spec misspells CLTV as CTLV at one point, so we work around it for now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-09 16:14:23 -05:00
Christian Decker
c5faae4d71 pay: Enable chainlag offset in direct override paymod 2024-05-08 23:18:27 -05:00
Christian Decker
ff0b7488eb pay: Implement offset and chainlag computation when paying
This actually uses the `chainlag` to make unsynced payments possible.
2024-05-08 23:18:27 -05:00
Christian Decker
4d27efc039 pay: Add the chainlag to the payment
The `chainlag` is defined as the positive difference between the
height of the last block processed by the node and the best height
known by the bitcoin backend. The chainlag is positive when we are
still catching up with the blockchain, and `0` otherwise.

The `chainlag` is used as an additional offset to the CLTV values when
sending payments, allowing payments to be sent even before the chain
sync completes.
2024-05-08 23:18:27 -05:00
Christian Decker
a7f4c28f5e pay: Remove the waitheight paymod
It is getting replaced with a paymod that adjusts the chain height
used to offset all calculations from.
2024-05-08 23:18:27 -05:00
Lagrang3
7335777595 renepay: fix some memory leaks 2024-05-08 22:32:13 -05:00
Lagrang3
7b18056b09 renepay: fix sources 2024-05-08 22:32:13 -05:00
Lagrang3
985a01b41d renepay: wake-up result collector every 50msec 2024-05-08 22:32:13 -05:00
Lagrang3
014e32ca2f renepay: a bit more verbose information in logs 2024-05-08 22:32:13 -05:00
Lagrang3
e97e6ede41 renepay: update test files 2024-05-08 22:32:13 -05:00
Lagrang3
16d00e09ef renepay: bug fix, local channel information
Listpeerchannels would update the local channel information setting the
liquidity in the outgoing channel to known_min=known_max=capacity,
when in fact it should be known_min=known_max=spendable.
2024-05-08 22:32:13 -05:00
Lagrang3
4adf9b4080 renepay: bug fix on the routebuilder
The route-builder checks the liquidity bounds of each route one at a
time. Every route that satisfy the contraints is recorded in the
uncertainty network and produces an HTLC burden on the channels it uses,
so that the following routes cannot count on the same liquidity twice.
2024-05-08 22:32:13 -05:00
Lagrang3
da00cae30b renepay: remove payment from route
Routes contain only routing information and the payment they're linked
to can be obtained through the payment_hash. We remove the dependency of
route building routines from the payment itself. In order to make
plain payment information available we define a payment_info structure.
2024-05-08 22:32:13 -05:00
Lagrang3
ca2b4e54ae renepay: add disabledmap abstraction
Define a new object called disabledmap that carries information about
the disabled channels and nodes.
2024-05-08 22:32:13 -05:00
Lagrang3
96bd0e455b renepay: refactor routefail
- use switch case over all possible WIRE_* errors,
- remove the virtual machine for routefail, use a simple two step
  solution: 1. update the gossip and 2. handle error cases
2024-05-08 22:32:13 -05:00
Lagrang3
cafc08be1d renepay: disable channels not in chan_extra_map
Expand the disabled set to include channels that are not present in the
chan_extra_map/uncertainty network.
2024-05-08 22:32:13 -05:00
Lagrang3
d2c44fc3df renepay: add a test for routehints 2024-05-08 22:32:13 -05:00
Lagrang3
761c295199 renepay: uncertainty network update revisited
- Update the uncertainty network with the gossmap+local_gossmods,
- ignore channels that fail to give their capacity.
2024-05-08 22:32:13 -05:00
Lagrang3
9f13621de9 renepay: pay selfpayments on spot
Resolve a selfpayment right from the result of `sendpay` instead of
waiting for the notification.
2024-05-08 22:32:13 -05:00
Lagrang3
fa199e21d2 renepay: minor fixes 2024-05-08 22:32:13 -05:00
Lagrang3
0e2660733f renepay: update unit tests 2024-05-08 22:32:13 -05:00
Lagrang3
1ee157f02b renepay: update the Makefile 2024-05-08 22:32:13 -05:00
Lagrang3
cc00d509b1 renepay: add a helper module json.c 2024-05-08 22:32:13 -05:00
Lagrang3
73c6142965 renepay: add error codes
Using enum renepay_errorcode simplifies the low level API of chan_extra and flow.
We can extract information about the nature of a function call failure
from its return value.
2024-05-08 22:32:13 -05:00
Lagrang3
7584629696 renepay: add routefail.c
Routefail consist mainly of an API `routefail_start` that handles the
failure of a forwarding request (encoded in a route). Internally there
is a routefail datastructure that goes through a series of execution
steps, eg. updating the gossmap, updating the uncertainty network, etc.
2024-05-08 22:32:13 -05:00
Lagrang3
480dec58f2 renepay: add routetracker.c
Routetracker is a structure that is used to follow the progress of the
route forwarding requests.
2024-05-08 22:32:13 -05:00
Lagrang3
84651fa4ba renepay: add routebuilder.c
Routebuilder constitute the module that builds the routes we try in the
payment. The public API is simply `get_routes`, it replaces the similar
interface for pay_flows.
2024-05-08 22:32:13 -05:00
Lagrang3
6766acbcdf renepay: payment state machine (mods)
Add a new implementation of the payment state machine.
This is based in the `pay` plugin concept of payment modifiers,
but here we take it to the next level.
The payment goes through a virtual machine that includes calling
functions and evaluating conditions.
2024-05-08 22:32:13 -05:00
Lagrang3
4b9fe23293 renepay: the plugin executable is main.c
- move the plugin executable from pay.c to main.c,
- adapt the plugin main program to handle concurrent pay calls,
2024-05-08 22:32:13 -05:00
Lagrang3
190649585f renepay: THE plugin global structure
The plugin global structure is now defined in payplugin.h
2024-05-08 22:32:13 -05:00
Lagrang3
7ffb722b27 renepay: refactor uncertainty API
The uncertainty structure is updated based on the result of a route,
previously chan_extra and pay_flow were used instead.
2024-05-08 22:32:13 -05:00
Lagrang3
2a4a23a362 renepay: rename uncertainty_network for uncertanty 2024-05-08 22:32:13 -05:00
Lagrang3
4c91bc0ef0 renepay: abandon pay_flow for route
The role of the structure pay_flow is not taken by a new structure
called route.
2024-05-08 22:32:13 -05:00
Lagrang3
ba54d678bc renepay: concurrent pay calls
Refactor the payment structure to handle multiple pay requests for the
same or different invoices.
2024-05-08 22:32:13 -05:00
Lagrang3
3cbbaa7ab5 renepay: separate flow and chan_extra
Flow and chan_extra are two different concepts, we keep their
definitions and APIs separate.
2024-05-08 22:32:13 -05:00
Rusty Russell
68c4b83ab1 pay: move preapproveinvoice command out so it can be called bu check.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: JSON-RPC: `check` `keysend` now checks with HSM that it will approve it.
2024-05-06 20:51:19 -05:00
Rusty Russell
e1034eec43 keysend: move preapprovekeysend outside pay loop, so it can be called by check.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: JSON-RPC: `check` `keysend` now checks with HSM that it will approve it.
2024-05-06 20:51:19 -05:00
Rusty Russell
dcbdb85497 libplugin: allow check setconfig on all dynamic options.
We need to pass through setconfig in check mode, then we need to have libplugin
add (and use!) a `check_only` parameter to all option setting.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: JSON-RPC: `check` `setconfig` on plugin options can now check the config value would be accepted.
2024-05-06 20:51:19 -05:00
Rusty Russell
fc21fc56dc libplugin: handle check for our commands.
We don't thoroughly handle `check setconfig`: it would be good to
allow this to do further checking!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-06 20:51:19 -05:00
Rusty Russell
cf72fb418e param: generalize check handling a little.
We want to extend it to plugins, and we want it to be allowed to be async for more power,
so rather than not completing the cmd if we're checking, do it in command_check_done()
and call it.

This is cleaner than the special case we had before, and allows check to us all the
normal jsonrpc mechanisms, especially async requests (which we'll need if we want to
hand check requests to plugins!).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-06 20:51:19 -05:00
Rusty Russell
e3c4bdf209 renepay: fix gcc -O3 overzealous warning.
gcc-12 (Ubuntu 12.3.0-9ubuntu2) 12.3.0 with -O3 gives:

```
In file included from plugins/renepay/test/../mcf.c:5,
                 from plugins/renepay/test/run-arc.c:13:
ccan/ccan/tal/str/str.h: In function ‘minflow’:
ccan/ccan/tal/str/str.h:43:9: error: ‘errmsg’ may be used uninitialized [-Werror=maybe-uninitialized]
   43 |         tal_fmt_(ctx, TAL_LABEL(char, "[]"), __VA_ARGS__)
      |         ^~~~~~~~
plugins/renepay/test/../mcf.c:1565:15: note: ‘errmsg’ was declared here
 1565 |         char *errmsg;
      |               ^~~~~~
cc1: all warnings being treated as errors
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-06 20:51:19 -05:00
Erik De Smedt
f1dc64b802 cln_plugin: Support wildcard subscriptions
Adapts `cln_plugin` to make it support wildcard `*`-subscriptions.
2024-04-30 15:24:00 -05:00
Erik De Smedt
95b98cf0ee cln_plugin: Example package subscribing to "*"
Creates an example package that subscribes to all notifications and logs
them. This is useful for testing the behavior of subscribing to "*".

I've also edited the Makefile to ensure that `make` builds the example
and that `make clean` removes the example
2024-04-30 15:24:00 -05:00