keepcalculator

06 Numbers and Powers

Lightning Network Channels: How They Work

Card No. 06·44569 · Updated · Standard formula, shown below

Lightning Network channels are two-party payment paths that let Bitcoin users transact off-chain instantly and cheaply. You open a channel by locking Bitcoin in a shared address, then send signed balance updates back and forth; only the final state touches the blockchain. This article explains the mechanics, costs, safety, and common pitfalls of running channels.

Background: Why Lightning Exists

Bitcoin’s base layer processes roughly 7 transactions per second and confirms each one in about 10 minutes. That throughput is fine for settlement, but not for everyday payments like buying coffee or streaming sats. The Lightning Network (LN) was proposed in 2015 and launched on mainnet in 2018 as a “layer 2” solution: it moves most transactions off-chain while keeping the security of the underlying blockchain.

The core idea is that two parties who expect to transact repeatedly can create a private ledger between themselves. Instead of broadcasting every payment to the whole network, they just update their shared balance. The blockchain only sees two transactions: the opening and the closing of the channel.

What Exactly Is a Channel?

A channel is a 2-of-2 multisignature address on the Bitcoin blockchain. Both parties deposit funds into this address (the “funding transaction”), and the channel is now open. From that moment, the two parties can exchange signed commitment transactions that reflect the current distribution of the funds. Each commitment transaction spends the funding output and splits it between the two parties according to the latest agreement.

Key properties of a channel:

  • Two parties only — a channel connects exactly two nodes (though you can route payments through many channels).
  • Off-chain balance updates — the parties exchange new commitment transactions without broadcasting them.
  • Either party can close — at any time, one side can broadcast the latest commitment to the blockchain, and the channel closes.
  • Capacity is fixed — the total amount locked in the channel never changes; only the split between the two parties changes.

How Opening and Closing Work

Opening a channel is a straightforward on-chain transaction:

  1. Alice and Bob agree on a channel capacity (say 0.1 BTC).
  2. One of them (or both) creates a funding transaction that sends 0.1 BTC to a 2-of-2 multisig address.
  3. Before broadcasting, they exchange initial commitment transactions that each can broadcast to get their share back.
  4. Once the funding transaction confirms, the channel is open and ready for off-chain payments.

Closing a channel also involves an on-chain transaction. Either party can broadcast the latest commitment transaction, which pays each side their current balance. There are two ways to close:

  • Cooperative close — both parties agree on the final state and sign a single closing transaction. This is cheaper and faster because it can use a simple output.
  • Force close — one party broadcasts the latest commitment unilaterally. This triggers a timelock (usually 144 blocks, about a day) before the other party can claim their funds, giving time to challenge any cheating attempt.

How Payments Route Through Channels

If you want to pay someone who is not your direct channel partner, Lightning uses a technique called hash time-locked contracts (HTLCs). Here’s a simplified example:

  1. Alice wants to pay Carol 1 BTC, but she only has a channel with Bob. Bob has a channel with Carol.
  2. Alice creates a payment hash (a random number hashed) and sends an HTLC to Bob: “I’ll pay you 1 BTC if you can provide the preimage of this hash within 48 hours.”
  3. Bob forwards the same HTLC to Carol, but with a shorter timelock (say 24 hours).
  4. Carol, who knows the preimage (because she is the recipient), reveals it to Bob to claim her 1 BTC.
  5. Bob now has the preimage, so he uses it to claim 1 BTC from Alice.

This way, neither party needs to trust the other. If someone fails to reveal the preimage, the HTLC expires and funds return to the original owner. The routing is done by nodes that charge a small fee (usually a base fee plus a rate per satoshi).

Choosing a Channel Partner and Amount

When you open a channel, you decide who to connect to and how much to lock up. These choices affect your ability to send and receive payments.

  • Channel capacity — the total amount locked. You can only send up to your balance and receive up to the other side’s balance. If you want to receive payments, you need inbound liquidity (the other party’s share).
  • Channel partner — you can open with a merchant, an exchange, or a well-connected routing node. Opening with a merchant you frequently pay makes sense because you control the outbound side. Opening with a large node like a liquidity provider can give you inbound liquidity, but you may pay fees for their service.
  • Number of channels — more channels increase your reach but also increase capital lockup and management complexity. A common strategy is to have a few well-connected channels rather than many small ones.

Costs and Fees

