If you’ve been keeping up with the Blockchain news cycle, you know that the scalability issue is still very much pressing for the Bitcoin network.

Currently, the blocks on Bitcoin are being mined every 10 minutes and the block size is limited to 1 megabyte. The network is capable of processing nearly 2000 transactions every 10 minutes which means it can only handle about 3 transactions per second. Compare this capacity to the throughput of Visa (~1700TPS) or Paypal (193TPS) and you’ll see that, at this point, Bitcoin is a pathetically slow payment system.

To remedy this problem, a number of initiatives were proposed both by Bitcoin core developers and the community over the years. The most promising of them include Segregated Witness, Schnorr signatures and, of course, payment channels which are the topic of today’s article.

In this post, we will discuss how payment channels work and talk about the outcomes their adoption might lead to. Strap in!

What are payment channels?

Before it is put into a block or even visible to the network, each Bitcoin transaction is preliminary signed off-chain.

If John wants to give some bitcoins to Jane he builds up a transaction to send outputs from his wallet. He signs it with his private key, and, then, broadcasts it out to the Bitcoin blockchain. And it’s only afterward that the miners learn of its existence, pick the transaction up and, eventually, write it into the distributed ledger (the procedure which is both time-consuming and costly).

Using a payment channel, however, John can run that same transaction “privately”, never showing to the Bitcoin network. He can settle the payment peer-to-peer – instantly and at no cost.

How do payment channels work?

There wouldn’t be such a thing as a payment channel, on Bitcoin or otherwise if it wasn’t for the advent of multisig transactions which are effectively a form of smart contracts.

The lightning network (and other payment channel specifications) use two-of-two multisig addresses which, as the name suggests, require two private keys to authorize unlocking funds from them.

How do payment channels work?

Here’s how it works: suppose John and Jane have to transact regularly and instead of doing it in a conventional way, which would incur substantial fees, they create a multisig address to which they both agree to send a certain number of bitcoins. For the sake of clarity, let’s say each contributes 4 bitcoins making the channel worth 8 bitcoins in total.

Note: normally this wouldn’t be the case as payment channels are much more suitable for micro-payments.

Aside from that, they both create a secret value and exchange hashes of it between one another.

John then builds a subsequent transaction to the opening one; in the Lightning Network, it is called a commitment transaction. As he attempts to give Jane one bitcoin, he sends 3 bitcoins to himself and 5 remaining ones to a multisig address that has a CSV-lock in it. If Jane tries to get to the funds out of it, she’ll have to wait a certain period of time (for example until 100 of new blocks are mined and written into a blockchain) before the coins are unlocked.

How do payment channels work?

Meanwhile, John could drain the address as well, but he needs a secret value of which Jane has given him the hash to do so.

After signing the transaction John hands it to Jane directly (instead of broadcasting it to Bitcoin).

Next, Jane mirrors exactly what John have done. She, too, creates a subsequent commitment transaction but sends 5 bitcoins to herself and 3 to the multisig address. The restrictions are valid for her as well – she knows Bob can’t get the funds until after 100 new blocks are mined and that she can’t unlock them without applying John’s secret (to which she has a hash). So Jane sends the signed, half-valid transaction to John and, finally, they broadcast the opening transaction (and pay a fee to miners) to get started with a payment channel.

Both of the commitment transactions remain half-valid; neither John or Jane signs and broadcasts them as that would shut down their payment channel.

At this point, we’re through with the first “payment”.

Now, if John wants to send another bitcoin to Jane (or Jane wants to send one back), they create another pair of subsequent transactions – this time without the opening one. They redistribute, so to speak, the balance on the channel and update its state. They create new secret values and hashes and, at the same time, exchange the older secrets – from the first transaction – between one another.

This is done to ensure trust.

If Jane decides to close the channel on her own (by broadcasting the first commitment transaction to the network) John would get his 3 bitcoins right away. Jane, on the other hand, will have to wait until 100 new blocks are mined before she can get the funds due to the CSV-lock. But, as we’ve mentioned earlier, there are two ways of unlocking funds from the multisig address – John can beat Jane to it by using the secret (from the first transaction) she has just given him. So, if she decides to cheat, John gets all the money.

Same works the other way around. John knows Jane can use his secret to drain the address; he’s incentivized strongly to keep on good behavior.

Once the payment channel is opened and recorded into the immutable blockchain, John and Jane can keep transacting across it indefinitely, incurring no fees. The only other time they’ll have pay again is when they decide to close the channel.

How do payment channels work?

What if there are more than two parties involved?

The Lightning Network seeks to utilize the principle of six degrees of separation. Sort of.

What this means is John doesn’t need to set up a payment channel with every person in the world – if Jane has a channel opened with someone he wants to transact, he can just send funds through her.

And it might be not just Jane; John might want to send funds through her, her friend, and, maybe, a few other people to reach the intended person. As long as there is route – a sequence of payment channels – from him to the receiver, he can theoretically complete such a transaction promptly.

So, here’s what happens:

  1. John wants to send one bitcoin to Gregg through Jane. He informs him about the intention and then Gregg creates a secret value to which he gives John a hash.
  2. Jane sends Gregg the money and, in exchange, receives the secret value to which John has a corresponding hash.
  3. She then shows the secret to John making it clear that the bitcoin made it to Gregg.
  4. John sends a bitcoin to Jane.

What if there are more than two parties involved?

Pretty simple, although there’s an issue: how could Jane be certain that John will keep his promise and repay her in the end?

Here’s where Hashed Time Locked Contracts come into play.

In a nutshell, John doesn’t send money to Jane directly; he again locks them up in a multisig address which Jane can then drain if she provides Gregg’s secret value along with her signature. If she fails to do so, however, John will be able to reclaim his bitcoin after a certain amount of time has gone by – there’s fall-back feature built-in to the contract.

The drawbacks of using Payment Channels

  • To open and close a payment channel, one has to pay transaction fees.
  • The Lightning Network is not really an option if you intend to transact big. One can’t send 2 bitcoins across a channel that’s worth 1 bitcoin and, therefore, the sum of funds one is able to move through the lightning network routes is limited to the size of the smallest channel included in them.
  • As the technology becomes adopted widely, many expect specialized hubs, run by wealthy companies, to appear on the Bitcoin network. They’ll allow multiple people to plug in and thus transact quickly through an intermediary. The problem is, these hubs will be centralized and, in a way, resemble banks in how they operate. Centralization is at odds with the Bitcoin principles. Many in the space feel uneasy about the adoption of the lightning network as, in their eyes, it might cause the network to lose sight of its ultimate goal which is doing away with financial institutions.

To conclude

Payment channels, being a layer-two solution, will alleviate a humongous part of blockchains’ traffic by making it possible to settle transactions off-chain; they will make Bitcoin and Ethereum and LiteCoin (and possibly other networks) a great deal more efficient.

However, will they solve completely the daunting issue of blockchain scalability? We have yet to see.

If you’d like to learn more about payment channels and blockchain tech in general – reach out to our expert. He’ll gladly provide you with a free consultation.