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.
Asked
Active
Viewed 2,513 times
3
Bill
- 75
- 1
- 7
-
As [eponymous's comment](https://bitcoin.stackexchange.com/questions/74537/why-there-is-no-block-index-or-block-height-included-in-the-block-header):"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 May 18 '18 at 17:13
-
Also read:[Can the outputs of transactions with duplicate hashes be spent?](https://bitcoin.stackexchange.com/questions/11999/can-the-outputs-of-transactions-with-duplicate-hashes-be-spent) and [Two blocks, two transactions, same hash](https://bitcoin.stackexchange.com/questions/3030/two-blocks-two-transactions-same-hash) – Bill May 18 '18 at 17:17
1 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
- 67,209
- 5
- 76
- 149
-
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 May 18 '18 at 16:01
-
Moreover, will that `getrawtransaction` will return more than one result? – sr_gi May 18 '18 at 16:02
-
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 May 18 '18 at 16:02
-
2`getrawtransaction` 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 May 18 '18 at 16:03
-
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 May 18 '18 at 17:45