First Successful Bitcoin-Litecoin Cross-Chain Transaction Completed
Well, let’s say Xena wants to trade one bitcoin to Zeke in exchange for 100 litecoins. You may question Xena’s sanity. However, she is savvy enough to realize that, if she simply sends her bitcoin to Zeke, he may abscond with it without sending her a single litoshi in return. For the same reason, Zeke isn’t willing to first send Xena 100 of his hard-earned litecoins either.
So usually Xena and Zeke would have to both trust Yolanda to facilitate their exchange. But Zeke and Xena are not willing to trust Yolanda either, as she could very well disappear with their coins too. Nor do they like the excessive fee Yolanda charges for what could otherwise be a routine transaction.
Xena and Zeke are in luck; an atomic swap allows them to cut out Yolanda (and her excessive fees) altogether while guaranteeing neither can screw the other over.
An atomic swap is a trustless exchange of different cryptocurrencies directly between the transacting parties, e.g., no trusted third-party in the middle. The ‘atomic’ part of it refers to the fact the transaction is guaranteed to either proceed to completion or fail entirely, and in the latter case, funds from each respective party remain secure.
The security of funds is guaranteed by each transacting party locking their funds into ‘funding transactions’ on both blockchains; for instance, Xena adds one bitcoin to a funding transaction on the Bitcoin blockchain, and Zeke adds 100 litecoins to a funding transaction on the Litecoin blockchain. Both party’s funding transaction proves to the other that funds are locked into the agreement. If Zeke tries to screw Xena, she can claim his 100 litecoins anyways; if Xena tries anything funny, Zeke can claim her one bitcoin regardless.
But if the transaction fails legitimately (for instance, it expires, drops the connection, etc.) the funding transactions are paid back to their original owners. No, I’m not going further into the logic of it (such as CheckLockTimeVerifys, Multisignature transactions, Hash Time Locked Transactions, and other wizardry). If you don’t trust me (and you shouldn’t, even though I’m not Yolanda), maybe you trust Lightning Labs to explain it? Also, here is a very intuitive explanation of how the Lightning Network (LN) works. If that doesn’t satisfy you, then you know what to do… here let me get that for you.
So what does all this mean? What are the possible future implications of atomic swaps now being a thing? It basically means that online exchanges no longer need be depended upon to facilitate exchanges between cryptocurrencies; cross-chain transactions can be decentralized across the LN. While it is bad news for online exchanges (although they will still be required to facilitate the exchange of cryptocurrencies for fiat money), it is great news for crypto-users.
The power of the Lightning Network is that it enables long-lived off-chain transaction channels, so, within these channels, users do not have to transact on the blockchain at all; this promises to solve Bitcoin’s scaling problem by all but eliminating the block size bottleneck while driving down transaction fees. The power of atomic swaps is that they eliminate the need for intermediary exchanges when users wish to trade one cryptocurrency for another, which should make cross-currency trading much cheaper and more liquid.
Together, the LN and atomic swaps promise to make cross-chain trades much easier and cheaper. Of course LN fees will still be incurred on associated cross-chain transactions; and cross-chain fees will likely end up being higher than same-chain fees because the cross-chain nodes (or networks of nodes) must maintain open funding transactions on all chains involved — that is, nodes must fund twice as much coin up front. That said, both same-chain and cross-chain LN fees promise to be much cheaper than current fees because LN clients can choose to use channels with the lowest costs, which sets up a supply and demand free-market fee system.
Full disclosure: Landon is an active contributor to the development of the LN.