Categories
lightning

c-lightning plugins

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.

Prerequisites

  • BTCPay Server, the docker version, with blockchain synced
  • c-lightning chosen as node software
  • ssh access into the server

Baby steps

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.

version: "3"

services:
  clightning_bitcoin:
    volumes:
      - clightning_bitcoin_plugins:/root/plugins
      - clightning_bitcoin_usr_local_bin:/usr/local/bin

volumes:
  clightning_bitcoin_plugins:
  clightning_bitcoin_usr_local_bin:

Next is to tell BTCPay of this new fragment and rebuild the server.

export BTCPAYGEN_ADDITIONAL_FRAGMENTS="$BTCPAYGEN_ADDITIONAL_FRAGMENTS;opt-add-clightning-plugins"
. 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
cd /root/plugins
apt-get update
apt-get install git  wget nano(or your preferred terminal text editor)
git clone https://github.com/lightningd/plugins.git
wget https://github.com/ZmnSCPxj/clboss/releases/download/0.11B/clboss-0.11B.tar.gz
tar -xzf clboss-0.11B.tar.gz
rm 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.

First is setup-clighting-plugins.sh

apt-get update
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
source $HOME/.cargo/env

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.

Second is setup-clboss.sh

apt-get update
apt-get install build-essential pkg-config libev-dev libcurl4-gnutls-dev libsqlite3-dev dnsutils git automake autoconf-archive libtool -y

cd clboss-0.11B

./configure
make
make install
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.

version: "3"

services:
  clightning_bitcoin:
    environment:
      LIGHTNINGD_OPT: |
        plugin=/root/plugins/plugins/rebalance/rebalance.py
        plugin=/usr/local/bin/clboss
    volumes:
      - clightning_bitcoin_plugins:/root/plugins
      - clightning_bitcoin_usr_local_bin:/usr/local/bin

volumes:
  clightning_bitcoin_plugins:
  clightning_bitcoin_usr_local_bin:

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]
bitcoin-lightning-cli.sh clboss-status

To summarise, Whoomp, there it is!

Categories
scamdemic

Masks are back

Or are they? Not according to the latest Government guidance in the UK. This page was updated today and still states you do not need to wear a mask at all.

https://www.gov.uk/government/publications/face-coverings-when-to-wear-one-and-how-to-make-your-own/face-coverings-when-to-wear-one-and-how-to-make-your-own

As always, do your own research.

Categories
scamdemic

The sky is falling

Everywhere except the Republic of Ireland it would seem, where the global pandemic seems to have passed it by. What have they done that is so special that they’ve escaped the wrath of this fatal pandemic?

https://www.globalresearch.ca/study-covid-19-deaths/5742850

So total deaths for all reasons in 2020 were lower than 2019. How is that possible if 2020 the year of the great pandemic?

Categories
Uncategorised

Accessibility as a coder

A deep dive into life after every coders worst nightmare becomes a reality.

https://joshwcomeau.com/accessibility/hands-free-coding

Categories
Uncategorised

Coventry driverless pods receive Royal Seal of Approval

Good news for Coventry and Milton Keynes

Coventry-based RDM Group had a surprise visitor to their display yesterday at celebrations held to mark the 50th birthday of Milton Keynes

Categories
Uncategorised

Keep the fight going

Keep the fight going

24/09/2017 - 1

Categories
Uncategorised

Come on Motor Trend, that’s not the rhetoric of the industry. Get with the program!

Come on Motor Trend, that's not the rhetoric of the industry. Get with the program!

Categories
Uncategorised

Tesla snubs Nvidia, develops own self-driving chip with AMD—report

Autopilot version 3? Will becoming a chip manufacturer be a step too far for Tesla?

Tesla’s obsession with building components in-house extends to AI chips.

Categories
Uncategorised

Berlin to become double-header as Brussels is replaced

I feel another cross Europe road trip is in the works.

This season’s Formula E schedule will feature an extra race in Berlin, after the Brussels ePrix on July 2 was officially called off.

Categories
Uncategorised

Today a legend fades

#TJ13 #F1 – Today a legend fades

By TJ13 contributor Oddball Today, Formula 1 was left with one less Legend. John Surtees, the only person to have won grand prix titles on both two and four wheels passed away. Surtees made is mark as a brilliant motorcyclist and dominated the top 500cc…

By TJ13 contributor Oddball Today, Formula 1 was left with one less Legend. John Surtees, the only person to have won grand prix titles on both two and four wheels passed away. Surtees made is mark…