Bitcoin Lightning Network #4: What happens when you close half of the Lightning Network?
Operating a Lightning Node is easy, but then again it doesn’t pay much either. What happens when you close down half of the Lightning Network capacity? Andreas finds out.
In the third part of my Lightning Network review I bought goods and services with Lightning, with varying degrees of success. Today, I’ll try to close all of the channels and hopefully recover most of my funds.
Today’s review is more of a demonstration. I hope you enjoy the change in format.
TL;DR: Operating the largest node on the Bitcoin Lightning Network has been educational, frustrating, fun, and at times terrifying. I look forward to trying it again once the technology matures.
Subscribe to the newsletter and I’ll tell you the next time I review something.
Parts of the review
Checking in on the Lightning node
It’s been a over a week since I last inspected the Lightning Node. Are the funds still there?
I connect to my Lightning Node node.
~ ssh andreas-tries-lightning-network
The funds are still there. My Lightning Node has routed 389 payments, making a profit of $0.34. I suspect the increase is mostly from the recent increase in bitcoin’s price.
Running a large Lightning Network node has been quite stressful. An exploit such as we saw with heartbleed could allow an attacker to drain all funds from the node while I’m sleeping. It’s time to end the experiment.
I disable the
lnd auto pilot feature.
$ vim ~/.lnd/lnd.conf...[Autopilot]
lnd. As an experienced user, I now know that the startup time of
lnd can be very long for a Lightning Node that has an unusually large amount of channels.
I look for a command to close channels.
$ lncli -h | grep close
closechannel Close an existing channel.
closeallchannels Close all existing channels.
closedchannels List all closed channels.
lncli closeallchannels command appears to be what I’m looking for.
lncli closeallchannels results in a prompt asking me whether I want to close the channel for each of my over 200 channels.
I will close each channel separately.
$ lncli listchannels > chan1.json
I now have a list of channels in the JSON format. The next step is to iterate over the list and run
lncli closechannel for each entry.
Most channels take a few seconds close. Something causes an
lncl freeze. I abort the
lncli closechannel command with
CTRL+C and restart it. After a few attempts most channels are closed.
The remaining channels cannot close gracefully because the Lightning Node on the other side of the channel is offline. I force close these channels using
lncli closechannel --force.
Closing a channel using
--force results in a unilateral close which makes the funds unavailable to me. The amount of time the funds are locked up depends on the channel policy. This policy is negotiated when the channel opens. Most channels will release the funds to me in between
Operating the largest node on the Bitcoin Lightning Network has been educational, frustrating, fun, and at times terrifying. I look forward to trying it again once the technology matures.
Want to know when I post another review? Subscribe to the newsletter below.
See you back here for the next review, blockchainers!
About The Author
Follow me on Medium and Twitter for more reviews.