Commit Graph

1505 Commits

Author SHA1 Message Date
Rusty Russell
0c7ce27a39 plugins/offers: establish_onion_path can have a simple boolean arg for connect_disable.
It's always the same string, so simplify the interface.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-09 15:09:29 +02:00
Rusty Russell
34052f9960 bitcoin: hoist scid hash into common code.
A second user is coming.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-09 15:09:29 +02:00
Rusty Russell
f64d48e716 plugins/pay: fix crash if we try to self-pay a bolt12 invoice.
It doesn't work but at least now it doesn't crash!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-09 15:09:29 +02:00
Rusty Russell
ec2b626630 plugins/pay: don't crash if getroute is empty.
This can't happen because we go the self-pay path in this case, but
once we fix that for bolt12, this can be reached.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-09 15:09:29 +02:00
ShahanaFarooqui
4b69c57d75 plugins: Remove requirements.txt for python plugins
Removing requirements.txt from clnrest and wss-proxy plugins due to their ever changing dependencies. We will only be dependent on pyproject.toml for more stable results.

Reference: https://github.com/ElementsProject/lightning/pull/7416#issuecomment-2181492069

Changelog-None.
2024-07-03 12:20:05 -07:00
niftynei
c6ac45d743 fundchannel: remove crash on race condition
If the peer sends you their signatures before we return from the *first*
openchannel_update then the state would still be in
MULTIFUNDCHANNEL_STARTED (not UPDATED) and we'd incorrectly switch the
state to MULTIFUNDCHANNEL_SIGNED, which would plunge us headfirst into
`check_sigs_ready`.

However the `mfc->txid` hadn't been set yet, so we'd crash when trying
to confirm that we've got sigs for the correct txid. Oops.

To fix this, we simply invert the check such that the *only* state that
will move into SIGNED is SECURED
2024-07-03 09:11:52 +09:30
ShahanaFarooqui
39626b9f8f clnrest: Fixes ssl_version deprecated warning
Reference Issue #6931: Fixes `Warning: option `ssl_version` is deprecated and it is ignored. Use ssl_context instead.`

Changelog-None.
2024-06-28 10:54:44 +09:30
ShahanaFarooqui
9f599365f9 clnrest: Updated requirements.txt (without coincurve)
As suggested by @cdecker, I compared `poetry show --tree` results from before/after `cd plugins/clnrest/ && poetry export --output requirements.txt && pip install -r requirements.txt` to check for any significant difference. There is no difference in the tree.

But poetry export removed coincurve & other dependencies from clnrest's requirements.txt.

Changelog-None.
2024-06-28 10:46:14 +09:30
Rusty Russell
9fd29d35dd common: move now-enlarged command_fail_badparam into its own source file.
It's getting a bit awkward to inline now: it's non-trivial.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-06-25 08:47:50 +09:30
Rusty Russell
e0e38c2cd5 common: new function command_log to log something about a specific command.
Needs implementations for lightningd and libplugin, since they both use this
infrastructure.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-06-25 08:47:50 +09:30
Rusty Russell
ead211e5e4 autoclean: call list in easy stages.
listforwards on a large node can easily run out of memory.  Sip, don't
gulp!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-06-20 16:14:38 +09:30
Rusty Russell
c62e1f432f autoclean: use filter to reduce processing.
We can filter down to only the list* fields we need.  In the case of a
node with 1M forwards, this reduces listforwards time from 5 seconds
to 4 seconds.  It will also reduce memory consumption.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-06-20 16:14:38 +09:30
Rusty Russell
c7ce9c55df libplugin: add plugin_option_dev_dynamic (our first dynamic dev option coming).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-06-20 16:14:38 +09:30
Rusty Russell
1f9ddd24b2 libplugin: support filtering of outgoing commands.
This is crude, handing a raw JSON string, but it works.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-06-20 16:14:38 +09:30
Rusty Russell
d2465d4498 autoclean: rework logic to clarify subsystems.
There are really three subsystems: invoices, forwards and sendpays,
each of which has two variants we care about (successes and failures).
If we split the code that way, we can extract the core differences in
each of these cases and share most of the logic.

