2

From my understanding a hash timelock function trade or atomic swap involves 2 transactions one separate blockchains. The BTC user named Bob is making a trade with Alice for her LTC. Assuming its a 1 to 1 trade and neither party trusts one another.

User bob makes a btc transaction sending his coin to an address they both control via multi-sig with 2-3. Meaning it needs 2 signatures to in order to make it a valid transaction. This address also has a "time lock" feature of being able to lock the coins for 60 minutes? (is that even a thing?)

Now Alice does the same thing with her LTC by locking it in another address with multi-sig.

They both see that the coins are locked away in these 2 addresses and they will be locked for 60 minutes.

Within this this 60 minutes, alice or bob signs the transaction of one of these addresses.

Once its proved its signed, now they will proceed to the next address to sign.

Now BOTH transactions are signed and is ready to be broadcasted.

I got this far, but I'm unsure if this was the correct way of understanding how an atomic swap might work. Can someone make it even more simple to understand?

My other question is what stops one of them trying to steal both of the coins once the lock is expired?

2

I am leaving out a few details here, but this will get you thinking on the right path...

Alice and Bob have accounts on both the Bitcoin and Litecoin networks. Bob has Bitcoin, but wants Litecoin. Alice has Litecoin and wants Bitcoin. They do not trust each other.

Both agree to trade Bob's 1 Bitcoin for 2.5 of Alice's Litecoin.

Alice starts the transaction with a contract on the Litecoin network. The contract states that she will deposit 2.5 Litecoin into Bob's Litecoin account, if Bob can provide a password (called a "Preimage") that produces a certain hash. If Bob does not provide the preimage within 21 hours, the Litecoin goes back into Alice's account.

So, the contract has Alice's account, Bob's account, 2.5 Litecoin, the hash of the preimage, and 21 hour expiry.

Bob can examine the contract by browsing the blockchain. He can see if he likes the terms. If he does, he can build a contract on the Bitcoin blockchain. That contract is very similar. It has:

Bob's account, Alice's account, 1 Bitcoin, the same hash that appeared in the contract on the Litecoin network, and a 10 hour expiry.

Alice can examine the contract on the Bitcoin network. If she likes the terms, she can use her preimage to "unlock" the 1 bitcoin. When she does, that preimage is published on the Bitcoin blockchain, and Bob can see it. He uses that preimage to "unlock" his 2.5 Litecoin on the Litecoin network.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.