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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
The original method name was lsps-lsps2-invoice but I somehow messed it
up and renamed during a rebase.
Changelog-Changed: lsps-jitchannel is now lsps-lsps2-invoice
Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
This commit adds a custom request type for the on_openchannel hook to
avoid calling unwrap() during runtime. We now return cleanly from the
hook in any case.
Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
The extra_fee tlv appended to the update_add_htlc message is set by the
LSP and should specify what was deducted from a single htlc. If it does
not match the expected amount, we log a warning message.
Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
We nearly always want to return `{"result":"continue"}` in case that
something went wrong. This commits adds two helper macros that help us
to cleanly return from a hook while logging necessary information.
Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
The `on_invoice_payment` hook is called when core-lightning successfully
collected all parts to an invoice. We'll use this to clean up the the
datastore when an invoice completes.
Caveat: This will be called on every succesfull invoice payment, we may
improve this in the future.
Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
This includes a mocked lsps2 service plugin, tests and some changes on
the client side. The client now can accept mpp payments for a
jit-channel opening from a connected LSP.
Changelog-Added: Lsps2 `fixed-invoice-mpp` mode for the lsps2 client
Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
We use non-anchor channels for now and make this configurable in the
future. The reason for this decission is that elements does not support
anchors.
Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>
please `connect` tests. We need to fix this in the future. Connectd
should not tell peers about features of disabled plugins.
We need to ensure that connectd only starts once the plugins have
returned from init.
Signed-off-by: Peter Neuroth <pet.v.ne@gmail.com>