When I called:

print bitcoin.getmemorypool()
print bitcoin.getwork()

using Python JSON for a testnet BitcoinQT server, I got the following responces:

{'previousblockhash': '00000000032e361b246e96c4e594523b6ff42bc0527e560f203fb20a08a86185', 'transactions': ..., 'version': 1, 'coinbasevalue': 5000400000, 'time': 1329342730, 'bits': '1c2336a4'}
{... 'data': '0000000108a86185203fb20a527e560f6ff42bc0e594523b246e96c4032e361b000000004c50804820b143e1583c8c49dd43a6ddb8bc777c57c2da4a92b39ee0e709bf504f3c290b1c2336a400000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000', ...}

Comparing the previous block hash from GetMemoryPool and one extracted from the block header from Getwork:

00000000 032e361b 246e96c4 e594523b 6ff42bc0 527e560f 203fb20a 08a86185
08a86185 203fb20a 527e560f 6ff42bc0 e594523b 246e96c4 032e361b 00000000

From what I can see, the data is reversed in chunks of 4 bytes. Why is such a procedure done, and what other fields from those two RPC calls undergo such an operation?

  • Like, seriously, it's bad enough that Bitcoin uses two different endiannesses on bytes, now we also have a little endianness of a big endianness words (I guess that's what one would call a set of 4 bytes?)?
    – ThePiachu
    Feb 15, 2012 at 22:09

1 Answer 1


The value of previousblockhash in getmemorypool output is the block hash in big-endian order.

The value of data in getwork output is formatted as I described in this answer to your question about how hash1 is calculated.

This byte order reversal on 4 byte words is done by a function called FormatHashBuffers in main.cpp. It's only done for the data and hash1 fields of the getwork output. There's no comment explaining why it's done.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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