Post
Topic
Board Development & Technical Discussion
Merits 1 from 1 user
Re: Understanding Atomic Swaps
by
noobWithAComputer
on 16/07/2018, 14:21:37 UTC
⭐ Merited by ETFbitcoin (1)
The concept of an atomic swap is not a part of the lightning network.

It's just a structure of transactions utilizing hashed timelock contracts (HTLCs) in order to achieve a trustless exchange of different currencies on different chains. Until now multiple atomic swaps were made on bitcoin.
ATM I'm writing a thesis about atomic swaps and how to recognize them. There are a few different scripts for HTLCs, but they all do the same thing: they lock value for a specific time, except the counterparty can provide the preimage of the given hash.

One implementation of an HTLC looks like this:
Code:
63 if
82 size
01 data1
20
88 equalverify
a8 sha256
20 data32

88 equalverify
76 dup
a9 hash160
14 data20

67 else
04 data4

b1 checklocktimeverify
75 drop
76 dup
a9 hash160
14 data20

68 endif
88 equalverify
ac checksig

In order to have an atomic swap you just need an implementation which achieves the same thing. In ethereum you could also write a smart contract which does the same. As far as both parties can watch the blockchain and what is happening there, it is possible to make an atomic swap.