<p>The witness serialization format only applies to transactions that have witnesses. If a transaction does not have witnesses, then its witness serialization format is the non-witness serialization format. </p>

<p>From BIP 144:</p>

<blockquote>
  <p>If the witness is empty, the old serialization format should be used.</p>
</blockquote>

CC BY-SA 3.0
2017-06-22T16:42:45.113Z
Thanks - silly mistake on my part. I even knew that's what BIP-144 said and somehow forgot it.
Rich Apodaca
CC BY-SA 3.0
2017-06-22T16:39:39.993Z
2017-06-22T16:39:39.993Z
Ava Chow
<p>From BIP 144: <em>If the witness is empty, the old serialization format should be used.</em></p>

<p>It is illegal to encode a transaction using the extended serialization format if the witness is empty. Another way to see it is that <em>every</em> transaction has a witness, which may be empty, and the correct way to encode that empty witness is using the old serialization format.</p>

<p>This also holds for the serialization done for the purposes of computing weight.</p>

<p>A non-witness transaction will be counted 3 times as its base size (which is the size of the serialization in the old format), and then once as its witness size (which is again the size of the serialization in the old format). The result is that the weight of a non-witness transaction is just 4 times its old size.</p>

CC BY-SA 3.0
2017-06-22T16:42:36.370Z
2017-06-22T16:42:36.370Z
Pieter Wuille
<p>I'm trying to understand block weight, a metric introduced by segwit (<a href="https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki" rel="nofollow noreferrer">BIP-141</a>):</p>

<pre><code>block weight = 3 * base size + total size
</code></pre>

<p>"base size" is the length of a pre-segwit block, which contains only serialized base transactions. "total size" is the length of a post-segwit block, which contains both serialized base transactions and serialized witness transactions (as defined in <a href="https://github.com/bitcoin/bips/blob/master/bip-0144.mediawiki" rel="nofollow noreferrer">BIP-144</a>). The weight of any block must not exceed 4 MB.</p>

<p>The weight of a block without pay-to-witness scripts can found by computing total size. It's tempting to set base size equal to total size:</p>

<pre><code>block weight = 3 * base size + base size = 4 * base size
</code></pre>

<p>But this assumes the length of the serialization of a non-segwit base transaction equals the length of the serialization of a non-segwit witness transaction. This doesn't appear to be the case:</p>

<p><a href="https://i.sstatic.net/yycjl.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/yycjl.png" alt="Serialization"></a></p>

<p>The <a href="https://github.com/bitcoin/bips/blob/master/bip-0144.mediawiki#serialization" rel="nofollow noreferrer">witness transaction serialization format</a> appears to follow the structure shown above (which is also the input to find wtxid). Notice two additional bytes before the list of inputs (marker and flag, respectively). Moreover, the witness requires at least one byte (the witness field count) even if no fields are present.</p>

<p>In other words, a witness transaction serialization will always be at least three bytes longer than a base transaction serialization, regardless of whether a witness is present.</p>

<p>If this is correct, then segwit is in fact <em>reducing</em> the block size limit for blocks devoid of pay-to-witness scripts by a factor proportional to the number of transactions in the block.</p>

<p>What am I missing?</p>

<segregated-witness><blocksize><witness-data><block-weight>
What is the weight of a block that contains no pay-to-witness scripts?
Rich Apodaca
# What is the weight of a block that contains no pay-to-witness scripts?

(Asked by: username_0 on 2017-06-22)

I'm trying to understand block weight, a metric introduced by segwit ([BIP-141](https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki)):

```
block weight = 3 * base size + total size

```

"base size" is the length of a pre-segwit block, which contains only serialized base transactions. "total size" is the length of a post-segwit block, which contains both serialized base transactions and serialized witness transactions (as defined in [BIP-144](https://github.com/bitcoin/bips/blob/master/bip-0144.mediawiki)). The weight of any block must not exceed 4 MB.

The weight of a block without pay-to-witness scripts can found by computing total size. It's tempting to set base size equal to total size:

```
block weight = 3 * base size + base size = 4 * base size

```

But this assumes the length of the serialization of a non-segwit base transaction equals the length of the serialization of a non-segwit witness transaction. This doesn't appear to be the case:

[![Serialization](https://i.sstatic.net/yycjl.png)](https://i.sstatic.net/yycjl.png)

The [witness transaction serialization format](https://github.com/bitcoin/bips/blob/master/bip-0144.mediawiki#serialization) appears to follow the structure shown above (which is also the input to find wtxid). Notice two additional bytes before the list of inputs (marker and flag, respectively). Moreover, the witness requires at least one byte (the witness field count) even if no fields are present.

In other words, a witness transaction serialization will always be at least three bytes longer than a base transaction serialization, regardless of whether a witness is present.

If this is correct, then segwit is in fact *reducing* the block size limit for blocks devoid of pay-to-witness scripts by a factor proportional to the number of transactions in the block.

What am I missing?

**Tags:** segregated-witness, blocksize, witness-data, block-weight


---

## 2 answers

### Answer by username_1 on 2017-06-22. Score: 3 | Accepted answer

The witness serialization format only applies to transactions that have witnesses. If a transaction does not have witnesses, then its witness serialization format is the non-witness serialization format.

From BIP 144:

> If the witness is empty, the old serialization format should be used.

> **Comments:**
> **username_0**: Thanks - silly mistake on my part. I even knew that's what BIP-144 said and somehow forgot it.  

---

### Answer by username_2 on 2017-06-22. Score: 3

From BIP 144: *If the witness is empty, the old serialization format should be used.*

It is illegal to encode a transaction using the extended serialization format if the witness is empty. Another way to see it is that *every* transaction has a witness, which may be empty, and the correct way to encode that empty witness is using the old serialization format.

This also holds for the serialization done for the purposes of computing weight.

A non-witness transaction will be counted 3 times as its base size (which is the size of the serialization in the old format), and then once as its witness size (which is again the size of the serialization in the old format). The result is that the weight of a non-witness transaction is just 4 times its old size.


---

