Since BIP144, transaction knowledge is composed of 2 portions (standard knowledge and witness knowledge). There also are two distinct transaction serialization codecs:
- The legacy serialization layout, which retail outlets model quantity, transaction inputs, transaction outputs, and locktime.
- The prolonged serialization layout, which additionally has a flag/marker to suggest the prolonged layout is in use, and has witness knowledge for each transaction enter.
The prolonged layout should be used if witness knowledge is provide. The legacy layout should be used if no witness knowledge is provide.
The txid is the double-SHA256 hash of the serialized transaction in legacy layout, which means that any witness knowledge must be stripped out (because the legacy layout does now not reinforce witness knowledge). If the transaction had no witness knowledge within the first position (as pre-segwit transaction do), the txid is simply the hash of the serialized transaction.
The hash (or wtxid) of a transaction is the double-SHA256 hash of the serialization together with doable witness knowledge. If the transaction comprises no witness knowledge, this similar to the txid.