LCOV - code coverage report
Current view: top level - src - invalid.cpp (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 0 23 0.0 %
Date: 2025-02-23 09:33:43 Functions: 0 3 0.0 %

          Line data    Source code
       1             : // Copyright (c) 2018-2021 The PIVX 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             : #include "invalid.h"
       6             : #include "invalid_outpoints.json.h"
       7             : 
       8             : #include "primitives/transaction.h"
       9             : 
      10             : #include <univalue.h>
      11             : 
      12             : namespace invalid_out
      13             : {
      14             :     std::set<COutPoint> setInvalidOutPoints;
      15             : 
      16           0 :     UniValue read_json(const std::string& jsondata)
      17             :     {
      18           0 :         UniValue v;
      19             : 
      20           0 :         if (!v.read(jsondata) || !v.isArray())
      21             :         {
      22           0 :             return UniValue(UniValue::VARR);
      23             :         }
      24           0 :         return v.get_array();
      25             :     }
      26             : 
      27           0 :     bool LoadOutpoints()
      28             :     {
      29           0 :         UniValue v = read_json(LoadInvalidOutPoints());
      30             : 
      31           0 :         if (v.empty())
      32             :             return false;
      33             : 
      34           0 :         for (unsigned int idx = 0; idx < v.size(); idx++) {
      35           0 :             const UniValue &val = v[idx];
      36           0 :             const UniValue &o = val.get_obj();
      37             : 
      38           0 :             const UniValue &vTxid = find_value(o, "txid");
      39           0 :             if (!vTxid.isStr())
      40           0 :                 return false;
      41             : 
      42           0 :             uint256 txid = uint256S(vTxid.get_str());
      43           0 :             if (txid.IsNull())
      44             :                 return false;
      45             : 
      46           0 :             const UniValue &vN = find_value(o, "n");
      47           0 :             if (!vN.isNum())
      48             :                 return false;
      49             : 
      50           0 :             auto n = static_cast<uint32_t>(vN.get_int());
      51           0 :             COutPoint out(txid, n);
      52           0 :             setInvalidOutPoints.insert(out);
      53             :         }
      54             :         return true;
      55             :     }
      56             : 
      57           0 :     bool ContainsOutPoint(const COutPoint& out)
      58             :     {
      59           0 :         return static_cast<bool>(setInvalidOutPoints.count(out));
      60             :     }
      61             : }
      62             : 

Generated by: LCOV version 1.14