LCOV - code coverage report
Current view: top level - src/script - keyorigin.h (source / functions) Coverage Total Hit
Test: fuzz_coverage.info Lines: 100.0 % 15 15
Test Date: 2026-08-03 07:28:34 Functions: 100.0 % 5 5
Branches: 49.1 % 110 54

             Branch data     Line data    Source code
       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 [ +  - ][ +  -  :    28607514 : struct KeyOriginInfo
             +  -  +  - ]
           [ -  -  -  -  
             -  -  -  - ]
           [ -  -  +  +  
          +  +  +  +  +  
                      - ]
           [ #  #  #  #  
          #  #  #  #  #  
             #  #  #  #  
                      # ]
           [ +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
                   +  - ]
           [ +  -  +  -  
          +  -  +  -  -  
          +  +  -  +  -  
             +  -  +  - ]
           [ +  -  +  -  
          +  -  +  -  +  
          +  +  +  +  +  
             +  -  +  + ]
      13                 :             : {
      14                 :        4173 :     KeyFingerprint fingerprint; //!< First 32 bits of the Hash160 of the public key at the root of the path
      15                 :        4173 :     std::vector<uint32_t> path;
      16                 :             : 
      17   [ +  -  -  + ]:        4173 :     friend bool operator==(const KeyOriginInfo& a, const KeyOriginInfo& b) = default;
      18                 :             : 
      19                 :      185521 :     friend bool operator<(const KeyOriginInfo& a, const KeyOriginInfo& b)
      20                 :             :     {
      21                 :             :         // Compare the fingerprints lexicographically
      22         [ +  + ]:      185521 :         if (a.fingerprint < b.fingerprint) return true;
      23         [ +  + ]:      120149 :         else if (a.fingerprint > b.fingerprint) return false;
      24                 :             : 
      25                 :             :         // Compare the sizes of the paths, shorter is "less than"
      26   [ -  +  -  +  :       90389 :         if (a.path.size() < b.path.size()) {
                   +  + ]
      27                 :             :             return true;
      28         [ +  + ]:       83210 :         } else if (a.path.size() > b.path.size()) {
      29                 :             :             return false;
      30                 :             :         }
      31                 :             :         // Paths same length, compare them lexicographically
      32                 :       80259 :         return a.path < b.path;
      33                 :             :     }
      34                 :             : 
      35                 :       30334 :     SERIALIZE_METHODS(KeyOriginInfo, obj) { READWRITE(obj.fingerprint, obj.path); }
      36                 :             : 
      37                 :       63944 :     void clear()
      38                 :             :     {
      39                 :       63944 :         fingerprint.fill(0);
      40         [ -  + ]:       63944 :         path.clear();
      41                 :       63944 :     }
      42                 :             : };
      43                 :             : 
      44                 :             : #endif // BITCOIN_SCRIPT_KEYORIGIN_H
        

Generated by: LCOV version