I'm parsing the binary data from the bitcoin core blockchain blkxxxxx.dat files. If I read out the magic number I get this:


Why isn't it stored the other way around, as the magic number is d9b4bef9? Is this just the way bytes are stored in memory?

I'm aware this is a complete noob question, but could anybody help me understand this. Thanks.

1 Answer 1


See little-endian and big-endian.

The choice made by Bitcoin authors for data transmitted over the network is somewhat arbitrary. I think the reference implementation (Bitcoin core) chooses to store the data on disk verbatim as received from the network.

The standard for the Internet is called network order and is big-endian. The Intel x86 family of processors are little endian. The early software developers of Bitcoin didn't convert native order to network order when constructing packets. At least, not entirely.

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.