Coverage Report

Created: 2026-04-20 22:07

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/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 <serialize.h>
9
#include <vector>
10
11
struct KeyOriginInfo
12
{
13
    unsigned char fingerprint[4]; //!< First 32 bits of the Hash160 of the public key at the root of the path
14
    std::vector<uint32_t> path;
15
16
    friend bool operator==(const KeyOriginInfo& a, const KeyOriginInfo& b)
17
25
    {
18
25
        return std::equal(std::begin(a.fingerprint), std::end(a.fingerprint), std::begin(b.fingerprint)) && a.path == b.path;
19
25
    }
20
21
    friend bool operator<(const KeyOriginInfo& a, const KeyOriginInfo& b)
22
310k
    {
23
        // Compare the fingerprints lexicographically
24
310k
        int fpr_cmp = memcmp(a.fingerprint, b.fingerprint, 4);
25
310k
        if (fpr_cmp < 0) {
26
120k
            return true;
27
189k
        } else if (fpr_cmp > 0) {
28
51.1k
            return false;
29
51.1k
        }
30
        // Compare the sizes of the paths, shorter is "less than"
31
138k
        if (a.path.size() < b.path.size()) {
32
8.72k
            return true;
33
129k
        } else if (a.path.size() > b.path.size()) {
34
3.60k
            return false;
35
3.60k
        }
36
        // Paths same length, compare them lexicographically
37
125k
        return a.path < b.path;
38
138k
    }
39
40
13.7k
    SERIALIZE_METHODS(KeyOriginInfo, obj) { READWRITE(obj.fingerprint, obj.path); }
_ZN13KeyOriginInfo16SerializationOpsI10SpanReaderS_17ActionUnserializeEEvRT0_RT_T1_
Line
Count
Source
40
13.6k
    SERIALIZE_METHODS(KeyOriginInfo, obj) { READWRITE(obj.fingerprint, obj.path); }
_ZN13KeyOriginInfo16SerializationOpsI10DataStreamKS_15ActionSerializeEEvRT0_RT_T1_
Line
Count
Source
40
50
    SERIALIZE_METHODS(KeyOriginInfo, obj) { READWRITE(obj.fingerprint, obj.path); }
_ZN13KeyOriginInfo16SerializationOpsI10DataStreamS_17ActionUnserializeEEvRT0_RT_T1_
Line
Count
Source
40
25
    SERIALIZE_METHODS(KeyOriginInfo, obj) { READWRITE(obj.fingerprint, obj.path); }
41
42
    void clear()
43
11.3k
    {
44
11.3k
        memset(fingerprint, 0, 4);
45
11.3k
        path.clear();
46
11.3k
    }
47
};
48
49
#endif // BITCOIN_SCRIPT_KEYORIGIN_H