<p>Eventually all messages are put in a sequence. The key word is "eventually".</p>

<p>Let's say there are two users A and B trying to spend a transaction at the same time.</p>

<p>A's transaction reaches Node1 and B's transaction reaches Node2.</p>

<p>Both nodes include the two different transactions in a block and are able to mine the block using those transactions. </p>

<p>Further, when Node1 receives B's transaction it is rejected as a double spend and when Node2 received A's transaction, it is rejected as a double spend as well.</p>

<p>At this point Node1 and Node2 are working on different chains. This needs to be resolved, and the following explains how.</p>

<p>Now, when Node1 and Node2 broadcast their mined blocks to the network, there will be two competing chains. Depending on the which chain other nodes are using you will get 1 confirmation for the transaction from different nodes. That is why spending transactions with 1 confirmation is not too clever an idea.</p>

<p>Eventually, both nodes will reorganise as more blocks are mined top either Node1 or Node2's block. The issue will be resolved when one chain outputs 2 or more blocks more than the other. The losing chain will be discarded by all nodes (who must accept the longest chain as the most valid). At that point the double-spent transaction that did not make it into the valid chain will be invalid forever. </p>

<p>Hope this helps.</p>

CC BY-SA 4.0
2020-06-04T09:39:50.357Z
Thanks, that clears things up :)
MHH
CC BY-SA 4.0
2020-06-04T08:01:33.343Z
2020-06-04T20:59:02.373Z
2020-06-04T20:59:02.373Z
jungly
<blockquote>
  <p>What would happen if me and my friend broadcast transaction with same input at the same time to a different nodes ?</p>
</blockquote>

<p>Some network nodes will have your transaction in their mempool, while other will have your friend's one.</p>

<p>If your transaction is really basic (no batch, not signaling RBF, not spending another unconfirmed transaction) then (unmodified [*]) nodes will accept the first transaction they are sent and reject the other one.</p>

<blockquote>
  <p>Also what would happened if i broadcast it 1 minute after him and pay much larger fee and his transaction is still unconfirmed?</p>
</blockquote>

<p>If your friend's transaction signals for <a href="https://bitcoincore.org/en/faq/optin_rbf/" rel="nofollow noreferrer">Replace By Fee</a> then your transaction will likely [**] replace your friend's transaction in the nodes' mempools <em>which opted in for RBF</em>.</p>

<p>[*] According to their incentives, miners are likely to run modified versions of the software (and especially regarding the policy).</p>

<p>[**] If it respects <a href="https://github.com/bitcoin/bips/blob/master/bip-0125.mediawiki#implementation-details" rel="nofollow noreferrer">the 5 RBF rules</a>.</p>

CC BY-SA 4.0
2020-06-04T08:06:24.010Z
2020-06-04T08:06:24.010Z
Antoine Poinsot
<p>Lets say me and my friend both have access to same private key which can sign some new transaction. What would happen if me and my friend broadcast transaction with same input at the same time to a different nodes ?</p>

<p>Also what would happend if i broadcast it 1 minute after him and pay much larger fee and his transaction is still unconfirmed? Would miner take my transaction than because it includes higher fee or would the stick with his transction because he broadcasted it first.</p>

<p>Thanks</p>

CC BY-SA 4.0
2020-06-03T22:08:49.673Z
Does this answer your question? [How does a double spend get resolved when two miners find conflicting blocks at the same time?](https://bitcoin.stackexchange.com/questions/54734/how-does-a-double-spend-get-resolved-when-two-miners-find-conflicting-blocks-at)
Tony Sanak
<bitcoin-core><transactions><mempool>
What if two people want to spend same input at the same time
MHH
# What if two people want to spend same input at the same time

(Asked by: username_0 on 2020-06-03)

Lets say me and my friend both have access to same private key which can sign some new transaction. What would happen if me and my friend broadcast transaction with same input at the same time to a different nodes ?

Also what would happend if i broadcast it 1 minute after him and pay much larger fee and his transaction is still unconfirmed? Would miner take my transaction than because it includes higher fee or would the stick with his transction because he broadcasted it first.

Thanks

**Tags:** bitcoin-core, transactions, mempool

> **Comments:**
> **username_1**: Does this answer your question? [How does a double spend get resolved when two miners find conflicting blocks at the same time?](https://bitcoin.stackexchange.com/questions/54734/how-does-a-double-spend-get-resolved-when-two-miners-find-conflicting-blocks-at)  

---

## 2 answers

### Answer by username_2 on 2020-06-04. Score: 4

Eventually all messages are put in a sequence. The key word is "eventually".

Let's say there are two users A and B trying to spend a transaction at the same time.

A's transaction reaches Node1 and B's transaction reaches Node2.

Both nodes include the two different transactions in a block and are able to mine the block using those transactions.

Further, when Node1 receives B's transaction it is rejected as a double spend and when Node2 received A's transaction, it is rejected as a double spend as well.

At this point Node1 and Node2 are working on different chains. This needs to be resolved, and the following explains how.

Now, when Node1 and Node2 broadcast their mined blocks to the network, there will be two competing chains. Depending on the which chain other nodes are using you will get 1 confirmation for the transaction from different nodes. That is why spending transactions with 1 confirmation is not too clever an idea.

Eventually, both nodes will reorganise as more blocks are mined top either Node1 or Node2's block. The issue will be resolved when one chain outputs 2 or more blocks more than the other. The losing chain will be discarded by all nodes (who must accept the longest chain as the most valid). At that point the double-spent transaction that did not make it into the valid chain will be invalid forever.

Hope this helps.

> **Comments:**
> **username_0**: Thanks, that clears things up :)  

---

### Answer by username_3 on 2020-06-04. Score: 4

> What would happen if me and my friend broadcast transaction with same input at the same time to a different nodes ?

Some network nodes will have your transaction in their mempool, while other will have your friend's one.

If your transaction is really basic (no batch, not signaling RBF, not spending another unconfirmed transaction) then (unmodified [\*]) nodes will accept the first transaction they are sent and reject the other one.

> Also what would happened if i broadcast it 1 minute after him and pay much larger fee and his transaction is still unconfirmed?

If your friend's transaction signals for [Replace By Fee](https://bitcoincore.org/en/faq/optin_rbf/) then your transaction will likely [\*\*] replace your friend's transaction in the nodes' mempools *which opted in for RBF*.

[\*] According to their incentives, miners are likely to run modified versions of the software (and especially regarding the policy).

[\*\*] If it respects [the 5 RBF rules](https://github.com/bitcoin/bips/blob/master/bip-0125.mediawiki#implementation-details).


---

