<blockquote>
<p>The total size including the above Compact Size is 1049. In addition to this, do I need to add the number of bytes(1) of CompactSize for the number of elements(5)?</p>
</blockquote>
<p>Indeed.</p>
<p>What matters is the total number of bytes of witness data for that input (i.e., all bytes subject to the witness discount). That also includes the encoding of the number of witness stack elements.</p>

CC BY-SA 4.0
2020-12-29T04:19:46.430Z
2020-12-29T04:19:46.430Z
Pieter Wuille
<p>Sigops limits have been changed to budget in Tapscript. BIP341 defines the budget calculation method as follows.</p>
<blockquote>
<p>The budget equals 50 + the total serialized size in bytes of the transaction input's witness (including the CompactSize prefix). Executing a signature opcode (OP_CHECKSIG, OP_CHECKSIGVERIFY, or OP_CHECKSIGADD) with a non-empty signature decrements the budget by 50.</p>
</blockquote>
<p><a href="https://github.com/bitcoin/bips/blob/master/bip-0342.mediawiki#Resource_limits" rel="nofollow noreferrer">https://github.com/bitcoin/bips/blob/master/bip-0342.mediawiki#Resource_limits</a></p>
<p>This CompactSize prefix include the number of witness elements at the beginning?</p>
<p>For example, if I have the following 5 sizes of witness data,</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>compact size</th>
<th>witness size</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>65</td>
</tr>
<tr>
<td>1</td>
<td>64</td>
</tr>
<tr>
<td>1</td>
<td>91</td>
</tr>
<tr>
<td>3</td>
<td>257</td>
</tr>
<tr>
<td>3</td>
<td>563</td>
</tr>
</tbody>
</table>
</div>
<p>The total size including the above Compact Size is <code>1049</code>. In addition to this, do I need to add the number of bytes(<code>1</code>) of CompactSize for the number of elements(<code>5</code>)?</p>
<p>That's because the above data output by Bitcoin Core feature_taproot.py is <code>1050</code>. The final budget will be <code>1100</code>, which is <code>50</code> added to this.</p>

<bitcoin-core><taproot>
How to calculate Tapscript sigops budget?
Shigeyuki Azuchi
# How to calculate Tapscript sigops budget?

(Asked by: username_0 on 2020-12-29)

Sigops limits have been changed to budget in Tapscript. BIP341 defines the budget calculation method as follows.

> The budget equals 50 + the total serialized size in bytes of the transaction input's witness (including the CompactSize prefix). Executing a signature opcode (OP\_CHECKSIG, OP\_CHECKSIGVERIFY, or OP\_CHECKSIGADD) with a non-empty signature decrements the budget by 50.

<https://github.com/bitcoin/bips/blob/master/bip-0342.mediawiki#Resource_limits>

This CompactSize prefix include the number of witness elements at the beginning?

For example, if I have the following 5 sizes of witness data,

| compact size | witness size |
| --- | --- |
| 1 | 65 |
| 1 | 64 |
| 1 | 91 |
| 3 | 257 |
| 3 | 563 |

The total size including the above Compact Size is `1049`. In addition to this, do I need to add the number of bytes(`1`) of CompactSize for the number of elements(`5`)?

That's because the above data output by Bitcoin Core feature\_taproot.py is `1050`. The final budget will be `1100`, which is `50` added to this.

**Tags:** bitcoin-core, taproot


---

## 1 answers

### Answer by username_1 on 2020-12-29. Score: 2 | Accepted answer

> The total size including the above Compact Size is 1049. In addition to this, do I need to add the number of bytes(1) of CompactSize for the number of elements(5)?

Indeed.

What matters is the total number of bytes of witness data for that input (i.e., all bytes subject to the witness discount). That also includes the encoding of the number of witness stack elements.


---

