/root/bitcoin/src/script/keyorigin.h
Line | Count | Source |
1 | | // Copyright (c) 2019-present The Bitcoin Core developers |
2 | | // Distributed under the MIT software license, see the accompanying |
3 | | // file COPYING or http://www.opensource.org/licenses/mit-license.php. |
4 | | |
5 | | #ifndef BITCOIN_SCRIPT_KEYORIGIN_H |
6 | | #define BITCOIN_SCRIPT_KEYORIGIN_H |
7 | | |
8 | | #include <pubkey.h> |
9 | | #include <serialize.h> |
10 | | #include <vector> |
11 | | |
12 | | struct KeyOriginInfo |
13 | | { |
14 | | KeyFingerprint fingerprint; //!< First 32 bits of the Hash160 of the public key at the root of the path |
15 | | std::vector<uint32_t> path; |
16 | | |
17 | 61.2k | friend bool operator==(const KeyOriginInfo& a, const KeyOriginInfo& b) = default; Branch (17:84): [True: 20.4k, False: 0]
Branch (17:84): [True: 20.4k, False: 0]
|
18 | | |
19 | | friend bool operator<(const KeyOriginInfo& a, const KeyOriginInfo& b) |
20 | 198k | { |
21 | | // Compare the fingerprints lexicographically |
22 | 198k | if (a.fingerprint < b.fingerprint) return true; Branch (22:13): [True: 83.6k, False: 114k]
|
23 | 114k | else if (a.fingerprint > b.fingerprint) return false; Branch (23:18): [True: 35.0k, False: 79.4k]
|
24 | | |
25 | | // Compare the sizes of the paths, shorter is "less than" |
26 | 79.4k | if (a.path.size() < b.path.size()) { Branch (26:13): [True: 12.1k, False: 67.3k]
|
27 | 12.1k | return true; |
28 | 67.3k | } else if (a.path.size() > b.path.size()) { Branch (28:20): [True: 6.02k, False: 61.2k]
|
29 | 6.02k | return false; |
30 | 6.02k | } |
31 | | // Paths same length, compare them lexicographically |
32 | 61.2k | return a.path < b.path; |
33 | 79.4k | } |
34 | | |
35 | 21.4k | SERIALIZE_METHODS(KeyOriginInfo, obj) { READWRITE(obj.fingerprint, obj.path); }_ZN13KeyOriginInfo16SerializationOpsI10SpanReaderS_17ActionUnserializeEEvRT0_RT_T1_ Line | Count | Source | 35 | 21.3k | SERIALIZE_METHODS(KeyOriginInfo, obj) { READWRITE(obj.fingerprint, obj.path); } |
_ZN13KeyOriginInfo16SerializationOpsI10DataStreamKS_15ActionSerializeEEvRT0_RT_T1_ Line | Count | Source | 35 | 84 | SERIALIZE_METHODS(KeyOriginInfo, obj) { READWRITE(obj.fingerprint, obj.path); } |
_ZN13KeyOriginInfo16SerializationOpsI10DataStreamS_17ActionUnserializeEEvRT0_RT_T1_ Line | Count | Source | 35 | 42 | SERIALIZE_METHODS(KeyOriginInfo, obj) { READWRITE(obj.fingerprint, obj.path); } |
|
36 | | |
37 | | void clear() |
38 | 185k | { |
39 | 185k | fingerprint.fill(0); |
40 | 185k | path.clear(); |
41 | 185k | } |
42 | | }; |
43 | | |
44 | | #endif // BITCOIN_SCRIPT_KEYORIGIN_H |