2

In the bitcoin transaction version 2, there are additional two bytes (hex: "0001") between transaction version (hex: "02000000"), and number of inputs (hex: "01"). What it is?

Here's an example https://btc-explorer.com/tx/4f692e7fb63256e4e741b952935e929ad545838d3697c5ee3f044a250c45fb4a

transaction hex: "020000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff4b031a0608048187145b622f4254432e434f4d2ffabe6d6dec50b9ca7f0e6731e89a2516f3df5fd7d65462ed2e68df7bf8e375232b7b28c701000000000000006200de217cb2aaea00000000ffffffff0212b0bf4a000000001976a91478ce48f88c94df3762da89dc8498205373a8ce6f88ac0000000000000000266a24aa21a9ed89dbbf72d51df862d19e0baa551d87e69b65a452496ec9d8203de66c754c30330120000000000000000000000000000000000000000000000000000000000000000000000000"

5

That is not something specific to version 2 transactions.

What you are looking at are the marker and flag bytes for a segwit transaction. Segwit transactions have a slightly different transaction format which is specified in BIP 144.

0
2

You might be interested in my article The Bitcoin Script Language. A part of that is to go into details of the transaction format. Especially helpful is this graphic I've created:

enter image description here

To answer the question directly: The first one is called "marker", the second one is called "flag". BIP 144 gives more details:

  • Rationale for not using just a single 0x00 byte as marker: that would lead to empty transactions (no inputs, no outputs, which are used in some tests) to be interpreted as new serialized data.
  • 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.

See BIP 141

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.