<p>You would need to find another party to do the swap. An example:</p>

<p>Alice and Bob have accounts on both chains. Alice has Litecoin that she wants to exchange into Bitcoin. Bob has Bitcoin that he wants to trade for Litecoin.</p>

<p>Alice tells Bob that she is willing to give him 2.5 Litecoin for 1 Bitcoin. Bob agrees. They both agree that Alice will publish a contract on the Litecoin blockchain that transfers 2.5 Litecoin from Alice to Bob.</p>

<p>Once the Litecoin contract is published, Bob examines it. He sees that the parameters are to his liking, so he publishes a contract on the Bitcoin blockchain that transfers 1 Bitcoin from Bob to Alice.</p>

<p>Alice examines the Bitcoin contract, and likes what she sees. She uses the preimage that she used to build the Litecoin contract to unlock the 1 Bitcoin. Bob is no longer the owner of the 1 Bitcoin.</p>

<p>When Alice used her preimage, that preimage was published on the Bitcoin blockchain. Bob sees it, and uses the same preimage to unlock the 2.5 Litecoin on the Litecoin blockchain.</p>

<p>That example is a simplified version of the typical scenario, but I hope it helps you see the coordination required to do an HTLC.</p>

<p>A little more detail into the mechanisms can be found on a writeup I did for HTLCs between the Bitcoin and Bitshares blockchains. It can be found at <a href="http://www.jmjatlanta.com/index.php/2018/09/27/bitshares-and-hashed-time-lock-contracts-htlc" rel="nofollow noreferrer">http://www.jmjatlanta.com/index.php/2018/09/27/bitshares-and-hashed-time-lock-contracts-htlc</a></p>

<p>If you are looking for more technical how-to, you can use the following resource: </p>

<p><a href="https://bitcoin.stackexchange.com/questions/74753/htlc-hash-time-lock-contract-using-bitcoin-qt">HTLC (Hash Time Lock Contract) using bitcoin-qt</a></p>

<p>I use the libbitcoin library for BTC. A tutorial that can get you started with HTLCs using that library can be found at <a href="http://aaronjaramillo.org/libbitcoin-cross-chain-swaps-with-htlcs" rel="nofollow noreferrer">http://aaronjaramillo.org/libbitcoin-cross-chain-swaps-with-htlcs</a></p>

CC BY-SA 4.0
2018-10-31T21:54:38.760Z
2018-10-31T22:07:21.393Z
2018-10-31T22:07:21.393Z
jmjatlanta
<p>I am running Bitcoin and Litecoin nodes fully synced on testnet.Can I perform atomic swapping by using this networks?</p>

<p>I heard it can be done through HTLC(Hash Time Locked Contracts). How can I do exactly by HTLC and trying to go deeper in to HTLC?</p>

<p>Thanks.</p>

<bitcoind><atomic-swap><hash-time-locked-contract>
How to perform atomic swap Bitcoin-Litecoin
Omkar Sai Sunku
# How to perform atomic swap Bitcoin-Litecoin

(Asked by: username_0 on 2018-08-22)

I am running Bitcoin and Litecoin nodes fully synced on testnet.Can I perform atomic swapping by using this networks?

I heard it can be done through HTLC(Hash Time Locked Contracts). How can I do exactly by HTLC and trying to go deeper in to HTLC?

Thanks.

**Tags:** bitcoind, atomic-swap, hash-time-locked-contract


---

## 1 answers

### Answer by username_1 on 2018-10-31. Score: 1

You would need to find another party to do the swap. An example:

Alice and Bob have accounts on both chains. Alice has Litecoin that she wants to exchange into Bitcoin. Bob has Bitcoin that he wants to trade for Litecoin.

Alice tells Bob that she is willing to give him 2.5 Litecoin for 1 Bitcoin. Bob agrees. They both agree that Alice will publish a contract on the Litecoin blockchain that transfers 2.5 Litecoin from Alice to Bob.

Once the Litecoin contract is published, Bob examines it. He sees that the parameters are to his liking, so he publishes a contract on the Bitcoin blockchain that transfers 1 Bitcoin from Bob to Alice.

Alice examines the Bitcoin contract, and likes what she sees. She uses the preimage that she used to build the Litecoin contract to unlock the 1 Bitcoin. Bob is no longer the owner of the 1 Bitcoin.

When Alice used her preimage, that preimage was published on the Bitcoin blockchain. Bob sees it, and uses the same preimage to unlock the 2.5 Litecoin on the Litecoin blockchain.

That example is a simplified version of the typical scenario, but I hope it helps you see the coordination required to do an HTLC.

A little more detail into the mechanisms can be found on a writeup I did for HTLCs between the Bitcoin and Bitshares blockchains. It can be found at <http://www.username_1.com/index.php/2018/09/27/bitshares-and-hashed-time-lock-contracts-htlc>

If you are looking for more technical how-to, you can use the following resource:

[HTLC (Hash Time Lock Contract) using bitcoin-qt](https://bitcoin.stackexchange.com/questions/74753/htlc-hash-time-lock-contract-using-bitcoin-qt)

I use the libbitcoin library for BTC. A tutorial that can get you started with HTLCs using that library can be found at <http://aaronjaramillo.org/libbitcoin-cross-chain-swaps-with-htlcs>


---

