<p>Per <a href="https://github.com/bitcoin/bips/blob/master/bip-0030.mediawiki" rel="noreferrer">BIP 30</a>, transactions are not allowed to have the same TXID as another transaction which has unspent outputs.</p>

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

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

CC BY-SA 4.0
2018-05-18T16:01:19.583Z
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
CC BY-SA 4.0
2018-05-18T16:02:46.897Z
Moreover, will that `getrawtransaction` will return more than one result?
sr_gi
CC BY-SA 4.0
2018-05-18T16:02:48.817Z
No, 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.
Ava Chow
CC BY-SA 4.0
2018-05-18T16:03:40.763Z
`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.
Ava Chow
CC BY-SA 4.0
2018-05-18T17:45:48.413Z
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
CC BY-SA 4.0
2018-05-18T15:56:20.030Z
2018-05-18T15:56:20.030Z
Ava Chow
<p>What would happened if two transactions have the same hash?<br>
Would it make the Unspent Transaction Outputs(UTXO) in the old transaction not spendable?<br>
I think it would make the outputs in the new transaction spendable and the outputs in the old transaction not spendable.</p>

CC BY-SA 4.0
2018-05-18T17:13:54.843Z
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
CC BY-SA 4.0
2018-05-18T17:17:51.943Z
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
<transactions>
What would happened if two transactions have the same hash?
Bill
# What would happened if two transactions have the same hash?

(Asked by: username_0 on 2018-05-18)

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.

**Tags:** transactions

> **Comments:**
> **username_0**: 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.  
> **username_0**: 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)  

---

## 1 answers

### Answer by username_1 on 2018-05-18. Score: 5 | Accepted answer

Per [BIP 30](https://github.com/bitcoin/bips/blob/master/bip-0030.mediawiki), 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.

> **Comments:**
> **username_2**: 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?  
> **username_2**: Moreover, will that `getrawtransaction` will return more than one result?  
> **username_1**: No, 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.  
> **username_1**: `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.  
> **username_3**: 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.  

---

