3

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

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 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.

| improve this answer | |
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.

| improve this answer | |
  • Thanks, that clears things up :) – MHH Jun 4 at 9:39

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.