It's a bit awkward to iterate over each "subsystem" in the JSON
parameter sense, so we have some iteration code to do that where we
need to.

The result is going to be much easier to paginate!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-06-20 16:14:38 +09:30
Rusty Russell
83eed5ce8e autoclean: use a pointer for our global clean_info.
We're about to make this a more complex struct, so introducing a
new_clean_info() function unifies the code paths.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-06-20 16:14:38 +09:30
Rusty Russell
84b6601bb3 autoclean: remove autocleaninvoice command.
Changelog-Removed: JSON-RPC: `autocleaninvoice` command (deprecated v22.11, EOL v24.02)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-06-20 16:14:38 +09:30
ShahanaFarooqui
35101c072a commando: update removal version for rpcs
We documented them as deprecated in v23.08 but unintentionally didn't deprecate them in the code. Thus we are starting their actual deprecation cycle from v24.08 release.

Updating removal version for commands `commando-rune`, `commando-listrunes`, and `commando-blacklist`

Changelog-None.
2024-06-18 14:06:06 +09:30
Rusty Russell
d1d9d7ee6f offers: remove deprecated @ prefix.
Somehow, this documentation got lost during the Great Rewrite, so
restore that too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-EXPERIMENTAL: JSON-RPC: `offer` removed `@` prefix support from `recurrence_base` (use `recurrence_start_any_period` set to `false`)
2024-06-14 11:30:26 +09:30
Rusty Russell
fc2f1f42c6 bcli: remove deprecated estimatefees responses.
Changelog-Removed: Plugins: `estimatefees` returning feerates by name (e.g. "opening"); deprecated in v23.05.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-06-14 11:30:26 +09:30
Vincenzo Palazzo
f2551091ca offer: make the blockheight nullable
However, it is possible to avoid this kind of crash, because
our assert is "wrong" because blockheight can be 0 and the
assert can fail.

In addition, the `rpc_scan` already checks for nullability, so the
assert is redundant

2024-06-07T14:14:29.278Z INFO    lightningd: v24.05-modded
2024-06-07T14:14:37.158Z INFO    lightningd: v24.05-modded
2024-06-07T14:14:29.329Z INFO    lightningd: Creating configuration directory /root/.lightning/signet
2024-06-07T14:14:37.589Z INFO    plugin-bcli: bitcoin-cli initialized and connected to bitcoind.
2024-06-07T14:14:29.715Z INFO    lightningd: Creating database
2024-06-07T14:14:37.591Z UNUSUAL lightningd: Waiting for initial block download (this can take a while!)
2024-06-07T14:14:29.752Z UNUSUAL hsmd: HSM: created new hsm_secret file
2024-06-07T14:14:37.603Z INFO    plugin-reckless-wrapper.py: initializing reckless-wrapper.py.
2024-06-07T14:14:29.798Z INFO    plugin-bcli: bitcoin-cli initialized and connected to bitcoind.
2024-06-07T14:14:29.802Z UNUSUAL lightningd: Waiting for initial block download (this can take a while!)
offers: plugins/offers.c:1235: init: Assertion `blockheight' failed.
2024-06-07T14:14:29.814Z INFO    plugin-reckless-wrapper.py: initializing reckless-wrapper.py.
offers: FATAL SIGNAL 6 (version v24.05-modded)
0x57ab55a56485 send_backtrace
2024-06-07T14:14:29.818Z INFO    plugin-chanbackup: Creating Emergency Recovery
   common/daemon.c:33
offers: plugins/offers.c:1235: init: Assertion `blockheight' failed.
offers: FATAL SIGNAL 6 (version v24.05-modded)
0x57ab55a5650d crashdump
   common/daemon.c:75
0x59f3ed3ba485 send_backtrace
0x7dd20b02213f ???
   common/daemon.c:33
   ???:0
0x59f3ed3ba50d crashdump
0x7dd20ae59ce1 ???
   common/daemon.c:75
   ???:0
0x7dd20ae43536 ???
0x764fa583813f ???
   ???:0
