Bitcoin transactions are slow. It takes minutes, hours, or sometimes days for a transaction to be confirmed and added to the blockchain. As more and more people begin to use Bitcoin, the Bitcoin network tends to get bogged down with a big queue of transactions waiting to be confirmed. To get your transaction moved to the head of the line, you will often end up paying much higher fees to the network to process your transaction first. While several forks to the blockchain have been proposed, and some implemented, to target this scaling issue, another potential solution comes in the form of atomic swaps over the Lightning Network.
What are Atomic Swaps?
Imagine Person A has 100 Litecoin and wants to trade them for 1 Bitcoin. Person B wants to trade 1 Bitcoin for 100 Litecoin. They don’t know one another and they live on opposite ends of the globe. Naturally, neither wants to be the first to send their funds to the other without a guarantee that the other person will uphold their end of the deal.
Today, most digital currency traders rely on third-party services, like exchanges, to act as an escrow service for transactions. Person A and Person B both transfer their funds to the exchange; when the exchange has received funds from both parties, it completes the transfer.
Atomic swaps are a way to swap two exchange cryptocurrencies across different blockchains on a peer-to-peer level, without the need for a third-party escrow service. Atomic swaps make use of multi-signature addresses and time-locks to create what is called a “hash-locked time contract.” Basically, continuing with the example scenario, Person A and Person B would submit a transaction on both the Bitcoin and Litecoin blockchain.
Both submit their respective funds to a special kind of account, which can be thought of as a locked box that requires a secret key to open. Person A can see that Person B’s bitcoins are in the box, but can only claim those funds by inputting the secret key. Person B, likewise, can see Person A’s litecoins in the box, but can only claim them by inputting the same secret key.
When person A enters the secret key and claims the funds, the secret key will be printed to the Bitcoin blockchain and revealed to Person B, effectively unlocking the other account and making those funds claimable, as well. This makes it possible for peer-to-peer transactions to happen across different blockchains, such as Bitcoin and Litecoin, in a way that they remain linked and traceable.
While atomic swaps are possible today on several blockchains, they aren’t particularly convenient. Setting up payment channels and completing a series of transactions across multiple blockchains is not an ideal situation for many users. The introduction of the Lightning Network, however, takes the potential for atomic swaps to a new level.
What is the Lightning Network?
The Lightning Network extends some of the key ideas of atomic swaps into a larger framework to facilitate rapid, secure, peer-to-peer cryptocurrency transactions across a network of connected peers, and potentially across multiple blockchains. Transactions happen on the Lightning Network using the same basic principles behind atomic swaps: bi-directional payment channels and hashed time-locked contracts (HTLCs). However, the Lightning Network aims to extend this technology to a broader network of connected peers, acting as a second payment layer atop of Bitcoin and other blockchain-based cryptocurrencies employing the same hashing algorithms.
For atomic swaps to happen without the Lightning Network, Person A would have to set up a unique “locked box” for each atomic swap they made. If Person A wanted to send money to Person B, Person C, and Person D, they would have to create a new “box” for each transaction.
If Person A has an established payment channel with Person B, Person B has an established channel with Person C, the Lightning Network allows Person A to transact directly with Person C using the network of established payment channels between connected peers (in this case, A is connected to B and B is connected to C).
The only time transactions are posted to the main blockchain are when a payment channel is opened or closed. Otherwise, as long as channels remain open, transactions happening between parties on the Lightning Network are settled off of the blockchain and remain uncommitted, reducing the load on the blockchain.
While the Lightning Network is still in a developmental stage, a successful cross-chain atomic swap between Bitcoin and Litecoin was conducted on a testnet in November, 2017. The implications of this technology point to an environment where a person who only held Litecoin could visit a merchant who only accepted Bitcoin and make a fast, secure, cross-chain payment directly across the Lightning Network without having to manually handle conversion or wait for confirmation to happen on the blockchain. The potential for the Lightning Network to offer faster, cheaper, and more efficient transactions has made it a highly anticipated technology within the Bitcoin and cryptocurrency space.