Kiara Bickers - Systems Thinker and Author

How Do Payment Channels Work? - #1 The Basics

February 16, 2022lightning

This is the first post in our 3-part introductory series on payment channels.

The Cost of On-chain Transactions

In the Bitcoin network, nodes are distributed all over the world, and the transaction data is synchronized across the network in blocks. Because this is a 10-minute process, users on the network also wait 10 minutes for their transactions to be confirmed. Bitcoin is not directly limited to a specific number of transactions per second, but it is indirectly limited by the maximum capacity of transaction weight per block.

The storage on the blockchain is a scarce resource, which is why users bid for their transactions to be confirmed in the next block. When there are more transactions waiting to be confirmed in the mempool, fees on-chain rise to match the increased demand for inclusion of their transaction on the chain.

For the network, every UTXO is data that each fully validating node is required to store. For the user, the price is 10-min processing and transaction fees.

What if we could get closer to instant payments, with fewer fees?

What are Payment Channels?

Payment channels, sometimes referred to as micropayment channels, are a trustless method of exchanging funds peer-to-peer. On the Bitcoin network, payment channels lock funds into a 2-of-2 multi-signature address that allows the two parties to exchange bitcoin off of the blockchain.

As bitcoin scales, more users will opt to transact their bitcoin in payment channels to avoid on-chain transaction fees.

For more on the history of payment channels, check out Christian Decker's Chaincode Lightning talks.

How do Payment Channels Work?

Channel Open: The Funding Transaction

To open a channel, a 2-of-2 multi-signature transaction is made to lock up funds.

Lightning Payment Channel Opening

If you want to open a channel with your local pizza shop, Homeslice Pizza, you can commit 1,100,000 sats (or $500 USD) to the channel by sending the funds to a 2-of-2 multi-signature address, also known as the funding transaction. The funds are locked because you and Homeslice both have to sign a new transaction to release the funds.

The funding transaction must be sent to the Bitcoin network and confirmed for the channel to be opened.

Payments in the Channel: Commitment Transactions

Once the channel is open, you can sign new transactions to update the balance.

Over the next few weeks, as you make new orders from Homeslice, you credit your balance by 110,031 sats and debit Homeslice's balance by 110,031 sats.

Lightning Payment Channel Commitment Transaction

Both parties mutually sign each commitment transaction, which updates the balance of the channel.

These transactions are considered valid and could be sent to the network, but instead, the parties keep these transactions off-chain. This way, the balance state of the channel can be updated thousands of times, getting us closer to instant micropayments.

Instead of being limited by block weight, users in payment channels are theoretically only limited by how fast both parties can create and sign a commitment transaction.

To ensure that neither party tries to cheat by broadcasting an old state of the network, all old transactions are invalidated. When a new commitment transaction is made, both parties invalidate the previous state of the channel. In the event of a conflict, only the latest commitment transaction is considered valid by the network.

Channel Close: The Settlement Transaction

When you and Homeslice Pizza agree to close the channel, one party sends the settlement transaction to the blockchain. This way, only two transactions ever hit the Bitcoin blockchain, minimizing fees for the users.

Lightning Payment Channel Closing

But this is not the typical payment channel; there are a few problems here.

Problem #1 - Locked Liquidity is Expensive

Although users save money in the long run by minimizing fees, payment channels require a lot of liquidity upfront. Additionally, profits in the channel are indefinitely locked up.

Problem #2 - Directionality is Limited

In our example, where you are the only peer to fund the channel, there is no initial balance for Homeslice Pizza to make payments to you. Not that they have a reason to, but their business does have inventory that they need to pay for.

What if they could make payments to one of their vendors with the funds locked up in your payment channel with them?

What if there was a way to move funds from an open channel to a third party without hitting the blockchain?

What is the Lightning Network?

The Lightning Network is a network of nodes connected by multiple payment channels! In the following posts in this series, we'll level up our understanding of payment channels and how they constitute the network as a whole.

Related Articles