ricmoo / pycoind

Pure-Python full node and libraries for bitcoind-based crypto-currencies (eg. bitcoin, litecoin, etc)
MIT License
120 stars 44 forks source link

Byte order in block database #12

Closed venzen closed 9 years ago

venzen commented 9 years ago

I'm connecting to a custom scrypt-based network and blocks received from the vanilla C++ client are not being validated. I discovered that the reason is that byte order is reversed between what pycoind receives in the block header and what is stored in its blocks database.

So, the question is, I guess, what is the expected endianess? The genesis block hash saved into the block db at init by pycoind is apparently stored as little-endian. But the C++ nodes are supplying headers with big-endian hashes, so when pycoind goes to look for the hash (or prev_hash) it doesn't find it and add_header() in blocks.py rejects the block based on raise InvalidBlockException('previous block does not exist')

Solved: OK, I just read the notes in the coin template file and saw the requirement that the endianness of the genesis block hash be reversed.

ricmoo commented 9 years ago

Ha ha! Awesome! I love to see problems fixed before I even see them. :)