<p>I see two ways:</p>
<blockquote>
<p>Txid + index</p>
<p>Txid + script hash</p>
</blockquote>
<p>Pros of the <strong>txid + index</strong>:</p>
<ul>
<li>Simple and short</li>
</ul>
<p>Cons of <strong>txid + index</strong>:</p>
<ul>
<li>It relies on array iteration being deterministic and all third party services using the same iteration method.</li>
</ul>
<p><strong>Txid + script hash</strong> does not rely on iteration order and since script hashes are stored on the blockchain they are not malleable after 6 confirmations.</p>
<p>Which would be the preferred way to go?</p>

CC BY-SA 4.0
2019-03-02T18:02:33.050Z
What if there are two outputs of the same transaction with the same scriptPubKey, but different amount? Also why would index not be deterministic? Transactions have a well defined order of their outputs. It's also not a question, as the Bitcoin protocol requires referring to the output being spent using txid+index.
Pieter Wuille
CC BY-SA 4.0
2019-03-02T18:16:37.227Z
@PieterWuille Great points, didn't consider multiple identical scripts having different amounts. That completely excludes that option. I will rely on txid+index like bitcoin then. Thanks a lot!
Soggiorno
<transactions><hash><script><utxo>
Uniquely identifying a UTXO
Soggiorno
# Uniquely identifying a UTXO

(Asked by: username_0 on 2019-03-02)

I see two ways:

> Txid + index
>
> Txid + script hash

Pros of the **txid + index**:

* Simple and short

Cons of **txid + index**:

* It relies on array iteration being deterministic and all third party services using the same iteration method.

**Txid + script hash** does not rely on iteration order and since script hashes are stored on the blockchain they are not malleable after 6 confirmations.

Which would be the preferred way to go?

**Tags:** transactions, hash, script, utxo

> **Comments:**
> **username_1**: What if there are two outputs of the same transaction with the same scriptPubKey, but different amount? Also why would index not be deterministic? Transactions have a well defined order of their outputs. It's also not a question, as the Bitcoin protocol requires referring to the output being spent using txid+index.  
> **username_0**: @PieterWuille Great points, didn't consider multiple identical scripts having different amounts. That completely excludes that option. I will rely on txid+index like bitcoin then. Thanks a lot!  

---

## 0 answers