Lightning is cheap, but not free. There are three types of costs:

  • On-chain fees — opening and closing a channel each require a Bitcoin transaction fee. These vary with network congestion. Opening a channel costs about the same as a regular Bitcoin transaction (currently a few dollars).
  • Routing fees — when your payment passes through other nodes, each node charges a fee. Most nodes set a base fee (e.g., 1 sat) plus a proportional fee (e.g., 0.01% of the amount). For small payments, the base fee dominates; for large ones, the percentage matters.
  • Opportunity cost — the Bitcoin locked in a channel cannot be spent or invested elsewhere. If you lock 0.1 BTC, you lose the ability to use that money until you close the channel.

Common Problems and Misconceptions

New users often run into these issues:

  • No inbound liquidity — you can send, but not receive. This is the #1 complaint. Solutions: open a channel with a service that provides inbound (like a Lightning service provider), or use a “splicing” technique to rebalance.
  • Channel stuck — if your peer is offline, you cannot route payments through them. You can still force-close, but that costs a fee and takes time.
  • Liquidity imbalance — if you send all your balance to the other side, the channel becomes one-directional. You can rebalance by sending a payment to yourself through another channel, but that costs fees.
  • Misconception: Lightning is anonymous — while payments are not on-chain, nodes can infer transaction patterns and IP addresses. For privacy, use Tor or a VPN.
  • Misconception: Channels are permanent — they are not; you can close them anytime. But frequent opening/closing is expensive, so it’s better to keep channels open for a while.

Safety and Risks

Lightning is secure if you follow best practices, but there are risks:

  • Losing your channel data — if you lose your channel state (e.g., hard drive failure) and your peer broadcasts an old state, you could lose funds. Always back up your channel database.
  • Cheating peers — a malicious peer might try to broadcast an old commitment that favors them. The protocol includes penalties: if you catch them, you can take all the channel funds. But this requires you to be online and watching.
  • Watchtowers — third-party services that monitor the blockchain for cheating attempts. They can protect you even when you’re offline, but they add a small fee.
  • Routing node risk — if you run a routing node, you are not at risk of losing funds (you only forward HTLCs), but you can be scammed if you do not enforce timeouts correctly.

Alternatives to Running Your Own Channels

Not everyone needs to manage channels. Alternatives include:

  • Lightning wallets with built-in services — many wallets (like Phoenix or Breez) automatically open and manage channels for you. They may charge a fee for the service, but you avoid the technical hassle.
  • Lightning Service Providers (LSPs) — companies that provide inbound liquidity and routing. You connect to them, and they handle the heavy lifting.
  • Submarine swaps — services that let you convert on-chain Bitcoin to Lightning (or vice versa) without opening a channel yourself. They use a single transaction and a swap service.
  • Centralized exchanges with Lightning — some exchanges allow you to withdraw Bitcoin via Lightning directly, so you don’t need to open channels at all.

Frequently Asked Questions

Do I need to run a full Bitcoin node to use Lightning?

No. You can use a Lightning wallet that connects to a third-party node, but for maximum security and autonomy, running your own node is recommended. Many wallets (like Zap or Zeus) can connect to your own node or a remote one.

Can I lose money in a Lightning channel?

Yes, but only if you make a mistake. If you lose your channel data or your peer cheats and you don’t respond, you could lose funds. However, the protocol is designed so that honest, online parties never lose funds. Using a watchtower mitigates the offline risk.

How many channels do I need?

It depends on your usage. If you only pay a few merchants, one or two channels may suffice. If you want to route payments or receive from many people, you need more inbound liquidity, which may require several channels. A common starting point is 3-5 channels.

What happens if my channel partner goes offline?

Your channel remains open, but you cannot route payments through it. You can still send payments if you have other routes. If you want to close, you can force-close, which broadcasts the latest state and starts the timelock. Your partner doesn’t need to be online for you to close.

Is Lightning private?

Lightning payments are not publicly visible on the blockchain, but nodes can see the payments they route. There are privacy-enhancing techniques like multi-path payments and Tor, but Lightning is not fully anonymous. For sensitive transactions, consider additional privacy tools.

How do I get inbound liquidity?

You can open a channel with a service that provides inbound (like an LSP), or you can ask a friend to open a channel to you. Some exchanges allow you to “buy” inbound liquidity. Alternatively, you can use a submarine swap to convert on-chain Bitcoin to Lightning, which gives you inbound capacity.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →