Commit graph

90 commits

Author SHA1 Message Date
daywalker90
8405796b8e msggen: new rust types for sat and sat_or_all
Also stop serializing amounts as string with msat suffix in cln-rpc
and serialize them as a raw number instead, like CLN does it

Changelog-None
2026-07-17 10:16:18 +02:00
daywalker90
17abce2450 lsps-plugin: print whole error chain for HtlcError 2026-07-06 19:25:22 +02: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
daywalker90
88f259ec56 crates: upgraded dependencies to latest 1.85 compatible versions as of the commit time
notable upgrades requiring code changes:

rcgen: signed_by now takes an Issuer instead of a Certificate and KeyPair

tonic/prost: prost feature was stripped out of tonic and moved into tonic_prost crates

rand: OsRng was renamed to SysRng

Changelog-None
2026-04-24 19:38:53 +02:00
daywalker90
28147d38ae crates: formatting with new 2024 edition rules
`cargo fmt --all`

Changelog-None
2026-04-24 15:48:06 +02:00
daywalker90
84d4d5920b crates: upgrade to 2024 rust edition
I've ran `cargo fix --edition` and three changes were noticeable:
- set_var is now unsafe, i've added a SAFETY comment on each to explain why
  this is fine here.
- conversions of several if let to match because of the new if let temporary scope
  I have reviewed and restored all of them since the behaviour was the same on each.
- the macro expr was converted to expr_2021 in the lsps plugin, i have reverted those
  aswell since we don't use const or _ expressions

Changelog-None
2026-04-24 15:48:06 +02:00
daywalker90
f488ca2bd8 crates: explicitly set workspace wide rust-version to 1.85
Also bump the resolver version so `cargo update` will respect this MSRV.

Changelog-None
2026-04-24 15:48:06 +02:00
Lagrang3
bbd1dfb474 rust libraries: update bitcoin to 0.32.2
Boost cln-rpc, cln-grpc, cln-plugin and lsps-plugin versions
to use bitcoin 0.32.2 for compatibility with rust lightning libraries.

Changelog-None.

Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
2026-03-19 17:33:11 +01:00
daywalker90
376468ffa3 cln-plugin: add a hook builder to make use of before, after and filters options 2026-03-14 04:15:49 +10:30
Peter Neuroth
2971f5d956 lightningd: add channel_id filter to listpeerchannels
Sometimes we don't know the short_channel_id yet (e.g the channel has
not been broadcasted), but we still know the channel_id from the funding
transaction. Add a channel_id filter to listpeerchannels and clarify
that id, short_channel_id and channel_id are mutually exclusive.

Changelog-Added: `listpeerchannels` now accepts a `channel_id` filter,
for cases where the `short_channel_id` is not known yet.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2026-02-24 16:51:59 +01:00
Peter Neuroth
4a1c922017 plugins: lsps: remove anyhow from tlvs
Remove anyhow as a dependency from the tlv module. This allows for a
cleaner error handling