0x7dd20ae4340e ???
   ???:0
0x7dd20ae52661 ???
   ???:0
   ???:0
0x57ab55a3effe init
   plugins/offers.c:1235
0x764fa566fce1 ???
0x57ab55a4763f handle_init
   ???:0
   plugins/libplugin.c:1376
0x57ab55a478ee ld_command_handle
0x764fa5659536 ???
   plugins/libplugin.c:1797
0x57ab55a47ec0 ld_read_json_one
   plugins/libplugin.c:1979
   ???:0
0x57ab55a47f49 ld_read_json
0x764fa565940e ???
   plugins/libplugin.c:1999
   ???:0
0x57ab55b934cc next_plan
0x764fa5668661 ???
   ccan/ccan/io/io.c:60
   ???:0
0x57ab55b93953 do_plan
0x59f3ed3a2ffe init
   ccan/ccan/io/io.c:408
   plugins/offers.c:1235
0x57ab55b939ec io_ready
   ccan/ccan/io/io.c:418
0x59f3ed3ab63f handle_init
0x57ab55b95302 io_loop
   plugins/libplugin.c:1376
   ccan/ccan/io/poll.c:455
0x59f3ed3ab8ee ld_command_handle
0x57ab55a486dc plugin_main
   plugins/libplugin.c:1797
   plugins/libplugin.c:2209
0x59f3ed3abec0 ld_read_json_one
0x57ab55a3f36d main
   plugins/libplugin.c:1979
   plugins/offers.c:1285
0x59f3ed3abf49 ld_read_json
0x7dd20ae44d09 ???
   plugins/libplugin.c:1999
   ???:0
0x59f3ed4f74cc next_plan
0x57ab55a3c799 ???
   ccan/ccan/io/io.c:60
0x59f3ed4f7953 do_plan
   ???:0
   ccan/ccan/io/io.c:408
0xffffffffffffffff ???
0x59f3ed4f79ec io_ready
   ccan/ccan/io/io.c:418
   ???:0
offers: FATAL SIGNAL 11 (version v24.05-modded)
0x59f3ed4f9302 io_loop
   ccan/ccan/io/poll.c:455
0x57ab55a56485 send_backtrace
0x59f3ed3ac6dc plugin_main
   common/daemon.c:33
   plugins/libplugin.c:2209
0x57ab55a5650d crashdump
0x59f3ed3a336d main
   plugins/offers.c:1285
   common/daemon.c:75
0x7dd20b02213f ???
0x764fa565ad09 ???
   ???:0
   ???:0
0x59f3ed3a0799 ???
0x0 ???
   ???:0
   ???:0
2024-06-07T14:14:37.734Z INFO    plugin-offers: Killing plugin: exited before replying to init
0xffffffffffffffff ???
   ???:0
2024-06-07T14:14:37.734Z **BROKEN** plugin-offers: Plugin marked as important, shutting down lightningd!
offers: FATAL SIGNAL 11 (version v24.05-modded)
0x59f3ed3ba485 send_backtrace
   common/daemon.c:33
0x59f3ed3ba50d crashdump
   common/daemon.c:75
0x764fa583813f ???
   ???:0
0x0 ???
   ???:0
2024-06-07T14:14:29.823Z INFO    plugin-bookkeeper: Creating database
2024-06-07T14:14:29.883Z INFO    plugin-offers: Killing plugin: exited before replying to init
2024-06-07T14:14:29.883Z **BROKEN** plugin-offers: Plugin marked as important, shutting down lightningd!

