Skip to content

refactor: Add consteval uint256 constructor

Motivation:

  • Validates and converts the hex string at compile time instead of at runtime into the resulting bytes.
  • Makes it possible to derive other compile time constants from uint256.
  • Potentially eliminates runtime dependencies (SetHexDeprecated() is called in less places).
  • Has stricter requirements than the deprecated uint256S() (requiring 64 chars exactly, disallows garbage at the end) and replaces it in a bunch of places.
  • Makes the binary smaller (tested Guix-built x86_64-linux-gnu bitcoind binary).
  • Minor: should shave off a few cycles of start-up time.

Extracted from #30377 which diverged into exploring consteval ParseHex() solutions.

Merge request reports

Loading