1

I called bitcoind getwork slightly earlier in the day and this is what I got:

{
    "midstate" : "6d8b2d759123e7311c552f0c99f6d520378062ac7a14fb11f6d433779d282faf",
    "data" : "00000002c2bf65e9637a1c11955c2ba1c45c9bffad322d4fa0d9529e0000014300000000e9587c30863f5f410ea9d0611d3da6b7d0afd390b4b8e33cd71297c9d20dc74651ad7ea71a01616400000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000",
    "hash1" : "00000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000010000",
    "target" : "0000000000000000000000000000000000000000000000646101000000000000"
}

So for the time being lets throw away the midstate which I will not be using since I am only trying to understand. So now doing the 32 bit byteswap on the data I get this:

Data
02000000 e965bfc2111c7a63a12b5c95ff9b5cc4 4f2d32ad9e52d9a04301000000000000 307c58e9415f3f8661d0a90eb7a63d1d90d3afd03ce3b8b4c99712d746c70dd2 a77ead51 6461011a 00000000

Now I am unable to figure out how to actually read this information. According to the wiki, the first 4 bytes are version. Here the first 4 bytes are version.

Version:
02000000

Isnt it supposed to be 2. The above is a really large number in big endian.

Now the previuos hash block:

Hash:
e965bfc2111c7a63a12b5c95ff9b5cc44f2d32ad9e52d9a04301000000000000

I am unable to find this hash anywhere on blockexplorer or block chain info? I tried to change the endianess once again but to no avail.

Finally I left the merkle root out and tried to confirm with the utc time:

Time:
a77ead51

Which corresponds to the year 2081. What exactly am I doing wrong here?

  • getwork has been pretty much deprecated, you should use getblocktemplate instead. – jgm Jun 4 '13 at 8:19
1

Isnt it supposed to be 2. The above is a really large number in big endian.

It's a small number in big endian. Think about it; big digits at the end.

Now the previuos hash block

I don't know why Bitcoin does this, but block hashes are stored in normal order internally, then byte-reversed before displaying them.

>>> s="e965bfc2111c7a63a12b5c95ff9b5cc44f2d32ad9e52d9a04301000000000000"
>>> import binascii
>>> s=binascii.unhexlify(s)
>>> s=s[::-1]
>>> s=binascii.hexlify(s)
>>> s

'0000000000000143a0d9529ead322d4fc45c9bff955c2ba1637a1c11c2bf65e9'

Time:
a77ead51

Use big endian. I got 1370324647 using this tool, then converted to 04 Jun 2013 with this tool.

  • I didnt know I have to do that extra step to get the data. Anyway I think I understand now. Thanks a lot. Just out of curiosity, how did you know this? – Enthusiast Jun 5 '13 at 1:43
  • @Enthusiast Reading wiki articles, bitcoin source code, pyminer source code. Also, I started writing a mining client, but I lost interest. – Nick ODell Jun 5 '13 at 16:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.