So I’ve recently started a new lightning node and thought I would give c-lightning a punt and see how it compared to my existing LND node. Now neither node has any ambitions at being a major player so I’m not suffering from the database issues that a couple of the real big boys are currently wrestling with; my motivations are purely for learning purposes.
I participate in quite a few Rings of Fire as this helps the node get bootstrapped with incoming and outgoing liquidity quickly, easily and in a decentralised fashion. For me, decentralised means not connecting to the large nodes that naturally attract liquidity and always runs the risk of being honeypots collecting data. I’ve always been on the periphery and my philosophy carries over into my node partner selection preferring plebs over suits.
Anyways, enough blabber, let’s get into the meat of this.
What am I trying to achieve?
I really wanted to use my new node to rebalance the first ring I got involved in and quickly found that converting the gold standard rebalancing script, which is made to run on an LND node to the equivalent c-lightning commands was not going to work.
So after asking around I was recommended both c-lightning plugins and clboss. The plugins have a rebalance script as part of the toolset, and clboss is a fire some funds at the node and leave it to do what it does kinda affair. As this was mainly a technical proof of concept, I focused on the hacky route to prove I could get them working before trying to productionise it.
- BTCPay Server, the docker version, with blockchain synced
- c-lightning chosen as node software
- ssh access into the server
Now by taking this proof off concept route there will be a fair bit of manual work needed to get the plugins off the ground, so be prepared.
First off we are going to create a snippet that will create some volumes for us so our work persists and make BTCPay aware of the snippet and have it integrated into the main compose file.
From the root directory of BTCPay on the host, cd into the
docker-compose-generator directory and create a file called
opt-add-clightning-plugins.yml and write the following into it with your editor of choice.
Next is to tell BTCPay of this new fragment and rebuild the server.
. btcpay-setup.sh -i
Once it spins back up we will have two new volumes created that will persist what we are about to do next in between teardowns and upgrades which both will recreate the containers from scratch. There will still be work to do should these events occur but at least they’re just watching scripts run.
One off steps
Getting the code into the right places in the containers is a one-off job.
docker exec -it btcpayserver_clightning_bitcoin bash
apt-get install git wget nano(or your preferred terminal text editor)
git clone https://github.com/lightningd/plugins.git
tar -xzf clboss-0.11B.tar.gz
I created two shell scripts for the setup of both of these individually so you can choose if you only want to have one or the other, alternatively you can combine the following contents into one script deduping the superfluous content.
apt-get install git gcc build-essential libssl-dev libffi-dev python3-dev autoconf make automake pkg-config zlib1g-dev curl nano -y
apt-get install libtool -y
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
pip3 install setuptools wheel
pip3 install pyln-client pyln-bolt7 pyln-proto
When executing, the rust setup needs manual intervention where you will enter
1 when prompted, otherwise it’s just a long boring wait.
apt-get install build-essential pkg-config libev-dev libcurl4-gnutls-dev libsqlite3-dev dnsutils git automake autoconf-archive libtool -y
chmod +x setup-clightning-plugins.sh
chmod +x setup-clboss.sh
Manual steps completed and automation in place to assist on renewal of the c-lightning container.
Release the Kraken
Let’s switch on these bad boys eh, now we’ve got this far.
We need to add a few more lines to the BTCPay compose file snippet we created at the start. I’ll put the whole file for the sake of completeness.
I needed the rebalance plugin for my needs but you get the idea that each plugin you need needs its own line referencing it to activate it on container launch. Once again, rebuild the server.
. btcpay-setup.sh -i
Once everything has had a chance to rebuild and spin up, you want to check there haven’t been any errors on launch, so run:
docker logs btcpayserver_clightning_bitcoin
and make sure there are no errors such as:
/usr/local/bin/clboss: error while loading shared libraries: libev.so.4: cannot open shared object file: No such file or directory
2022-03-22T11:04:58.640Z INFO plugin-clboss: Killing plugin: exited before replying to getmanifest
Traceback (most recent call last):
File "/root/plugins/plugins/rebalance/rebalance.py", line 2, in <module>
from pyln.client import Plugin, Millisatoshi, RpcError
ModuleNotFoundError: No module named 'pyln'
What you want to see is a nice clean:
Installing bundled plugins
C-Lightning starting, listening on port 9735
Then on the host you can run the following to test both plugins are working
bitcoin-lightning-cli.sh rebalance [outgoing short channel id] [incoming short channel id] [amount in sats]
To summarise, Whoomp, there it is!