Atomic Swaps a Cure for Centralized Exchange Headaches

in #bitcoin6 years ago (edited)

I have got some bitcoins but I want ether. Sitting down to think about the long process I have to pass through to get ether for BTC gets me worried and my head pounding, a serious headache is on it's way. It puts me at risk of losing my coins to an unknown individual usually a hacker if the trusted intermediary is compromised. First, I send my coins to a centralized exchange this puts me in a dangerous situation because I no longer own my coins since I don’t know the private address of the exchange’s public address. After this I sell my BTC for ether and then transfer the ether to my ethereum address. Finally, I breathe a sigh of relief knowing that the funds are now back in my possession and settle for the local aspirin to cure my headache.
Atomic swaps also known as Cross Chain trading has come to change all this. Atomic swaps refer to the P2P exchange of one cryptocurrency for another across diferent blockchains. Imagine switching from one cryptocurrency to another like changing clothes or buying those nice groceries with ether from a
store that only accepts bitcoins. Cool right?
Atomic swaps can be done offchain or onchain. For the two blockchains to support atomic swaps between each other they must:

  1. Support Hash Time Lock Transactions (HTLCs).
  2. Have the same hashing algorithms.

On-Chain Atomic Swaps

This has already been carried out by lightning labs where Litecoins were
swapped for bitcoins on their testnets. Alice has 1 bitcoin but wants 10 litecoins
and Bob has 10 litecoins but wants 1 BTC. Alice creates a pre-image x, hashes it and H(x) is produced which is shared with Bob. She creates a transaction with the hash which sends 1 bitcoin to a 2-of-2 multisig address. The only ways the bitcoin can be withdrawn are if Bob is able to provide the x to withdraw the
bitcoin to his account and if the timelock of the transaction expires before Bob is able to get the value of x this causes the funds to be returned to Alice this refund transaction is signed before hand by Alice and Bob. Bob does likewise and sends the 10 litecoins to a multisig wallet on the Litecoin blockchain. Alice can claim these coins only if she reveals x to Bob and he can receive his coins only if the timelock expires before Alice presents x. This timelock is shorter than the frst timelock to give Bob enough time to claim the 1 bitcoin before the first timelock expires. Alice is forced to claim it if not she and Bob get refunded their coins this defines the atomicity of atomic swaps which is, either the swap goes through completely or doesn’t work out. Alice and Bob can monitor each other’s activity by watching the blockchains.

Off-Chain Swaps/Lightning Swaps

The Lightning network has the infrastructure in place to facilitate atomic swaps. Alice and Bob must have two payment channels open between them on the two blockchains. It is similar to normal lightning transactions and does not require Alice and Bob to be side by side on the lightning network. Lightning swaps take all the attributes of the lightning network such as atomicity, speed and near cost free.
Atomic swaps will bring about completely decentralized exchanges which might just wipe out these centralized exchanges completely. Then, I’ll just sit back, sip my coffee and watch my coins swap with no fear of loss because I own and protect my private keys through the process. No more aspirin after a swap thanks to Atomic Swap.

Coin Marketplace

STEEM 0.25
TRX 0.25
JST 0.040
BTC 94101.38
ETH 3397.72
USDT 1.00
SBD 3.40