This 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 that 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 by law to store. For the user, the price is 10-min processing and transaction fees.
What if we could get closer to instant payments, with less 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 opt out of 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 transaction a 2-of-2 multi-signature is made to lock up funds.
If you want to open a channel with your local pizza stop, 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 anchor or funding transaction. The funds are essentially locked because you and Homeslice both have to sign a new transaction in order to release the funds.
The funding transaction must be sent to the bitcoin network and confirmed in order for the channel to be opened.
Payments in the Channel: Commitment Transactions
Once the channel is open you can sign new transactions to make changes to the balance.
Over the next weeks, as you make new orders to Homeslice you credit your balance by 110,031 sats and debit Homeslice’s balance by 110,031 sats.
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 can also 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 commit 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 commit transaction is made, both parties invalidate the previous state of the channel. In the event of a conflict, only the newest commitment transaction is considered valid to the network.
Channel Close: The Settlement Transaction
When you and Homeslice pizza are in unanimous agreement to close the channel, one party sends the settlement transaction to the blockchain. This way, only two transactions ever hit the bitcoin blockchain, and the users get to minimize fees.
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 up front. And profits in the channel are indefinitely locked up.
Problem #2 - Directionally 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 too, 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 3rd 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 on payment channels, and how they constitute the network as a whole.