Bitcoin

bitcoin core – How Are The TXIDs Determined from the raw hex data of a block? Also, what is the coinbase transaction?

Transaction ID (TXID) are determined by a double SHA256 hash of the transaction data, but represented in little-endian.

For example, the transaction data of the coinbase transaction is:

01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0704ffff001d0102ffffffff0100f2052a01000000434104d46c4968bde02899d2aa0963367c7a6ce34eec332b32e42e5f3407e052d64ac625da6f0718e7b302140434bd725706957c092db53805b821a85b23a7ac61725bac00000000

Hash it twice with SHA256.

SHA256(SHA256(tx_data)) = 82501c1178fa0b222c1f3d474ec726b832013f0a532b44bb620cce8624a5feb1

Reverse the bytes to little-endian:

b1fea52486ce0c62bb442b530a3f0132b826c74e473d1f2c220bfa78111c5082

Same goes for every transaction that’s included in the block.


Source link

Related Articles

Leave a Reply

Your email address will not be published.

Back to top button