# If a double spend is executed, what happens to the original transaction?

So I think i have read enough about double spending so as to be able to execute one.

But I have found nowhere what happens to the original transaction.

A doublespend is a set of transactions which are conflicting with each other. This happens when all transactions are trying to spend some of the same UTXO for inputs. As UTXO can only be spend once, only one of the transactions of the set can be confirmed. When one gets confirmed, all the others become invalid, the invalid transaction will then be forgotten by the network at that point.

Just be sure that some of the inputs match, otherwise you're sending the payment a second time instead of creating a conflicting transaction.

• So when its forgotten the coins go back to me right?
– user45038
Jan 12 '17 at 9:14
• If the first transaction uses the UTXOs `A`, `B`, and `C` as inputs, and the second transaction uses `C` and `D`, then `A` and `B` would be shown as spendable when the second transaction confirms.
– Murch
Jan 12 '17 at 9:16

Think of a double spend as tricking the recipient of a payment into temporarily thinking that they have been paid. To them, it appears as if you have broadcast a valid transaction, so they hold up their end of the deal. Only after they cannot undo their end (goods have been shipped, digital product has been downloaded, etc...) do they learn that a different transaction has invalidated the payment they thought they had.

In other words, the first transaction was valid...so far as the recipient knew. Once the second transaction is accepted into a block, all nodes consider the first transaction invalid, and dump it. It's like it never happened.

Bitcoin network works on the mathematical proof of work.

If double spending happens, the bitcoin network will accept the transaction with longest block/transaction list.

so if First spending has Five sequential and Second has Eight sequential blocks, bitcoin network will discard first one and accept second one as it have more blocks which can only be achieved by valid mathematical proof.