It is well-known that Bitcoin’s upcoming lightning network promises instant confirmations and low fees. What is not as well-known is that this highly anticipated scaling layer is actually not limited to Bitcoin. The very same peer-to-peer protocol can potentially be extended to, and made interoperable with, many altcoins. This could allow for trustless altcoin payment processors, decentralized altcoin exchanges and perhaps even cheaper bitcoin-to-bitcoin payments and more.
The Swaps that are Atomic
Interoperability between Bitcoin and altcoins is not new. So-called atomic swaps (or atomic cross-chain trading) were first described by Tier Nolan back in 2013.
Let’s say Alice has 200 litecoins, but prefers 1 bitcoin. And Bob has 1 bitcoin, but prefers 200 litecoins. So Alice and Bob agree to trade. But neither Alice nor Bob trust each other, so neither wants to be the first to send over the coins. The other may not return the favor.
That’s why Alice and Bob set up an atomic swap.
Atomic swaps utilize a clever trick known as a hash time-locked contract, which in turn leverages the potential of multisignature addresses and time-locks. All this is enabled by the basic scripting language found in Bitcoin and most altcoins, including Litecoin.
In short, Alice and Bob submit transactions to both blockchains: one on Bitcoin and one on Litecoin. The Bitcoin transaction sends 1 bitcoin from Bob to Alice, but Alice can only claim this bitcoin if she reveals a secret number only she knows. The Litecoin transaction sends 200 litecoins from Alice to Bob, but requires the same secret number on both chains.
When Alice claims her bitcoin, she reveals her secret number on the Bitcoin blockchain. And with that same secret number, Bob can, in turn, claim his 200 litecoins.
Even though the transactions are on completely different blockchains, they are effectively linked. Bob just needs to monitor the Bitcoin blockchain to see if Alice claimed her bitcoin so that he can claim his litecoins.
All this works today. But it is a bit of a hassle. Alice and Bob need to find each other to set up the atomic swap, which then requires several transactions on multiple blockchains.
Altcoins that are forked from Bitcoin’s codebase — like Litecoin, Dogecoin or Zcash — are typically capable of hosting lightning networks as well. Other altcoins, as long as they include similar or more extensive scripting capabilities (like Ethereum or Ethereum Classic), enable similar solutions.
Like atomic swaps, the lightning network utilizes hash time-locked contracts. Where atomic swaps effectively link blockchains, the lightning network links payment channels. This way, if both Alice and Bob have a payment channel open with Carol, they can transact through Carol, without needing to trust Carol.
Because the underlying mechanics are the same, it’s no stretch to merge the lightning network with atomic swaps. This process makes different lightning networks interoperable across blockchains.
This means that a peer that opens channels on both blockchains could serve as a payment processor, an altcoin exchange and more.
Let’s say, for example, that Alice wants to buy a computer from Bob, for which Bob charges 1 bitcoin, but Alice only owns litecoins. Luckily, Carol has a Litecoin channel open with Alice, and a Bitcoin channel open with Bob. So Alice can now send 200 litecoins to Carol, for Carol to send 1 bitcoin to Bob. Since this is all linked with hash time-locked contracts, Carol effectively acts as a trustless payment processor.
And if Alice and Bob both have a Bitcoin payment channel as well as a Litecoin channel with Carol, they can also swap funds. Alice can send 200 litecoins to Carol, which Carol forwards to Bob. Bob then sends 1 bitcoin to Carol in exchange, which Carol now forwards to Alice. And again, all this is still linked with hash time-locked contracts, so now Carol effectively acts as a trustless altcoin exchange.
Lastly, alternative lightning networks may even improve Bitcoin’s lightning network in some ways. For example, a bitcoin-to-bitcoin payment could be routed through Litecoin peers, if that happens to be the cheapest route. Or, users operating on multiple coins could rebalance their channels. If Alice has 400 litecoins but no bitcoins in her channel with Bob, she may want to exchange 200 litecoins to fund her Bitcoin channel.
Difficulties to be Overcome
There are some difficulties to be overcome to achieve the scenario described above:
One is denial of service (DoS) protection. While the mechanics of the lightning network ensure that no peers can steal funds, intermediaries can block or stall the payment process. To solve this, channels with non-cooperating peers must be closed. This form of punishment should make DoS attacks expensive, as non-cooperating peers need to keep opening channels.
But to verify that the channel was closed and the attacker punished, each peer along a payment chain must be able to monitor all participants. Even if only two peers along a chain of six use Litecoin, all six peers should be able to recognize a Litecoin transaction in case the channel is closed.
However, with SegWit activated on Litecoin and now Bitcoin, the time for Atomic Swaps is very nearly here, and new opportunities await for the universe of cryptocurrency.