What is the Lightning Network?

The Lightning Network is a so-called 'Layer 2' solution for faster Bitcoin transactions, allowing for near-instant payments with little or no fees at all. By many, it is considered the future of Internet payments, and indeed, it gained unexpected and impressive growth since it's initial beta release in 2018. Major merchant and payment services are expected to adopt it within the next few years.

If you are already a Bitcoin holder, joining the network is relatively easy, from simply installing a (custodial) wallet on your smartphone or Desktop PC to running your own node (the recommended method if you want full control and security for your funds) on preconfigured out-of-the box or self-made Raspberri Pi devices, a desktop computer or web server.

How to participate in the Lightning Network

Please note that the network is still in beta state. For safety reasons, only small transactions of up to ~ 100 USD are supported at this point. If you want to adopt early though, here are several options on how to set up your own Lightning node:

Pre-Configured hardware solutions (basically plug & play)

Quick setup solutions for Windows, MacOS and Linux:

On a Raspberry Pi:

Custodial wallets:

Custodial wallets are seamless tools to send and receive Bitcoin via the Lightning Network without the need to run your own node, the payoff is that you have to trust a 3rd party.

Server-side implementations:

  • BTCPay Server is a cross platform, self-hosted server compatible with the Bitpay API, and integrating a full Bitcoin and Lightning Network node

Lightning browser addons/plugins:

Lightning Network (LND) - useful commands

Nodes

Connect to other nodes

lncli connect [uri]
lncli connect 02a209432db157f414e668dbce5ee0f986dedd7b9ecbbdb4cf9a47215e85f70d5c@122.154.122.30:9735

Retrieving node information

lncli listpeers | jq '[ .peers | .[] | select(.pub_key=="node id") ]'
Example:
lncli listpeers | jq '[ .peers | .[] | select(.pub_key=="032b71cc07ea5ff346e7ce9eddad0b55d7e18b788a1e6b4dda3fbd3a7ddbf79bbc") ]'

Channels

Open a channel:

lncli openchannel [nodeid] [amount]
Example:
lncli openchannel 02d249db09237f974f1c67775accee37a9d1eb3f04f236dda177f5a5c083094f15 200000

Number of active channels:

lncli listchannels | jq '[ .channels | .[] | select(.active==true) ] | length'

Number of inactive channels:

lncli listchannels | jq '[ .channels | .[] | select(.active==false) ] | length'

Close all active channels:

lncli listchannels | jq '.[][]' | jq -r '.channel_point' | tr : ' ' | xargs -n2 lncli closechannel

Close all inactive channels:

lncli listchannels | jq '.[][]' | jq -c -r 'select(.active == false) | .channel_point' | tr : ' ' | xargs -n2 lncli closechannel --force

Local balances in active channels - list:

lncli listchannels | jq '[ .channels | .[] | select(.active==true and .local_balance!="0") ] | .[] | .local_balance | tonumber'

Total balance in active channels - summarized:

lncli listchannels | jq '[ .channels | .[] | select(.active==true)] | map(.local_balance|tonumber) | add'

Remote balance in active channels - list:

lncli listchannels | jq '[ .channels | .[] | select(.active==true and .remote_balance!="0") ] | .[] | .local_balance | tonumber'

Remote balance in active channels - summarized:

lncli listchannels | jq '[ .channels | .[] | select(.active==true)] | map(.remote_balance|tonumber) | add'

Local balance in inactive channels - list:

lncli listchannels | jq '[ .channels | .[] | select(.active==false and .local_balance!="0") ] | .[] | .local_balance | tonumber'

Local balance in inactive channels - summarize:

lncli listchannels | jq '[ .channels | .[] | select(.active==false)] | map(.local_balance|tonumber) | add'

Remote balance in inactive channels - list:

lncli listchannels | jq '[ .channels | .[] | select(.active==false and .remote_balance!="0") ] | .[] | .local_balance | tonumber'

Remote balance in inactive channels - summarize:

lncli listchannels | jq '[ .channels | .[] | select(.active==false)] | map(.remote_balance|tonumber) | add'

Chance the fees of all channels to a minimum:

lncli updatechanpolicy --base_fee_msat 0 --fee_rate 0.000001 --time_lock_delta 144

On-Chain Funding

Send all funds to Layer 1 Bitcoin wallet:

lncli sendcoins --sweepall <address>
lncli sendcoins --sweepall bc11238afej06mgmm7574jp7uiealvtce6vecx28c

Useful tips thay may come in handy:

Bitcoin Wallets

Do you want to learn more?

Beginner's Resources

Want to dig even deeper? Check out these: