Hello everyone,
Started doing some research on bitcoin blocks, when i run a node the blocks are stored on => ...\BTC\blocks (windows)
I opened with hex viewer and I could indeed see the infamous"chancelor..." in the genesis block.
How can the transaction history be decoded from this block.
You need all blocks to get full transaction history.
If you mean decoding the block and such, honestly the best tool is just using Bitcoin Core which you seem to have installed.
But if you want to decode individual blk files, I found
this small program that might do the trick!
python-bitcoin-blockchain-parser]This repository actually looks a bit better to me, since it has more features and it's Python 3-based so you won't need to compile it!
For doing it manually, I like to follow along code such as the one from the link above. As you can see, there is this hex code that you should be able to find in your .dat file, which separates blocks. If you count the bytes between these separators, it should be always around 1MB.
BITCOIN_CONSTANT = b"\xf9\xbe\xb4\xd9"
In
line 46, in
get_blocks(), you can see how one blk....dat file is split up and the raw bytes of each block are returned.
For decoding that block manually, you can have a look into the codebase of the above project or refer to the
Block structure according to Bitcoin Wiki.
Here's the block header and the corresponding Bitcoin Core code
is found here.
// header
int32_t nVersion;
uint256 hashPrevBlock;
uint256 hashMerkleRoot;
uint32_t nTime;
uint32_t nBits;
uint32_t nNonce;
Secondly the blocks are not 1MB they are like 127MB.
How do block explorer or a normal person decode this information from these blocks?
Thanks in advance.
That's because one such file contains more than one block.