Changelog-None

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
c7bbf84c83 plugins: lsps: remove cln dependencies from core module and clean up service
The core module shouldn't depend on anything from the cln_adapters
module. This ensures that we can switch out interfaces in the future
(e.g a different database than cln's datastore).

This change made it necessary to refactor the service plugin which
allowed us to clean it up on the go

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
30268ad945 plugins: lsps: move feature helpers to core module
This removes the util.rs module and leaves us with proto, core and
cln_adapters

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
f678a70610 plugins: lsps: remove lsps2 module
Separate concerns of the lsps2 modules into their respective layers:
core for tlv, as it is lightning related, not specifically
core-lightning. cln_adapters for core-lightning related types.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
fa62c64de7 plugins: lsps: split up handlers
This commit separates the business logic from core-lighting behaviour
and moves the core-lightning related implementations into the
cln_adapters module.

Splits up tests as well

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
e001652ab1 plugins: lsps: add own trait for lightning provider
Clean up the CLN interface

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
a05c2c9c2c plugins: lsps: add own trait for datastore provider
This now only makes it easier to test, but also more modular. It allows
us to use any kind of storage, not only the datastore.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
38c84be25e plugins: lsps: add own trait for blockheight provider
The ClnApi trait is way overloaded. We break things down to make it more
modular on the service side.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
38b3d14eb9 plugins: lsps: add own trait for lsps offer provider
The cln api trait is really cluttered, we try to clean it up a little
bit.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
e50f5ee863 plugins: lsps: refactor service hook
We have some shared behavior and can use the MessageSender for the
service hook as well

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
462ca844dd plugins: lsps: replace heavy transport
We replace the legacy transport by a slim custommsg hook that makes use
of the lightweight multiplexed transport and avoids deserialization and
serialization through this extra layer

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
d5bcde09ae plugins: lsps: implement ClnSender for bolt8 transport
Implement the MessageSender trait for Bolt8 transport via core-lightning

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
3cf99c358b plugins: lsps: add slim multiplexing transport
We can separate concerns here by adding a lightweight multiplexing
transport client. This helps us to clean up any direct dependencies on
CLN

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
7401585088 plugins: lsps: move client transport to cln_adapters
cln_adapters is the layer that holds concrete implementations that are
related to core-lightning.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
9adc8cdfed plugins: lsps: slim down lsps service
This commit replaces the lsps service. Therefore we add the cln_adapters
module that handles the communication with core-lightning. We add a
lightweight LspsService that wraps the router and allows handlers to
register themselves to the service/router.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
461065aff7 plugins: lsps: add router compatible lsps2 service handler
This commit copys and adapts the lsps2 service handlers to match the
slim router handlers

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
ffc05ddcf0 plugins: lsps: add slim generic json-rpc router
This router is very lightweight and can handle routing for the lsps
service. It avoids allocations by just borrowing from the request. This
is much cleaner than what we have now and reduces the amount of
serializations by a lot.

Also it supports typed handlers which will remove serialization overhead
from the handlers in future commits

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
1159adb0e2 plugin: lsps: move json-rpc server to core module
This removes the jsonrpc module

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
b9172239d0 plugins: lsps: switch to typed transport
There is no need to communicate via a generic JsonRpcClient if all
messages are well defined and we can use the typed transport to remove a
whole lot of overhead and just pass the ResponseObjects directly to the
Transport layer

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
1bb76f84e2 plugins: lsps: add request to transport trait
Introducing "request" to the transport trait that uses the RequestObject
and JsonRpcResponse directly reduces some overhead and unnecessary
conversions. Why do we implement a generic transport over &str when we
already know that we are dealing with JSON-RPC 2.0 here.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
2546642c32 plugins: lsps: move id generation into jsonrpcrequest
There is no need to generate the id in some client when we can actually
generate it on a lower layer as we know by LSPS0 how we have to generate
it.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
5ed743e10d plugins: lsps: add lsps0 encoding and decoding
In order to seperate concerns, this adds the basic encoding of an lsps0
frame to the proto module.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
0927179fe1 plugins: lsps: replace owned types by references
Improves flexibility in transport implementations.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
e08756cd57 plugins: lsps: use transport specific error
instead of using std::error, this is more specific and keeps the errors
"type-safe"

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
e591323ac8 plugins: lsps: remove peer_id from transport
As we pass the peer_id through the transport methods, there is no need
to store the peer_id in the Bolt8Transport struct anymore

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
0f624ed67f plugins: lsps: add peer_id to transport
Frankly, transport without a target doesn't make sense, so this commit
adds a PublicKey (from secp256k1) as the target to the Transport trait.
It can easily be replaced by a common PeerId without changing the api
for external implementations if needed in the future

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
6e868443e2 plugins: lsps: move transport to core module
This commit is part of a series of commits to make the lsps plugin crate
layered and modular for efficient reuse in external projects.

The core module is responsible for common business logic and interfaces
and acts as the intermediate layer for an actual implementation

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
5274556518 plugins: lsps: refactor client to use jsonrpcresponse
This makes it easier for client implementations to separate transport or
parser related issues from actuall json-rpc error responses. Also this
helps to segregate the individual responsibilities of the crates
further.

This further alows us to remove the error enum from proto/jsonrpc
completely as this now only deals as a from/to-wire module

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
bad42c711b plugin: lsps: simplify json-rpc response object
We can use an enum as a more idiomatic rust style to create and retreive
json-rpc responses. The actual response data is kept in the body enum
while the surrounding only holds the identifier.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
67f11b62e6 plugins: lsps: refactor jsonrpc error
In order to create a sane dependecy structure for this crate, this
commit cleans up the jsonrpc error enum and shifts responsibilities
towards the transport client

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
9c474a6d5c plugins: lsps: move transport error to client module
The error belongs to the transport definition, not into the
wire/protocol module.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
a51f6e1ebb plugins: lsps: remove debug print from library module
This commit is part of a series that refactor the lsp plugin crate into
a modularized crate with the goal to separate the actual plugin runtime
as much as possible from library code to make it accessible for 3rd
party plugin implementations.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
b7be5ef3a2 plugins: lsps: refactor lsps2 and lsps0 error enums
Split them up how they are actually defined.

This commit is part of a series that refactor the lsp plugin crate into
a modularized crate with the goal to separate the actual plugin runtime
as much as possible from library code to make it accessible for 3rd
party plugin implementations.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
b88dc5972f plugins: lsps: move lsps2 model to proto module
This commit is part of a series that refactor the lsp plugin crate into
a modularized crate with the goal to separate the actual plugin runtime
as much as possible from library code to make it accessible for 3rd
party plugin implementations.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
ba93a7ca62 plugins: lsps: move primitives into lsps0
Those primitives are actually defined in lsps0

This commit is part of a series that refactor the lsp plugin crate into
a modularized crate with the goal to separate the actual plugin runtime
as much as possible from library code to make it accessible for 3rd
party plugin implementations.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
5847cd443f plugins: lsps: move jsonrpc into proto module
This commit is part of a series that refactor the lsp plugin crate into
a modularized crate with the goal to separate the actual plugin runtime
as much as possible from library code to make it accessible for 3rd
party plugin implementations.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
bd9fd581f1 plugins: lsps: move feature types into proto module
This commit is part of a series that refactor the lsp plugin crate into
a modularized crate with the goal to separate the actual plugin runtime
as much as possible from library code to make it accessible for 3rd
party plugin implementations.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
a94885ba7f plugins: lsps: move errors into proto module
This commit is part of a series that refactor the lsp plugin crate into
a modularized crate with the goal to separate the actual plugin runtime
as much as possible from library code to make it accessible for 3rd
party plugin implementations.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
39c36a03dd plugins: lsps: move lsps0 model into proto module
This commit is part of a series that refactor the lsp plugin crate into
a modularized crate with the goal to separate the actual plugin runtime
as much as possible from library code to make it accessible for 3rd
party plugin implementations.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30
Peter Neuroth
06fe54c467 plugins: lsps: move primitives into proto module
This commit is part of a series that refactor the lsp plugin crate into
a modularized crate with the goal to separate the actual plugin runtime
as much as possible from library code to make it accessible for 3rd
party plugin implementations.

Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
2025-12-17 05:56:01 +10:30