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

Andreas Brekken
Jul 27, 2018 · 4 min read

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.

Image for post
Image for post

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.

Image for post
Image for post

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.

Image for post
Image for post

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.

Shitcoin.com

There’s a lot of “blockchain” projects out there, but do…

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store