What's the segwit transaction serialization "flag" field for?

1

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?

esneider

Posted 2019-01-28T00:24:25.617

Reputation: 111

Answers

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.

esneider

Posted 2019-01-28T00:24:25.617

Reputation: 111

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. 2019-01-28T07:28:03.630

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 2019-01-29T09:44:16.307

@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. 2019-01-29T09:49:33.520