#lightning #grpc #expose #grpc-api #bindings #cln #primitive

cln-grpc

The Core Lightning API as grpc primitives. Provides the bindings used to expose the API over the network.

11 releases

0.2.0 Sep 22, 2024
0.1.9 Jun 5, 2024
0.1.8 Mar 8, 2024
0.1.7 Nov 22, 2023
0.1.0 Apr 20, 2022

#3 in #cln

Download history 606/week @ 2024-07-29 394/week @ 2024-08-05 318/week @ 2024-08-12 287/week @ 2024-08-19 398/week @ 2024-08-26 353/week @ 2024-09-02 95/week @ 2024-09-09 277/week @ 2024-09-16 349/week @ 2024-09-23 524/week @ 2024-09-30 587/week @ 2024-10-07 571/week @ 2024-10-14 413/week @ 2024-10-21 211/week @ 2024-10-28 378/week @ 2024-11-04 394/week @ 2024-11-11

1,410 downloads per month
Used in 8 crates

MIT license

555KB
13K SLoC

cln-grpc - Secure Networked RPC Interface

This plugin provides a standardized API that apps, plugins, and other tools could use to interact with Core Lightning. We always had a JSON-RPC, with a very exhaustive API, but it was exposed only locally over a Unix-domain socket. Some plugins chose to re-expose the API over a variety of protocols, ranging from REST to gRPC, but it was additional work to install them.

So with v0.11.0, we released a new interface: cln-grpc, a Rust-based plugin that exposes the existing interface over the network in a secure manner. The gRPC API is automatically generated from our existing JSON-RPC API, so it has the same low-level and high-level access that app devs are accustomed to but uses a more efficient binary encoding where possible and is secured via mutual TLS authentication.

To use it, just add the --grpc-port option, and it’ll automatically start alongside Core Lightning and generate the appropriate mTLS certificates. To use the gRPC interface, copy the client key and certificate, generate your client bindings from the protobuf definition and connect to the port you specified earlier.

While all previous built-in plugins were written in C, the cln-grpc plugin is written in Rust, a language that will be much more prominent in the project going forward. In order to kick off the use of Rust, we also built a number of crates:

  • cln-rpc: native bindings to the JSON-RPC interface, used for things running on the same system as CLN.
  • cln-plugin: a library that facilitates the creation of plugins in Rust, with async/await support, for low-footprint plugins.
  • cln-grpc: of course, the library used to create the gRPC plugin can also be used directly as a client library.

All of these crates are published on crates.io and will be maintained as part of the project moving forward.

Dependencies

~13–22MB
~279K SLoC