From sipa on IRC (2023-01-06):
jamesob: Probably dumb question, but why does uint256::ToString()
(-> HexStr()
) print out the blob in reversed byte order?
sipa: Because that's what it has always done, really.
sipa: And people expect txids and block hashes in hex notation to be reserved.
sipa: Historically, that was because txids/block hashes were 256-bit numbers constructed by interpreting the double-sha256 output as a little-endian integer, and then printing it out for human consumption in hex (where humans expect numbers in big endian).
sipa: But now uint256 is just a byte array wrapper, the behavior is maintained because block hashes and txids are always printed in reverse.
sipa: (block hashes are still interpreted a little-endian numbers for the purpose of comparing PoW to the target, but that's handled by the arith_uint256 class now)