I can see in BIP-141 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.

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?

1 Answer 1


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; 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.