Bitcoin

Separated Witness – Interpretation of marker bytes by legacy transaction parser

The marker byte is interpreted by the legacy transaction parser as the input number of the transaction and is always 0. My question is why in the legacy transaction parser a transaction with 0 inputs is considered valid?

The Mastering Bitcoin book mentions interpretation of marker bytes by the legacy transaction parser.

In legacy serialization, the marker byte was interpreted as the input number (0). Because a transaction cannot have zero input, the marker signals to newer programs that extended serialization is being used. The flag field provides a similar signal and also simplifies the process of updating the serialization format in the future.

Also, this answer by Ava Chow notes:

In particular, you’re missing the point that the field immediately after the version number is a single 0 byte (called the marker byte) instead of an input count. This was done specifically to ensure that transactions appear as if they had no input to the legacy transaction parser.

From what I understand, the minimum number of inputs for a transaction is 1, so why would a legacy transaction parser that sees a transaction with 0 inputs (marker bytes) consider the transaction valid?

Related Articles

Back to top button