7
7
I'd like to learn how segregated witness works, and I thought the raw transaction data would be a good place to start
If this is the structure of current transactions:
version | [inputcount] {[txid] [vin] [signature] [sequence]} | [outputcount] {value} {varint} {lockingscript} | [locktime]
What does a segregated witness transaction look like?
Thank you, Pieter. Is there a specific version number that will be used to identify SegWit transactions? – inersha – 2016-10-20T18:22:20.830
No, that's not possible. The version number is part of the serialized data. If we used that to identify the type of serialization itself, a new node wouldn't understand transactions passed by old nodes (which would have the new version number, but the old serialization). – Pieter Wuille – 2016-10-20T18:24:01.150
@PieterWuille Is there any change to the BLOCK serialization? For example, are ALL tx witnesses appended to the end of an otherwise backwards-compatible block? Or do all the witnesses remain where they normally occur in each
tx, but are stripped out before serializing for a non-SW node? Do thedummyandflagsbytes need to be stripped out as well for non-SW nodes? – pinhead – 2017-03-24T18:44:57.7231A witness block is serialized as a normal block, but with witness serialization for the transactions. So the dummy and flags need to be stripped before relay to old nodes, indeed. – Pieter Wuille – 2017-03-24T19:01:21.813
@PieterWuille got it thanks. And the dummy byte - that makes SW transactions individually NOT backwards compatible? Are there any network-layer consequences of this? Will old nodes ban SW nodes or anything like that? – pinhead – 2017-03-24T22:10:55.700
1
The serialization of SW transactions is not compatible. The transactions are. See http://bitcoin.stackexchange.com/questions/52152/how-is-segwit-a-soft-fork/52153#52153
– Pieter Wuille – 2017-03-24T22:15:35.533