Commit Graph

14804 Commits

Author SHA1 Message Date
daywalker90
bd575b51e5 msggen: fix edge cases in rust composite field names 2024-05-17 16:30:43 +02:00
daywalker90
c98185d944 tools: allow spelling of HtlcTlv 2024-05-17 16:30:43 +02:00
daywalker90
6db56180f9 msggen: allow backfilling of already deprecated fields 2024-05-17 16:30:43 +02:00
daywalker90
c9a9d62367 msggen: add listinvoicerequests, disableinvoicerequest, invoicerequest methods
Changelog-None
2024-05-17 16:30:43 +02:00
daywalker90
6acfca7517 msggen: add routes to decode and decodepay
Changelog-None
2024-05-17 16:30:43 +02:00
daywalker90
c8d88c9130 msggen: fix invoice request missing exposeprivatechannels
Changelog-None
2024-05-17 16:30:43 +02:00
daywalker90
bd1123cf32 msggen: add help method
Changelog-None
2024-05-17 16:30:43 +02:00
daywalker90
5510445bbc msggen: add funderupdate method
Changelog-None
2024-05-17 16:30:43 +02:00
daywalker90
5047bc6dd1 msggen: add emergencyrecover, recover, recoverchannel methods
Changelog-None
2024-05-17 16:30:43 +02:00
daywalker90
16c036eed8 msggen: add dev-forget-channel method
Changelog-None
2024-05-17 16:30:43 +02:00
daywalker90
a9ff3cb039 pytests: use reserve_unused_port() everywhere
Changelog-None
2024-05-16 17:31:02 +02:00
Erik De Smedt
934b85a023 Updated poetry.lock file 2024-05-16 14:00:18 +02:00
Erik De Smedt
24ae7751cf Makefile: Include pyln-grpc proto in PYTHONPATH
When running `make check-python` we'll expclicitly include
`pyln-grpc-proto` in the `PYTHONPATH`.

This ensures we always run the tests using the version installed in
`./contrib/pyln-grpc-proto`
2024-05-16 14:00:18 +02:00
Christian Decker
b4d10a2e82 gci: Try to fix the pyln-grpc installation in CI 2024-05-16 14:00:18 +02:00
Erik De Smedt
7ba53dc828 Fix test for notification of custommsg
I forgot to add a `break` clause at the end of the test.

Without the break the test will keep waiting forever
on a `custommsg` that will never arrive
2024-05-16 14:00:18 +02:00
Erik De Smedt
f49cb2cb1a Include grpc-msg-buffer-size in docs 2024-05-16 14:00:18 +02:00
Erik De Smedt
151975b282 msggen: Allow non_camel_case for notification
In rust enum are expected to be CamelCase.
However, we are generating enum's using CAPITAL_SNAKE_CASE.

This generates a warning and breaks CI.

See `cln_rpc::notifications::ConnectAddressType::LOCAL_SOCKET`
2024-05-16 14:00:18 +02:00
Erik De Smedt
c1062b1db7 Test for notifications over grpc 2024-05-16 14:00:18 +02:00
Erik De Smedt
867465c0ed cln_rpc: Test deserialize_connect_notification 2024-05-16 14:00:18 +02:00
Erik De Smedt
83cc6c44e0 msggen: Schema for ConnectNotification + collisions
The schema in the docs for the `ConnectNotification` was faulty.
I've already fix this in https://github.com/ElementsProject/lightning/pull/7085

The new schema is

```
{
  "connect" :  {
    "address" : {
      "address" : "127.0.0.1",
      "port" : 38012,
      "type" : "ipv4"
  },
  "direction" : "in",
  "id" : "022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59"
  }
}
```

The `address` in the `connect` field will be encoded in protobuf as
`ConnectAddress`. However, this collides with the `ConnectAddress` that
is defined in the `connect` rpc-method.

This commit
- Updates the schema in `doc/schemas/notification/connect.json`
- Changes `msggen` to include an override to `PeerConnect` for any
  notification typename that starts with `Connect`

Both have an `address` field which is a composite type. This results in
naming collisions

schema's: Updated schema for connect-notification

schema for connect notification + overrides

