Wednesday, November 27, 2024
HomeBitcoinbitcoind - Unable to parse blocks from blk*.dat for testnet (3 and...

bitcoind – Unable to parse blocks from blk*.dat for testnet (3 and 4)


For the Bitcoin mainnet, I can simply fetch one block by following steps:

  1. Open the LevelDB database at /information/blocks/index

  2. Get by key: 629986b32020caeb48a421956936dd88dc8d7825441bbc96fec10e98b800000000(hex)

    Simply for instance. That is block #12345 with block hash 00000000b8980ec1fe96bc1b4425788ddc88dd36699521a448ebca2020b38699. Remodel it into the inner illustration in bitcoin-core and prepend ASCII ‘b’ to it.

  3. Observe this reply and parse the worth.

I can get:

8eed3c -- client_version (259900)
df39 -- block_height (12345)
1d -- block_status (29)
01 -- tx_number (1)
00 -- blk_file (0)
80afc145 -- blk_start (2892101)
9fd565 -- rev_start (not care about this)

01000000 -- block_version
df9c748f06fcb1e7a4152e76b974e8a5c51c235afb6044388260877600000000 -- prev_blockhash
5731362967a95ffbce2027abf78111e87e804aa8ad6b5b483bb96e827ac91dfd -- merkle_root
5cdff449 -- time
ffff001d -- bits
1f35c72e -- nonce

Open /blocks/blocks/blk00000.dat and go to offset 2892101, there’s 01000000 df9c748f06fcb1..., which is the right block header and is identical as one decoded above.

File dump:

002C2140   D9 D8 00 00  00 01 00 00  00 DF 9C 74  8F 06 FC B1  ...........t....
002C2150   E7 A4 15 2E  76 B9 74 E8  A5 C5 1C 23  5A FB 60 44  ....v.t....#Z.`D
....

But it surely’s simply damaged for testnet3 and testnet4. For instance, use the precisely identical method above, additionally with block #12345, I obtained:

8eed3c -- client_version
df39 -- block_height (12345)
801d -- block_status
01 -- tx_number
00 -- blk_file (0)
9cf0ff70 -- blk_start (62668912)
83f19804 -- rev_start

00600720 -- model
39905ba030a61e45209006737dc9dc4cfbe2f077919b01cbc7a20a0000000000 -- prev_blockhash
8cf89e0e3a833718dc0b05da4ad7b5faeff63507ed5d02b66a0b2ce7bb82f12d -- merkle_root
734c3e66 -- time
f0ff0f1b -- bits
924847df -- nonce

Seek the advice of file blocks/testnet4/blocks/blk00000.dat at place 9cf0ff70, it says

03BC4070   73 73 15 A8  83 AE 8E 19  A5 F9 1D E0  A6 0D FC 9E  ss..............
03BC4080   BE 3C 81 74  E4 F3 57 14  B7 31 3A D0  C4 4C EF E2  .<.t..W..1:..L..
03BC4090   9D 14 53 14  0A A1 8E 19  65 4C 3D 5A  43 8D 38 AE  ..S.....eL=ZC.8.
03BC40A0   50 A5 8A B8  83 B4 E8 17  02 B6 C3 32  E9 AB 20 C8  P..........2.. .
03BC40B0   8F 0C 90 9F  F8 19 FC 50  5C 4D 38 E8  CE 90 E8 E9  .......PM8.....
03BC40C0   9A 43 26 4D  DA 73 83 18  64 4C 3D 85  82 AF 8F 19  .C&M.s..dL=.....
03BC40D0   65 4C 3D 85  82 AE 8E 19  65 4C 3D 85  82 AE 8E 19  eL=.....eL=.....
03BC40E0   65 4C 3D 85  82 AE 8E 19  65 4C 3D 85  82 AE 8E E6  eL=.....eL=.....

Clearly it isn’t a block information.

I attempted looking out the testnet4 genesis block signature 03/Could/2024 0000000... within the testnet4/blocks folder, with no end result both.

❯ rg --binary -uuu '03/Could/2024 0000'

Is there some obfuscation or one thing utilized for the testnet blk* file information? Or I missed one thing? Thanks!

My Bitcoin Core model: v28.99.0-0ca1d1bf69ca

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments