Extracted from pseudoramdom's work in #35436:
Instead of using c style arrays for key fingerprints, use std::array's whose length can always reasoned about at compile time and for most operations the compiler enforces the size being correct.
using KeyFingerprint = std::array<unsigned char, 4>;
- unsigned char vchFingerprint[4];
+ KeyFingerprint fingerprint;
This allows the replacement of a lot of raw memcpy + trust-me-bro lengths, with the assignment operator:
- memcpy(ret.vchFingerprint, vchFingerprint, 4);
+ ret.fingerprint = fingerprint;
This commit also adds two helper functions for
- Retrieving the fingerprint of a key identifier (
CKeyID) - Retrieving the fingerprint of the key identifier of an XPUB.