segregated witness – Can a non-segwit transaction be serialized in the segwit format?


The extended serialization format introduced in BIP144, which is used for serializing witnesses, specifies:

If the witness is empty, the old serialization format must be used.

So, no, using the extended serialization format for a transaction with all empty witnesses would be incorrect.

Note that this is not a consensus or policy rule, but just a serialization rule. Violating it doesn’t mean the transaction is invalid or non-standard, only that it was conveyed in an incorrect manner. It’s a property of the protocol used between nodes, but in theory, two nodes could privately agree on a different protocol which has different serialization rules, as long as they use the normal protocol with normal nodes.

That said, the wtxid introduced in BIP141 is defined as the double-SHA256 hash of the BIP144 serialization of the transaction. This aspect is a concensus rule, as the hash value is normative. Even hypothetical nodes that use a different serialization format must use the BIP144 serialization for wtxid computation. In particular, the combination implies that for non-segwit transactions the txid and wtxid are equal.

It is also the case that Bitcoin Core versions 0.14.x through 0.18.x unintentionally permitted using the extended format even for transactions without witnesses. This was just on deserialization; even if a transaction would be received this way, it would be serialized correctly on relay.



Source link

Author

Leave a Comment