bitcoind – Why does Bitcoin Core print SHA256 hashes (uint256) bytes in reverse order?

on

|

views

and

comments


From sipa on IRC (2023-01-06):

jamesob: In all probability dumb query, however why does uint256::ToString() (-> HexStr()) print out the blob in reversed byte order?

sipa: As a result of that is what it has at all times finished, actually.

sipa: And folks anticipate txids and block hashes in hex notation to be reserved.

sipa: Traditionally, that was as a result of txids/block hashes have been 256-bit numbers constructed by deciphering the double-sha256 output as a little-endian integer, after which printing it out for human consumption in hex (the place people anticipate numbers in large endian).

sipa: However now uint256 is only a byte array wrapper, the habits is maintained as a result of block hashes and txids are at all times printed in reverse.

sipa: (block hashes are nonetheless interpreted a little-endian numbers for the aim of evaluating PoW to the goal, however that is dealt with by the arith_uint256 class now)

Share this
Tags

Must-read

Waymo raises $16bn to gas international robotaxi enlargement | Know-how

Self-driving automobile firm Waymo on Monday stated it raised $16bn in a funding spherical that valued the Alphabet subsidiary at $126bn.Waymo co-chief executives...

Self-driving taxis are coming to London – ought to we be anxious? | Jack Stilgoe

At the top of the nineteenth century, the world’s main cities had an issue. The streets had been flooded with manure, the unintended...

US regulators open inquiry into Waymo self-driving automobile that struck youngster in California | Expertise

The US’s federal transportation regulator stated Thursday it had opened an investigation after a Waymo self-driving car struck a toddler close to an...

Recent articles

More like this

LEAVE A REPLY

Please enter your comment!
Please enter your name here