Page MenuHomePhabricator

[Chronik] Add hash structs for type-safe and endian-safe handling of hashes
ClosedPublic

Authored by tobias_ruck on Jun 25 2022, 23:11.

Details

Summary

Allows type-safe handling of hashes, so e.g. Sha256 and Sha256d
can't be mixed.

It is designed to force making endianness explicit as much as possible, as
the different protocols used with Bitcoin ABC use varying endianness:

  • In the Bitcoin protocol:
    • Byte order is little-endian
    • Hex representation is big-endian
  • In the SLP protocol:
    • Byte order is big-endian
    • Hex representation is big-endian
Test Plan

cmake .. -GNinja -DBUILD_BITCOIN_CHRONIK=on && ninja check-bitcoinsuite

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

chronik/bitcoinsuite-core/src/hash.rs
1 ↗(On Diff #34145)

Copyright

108 ↗(On Diff #34145)

Nit: move the comment to its own line

This is now ready to review.

This revision is now accepted and ready to land.Jul 5 2022, 14:48