<p>No Atomic Swaps are by definition <strong>atomic</strong> meaning either there's a swap and both parties redeem the coins or no . I suggest you take a look at the Decred repository to understand the mechanics of the swap .</p>

CC BY-SA 4.0
2018-08-09T17:06:06.460Z
the term "atomic" swap is used, even though its not atomic. i bet decred is just as "atomic", I will take a look... anyways but the question i'm asking is in relation to a double spend, and if there can be proof of a spent input.
jaybny
CC BY-SA 4.0
2018-08-09T17:20:07.877Z
decred uses the standard timeOut technique, which (i believe) requires one party to move the coins again - or else the swap does not go through
jaybny
CC BY-SA 4.0
2018-08-09T12:14:06.050Z
2018-08-09T12:14:06.050Z
halius
<p>I am designing an cross-chain atomic swap in a custom blockchain - Protoblock. I think it can be done as long as Protoblock knows how to parse <strong>p2pkh</strong> bitcoin transactions. The critical part is being able to "reverse" things when it sees a double spend.  </p>

<ul>
<li>Alice has 1 Bitcoin  </li>
<li>Bob has 100 Fantasybit  </li>
<li>Alice will swap 1 BTC for Bobs 100 FB</li>
</ul>

<hr>

<p>Step1) Bob signs a Protoblock "Swap" transaction(TX1a) that contains an <strong>unsigned</strong> bitcoin transaction(TX1b) that must have 1. a ScriptSig input with p2pkh from Alice(bitcoin-address) and 2. a p2pkh output to Bob(bitcoin-address) </p>

<p>Step2) 100 FB of Bobs is locked for 24 hours or until... </p>

<p>Step3) a Protoblock transaction(TX2a) is seen that contains the signature for TX1b and TXID(TX1a)</p>

<p>Step4) 100 FB is transferred to Alice and is locked for 24 hours or until... </p>

<p>Step5) a Protoblock transaction(TX3a) is seen that contains a <strong>signed</strong> bitcoin transaction(TX2b) that has 1. the same ScriptSig input(s) with p2pkh from Alice(bitcoin-address) as TX1b and 2. an output that is NOT a p2pkh output to bob(bitcoin-address) </p>

<p>Step6) 100 FB is sent back to Bob, the same state as before Step1 </p>

<hr>

<p>The reason for Step5 is that, a signed bitcoin transaction is not enough to prove that Bob received the bitcoin from Alice, because Alice could just sign the transaction, but not spend it to bitcoin, and just double spend it.</p>

<p>However, Bob will see that Alice spent the input and will create TX3a that gives him back his 100 Fantasybit. In fact, anyone can be watching bitcoin and create TX3a as a service for Bob. </p>

<p><strong>Question: is there a way that Alice can spend the same inputs from TX1b, that will be undetectable with above algo?</strong>  </p>

<p><em>Note: the bitcoin transaction with the outputs for the TX1b inputs, will be created by the wallet software doing the atomic swap. So Alice will first have to send her 1 Bitcoin to herself to make sure its a simple p2pkh. Here is the Protoblock code that creates the p2pkh outputs and bitcoin tx:</em></p>

<p><a href="https://github.com/SatoshiFantasy/--skillSale/blob/4e59f50b7555527046804418d6483b0df1933637/share/fantasybit-core/FantasyAgent.cpp#L444" rel="nofollow noreferrer">https://github.com/SatoshiFantasy/--skillSale/blob/4e59f50b7555527046804418d6483b0df1933637/share/fantasybit-core/FantasyAgent.cpp#L444</a></p>

<p><a href="https://github.com/SatoshiFantasy/--skillSale/blob/4e59f50b7555527046804418d6483b0df1933637/share/fantasybit-core/FantasyAgent.cpp#L525" rel="nofollow noreferrer">https://github.com/SatoshiFantasy/--skillSale/blob/4e59f50b7555527046804418d6483b0df1933637/share/fantasybit-core/FantasyAgent.cpp#L525</a></p>

<input-script><p2pkh><atomic-swap>
Can I prove a double spend attempt with a signed tx with same input?
jaybny
# Can I prove a double spend attempt with a signed tx with same input?

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

I am designing an cross-chain atomic swap in a custom blockchain - Protoblock. I think it can be done as long as Protoblock knows how to parse **p2pkh** bitcoin transactions. The critical part is being able to "reverse" things when it sees a double spend.

* Alice has 1 Bitcoin
* Bob has 100 Fantasybit
* Alice will swap 1 BTC for Bobs 100 FB

---

Step1) Bob signs a Protoblock "Swap" transaction(TX1a) that contains an **unsigned** bitcoin transaction(TX1b) that must have 1. a ScriptSig input with p2pkh from Alice(bitcoin-address) and 2. a p2pkh output to Bob(bitcoin-address)

Step2) 100 FB of Bobs is locked for 24 hours or until...

Step3) a Protoblock transaction(TX2a) is seen that contains the signature for TX1b and TXID(TX1a)

Step4) 100 FB is transferred to Alice and is locked for 24 hours or until...

Step5) a Protoblock transaction(TX3a) is seen that contains a **signed** bitcoin transaction(TX2b) that has 1. the same ScriptSig input(s) with p2pkh from Alice(bitcoin-address) as TX1b and 2. an output that is NOT a p2pkh output to bob(bitcoin-address)

Step6) 100 FB is sent back to Bob, the same state as before Step1

---

The reason for Step5 is that, a signed bitcoin transaction is not enough to prove that Bob received the bitcoin from Alice, because Alice could just sign the transaction, but not spend it to bitcoin, and just double spend it.

However, Bob will see that Alice spent the input and will create TX3a that gives him back his 100 Fantasybit. In fact, anyone can be watching bitcoin and create TX3a as a service for Bob.

**Question: is there a way that Alice can spend the same inputs from TX1b, that will be undetectable with above algo?**

*Note: the bitcoin transaction with the outputs for the TX1b inputs, will be created by the wallet software doing the atomic swap. So Alice will first have to send her 1 Bitcoin to herself to make sure its a simple p2pkh. Here is the Protoblock code that creates the p2pkh outputs and bitcoin tx:*

<https://github.com/SatoshiFantasy/--skillSale/blob/4e59f50b7555527046804418d6483b0df1933637/share/fantasybit-core/FantasyAgent.cpp#L444>

<https://github.com/SatoshiFantasy/--skillSale/blob/4e59f50b7555527046804418d6483b0df1933637/share/fantasybit-core/FantasyAgent.cpp#L525>

**Tags:** input-script, p2pkh, atomic-swap


---

## 1 answers

### Answer by username_1 on 2018-08-09. Score: -1

No Atomic Swaps are by definition **atomic** meaning either there's a swap and both parties redeem the coins or no . I suggest you take a look at the Decred repository to understand the mechanics of the swap .

> **Comments:**
> **username_0**: the term "atomic" swap is used, even though its not atomic. i bet decred is just as "atomic", I will take a look... anyways but the question i'm asking is in relation to a double spend, and if there can be proof of a spent input.  
> **username_0**: decred uses the standard timeOut technique, which (i believe) requires one party to move the coins again - or else the swap does not go through  

---

