<p>If your question is about how witness data is <em>transmitted</em> to other peers in the P2P protocol, the right place to look is <a href="https://github.com/bitcoin/bips/blob/master/bip-0144.mediawiki" rel="nofollow noreferrer">BIP-144</a>; the P2P side of the segwit specification.</p>
<p>In short, the witness data is inserted after the transaction output data in every individual <em>transaction</em>, together with a special marker after the version number to indicate whether or not witness data is present. Full blocks then consist of the block header, a transaction counter, and a concatenation of all transaction (which include that witness data).</p>
<p>Note that this is not the only way that blocks are transmitted. BIP-152 (compact blocks) send blocks where the transactions are replaced with short hashes, anticipating that the receiver will already have those transactions (including their witness data).</p>
<p>As for how witness data is <em>stored</em>: that is an implementation detail that is up to the client software, and not specified in BIP documents. Bitcoin Core stores blocks using the same serialization as used in the P2P protocol, as described above.</p>

CC BY-SA 4.0
2020-11-02T18:01:49.883Z
2020-11-02T21:49:18.893Z
2020-11-02T21:49:18.893Z
Pieter Wuille
<p>I can see in <a href="https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#Commitment_structure" rel="nofollow noreferrer">BIP-141</a> where the merkle hash is stored.  And I think its clear that the witness data won't be streamed inline with the TXN data.  So I assume the witness data is simply thunked on to the end of the <a href="https://en.bitcoin.it/wiki/Block" rel="nofollow noreferrer">raw block</a>.</p>
<p>Is this something so blatantly obvious that it doesn't need to be specified in a BIP or wiki anywhere, or did I just miss the mention?</p>

<segregated-witness><witness-data>
Where is the witness data stored in the raw block data
Dan
# Where is the witness data stored in the raw block data

(Asked by: username_0 on 2020-11-02)

I can see in [BIP-141](https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#Commitment_structure) where the merkle hash is stored. And I think its clear that the witness data won't be streamed inline with the TXN data. So I assume the witness data is simply thunked on to the end of the [raw block](https://en.bitcoin.it/wiki/Block).

Is this something so blatantly obvious that it doesn't need to be specified in a BIP or wiki anywhere, or did I just miss the mention?

**Tags:** segregated-witness, witness-data


---

## 1 answers

### Answer by username_1 on 2020-11-02. Score: 4 | Accepted answer

If your question is about how witness data is *transmitted* to other peers in the P2P protocol, the right place to look is [BIP-144](https://github.com/bitcoin/bips/blob/master/bip-0144.mediawiki); the P2P side of the segwit specification.

In short, the witness data is inserted after the transaction output data in every individual *transaction*, together with a special marker after the version number to indicate whether or not witness data is present. Full blocks then consist of the block header, a transaction counter, and a concatenation of all transaction (which include that witness data).

Note that this is not the only way that blocks are transmitted. BIP-152 (compact blocks) send blocks where the transactions are replaced with short hashes, anticipating that the receiver will already have those transactions (including their witness data).

As for how witness data is *stored*: that is an implementation detail that is up to the client software, and not specified in BIP documents. Bitcoin Core stores blocks using the same serialization as used in the P2P protocol, as described above.


---

