Saturday, May 21, 2022
HomeBitcoinIn what format does a block retailer the transaction information?

In what format does a block retailer the transaction information?


Bitcoin core shops the info within the community format for blocks and for the transactions in these blocks.


Here is an instance

Block 170 accommodates the primary transaction aside from coinbase transactions. In it Satoshi Nakamoto paid Hal Finney 10 BTC. This was the primary time one particular person paid one other particular person in Bitcoin.

For the reason that information is in binary, we should use a printable illustration of it to make it viewable on this web-page. I select hexadecimal:

0100000001c997a5e56e104102fa209c6a852dd90660a20b2d9c352423edce25
857fcd3704000000004847304402204e45e16932b8af514961a1d3a1a25fdf3f
4f7732e9d624c6c61548ab5fb8cd410220181522ec8eca07de4860a4acdd1290
9d831cc56cbbac4622082221a8768d1d0901ffffffff0200ca9a3b0000000043
4104ae1a62fe09c5f51b13905f07f06b99a2f7159b2225f374cd378d71302fa2
8414e7aab37397f554a7df5f142c21c1b7303b8a0626f1baded5c72a704f7e6c
d84cac00286bee0000000043410411db93e1dcdb8a016b49840f8c53bc1eb68a
382e97b1482ecad7b148a6909a5cb2e0eaddfb84ccf9744464f82e160bfa9b8b
64f9d4c03f999b8643f656b412a3ac00000000

Some weeks in the past I believed it might be neat to work out by hand what that meant. here is how far I bought earlier than shedding curiosity:

Hex Knowledge Which means
01000000 Model 1 (little endian uint32)
01 Variety of transaction inputs (varint)
First enter
c997a5e56e104102 fa209c6a852dd906 60a20b2d9c352423 edce25857fcd3704 Hash of referenced transaction (32 octets)
00000000 index of output in referenced transaction (uint32)
48 size of signature script (varint). 48 hex is 72 decimal.
47304402204e45e1 6932b8af514961a1 d3a1a25fdf3f4f77 32e9d624c6c61548 ab5fb8cd41022018 1522ec8eca07de48 60a4acdd12909d83 1cc56cbbac462208 2221a8768d1d0901 signature script (72 octets)
ffffffff sequence
02 Variety of outputs
First output
00ca9a3b00000000 quantity 1000000000 satoshi i.e. 10 BTC (int64)
43 size of script
4104ae1a62fe09c5 f51b13905f07f06b 99a2f7159b2225f3 74cd378d71302fa2 8414e7aab37397f5 54a7df5f142c21c1 b7303b8a0626f1ba ded5c72a704f7e6c d84cac script
Second output
00286bee00000000 quantity 40 BTC. That is change.
43 size of script
410411db93e1dcdb 8a016b49840f8c53 bc1eb68a382e97b1 482ecad7b148a690 9a5cb2e0eaddfb84 ccf9744464f82e16 0bfa9b8b64f9d4c0 3f999b8643f656b4 12a3ac script
00000000 lock time = unlocked (4 octets)

I ought to in all probability decode the locking scripts on the outputs. 41 is OP_PUSHDATA for 4116 bytes. Then we now have the 4116 bytes of information to be pushed onto the stack and eventually ac is OP_CHECKSIG which expects a signature and public key on the stack which it takes off the stack and checks. This script solely actually will get executed when the cash is spent.

You may verify the little endian numbers by reversing them byte-wise (two hex digits at a time) into an enormous endian illustration and feeding that into Home windows Calculator in programmer mode – here is that second output quantity (00286bee00000000LE -> 00000000ee6b2800BE):

Calculator

That is how we all know 00286bee00000000 means 40000000000 Satoshi. Which is 40 BTC.

This early transaction is an early sort often called Pay to Public Key (P2PK). It’s the easiest sort. Widespread sorts used these days are extra sophisticated.

You may, in fact, quite simply get a JSON illustration of this transaction utilizing most blockchain explorers. I discover {that a} bit unsatisfactory as they typically introduce some synthetic parts (e.g. each ‘hex’ and ‘asm’ representations of the script) so that you’re by no means sure how precisely the JSON objects correspond to components of the underlying information. Therefore the above decoding try.


Associated questions

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments

x