mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-12 05:32:22 +02:00
c9a70f9338script: qa: Improve Key::Fingerprint type safety (David Gumberg) Pull request description: 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. ```cpp using KeyFingerprint = std::array<unsigned char, 4>; ``` ```diff - unsigned char vchFingerprint[4]; + KeyFingerprint fingerprint; ``` This allows the replacement of a lot of raw `memcpy` + trust-me-bro lengths, with the assignment operator: ```cpp - memcpy(ret.vchFingerprint, vchFingerprint, 4); + ret.fingerprint = fingerprint; ``` This commit also adds two helper functions for - Retrieving the [fingerprint of a key identifier](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#user-content-Key_identifiers) (`CKeyID`) - Retrieving the fingerprint of the key identifier of an XPUB. ACKs for top commit: w0xlt: ACKc9a70f9338sedited: ACKc9a70f9338pseudoramdom: Code review ACK w/ some minor nitsc9a70f9338polespinasa: ACKc9a70f9338Tree-SHA512: 3ee76742c0bc317dfbc12a6731afdcc40495db6e4d5d94880d0a721990d36cb3e4d374ccc96079ba1f8ad3f88581ee5a609bfe259c0ea7cd28cade373aac1b38