Override ConnectAddress to `PeerConnectAddress` in protobuf
for notifications
2024-05-16 14:00:18 +02: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
Erik De Smedt
521ac6a12a msggen: Implement notification-server 2024-05-16 14:00:18 +02:00
Erik De Smedt
fa43d3ecfc msggen: Add notifications to proto-file 2024-05-16 14:00:18 +02:00
Erik De Smedt
05b9fc1998 msggen: Add conversions for notification pb to json 2024-05-16 14:00:18 +02:00
Erik De Smedt
686dae2b9f msggen : Add notification-messages to proto-file 2024-05-16 14:00:18 +02:00
Erik De Smedt
c5a47c3149 msggen: RequestStructs for notification-streams
I'm working to expose a stream of notifications over grpc.
This requries me to define structs that can be used to request
a stream of notifications.

These structs are all empty.
2024-05-16 14:00:18 +02:00
Erik De Smedt
6b34c722f3 cln-rpc: Test for serialization of block_added 2024-05-16 14:00:18 +02:00
Erik De Smedt
d743cf253f msggen: Add test for serialization of notifications 2024-05-16 14:00:18 +02:00
Erik De Smedt
eea9c8253b msggen: Choose better when a subfield is optional
**Problem Description**

In previous commits I introduced some new fields to `msggen`.
One example is `CustomMsgResponse` in `cln-grpc/src/notification.rs`.

```rust
pub struct CustomMsgResponse {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub peer_id: Option<PublicKey>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub payload: Option<String>,
}
```

The `peer_id` and `payload` are required parameters.
However, the generated code is still marking them as `Optional`.

This is a choice made by `msggen`. It does this because `payload` and
`peer_id` are recently added fields. By marking the field as optional
the language bindings would also work when used on an older version of
Core-Lightning.

In this scenario. Marking them as optional is overkill.
The `CustomMsgStruct` and `payload` field are created in the same
version of CoreLightning.

This commit solves this behavior.
2024-05-16 14:00:18 +02:00
Erik De Smedt
6e61dde41e msggen: Provide parent in visit-method of patch
In the next commit I'll change the behavior of `OptionalPatch`.
The changes require me to have access to the `parent` of a field.

Splitting it up in a separate commit makes it easier to review.
You can run `msggen` against this version and the previous `version`.

I've tested it. It returns exactly the same output.
2024-05-16 14:00:18 +02:00
Erik De Smedt
15276b7ff5 msggen: Add notification-structs to cln_rpc
In Core Lightning notifications are JSON-messages. This commit
introduces structs that can be used to parse the notification
messages.

Using `msggen` all required tructs are automatically generated
2024-05-16 14:00:18 +02:00
Erik De Smedt
0251b45027 msggen: Move rpc-model generator 2024-05-16 14:00:18 +02:00
Erik De Smedt
d59029b464 msggen: Cut gprc into pieces!!!
No, this isn't my last resort.

The file to generate `gprc`-bindings got quite long.
I've put it in a separate folder and cut it into smaller pieces
2024-05-16 14:00:18 +02:00
Erik De Smedt
4e93bb6d9d msggen: Add notifications to the Model
Included a `notifications`-field in the `Service` and wrote the code
to parse them.

Add block-added to utils.py
2024-05-16 14:00:18 +02:00
Erik De Smedt
745f410aa6 Add schema's notifications
I've added the schema for a couple of 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
6af32885fa libplugin: add test for dynamic setting values.
Serves as an example, but also shows a quirk which we fix in the next patch.

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
daywalker90
c1c67635fc msggen: add upgradewallet method
Changelog-None
2024-05-15 22:11:10 +02:00
daywalker90
8edd3d4a06 msggen: add setpsbtversion method
Changelog-None
2024-05-15 22:11:10 +02:00
daywalker90
ad31a18b1d msggen: add setconfig method
Changelog-None
2024-05-15 22:11:10 +02:00
daywalker90
5ed04c9788 msggen: add sendonionmessage method
Changelog-None
2024-05-15 22:11:10 +02: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
Rusty Russell
f9021b6ca6 pytest: add test for paying an invoice with a one-hop blinded path.
This demonstrates a number of issues reported by Carla: no surprise
since there was no test!

(We create a one-hop blinded path when we only have private channels).

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
daywalker90
dab9605e1f msggen: add splice_update method 2024-05-15 12:11:18 +02:00