babybitcoin.space

How Does a Bitcoin Lightning Channel Open and Close?

A Lightning channel opens when two parties commit bitcoin to a shared multisignature address on the Bitcoin blockchain, and closes when they broadcast the final balance to settle those funds back on-chain. The channel itself is a payment path that allows near-instant, low-fee transactions between the two participants, without every individual payment being recorded on Bitcoin's main ledger.

What a lightning channel actually is

Think of a Lightning channel as a private tab between two people. You each deposit some bitcoin into a 2-of-2 multisignature address - meaning both of you must sign to spend from it. Once that deposit is confirmed on-chain, you can update the balance between yourselves as many times as you like, off-chain. Only the opening and closing transactions touch the Bitcoin blockchain; everything in between is just the two of you agreeing on who owes what.

Opening a Channel

Opening a channel is an on-chain Bitcoin transaction. Here is how it works in practice:

  1. Choose a peer. You need someone else running a Lightning node. This could be a friend, a merchant, or a routing node you find through the network's gossip protocol. Most wallets let you connect by scanning a QR code or pasting a node URI.

  2. Select a funding amount. You decide how much bitcoin to commit to the channel. That amount becomes the capacity of the channel. You can fund the channel entirely from your side, or both parties can contribute. If only you fund it, the other side can still receive payments up to that amount, but cannot send more than they receive first.

  3. Construct the funding transaction. Your wallet creates a Bitcoin transaction that sends your chosen amount to a 2-of-2 multisignature address. Both you and your peer generate keys for this address. Neither of you can spend the funds alone.

  4. Broadcast the transaction. The funding transaction goes to the Bitcoin mempool and gets confirmed like any other transaction. Once it has enough confirmations (the number depends on your wallet settings and how much risk you accept), the channel is open and ready for payments.

At this point, the channel exists. You and your peer each hold a copy of the latest "commitment transaction" - a pre-signed transaction that pays each of you your current balance. Neither of you can broadcast it unilaterally without the other noticing, because the protocol gives each side a way to punish the other if they try to cheat.

Using the Channel

Once open, you can send and receive payments. Each payment updates the balance split between you and your peer. No new on-chain transactions are created. Instead, you exchange signed commitment transactions that reflect the new balances. The old ones are invalidated.

This is where the speed comes from. A Lightning payment settles in seconds or less, and the fee is typically a fraction of a cent. The only cost is the on-chain fee you already paid to open the channel, plus whatever you will pay to close it.

Closing a Channel

Closing a channel means settling the final balance on the Bitcoin blockchain. There are three ways it can happen.

Cooperative Close

This is the ideal scenario. Both parties agree to close the channel and broadcast a closing transaction that pays each of you your current balance. Because both sign, the transaction is simple and inexpensive. The on-chain fee is whatever you set; most wallets let you choose between faster and cheaper options.

  1. Either party sends a "close" request with the final balance.
  2. The other party signs the closing transaction.
  3. The closing transaction is broadcast and confirmed on-chain.
  4. Each side receives their bitcoin to the address they specified.

A cooperative close typically confirms in the next block or two, depending on the fee.

Unilateral Close

If your peer goes offline, refuses to cooperate, or you lose connection, you can close the channel by yourself. You broadcast your latest commitment transaction. That transaction pays you your current balance and sends your peer theirs, based on the last state you both agreed on.

There is a catch: the commitment transaction includes a timelock. Your peer cannot claim their funds immediately. They must wait a certain number of blocks (typically a few hundred, which is a few days). This delay exists to give you time to punish them if they tried to broadcast an old, invalid state.

Force close (with cheating penalty)

If your peer broadcasts an old commitment transaction that gives them more than they are entitled to, you can respond. The protocol gives you a "revocation key" that lets you claim all the funds in the channel as a penalty. This is the enforcement mechanism that keeps both sides honest. In practice, honest nodes never cheat, because the penalty is total loss of the channel balance.

What happens after closing

Once the closing transaction is confirmed on-chain, the channel no longer exists. Each party has their bitcoin back in a regular on-chain wallet. If you want to use Lightning again, you open a new channel.

Important Practical Points

Lightning channels are not permanent. They are temporary payment relationships that you open, use, and close as needed. The security model relies on the ability to punish cheating, not on trust. If both parties behave, the channel is cheap and fast. If one party disappears, the other can recover their funds, albeit with a delay and a higher fee.

Not financial advice. babybitcoin.space publishes market data and general information about babybitcoin. Crypto assets are volatile and you can lose everything you put in. Nothing here is a recommendation to buy, sell or hold, and we make no price predictions.

Prices are sourced from third parties and may be delayed or wrong. Verify anything you intend to act on against a primary source.

Back to bitcoin