bitcoin/bitcoin — pull request #5490 by laanwj (2014-12-16 17:43:22+00:00)
Title: Replace uint256/uint160 with opaque blobs where possible (cont'd)

Second attempt at #5478. See discussion there.

This pull replaces almost all uses of `uint256` and all uses of `uint160` to use opaque byte blobs `blob256` and `blob160` with **only** the following operations:

- Default initialization to 0, or from a vector of bytes
- Assignment from other blobXXXs
- `IsNull()` compare to special all-zeros value
- `SetNull()` clear to special all-zeros value: Bitcoin needs `IsNull()` / `SetNull()` because we often use the all-zeroes value as a marker for errors and empty values.
- `<` for sorting in maps.
- `!=` `==` test for (in)equality
- `GetHex`/`SetHex`/`ToString` because they're just so useful
- `begin()`/`end()` raw access to the data
- `size()` returns a fixed size
- `GetSerializeSize()` `Serialize` `Unserialize` serialization just reads and writes the bytes
- `GetCheapHash()` this is similar to `GetLow64()` and returns part of the value as uint64_t, for cheap hashing when the contents are assumed distributed uniformy random.

`uint256` (used for proof-of-work mainly), on the other hand, loses all functionality like raw bytes access and serialization. Its memory should not be accessed directly. This is necessary for #888 (big endian support).
`uint160` is completely removed as Bitcoin Core does no 160-bit integer arithmetic.

For overall steps (see commits)