DEV Community

Cover image for Run a cln node with clightning4j tools on a tiny VPS
Vincenzo Palazzo
Vincenzo Palazzo

Posted on

Run a cln node with clightning4j tools on a tiny VPS

In this post, we will talk on how to set up a lightning node quickly using clightning4j tools.
For this we will use a free AWS virtual machine but the same can be used with DigitalOcean where you can use my invite link to have $100 for free (for a couple of months of core lightning free).
Other than that, you need to install on your virtual machine, docker, and docker-compose
We will try to do it step by step below.


Introduction to clightning4j tools

clightning4j is a collection of tools to make integration of core lightning and running one node easier. One of the most important plugins is btcli4j which is a backend plugin that supports rest and pruning mode for bitcoin, so you can run your node in a lightweight environment and very quickly.
In addition, it offers a Java library JRPClightning to interact with core lightning and also develop a plugin for core lightning.
This collection of tools is just a way to implement ideas born more than 2 years ago, but the intention is to move the more successful idea into a more modern language like Dart, Rust, and Go. So, yeah I make a lot of mistakes but I also learned a lot in the process :)


Hands-on the configuration

For this article, I will choose to go with the AWS virtual machine where I installed Debian, and you can start to follow the guide from this page. However, this guide will be independent of the services and will be dependent only on the Debian operative system
When you have your machine up and running choose your best method to connect to the virtual machine, I will use ssh, and the first two commands that I run every time at the first login are the following:

>> sudo apt update && sudo apt upgrade -y
Enter fullscreen mode Exit fullscreen mode

After the process will finish we need to install docker and docker-compose. We will start to install docker with the official guide and we will run the following commands for Debian:

>> sudo apt-get install \
    ca-certificates \
    curl \
    gnupg \
    lsb-release
Enter fullscreen mode Exit fullscreen mode

After that, we add the GPG signature

>> sudo mkdir -p /etc/apt/keyrings
>> curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
Enter fullscreen mode Exit fullscreen mode

and after

>> echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Enter fullscreen mode Exit fullscreen mode

Ok, you don't see anything right? This is normal 👩🏾‍🔬
Let's run the last commands, which are:

>> sudo apt-get update
>> sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin

Enter fullscreen mode Exit fullscreen mode

After the completion of the process, we need to see if all is ok, and we run the hello-world in docker, with the following command
sudo docker run hello-world
Done, we have docker installed, you should also have the docker compose command available


Configuring clightning4j node

The easier way to start it is to visit the GitHub repository clightning-node and take one of the examples that are present in the example directory,
we will use the grpc-docker-compose.yml, now we run the following commands

>> mkdir cln && cd cln
>> wget https://raw.githubusercontent.com/clightning4j/clightning4j-node/main/examples/grpc-docker-compose.yml
>> sudo docker compose up --build
Enter fullscreen mode Exit fullscreen mode

and when you have your node up un running, open a new console and run the following command

>> sudo docker compose run -T cln_test lightning-cli --testnet getinfo
Enter fullscreen mode Exit fullscreen mode

and the output would be

{
   "id": "028fe59bd7bbe3982699535e7e43b305c69099fbdd9902b1af5875a121fdb9a3dc",
   "alias": "lndart-testnet",
   "color": "028fe5",
   "num_peers": 6,
   "num_pending_channels": 0,
   "num_active_channels": 8,
   "num_inactive_channels": 0,
   "address": [
      {
         "type": "ipv4",
         "address": "52.55.124.1",
         "port": 19735
      },
      {
         "type": "torv3",
         "address": "s5esrtw7l4uix5idxoa3lcdrihmchsk2evrtelnp6peke4rqfdjp54id.onion",
         "port": 19735
      }
   ],
   "binding": [
      {
         "type": "ipv4",
         "address": "172.31.95.0",
         "port": 19735
      }
   ],
   "version": "v0.12.0rc1",
   "blockheight": 2314748,
   "network": "testnet",
   "fees_collected_msat": 0,
   "lightning-dir": "/home/clightning4j/.lightning/testnet",
   "our_features": {
      "init": "088080080269a2",
      "node": "888080080269a2",
      "channel": "",
      "invoice": "02000000024100"
   }
}
Enter fullscreen mode Exit fullscreen mode

Congratulation, you ran your first clightning4j-node in a very tiny virtual machine, and you can start to play with all the cool stuff that core lightning has.

Ah, you have also all your private data on the /cln/data dir so you will be able to move your data to another machine when you finish playing with the docker image.
Conclusion

The docker image is released in sync with core lightning (quite in sync) and the idea is to migrate all the stacks to a more performance one by removing JVM and using more of Rust and Golang. However, the system works quite well also integrates with Kotlin, so it is good to test if this will be just a side project or can be useful for someone.


Support

In addition, there is also a bolt 12 offer on my website here

Or, simply connect to my ln node to grow my network :)
https://bruce.lnmetrics.info

You can find me on Github Vincenzo Palazzo

Image description
This work is sponsored by a Brink grant

Top comments (0)