HomeBitcoinWhat Are The Elements Of A Bitcoin Transaction In SegWit Format?

What Are The Elements Of A Bitcoin Transaction In SegWit Format?


In a solution to In what format does a block retailer the transaction information? I gave an instance of hand decoding the construction of the earliest Bitcoin transactions from a hex dump.

A Segwit transaction provides some fields which can be an optionally available a part of the transaction construction. In non-Segwit transactions, these Segwit fields are absent (have zero size).

The primary such optionally available discipline is the witness flag simply after the model quantity

The second optionally available discipline is the witness information simply earlier than the ultimate lock-time discipline.

Area Dimension Description Knowledge kind Feedback
4 model uint32_t
0 or 2 flag optionally available uint8_t[2] If current, all the time 0001, and signifies the presence of witness information
1+ tx_in rely var_int
0+ tx_witnesses tx_witness[] A listing of witnesses, one for every enter; omitted if flag is omitted above
4 lock_time uint32_t

So any parser has to have a look at 2 bytes following the model quantity and determine if it’s a segwit flag (0x0001 big-endian!) or a tx_in_count varint and possibly a part of a tx_in construction.

I believe, although I am removed from sure, that this construction was designed in order that older pre-Segwit software program (maybe simply these following the pre-Segwit Bitcoin-core parsing algorithm?) would discover the transaction information legitimate sufficient to just accept blocks containing Segwit transactions.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments