<p>When you say &quot;transactions&quot;, I assume you mean &quot;transaction output&quot;.</p>
<p>It is literally not possible to have a transaction output that is larger than the transaction size limit. Otherwise the transaction containing that output would not be in the blockchain.</p>
<p>Rather I think what you are looking for is that the output script is larger than the maximum script size. Such scripts are provably unspendable and can be excluded from the UTXO set.</p>
<p>Bitcoin Core has a function to determine whether outputs are unspendable. It is not an exhaustive list and is just the two that you mention: Scripts beginning with OP_RETURN, and scripts larger than the max script size.</p>
<p>However there are other scripts that are provably unspendable, just that they require a little more work to prove. For example scripts that use invalid or disabled opcodes are provably unspendable. The script interpreter will fail if any such opcode is found in the script when it is verifying the spend.</p>
<p>But even that has a catch. Unknown opcodes that are not executed (e.g. in an unexecuted IF branch), the script can still pass validation. However if the script contains any of the disabled opcodes anywhere (there are a few exceptions to this as some &quot;disabled&quot; opcodes were actually just outright removed), it is invalid.</p>
<p>There are also potentially scripts that require something larger than the maximum stack item size to be pushed to the stack. Or something that manipulates a stack item so that it becomes a negative locktime when used with OP_CHECKLOCKTIMEVERIFY or OP_CHECKSEQUENCEVERIFY.</p>
<p>Then there are output scripts that are programmed invalidly such as having just an OP_ELSE or OP_ENDIF with no OP_IF/OP_NOTIF coming before it.</p>
<p>All of these things are hard to determine and really require inspecting the individual scripts. They also require having a consensus conforming script interpreter, which itself is hard to do because the exact semantics of scripts are actually unclear.</p>

CC BY-SA 4.0
2021-01-16T04:38:48.853Z
then how does websites like blockchain.com create the UTXO charts?
LeanMan
CC BY-SA 4.0
2021-01-16T04:44:07.987Z
@LeanMan They do the easy thing of just looking for OP_RETURNs and (maybe) scripts larger than the max script size.
Ava Chow
CC BY-SA 4.0
2021-01-16T04:59:46.177Z
I did try to calculate it like that and I was off by a few thousand or so UTXO
LeanMan
CC BY-SA 4.0
2020-08-21T16:24:32.277Z
2020-08-21T17:02:49.143Z
2020-08-21T17:02:49.143Z
Ava Chow
<p>Glassnode have a chart showing the Bitcoin Provably Lost Supply [BTC].
You can filter out the Burn, Unclaimed and just show the Op Return. See <a href="https://studio.glassnode.com/metrics?a=BTC&amp;ema=0&amp;m=supply.ProvablyLost&amp;mAvg=0&amp;mMedian=0&amp;zoom=all" rel="nofollow noreferrer">here</a></p>

CC BY-SA 4.0
2024-03-26T12:30:28.343Z
2024-03-26T12:30:28.343Z
Donal
<p>As far as I understand, one can count the UTXOs by iterating through the blockchain starting at block height 0 and counting the number of outputs and subtracting the number of inputs for each block and summing up the result. In addition to this, subtract any provably unspendable transactions such as OP_RETURNs. I believe the list of provably unspendable transactions is something a long the lines of:</p>
<ul>
<li>transaction outputs that start with OP_RETURNS</li>
<li>transaction outputs that are greater than the transaction size limit</li>
</ul>
<p>Are there any knowledge gaps above?</p>
<p>If not, how do you count the list of provably unspendable transactions.</p>
<ul>
<li>OP_RETURNS: Is it just count the TX that has OP_RETURN in their TX? Is there anything else to do here?</li>
<li>TX size restriction: How does one go about counting this?</li>
</ul>

<blockchain><utxo-set>
How to count the provably unspendable UTXO in the blockchain?
LeanMan
# How to count the provably unspendable UTXO in the blockchain?

(Asked by: username_0 on 2020-08-21)

As far as I understand, one can count the UTXOs by iterating through the blockchain starting at block height 0 and counting the number of outputs and subtracting the number of inputs for each block and summing up the result. In addition to this, subtract any provably unspendable transactions such as OP\_RETURNs. I believe the list of provably unspendable transactions is something a long the lines of:

* transaction outputs that start with OP\_RETURNS
* transaction outputs that are greater than the transaction size limit

Are there any knowledge gaps above?

If not, how do you count the list of provably unspendable transactions.

* OP\_RETURNS: Is it just count the TX that has OP\_RETURN in their TX? Is there anything else to do here?
* TX size restriction: How does one go about counting this?

**Tags:** blockchain, utxo-set


---

## 2 answers

### Answer by username_1 on 2020-08-21. Score: 4

When you say "transactions", I assume you mean "transaction output".

It is literally not possible to have a transaction output that is larger than the transaction size limit. Otherwise the transaction containing that output would not be in the blockchain.

Rather I think what you are looking for is that the output script is larger than the maximum script size. Such scripts are provably unspendable and can be excluded from the UTXO set.

Bitcoin Core has a function to determine whether outputs are unspendable. It is not an exhaustive list and is just the two that you mention: Scripts beginning with OP\_RETURN, and scripts larger than the max script size.

However there are other scripts that are provably unspendable, just that they require a little more work to prove. For example scripts that use invalid or disabled opcodes are provably unspendable. The script interpreter will fail if any such opcode is found in the script when it is verifying the spend.

But even that has a catch. Unknown opcodes that are not executed (e.g. in an unexecuted IF branch), the script can still pass validation. However if the script contains any of the disabled opcodes anywhere (there are a few exceptions to this as some "disabled" opcodes were actually just outright removed), it is invalid.

There are also potentially scripts that require something larger than the maximum stack item size to be pushed to the stack. Or something that manipulates a stack item so that it becomes a negative locktime when used with OP\_CHECKLOCKTIMEVERIFY or OP\_CHECKSEQUENCEVERIFY.

Then there are output scripts that are programmed invalidly such as having just an OP\_ELSE or OP\_ENDIF with no OP\_IF/OP\_NOTIF coming before it.

All of these things are hard to determine and really require inspecting the individual scripts. They also require having a consensus conforming script interpreter, which itself is hard to do because the exact semantics of scripts are actually unclear.

> **Comments:**
> **username_0**: then how does websites like blockchain.com create the UTXO charts?  
> **username_1**: @username_0 They do the easy thing of just looking for OP_RETURNs and (maybe) scripts larger than the max script size.  
> **username_0**: I did try to calculate it like that and I was off by a few thousand or so UTXO  

---

### Answer by username_2 on 2024-03-26. Score: 0

Glassnode have a chart showing the Bitcoin Provably Lost Supply [BTC].
You can filter out the Burn, Unclaimed and just show the Op Return. See [here](https://studio.glassnode.com/metrics?a=BTC&ema=0&m=supply.ProvablyLost&mAvg=0&mMedian=0&zoom=all)


---

