LCOV - code coverage report
Current view: top level - src/script - keyorigin.h (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 17 17 100.0 %
Date: 2025-02-23 09:33:43 Functions: 1 1 100.0 %

          Line data    Source code
       1             : // Copyright (c) 2019 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 PIVX_SCRIPT_KEYORIGIN_H
       6             : #define PIVX_SCRIPT_KEYORIGIN_H
       7             : 
       8             : #include <serialize.h>
       9             : #include <vector>
      10             : 
      11      143713 : 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             :     {
      18             :         return std::equal(std::begin(a.fingerprint), std::end(a.fingerprint), std::begin(b.fingerprint)) && a.path == b.path;
      19             :     }
      20             : 
      21       24147 :     SERIALIZE_METHODS(KeyOriginInfo, obj) { READWRITE(obj.fingerprint, obj.path); }
      22             : 
      23       48261 :     void clear()
      24             :     {
      25       48261 :         memset(fingerprint, 0, 4);
      26       48261 :         path.clear();
      27             :     }
      28             : 
      29        2262 :     std::string pathToString() const
      30             :     {
      31        2262 :         std::string keypath_str = "m";
      32       13411 :         for (uint32_t num : path) {
      33       11149 :             keypath_str += "/";
      34       11149 :             bool hardened = false;
      35       11149 :             if (num & 0x80000000) {
      36       11149 :                 hardened = true;
      37       11149 :                 num &= ~0x80000000;
      38             :             }
      39             : 
      40       11149 :             keypath_str += std::to_string(num);
      41       11149 :             if (hardened) {
      42       11149 :                 keypath_str += "'";
      43             :             }
      44             :         }
      45        2262 :         return keypath_str;
      46             :     }
      47             : };
      48             : 
      49             : #endif // PIVX_SCRIPT_KEYORIGIN_H

Generated by: LCOV version 1.14