1

Since segregated witness is in place inside Bitcoin blockchain, my understanding is that witness data are no longer stored inside the blocks, so if blocks are linked to each other where theirs corresponding witness data are stored ? There is a parallel block chain ?

1 Answer 1

1

If the client is SegWit enabled, the full transaction including witness data can be stored in the same format as the transaction is received over the wire. There is no need for separate storage - it can all be included in the block.

If the client is not SegWit enabled, SegWit transactions are stripped of their witness and the witness marker/flag before sending/receiving, so these clients will not receive witness data, and therefore will not store it at all and will only use the legacy format.

This means the block storage between the two clients is different, but they are still sharing the same blockchain and transaction history.

Compatibility is made possible because even when SegWit is used and the witness is present, the SegWit client will calculate a txid by stripping the transaction back to its legacy format (removing the witness parts) before hashing. The txid is common between the SegWit and non-SegWit clients as a means to identify which transaction is being referred to. SegWit clients can identify data by a wtxid too, which is the hash of the serialized transaction with witness format - but this wtxid is not used as part of a txOutPoint to refer to a previous transaction - the txid is always used.

SegWit transactions are forward compatible with non-supporting software clients because the transaction with its witness data stripped from it appears as though it is an ANYONECANSPEND transaction - the stack is left with a non-zero value on top after evaluating the scriptPubKey, which is indicates successful evaluation.

1
  • I read @Guillaume07 question as more related to the block serialization structure rather than the TXN serialization structure. Obviously the witness data is thunked into the TXN after the fact and must exist outside of the normal block serialization to exist at all. To Guillaume07 question, I think it is just concatenated on to the end of the block. Non-segwit clients will just stop parsing after the last TXN, and segwit clients would keep scanning. The witness merkel tree is stored in the coinbase TXN as an OP_RETURN UTXO.
    – Dan
    Nov 2, 2020 at 14:42

Your Answer

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

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