What would happened if two transactions have the same hash?

2

2

What would happened if two transactions have the same hash?
Would it make the Unspent Transaction Outputs(UTXO) in the old transaction not spendable?
I think it would make the outputs in the new transaction spendable and the outputs in the old transaction not spendable.

Bill

Posted 2018-05-18T15:42:14.200

Reputation: 65

Question was closed 2018-05-18T19:06:46.930

As eponymous's comment:"All blocks after 2012 contain the height in the block's coinbase transaction". It is difficult to create a new coinbase transaction with duplicate hashes because the height is included in the coinbase transaction.

Bill 2018-05-18T17:13:54.843

Answers

4

Per BIP 30, transactions are not allowed to have the same TXID as another transaction which has unspent outputs.

This means that there can be transactions that have the same TXID, but only after the first transaction's outputs are already spent. So in this case, the duplicate TXID does not matter.

For transactions that do have duplicated TXIDs (there are a few of them), only the most recent of those transactions can have its outputs spent. The earlier transactions with the same TXID cannot be spent from and their Bitcoin are lost forever.

Andrew Chow

Posted 2018-05-18T15:42:14.200

Reputation: 40 910

I was about to answer the question, but I was not sure about some details. Does that means that if the old transaction has unspent outputs, all will be evicted from the UTXO set, and the new ones will be included?sr-gi 2018-05-18T16:01:19.583

Moreover, will that getrawtransaction will return more than one result?sr-gi 2018-05-18T16:02:46.897

1No, the new transaction will be rejected entirely for having a duplicate txid. There are just special cases for the few duplicate txid transactions that occurred before BIP 30's introduction.Andrew Chow 2018-05-18T16:02:48.817

2getrawtransaction will return the same thing because the duplicate txid transactions are literally the same transaction (everything about them is the same except for the block that they are a part of). it will only return data for the most recent of the duplicates.Andrew Chow 2018-05-18T16:03:40.763

Just to mention an example, the coinbase transactions of blocks #91722 and #91880 have the same hash, and they both have an UTXO.

cpsola 2018-05-18T16:23:24.357

Note that disckjet's examples predate BIP30's activation. In the current consensus rules, such a duplicate txid wouldn't be permitted anymore. Also note that it isn't a case of an actual collision; just the same transaction issued twice.Pieter Wuille 2018-05-18T17:45:48.413