This illustrated walkthrough includes older software and hardware. Its screenshots explain the workflow, but menu names, prices, requirements and service availability may differ. Use the linked project documentation for the version you are running.
About
This page aims to help people understand a little more on the mechanics of Lightning and how it interacts with the underlying Bitcoin network. We aim to achieve this by using simple terminology and without getting too deep into the technicals, although there will be some further reading linked for those that want to take things a step further. Thanks to the developers of the various applications that interact with Lightning, many of the concepts outlined here are obfuscated away behind simple user interfaces. However, it always pays to have a good base level of understanding to help a user be more aware of what is happening when they send or receive a payment via Lightning.
Get started
Theory is great but there’s nothing quite like getting your hands dirty! Once you’re set up, feel free to send me an invoice for a few sats to test your setup.
The original Breez Mobile app is in maintenance mode, with critical and security fixes rather than new feature development. Its documented features include encrypted cloud backups, iCloud and WebDAV; complete the backup flow for that exact app and retain any required encryption credential before funding it. Do not assume that recording a seed alone restores active Lightning channels. Breez SDK-based apps are separate products with their own recovery models. Check channel-opening and swap fees before using an on-chain deposit or withdrawal.
If you want to do things through your own node, then using an implementation such as myNode or RaspiBlitz makes set up easy. They come pre packaged with node management tools like RTL and Thunderhub and make connecting mobile wallets like Zap or Zeus very simple. Here is a simplified workflow for using these processes…
- Setup your node
- Enable Lightning and create a wallet
- Decide how much you want to open the channel with based on your expected spending habits
- Fund your new on chain wallet with the desired amount of sats
- Identify a suitable channel partner using the advice below and obtain their node’s public key
- Open the channel using RTL or Thunderhub and wait for it to be confirmed on the blockchain
- Select a mobile wallet and connect it to your node using the guides relevant to your chosen node/wallet combo (this is completely optional as RTL or Thunderhub can be used to transact, but are not mobile native).
- You can now send some sats over Lightning using your own node
- See the steps outlined here for gaining some inbound liquidity to allow you to receive sats
The Bitcoin and Lightning stack
The Bitcoin ‘base layer’ (the blockchain) cannot facilitate enough transactions to allow billions of people to use it every day. For example, if a couple of million people suddenly wanted to start using the network daily for everyday purchases, the transaction queue and fee rate would quickly spike as people compete to get their transactions processed. To alleviate this and enable the network to scale to cope with the expected exponential increase in transaction numbers, a layered system is being worked on and rolled out, much like the Internet Protocol stack.
Of course these transaction levels could be drastically increased by using a centralised database, similar to the current financial system we have today. But that wouldn’t be very ‘Bitcoin’, would it? Transactions could be censored, privacy would be non-existant and we would be no better off. Enter the original ‘layer 2’ Bitcoin solution, The Lightning Network.
The Lightning Network is a scaling protocol built on Bitcoin for payments that usually settle quickly off-chain. Self-custodial channels use Bitcoin transactions to enforce balances without requiring every payment to enter a block. A user with the required current channel data can initiate a unilateral on-chain exit, but confirmations, fees and timelocks affect when funds become spendable. Monitoring and reliable backups remain necessary; a custodial wallet adds a separate trust relationship.
Nodes connect through channels. The highlighted path is one possible route, not a live network map.
Channels
Lightning uses payment channels settled on Bitcoin’s blockchain. It can provide fast payments, but success and cost depend on liquidity, connectivity and the wallet or service. Channel monitoring and implementation-specific backups add requirements beyond ordinary on-chain custody.
A channel is opened by one or two users locking up an amount of sats into an on chain ‘funding transaction’ that creates a 2 of 2 multi-signature wallet on the Bitcoin network, with each user receiving one of the keys. The opening channel ‘state’ will reflect the amount a user contributes and each party will sign off to say that they accept this is correct. This ‘sign off’ is actually an unbroadcasted Bitcoin transaction containing the signature of both parties which are passed to one another via the Lightning network. These signed but unbroadcasted transactions allow either party to close the channel at any point and ensures the sats contained within are returned ‘on chain’ to their rightful owner.
Alice funds a channel with Bob. After confirmation, they can update their balances off-chain.
Illustrative balances. Fees and channel reserves are omitted.Each time a payment is made from person A to person B, sats are pushed from one side of the channel to the other (think beads sliding along an abacus). The two parties then sign a Bitcoin transaction to reflect the updated channel balance of each and pass across to the other participant. This process can be repeated an unlimited amount of times and these signed transactions are only ever broadcast to the Bitcoin network in the event of a channel closure.
Alice sends Bob 10,000 sats. Their balances change without an on-chain transaction for this payment.
Illustrative balances. Fees and channel reserves are omitted.Who to open a channel with?
You can open a channel with pretty much any network participant you like, however there are a number of things to consider before doing so…
- Is it someone you are likely to be transacting with often? If they are, it makes sense to have a direct channel open to minimise routing fees.
- Are they a reliable peer? If they are offline regularly this will cause you issues when sending or receiving transactions.
- Are they well connected? If you only have 1 or 2 peers, it pays for them to be fairly well connected so that you can route transactions through them across the network. This will become clearer in the next section on transactions.
- Are they trustworthy? This is covered in detail below, but your peer has the option (although unlikely to succeed) to attempt to cheat you when closing a channel. It can save you some hassle to choose a peer you know or a public node entity that is commonly accepted as being an honest node operator
You can compare these stats and many more when choosing a peer at 1ml or use a simplified version here that gives nodes an aggregated score based upon a combination of things like uptime, liquidity and how well connected they are. It then displays the best 5%.
Channel Closures
Closing a channel settles it on Bitcoin's base layer. A cooperative close is negotiated by both peers; a unilateral close publishes a commitment transaction. Fees depend on the channel type and close mechanism, and extra claim transactions may be needed. It is not correct that the original opener always pays every closing and recovery fee.
Collaborative close
Where one party initiates a channel closure, communicates this with their channel partner. Both parties agree to close the channel and the most recent state is broadcast to the network and each participant receives their sats back to their on chain wallet. This scenario covers the vast majority of all Lightning channel closures.
Force Close
In a force close, a peer publishes a commitment transaction without needing the other peer online. The broadcaster's own balance normally has a relative timelock, while HTLC outputs can need additional transactions and deadlines. The delay is negotiated for that channel; 2,016 blocks is an example, not a universal setting or a guaranteed two-week wait.
Disputed close
A revoked-state close must be detected and acted on before the relevant timelock expires. The counterparty or a compatible watchtower uses revocation data saved during earlier channel updates to claim the revoked outputs. Keep monitoring and recovery arrangements working; simply coming online after a deadline cannot undo a confirmed theft.
The penalty mechanism spends a revoked commitment's outputs using the revocation secret. It does not replace the transaction by publishing a newer channel state. This is why stale channel databases are dangerous and why nodes exchange revocation information as they update the channel.
Transactions
A channel records changing balances between participants. A conventional channel has a funding transaction and a closing transaction; splicing, swaps or on-chain enforcement can add transactions and fees. Closing may involve confirmation delays and timelocks.
Thankfully not, this is where the Lightning Network starts to shine! Provided you have 1 or 2 channels to fairly well connected nodes, you can route transactions to people you aren’t directly connected with, via people you have a direct connection (a channel) with.
Alice pays Dan through Bob and Carol. She does not need a direct channel with Dan.
Example fees: Bob and Carol keep 1 sat each. Every hop needs enough outgoing liquidity.Lightning does not publish each payment as an on-chain transaction, but peers, routing nodes and service providers can observe parts of a payment. Its privacy properties depend on the wallet, route and deployment.
Here is a simplified run down of what happens for the transaction above to be successful. It sounds complicated, but it all happens under the hood in a matter of seconds.
- Dan sends Alice an invoice (a payment instruction) for 10,000 sats. This is generated by Dan’s Lightning wallet and can be sent to Alice via any communication method
- Alice receives the invoice and opens it with her Lightning wallet. She checks the details and confirms the invoice payment
- Alice’s Lightning node uses its knowledge of the Lightning network to look for a suitable path to route the payment to Dan
- Once a route is found, the initial hop goes to Bob, whom Alice has a direct channel with
- Alice’s message to Bob says that if he sends 10,001 sats to Carol, he can keep 1 sat for himself
- They update their channel state
- Bob sends a message to Carol to say that if she sends 10,000 sats to Dan, she can keep 1 sat for herself
- They update their channel state
- Carol sends a message to Dan, which Dan has a secret to unlock, allowing him to claim the 10,000 sats from Alice
- They update their channel state
- Alice’s wallet tells her the transaction was successful
There are no ‘real world’ identities in Lightning, the names above are purely for illustration purposes. Each participant has a Node Public Key which acts as their ‘Lightning ID’.
Drawbacks
Whilst the Lightning Network provides a fantastic scaling solution for Bitcoin, it of course has some limitations. These are outlined breifly below…
-
Channel management - If a user makes a lot of payments in a single direction, channels can become unbalanced, meaning that all of the funds are stuck on one side of the channel. This then requires the user to take action by balancing their channels. This can be done by circular rebalancing (paying yourself out of one channel and into another) or via a submarine swap service that allows you to drain off or fill up an existing channel for a small fee. Most of the common Lightning node management tools have some form of swap service built in.
- Inbound liquidity - If a user opens a channel to someone else, all of the funds initially sit on their side of the channel. This means they can only send payments and cannot receive. Lightning wallets like Breez and Phoenix have recently released upgrades that mitigate this by opening channels on the go as required. However for those running their own Lightning Node and managing their own channels, these are the main ways around this…
- Get someone else to open a channel to you. Certain companies like LN Big will reciprocate any channels opened with to them
- Spend some sats ‘away’ to the other side of the channel
- Purchase some inbound liquidity from a service like Lightning Pool
- Use a submarine swap service
-
Channel Size - If a user opens a channel for 1 million sats and then needs to make a payment of 1.5 millions sats, they cannot do so without the use of Multi Path Payments which allows the use of more than one payment channel controlled by a single user to route a transaction. Fortunately, this is fast becoming standard practice and hugely increases the user experience and improves payment success rates
-
Route liquidity - If Alice wants to send a large payment to Dan over Lightning, she needs all of the people on her chosen route to have at least that amount of channel balance otherwise the payment will fail. This only really becomes an issue for larger payments.
-
Hot Wallets - Due to the nature of the Lightning network, a user’s Lightning node needs to be online 24/7 to acknowledge and sign transactions back and forth. This means that it is advisable that users do not lock up large amounts of bitcoin without taking proper security and backup precautions.
Back up according to the Lightning implementation. LND requires its seed (and any seed ) plus up-to-date static channel backups for its usual disaster-recovery route. Preserve the channel.backup file off the node and refresh it as channels change. It asks peers to close channels; it is not a snapshot for resuming them. Never restore an old channel database casually.
FAQ
Do I need to use Lightning?
Choose according to the payment size, urgency and current fees. On-chain fees vary with demand; Lightning may help with frequent small payments, but channel liquidity, routing and service fees also matter. There is no stable percentage of users for whom one method is always cheaper.
Do I need a node?
Lightning payments depend on compatible features, a usable route and sufficient liquidity. Payments can fail or incur fees; running your own node also adds backup, uptime and maintenance responsibilities.
Who maintains the Lightning Network?
Lightning payments depend on compatible features, a usable route and sufficient liquidity. Payments can fail or incur fees; running your own node also adds backup, uptime and maintenance responsibilities.
Is there a ‘Lightning coin’?
No, Lightning transactions essentially transfer ownership of bitcoin from on person to another.
Why do payments fail?
Payment failures occur for many different reasons, however the most common is that the node you are transacting through cannot find a suitable payment route to the destination.
What does balanced channels mean?
Useful channel balance depends on the direction and size of expected payments. Equal local and remote balances are not a universal target, and a balanced channel does not guarantee successful routing.
Using the example below, the blue balance on the left is the ‘local balance’. This represents the size of the balance on my side of each channel and is how much I can spend within each. The green balance on the right is the ‘remote balance’. This represents the size of the balance on my peer’s side of the channel and is how much I can receive within each.
FIG. 05FAQ
Channel balance graphs from Thunderhub
How do I balance my channels?
The two most common Lightning node management tools Ride the Lightning and Thunderhub make this very simple within the user interfaces. Click the links for video demo’s of both.
What happens if my node breaks while I have open channels?
First try to repair the existing LND node. If disaster recovery is necessary, keep the old node offline, recover the seed into a replacement LND installation, then restore the static channel backup using LND's documented procedure. Peers must cooperate by force-closing; recovery speed varies. Do not run two instances from the same channel state or restore a stale channel.db as if it were a normal wallet backup.
Why do my channel balances change over time?
Routing a payment changes local and remote balances. An unannounced channel is not advertised in the public channel graph, but that is not a cryptographic guarantee that it can never forward payments or be discovered. Private invoice hints, peers and observed payment traffic can disclose channel information.
How do I get my sats off Lightning?
You can close a channel, which will refund your balance back to your on chain wallet. Alternatively, if you have received a lot of Lightning payments and your channel balance is getting full, you can complete a loop out which will drain a percentage of your channel balance back to an on chain wallet, freeing up some channel capacity for you to receive again. The reverse operation (loop in) can be used to ‘top up’ your channel balance if you have made lots of payments and no longer have sufficient outbound liquidity.
CoinOS appears here as a swapping example from the original article. Establish who controls the keys in the exact account mode before depositing, and inspect the swap quote, fees and withdrawal conditions. Non-custodial key control does not by itself remove software, service-availability or swap risks; the old instruction should not be read as a guarantee that every current CoinOS flow removes third-party exposure.
Can I make my channel larger after I have opened it?
Some implementations support splicing, which changes a channel's capacity through an on-chain transaction while retaining the channel relationship. Phoenix is one deployed example. Both peers and the implementation must support the flow; otherwise use another channel. Multi-part payments combine liquidity across channels but do not themselves resize them.
Can I make money on the Lightning Network?
Yes, technically you can earn sats via routing. However, the gains to be had vs the node and channel management required put this practice out of reach for the average Lightning user.
How much does it cost to open or close a channel?
That depends on the current state of the Bitcoin mempool at the time and the fee rate negotiated with your channel partner.
What is Keysend?
Keysend is a development that allows for spontaneous payments to be routed without an invoice.
What are MPP?
Multi Path Payments allows a user to send payments that are larger than the capacity of their single largest channel by utilising the liquidity of more than 1 channel at the same time. This needs to be active at the node level
If after reading this guide you want to try Lightning for yourself but think you’d benefit from a more personalised tuition approach, I offer private support calls.
Lightning Tools
Other Resources
- White paper
- In depth Lightning Network explainer
Mastering the Lightning Network, by Andreas M. Antonopoulos, Olaoluwa Osuntokun and René Pickhardt: the first edition was published on 21 December 2021, and its manuscript is available from the authors’ repository.
- Lightning Wiki
- Lightning Node Management by Openoms
- Extensive list of Lightning resources
- Another Lightning resource hub
Videos
- Ministry of Nodes LN overview
- Ministry of Nodes practical application
- TFTC Breez Wallet walkthrough
- BTC Sessions full Lightning intro and setup guide
- BTC Sessions Phoenix Wallet walkthrough
- KIS Bitcoin RTL walkthrough