Fixes: 9d75fbe237
Reported-by: @farscapian
Link: https://github.com/ElementsProject/lightning/issues/7378
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2024-06-14 10:39:02 +09:30
Alex Myers
b17bc9cc69 meta: bump rust versions for 24.05 release 2024-06-04 20:23:24 -05:00
Alex Myers
f109bc27e1 meta: update changelog for 24.05rc2 2024-05-29 20:16:44 -05:00
Aditya Sharma
4789eb9fa0 chanbackup: typo fix. 2024-05-29 10:34:58 -05:00
Alex Myers
c9f7b78473 meta: update python versions to 24.05
Changelog-None
2024-05-23 18:09:03 -05:00
Lagrang3
428b23c975 renepay: relax knowledge mod
Add a payment mod that relaxes the knowledge of the uncertainty network
as a function of time.

Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
2024-05-23 15:15:57 -05:00
Lagrang3
2664faea38 renepay: put global variables into renepayconfig.h
Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
2024-05-23 15:15:57 -05:00
Vincenzo Palazzo
fbecefe5ac offer: fix type to the getchaininfo rpc
This is violate what the docs of getchainfo is telling us that the
last_block_height is a u64.

```
2024-05-17T09:53:23.464Z **BROKEN** plugin-offers: Got error reply to getchaininfo: '{\"error\":{\"code\":-1,\"data\":null,\"message\":\"invalid type: string \\\"0\\\", expected u64\"},\"id\":\"init/offers:getchaininfo#1\",\"jsonrpc\":\"2.0\"}\n\n'
2024-05-17T09:53:23.496Z INFO    plugin-offers: Killing plugin: exited before replying to init
2024-05-17T09:53:23.496Z **BROKEN** plugin-offers: Plugin marked as important, shutting down lightningd!
2024-05-17T09:53:23.496Z DEBUG   lightningd: io_break: lightningd_exit
2024-05-17T09:53:23.496Z **BROKEN** plugin-topology: Reading JSON input: Connection reset by peer
2024-05-17T09:53:23.504Z INFO    plugin-topology: Killing plugin: exited before replying to init
2024-05-17T09:53:23.504Z **BROKEN** plugin-topology: Plugin marked as important, shutting down lightningd!
2024-05-17T09:53:23.504Z DEBUG   lightningd: io_break: lightningd_exit
2024-05-17T09:53:23.504Z DEBUG   plugin-bookkeeper: Setting up database at sqlite3://accounts.sqlite3
2024-05-17T09:53:23.504Z DEBUG   connectd: REPLY WIRE_CONNECTD_START_SHUTDOWN_REPLY with 0 fds
2024-05-17T09:53:23.504Z DEBUG   lightningd: io_break: connectd_start_shutdown_reply
```

Fixing the following crash

```
Got error reply to getchaininfo: '{"error":{"code":-1,"data":null,"message":"invalid type: string \"0\", expected u64"},"id":"init/offers:getchaininfo#1","jsonrpc":"2.0"}

'lightningd: lightningd already running? Error locking PID file: Resource temporarily unavailable
```

Fixes: 847208f5d8
Changelog-None: offer: fix type to the getchaininfo rpc
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2024-05-22 07:46:39 -05:00
Vincenzo Palazzo
4b4516c67c bcli: make last height optional
This is on me, and the last height is optional, and not required,
because sometimes you do not want wait the sync of the blockchain
but just get the information of the current status.

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2024-05-22 07:46:39 -05:00
Lagrang3
abfcc9bc5d renepay: clean unit tests
Delete temporary gossmap files after unit tests completion.

Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
2024-05-20 16:58:49 -05:00
Lagrang3
638fff8526 renepay: fix memleak in CI
Keep a double-entry record of pending routes so that we can flag them as
not memory leaks.

Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
2024-05-20 16:58:49 -05:00
Lagrang3
4b8d9116de renepay: test channel capacity unavailable
Add a test that checks `get_route` and `uncertainty_update` behaviour's
handling of missing channel capacities.

Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
2024-05-20 16:58:49 -05:00
Alex Myers
d30b1c8dc2 unit-test: update mocks 2024-05-20 16:58:49 -05:00
Rusty Russell
7040d49242 renepay: fix 32-bit compilation.
```
plugins/renepay/mods.c: In function 'payment_continue':
plugins/renepay/mods.c:63:7: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
   63 |       (u64)payment_virtual_program[payment->exec_state++];
      |       ^
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-17 14:06:36 -05:00
Rusty Russell
e03f56fe39 bcli: fix compilation on 32-bit platforms.
Reported-by: Shahana Farooqui
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-17 14:06:36 -05:00
Vincenzo Palazzo
ce70167ead core: notify plugins when a log line is emitted.
Currently make a plugin that do reportings of logs on
a services like graphana is not possible. So this commit
include the possibility to write a plugin that do the report
of this analisys.

Changelog-Added: core: notify plugins when a log line is emitted.
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2024-05-17 13:03:12 -05:00
Erik De Smedt
505be716aa grpc-plugin: Implement notifications
Use the changes in the `cln-grpc`-crate to support
notifications.
2024-05-16 14:00:18 +02:00
Rusty Russell
757e6f8a9b libplugin: allow display of default values.
This means we can see the values in listconfigs, even if we haven't set
them yet.

In particular, we now see the following:

* autoclean-cycle.value_int=3600
* bitcoin-rpcclienttimeout.value_int=60
* bitcoin-retry-timeout.value_int=60
* funder-max-their-funding.value_str=4294967295sat
* funder-per-channel-min.value_str=10000sat
* funder-reserve-tank.value_str=0sat
* funder-fund-probability.value_int=100

Changelog-Changed: plugins: libplugin now shows plugin option default values (where they're non-trivial)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-15 15:50:54 -05:00
Rusty Russell
f7afe1a35f plugins: two minor things I noticed.
1. sql's dev-sqlfilename should be registered as a dev option.
2. bcli's timeout is an integer, not a string.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-15 15:50:54 -05:00
Rusty Russell
3c48438821 pay: fix bolt12 blinded path cltv logic.
The spec has moved a bit here: the `outgoing_cltv_value` in the final onion
is basically the blockheight now (plus the 1 block delta we give ourselves).

Also, we were doubling ours, since p->min_final_cltv_expiry was already set
to p->blindedpay->cltv_expiry_delta above.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-15 10:55:16 -05:00
Rusty Russell
121403b5df offers: add final node's CLTV delta in when creating blinded path payinfo.
It should probably be renamed "minimum_cltv_delta" or something.

Fixes: https://github.com/ElementsProject/lightning/issues/7179
Reported-by: @carlaKC
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-15 10:55:16 -05:00
Rusty Russell
8b5bf716a8 offers: use node_id not scid inside blinded path.
Without this, it was broken because our peer will no longer forward
via scids for private channels.  We could use the scid alias, but the
node id is right at hand.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-15 10:55:16 -05:00
Rusty Russell
847208f5d8 offers: put correct CLTV limit inside blinded paths.
At plugin startup, we don't have an accurate blockheight and can get 0!

Fixes: https://github.com/ElementsProject/lightning/issues/7161
Reported-by: @carlaKC
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-15 10:55:16 -05:00
daywalker90
abd1b5fe50 cln-plugin: fix over-escaping rpc errors 2024-05-15 13:26:02 +02:00
daywalker90
b69609b9c3 cln-plugin: Add dynamic configs and a callback for changes
Changelog-Added: cln-plugin: Add dynamic configs and a callback for changes
2024-05-15 13:26:02 +02:00
Rusty Russell
9aed594177 pytest: test fetchinvoice reply path which is not a direct peer.
Our fetchinvoice always creates a reply path which terminates at their peer,
so we need a dev overrride for that.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-14 18:16:26 -05:00
Rusty Russell
8714289c8c plugin/offers: connect if necessary for replying to invoice_request.
You can disable this with `fetchinvoice-noconnect`.

Changelog-EXPERIMENTAL: We will now reply to invoice_request messages even if reply path requires us to make an outgoing connection (LDK does this)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-14 18:16:26 -05:00
Rusty Russell
2e1274ba76 plugins/fetchinvoice: use new generic connect-if-needed infrastructure.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-14 18:16:26 -05:00
Rusty Russell
b94be330e6 plugins: generalize "connect if we can't route" logic, link into offers plugin.
We're going to dynamically connect if we need to, to reply to incoming invoice_requests.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-05-14 18:16:26 -05:00
Se7enZ
ca4710e942 bcli: Add rpcclienttimeout parameter and use max value of it and retry_timeout 2024-05-13 14:26:24 -05:00