<p>There is a problem with the transaction favoring a party, and they can use the timeout to their advantage. But it is not as dire as some think.</p>

<p>Here is an example:</p>

<p>Alice creates a contract on the Bitshares blockchain that will pay Bob 1 Bitcoin if Bob can come up with the secret. If he does not do this within 24 hours, Alice gets her Bitcoin back.</p>

<p>Bob creates a contract on the Litecoin network that will pay Alice 2.5 Bitcoin if she comes up with the same secret within 12 hours.</p>

<p>Alice has a small advantage here. She has the secret. She can wait until near the 12 hour mark to decide if the price moved in her favor. If the price is not to her liking, she does nothing. Bob gets his Litecoin back, and Alice waits another 12 hours to get her Bitcoin back.</p>

<p>If Alice decides to take the Litecoin, Bob has few choices. He has to take the Bitcoin or leave empty handed.</p>

CC BY-SA 4.0
2018-11-04T14:11:02.610Z
2018-11-04T14:11:02.610Z
jmjatlanta
<p>In the normal case where nobody wants to betray the other party, an atomic swap consists of four transactions:</p>

<ul>
<li>a hashed timelock contract (HTLC) from party A on chain A.
It contains an if-statement with two paths: One with a check for the hash of the secret and the public key hash of party B and one with the timeout and the public key hash of party A.</li>
<li>another HTLC from party B on chain B. Same structure but the public key hashes are swaped. The locktime is shorter, but the secret is the same.</li>
<li>a claiming transaction from party A on chain B. Party A now wants to claim the transaction value by providing the secret. As party B watches the blockchain, he sees the transaction from A and now also knows the secret.</li>
<li>With the secret he now can claim his part of the trade on chain A.</li>
</ul>

<p>That's of course a bit of an abstraction, becaus in reallity all of this is further devided into input and output scripts, but for a general understanding I hope, my short explanation is sufficient.
For more deteil (but also more confusion), read <a href="https://en.bitcoin.it/wiki/Atomic_cross-chain_trading" rel="nofollow noreferrer">https://en.bitcoin.it/wiki/Atomic_cross-chain_trading</a></p>

<p>So, when you are party A and "give" the secret to party B (by sending your claiming transaction)*, you already have received your part of the trade and don't need to worry about anything anymore.</p>

CC BY-SA 4.0
2018-07-16T13:50:38.103Z
2018-07-16T13:50:38.103Z
noobWithAComputer
<p>Can somebody explain me why atomic swaps are not flawed in that way:</p>

<p>When I give him/her my secret he/she could decide wheter to make the trade or not. If the price does favor him/her after a certain amount of time he/she will execute the trade if not wait for the timeout. Do I miss something?</p>

CC BY-SA 3.0
2018-03-18T01:18:47.420Z
I mean not flaw, but it is communicated way better than it actually is imo. I mean is my statement true?
Ini
CC BY-SA 3.0
2018-03-18T03:12:09.587Z
I'm not sure if I understood, but maybe yes. I think people doing that would be blacklisted or something for trolling.
Osias Jota
CC BY-SA 3.0
2018-04-11T12:39:47.700Z
I think it's a very valid point. perhaps can be addressed by limiting the period to a few minutes and automate the channel.
Damien
CC BY-SA 3.0
2018-03-17T03:18:12.097Z
What's the flaw?
Osias Jota
<atomic-swap>
Atomic Swap - Problem?
Ini
# Atomic Swap - Problem?

(Asked by: username_0 on 2018-03-17)

Can somebody explain me why atomic swaps are not flawed in that way:

When I give him/her my secret he/she could decide wheter to make the trade or not. If the price does favor him/her after a certain amount of time he/she will execute the trade if not wait for the timeout. Do I miss something?

**Tags:** atomic-swap

> **Comments:**
> **username_1**: What's the flaw?  
> **username_0**: I mean not flaw, but it is communicated way better than it actually is imo. I mean is my statement true?  
> **username_1**: I'm not sure if I understood, but maybe yes. I think people doing that would be blacklisted or something for trolling.  
> **username_2**: I think it's a very valid point. perhaps can be addressed by limiting the period to a few minutes and automate the channel.  

---

## 2 answers

### Answer by username_3 on 2018-11-04. Score: 1

There is a problem with the transaction favoring a party, and they can use the timeout to their advantage. But it is not as dire as some think.

Here is an example:

Alice creates a contract on the Bitshares blockchain that will pay Bob 1 Bitcoin if Bob can come up with the secret. If he does not do this within 24 hours, Alice gets her Bitcoin back.

Bob creates a contract on the Litecoin network that will pay Alice 2.5 Bitcoin if she comes up with the same secret within 12 hours.

Alice has a small advantage here. She has the secret. She can wait until near the 12 hour mark to decide if the price moved in her favor. If the price is not to her liking, she does nothing. Bob gets his Litecoin back, and Alice waits another 12 hours to get her Bitcoin back.

If Alice decides to take the Litecoin, Bob has few choices. He has to take the Bitcoin or leave empty handed.


---

### Answer by username_4 on 2018-07-16. Score: 0

In the normal case where nobody wants to betray the other party, an atomic swap consists of four transactions:

* a hashed timelock contract (HTLC) from party A on chain A.
  It contains an if-statement with two paths: One with a check for the hash of the secret and the public key hash of party B and one with the timeout and the public key hash of party A.
* another HTLC from party B on chain B. Same structure but the public key hashes are swaped. The locktime is shorter, but the secret is the same.
* a claiming transaction from party A on chain B. Party A now wants to claim the transaction value by providing the secret. As party B watches the blockchain, he sees the transaction from A and now also knows the secret.
* With the secret he now can claim his part of the trade on chain A.

That's of course a bit of an abstraction, becaus in reallity all of this is further devided into input and output scripts, but for a general understanding I hope, my short explanation is sufficient.
For more deteil (but also more confusion), read <https://en.bitcoin.it/wiki/Atomic_cross-chain_trading>

So, when you are party A and "give" the secret to party B (by sending your claiming transaction)\*, you already have received your part of the trade and don't need to worry about anything anymore.


---

