Does it store the raw transaction data literally like (excuse the formatting inaccuracies):
0x24134i59435ej3...9 sends 0x9wri03vw3sdfsd...i 26.00000023423 Bitcoin.
Or is it stored differently?
Bitcoin Stack Exchange is a question and answer site for Bitcoin crypto-currency enthusiasts. It only takes a minute to sign up.Sign up to join this community
Here's an example
Block 170 contains the first transaction other than coinbase transactions. In it Satoshi Nakamoto paid Hal Finney 10 BTC. This was the first time one person paid another person in Bitcoin.
Since the data is in binary, we must use a printable representation of it to make it viewable in this web-page. I choose hexadecimal:
0100000001c997a5e56e104102fa209c6a852dd90660a20b2d9c352423edce25 857fcd3704000000004847304402204e45e16932b8af514961a1d3a1a25fdf3f 4f7732e9d624c6c61548ab5fb8cd410220181522ec8eca07de4860a4acdd1290 9d831cc56cbbac4622082221a8768d1d0901ffffffff0200ca9a3b0000000043 4104ae1a62fe09c5f51b13905f07f06b99a2f7159b2225f374cd378d71302fa2 8414e7aab37397f554a7df5f142c21c1b7303b8a0626f1baded5c72a704f7e6c d84cac00286bee0000000043410411db93e1dcdb8a016b49840f8c53bc1eb68a 382e97b1482ecad7b148a6909a5cb2e0eaddfb84ccf9744464f82e160bfa9b8b 64f9d4c03f999b8643f656b412a3ac00000000
Some weeks ago I thought it would be neat to work out by hand what that meant. here's how far I got before losing interest:
||Version 1 (little endian uint32)|
||Number of transaction inputs (varint)|
||Hash of referenced transaction (32 octets)|
||index of output in referenced transaction (uint32)|
||length of signature script (varint). 48 hex is 72 decimal.|
||signature script (72 octets)|
||Number of outputs|
||amount 1000000000 satoshi i.e. 10 BTC (int64)|
||length of script|
||amount 40 BTC. This is change.|
||length of script|
||lock time = unlocked (4 octets)|
I should probably decode the locking scripts on the outputs.
41 is OP_PUSHDATA for 4116 bytes. Then we have the 4116 bytes of data to be pushed onto the stack and finally
ac is OP_CHECKSIG which expects a signature and public key on the stack which it takes off the stack and checks. This script only really gets executed when the money is spent.
You can check the little endian numbers by reversing them byte-wise (two hex digits at a time) into a big endian representation and feeding that into Windows Calculator in programmer mode - here's that second output amount (
That's how we know
00286bee00000000 means 40000000000 Satoshi. Which is 40 BTC.
This early transaction is an early type known as Pay to Public Key (P2PK). It is the simplest type. Popular types used nowadays are more complicated.
You can, of course, rather easily get a JSON representation of this transaction using most blockchain explorers. I find that a bit unsatisfactory as they often introduce some artificial elements (e.g. both 'hex' and 'asm' representations of the script) so you're never certain how exactly the JSON items correspond to parts of the underlying data. Hence the above decoding attempt.