1

According to bip 141, the segwit transaction serialization format (used to compute the wtxid) is:

[nVersion][marker][flag][txins][txouts][witness][nLockTime]

The bip mentions that the flag field MUST currently be 0x01. What's the purpose of this field? Is it some kind of upgrading mechanism of the serialization format?

0

Found it in bip 144:

Rationale for the 0x01 flag byte in between: this will allow us to easily add more extra non-committed data to transactions (like txouts being spent, ...). It can be interpreted as a bitvector.

So the 0x01 flag is indicating that the witness data should be included in the (bip144) transaction serialization.

  • I still don't fully understand. The 0x00 marker already prevents parsing by non-witness aware nodes. I suppose the 0x01 flag individual bits can signal inclusion of future data, such as prevouts? So up to 7 additional "data types" which can be included? Also, this data would be non-committed to the merkle root, but committed to the witness root hash, yes? – James C. Jan 28 at 7:28
  • 2
    @James C. All correct. It's intended for future extensibility with other types of witness data. Such new witnesses would need their own new witness commitments in the coinbase as well, as the existing wtxid would not cover them. – Pieter Wuille Jan 29 at 9:44
  • @PieterWuille Perfect, I will look at how this is parsed again in the implementation, I didn’t think about new “wtxid” being required, but logical, thx! – James C. Jan 29 at 9:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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