Bitcoin Lightning Network #4: What happens when you close half of the Lightning Network?

Andreas Brekken
Shitcoin.com
Published in
4 min readJul 27, 2018

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

  1. Compiling and running a node
  2. Becoming a hub
  3. Paying for goods & services
  4. Final thoughts

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]
autopilot.active=0

And restart 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.

The lncli closeallchannels command appears to be what I’m looking for.

However, running 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 anlncl 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 1440 and 20180 minutes.

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

Andreas Brekken is the CEO of Shitcoin.com and has been obsessed with cryptocurrency since 2011. He was the CTO/co-founder of Justcoin.com and later worked as an engineer with Kraken.com.

Follow me on Medium and Twitter for more reviews.

--

--