0

Related to post Murch Explanation of Segwit Tx Fee Rate he breaks a TX down into:

  • TxHeader
  • TxInput
  • TxOutput

To calculate the weight and the final virtual size of a transaction (P2PKH,P2WPKH,P2SH-P2WPKH)

My question relates to what is the TxHeader in detail. I haven't heard about this classification in any articles.

1

When I look at the following Transaction Description Transactions I see the following distinction so I conclude:

TxHeader:

Field Size (in bytes)
Version no 4
Flag 2 (optional only for segwit v0 right now)
In-counter 1 - 9 bytes (varint)
Out-counter 1 - 9 bytes (varint)
lock_time 4 bytes

TxInput:

Field Size (in bytes)
list of inputs (in-counter)-many inputs

TxOutput:

Field Size (in bytes)
list of inputs (out-counter)-many inputs
6
  • Can somebody confirm ?
    – norisgOG
    Mar 9 at 9:22
  • 1
    The header can vary. You are nearly right. Basically it starts with version and inputCount. If the inputCount = 0 then the inputCount is the flag and the inputCout follows. If the initial inputCount is > 0 then its the inputCount and the inputs are following. Mar 9 at 11:07
  • FYFI I coded exactly that data reading: github.com/mrqc/bitcoin-blk-file-reader/blob/master/analyze.py Mar 9 at 11:07
  • See the readTransaction(...) function there. Mar 9 at 11:08
  • 1
    Ok so what your are essentially decribing is, how the algorithm is implemented,got it, but I think looking at your code when the 5 th byte is 0 then the next byte is the flag (not the already read inputCount) and the 7th Byte is the inputCount. Thanks for the Code Snippet very pratical for understanding
    – norisgOG
    Mar 9 at 23:47

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.