I’ve been playing with owning some bitcoin for a while. Like long enough to own some but not long enough to have made any money. Like… I didn’t buy it when it was cheap before 2017. But that isn’t the point. The point is, I have fun playing with it and owning some and I decided to play around with the a bitcoin lightning node on on my VPS.
Can you run a bitcoin lightning node on a virtual private server?
Why would someone want to install a bitcoin lightning node on a virtual private server with limited disk space Here are my reasons.
- I don’t have unlimited bandwidth at my home. Seriously? Yes Seriously. I look forward to the day when my city has access to a fiber network. In the mean time, it is what is is. Why do you need unlimited bandwidth anyway? Well, it turns out the existing blockchain is pretty big. It takes around 500GB (time of writing) for the first download and then the node is going to be adding some extra traffic 24/7 from then on.
- I don’t have a spare little computer to keep on 24/7 to run my bitcoin node. Seriously? Yes all my little computers are busy. I suppose I could get another one but… well that bandwidth thing is sort of important.
- I already have a VPS and well, to be frank this blog doesn’t get much traffic.
But what about the practicality of it? I thought you need a lot of disk space.
- Well it turns out you can run bitcoind in a pruned mode. Basically, you choose how much disk space you want to allocate to your local installation and when the daemon downloads new blocks, any old blocks are discarded if they exceed your pruned size.
- Yet to be determined though, what if my lightning node gets real busy, could the database star taking up a lot of size? I suppose that could be an issue. I haven’t got that far yet. I’m putting the in the list here as a reminder. I’ll either get that far or I won’t.
I used lightningd or Core Lightning (CLN) because supposedly it takes a few less resources. And they said you can run it against a pruned node.
OK so how did it go?
Here are the installation steps I’ve taken so far:
- Install bitcoind. This is actually pretty easy. You can get the latest release right from the GitHub bitcoin. Basically I just had to put prune=<some size in MB> in the bitcoin.conf and fire it up. They really do make it quite simple to get started. BTW you can download a pruned snapshot. It makes it so you don’t have to download the entire blockchain initially. Saves a lot of time and bandwidth.
- A lot of guides I found on the internet suggested installing some kind of block explorer. One such was btc-rpc-explorer. I installed this and tested it out but I didn’t really find anything useful for my lightning node by installing it.
- Next comes the lightningd setup. I built and installed CLN according to various guides. (Easy to google).
- You probably want some UI to manage the lightning node. You can do everything from the command line with lightning-cli but that gets sort of old and hard to keep track of after a bit. I chose Ride The Lightning. I haven’t got enough experience on this to recommend something else or unrecommend this one, but installation is straight forward according to their docs and it seems to be able to do all the important things on your lightning node.
Here is the only major issue I found:
Because I’m running bitcoind in pruned mode, lightningd needs some care setting up. Mainly, the issue is described in a bug (still open while I’m writing this). What happens is, lightningd requests a block from bitcoind but bitcoind doesn’t have it any more. They’ve talked about getting the block from a peer or something but no resolution. So, there is a workaround on the bug for a script that disables the network status of bitcoind if the current block gets too far ahead of the lightning block being processed. That made it so I could get my bitcoind up to date and lightningd was also up to date and running.
What’s next?
- This is all #reckless. Due to pruned mode, it seems the lightningd is a bit vulnerable to not having access to date it might need. I need to research this more fully. For now, play with pretty small number of sats.
- I want to research automated plugins. CLBoss looks interesting.
- Need to research backup mechanisms. How do the normal backup mechanisms of lightning nodes differ when you have a pruned node? Is running a bit risky a guarantee of loss of my funds? (Hope not lol)