LCOV - code coverage report
Current view: top level - src/masternode - payments.h (source / functions) Hit Total Coverage
Test: test_dash_coverage.info Lines: 7 7 100.0 %
Date: 2026-06-25 07:23:51 Functions: 2 2 100.0 %

          Line data    Source code
       1             : // Copyright (c) 2014-2024 The Dash Core developers
       2             : // Distributed under the MIT/X11 software license, see the accompanying
       3             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       4             : 
       5             : #ifndef BITCOIN_MASTERNODE_PAYMENTS_H
       6             : #define BITCOIN_MASTERNODE_PAYMENTS_H
       7             : 
       8             : #include <consensus/amount.h>
       9             : 
      10             : #include <string>
      11             : #include <vector>
      12             : 
      13             : class CBlock;
      14             : class CBlockIndex;
      15             : class CDeterministicMNManager;
      16             : class ChainstateManager;
      17             : class CTransaction;
      18             : class CTxOut;
      19             : 
      20             : struct CMutableTransaction;
      21             : 
      22             : namespace governance {
      23             : class SuperblockManager;
      24             : }
      25             : namespace Consensus { struct Params; }
      26             : 
      27             : /**
      28             :  * This helper returns amount that should be reallocated to platform
      29             :  * It is calculated based on total amount of masternode rewards (not block reward)
      30             :  */
      31             : CAmount PlatformShare(const CAmount masternodeReward);
      32             : 
      33             : class CMNPaymentsProcessor
      34             : {
      35             : private:
      36             :     CDeterministicMNManager& m_dmnman;
      37             :     governance::SuperblockManager& m_superblocks;
      38             :     const ChainstateManager& m_chainman;
      39             :     const Consensus::Params& m_consensus_params;
      40             : 
      41             : private:
      42             :     [[nodiscard]] bool GetBlockTxOuts(const CBlockIndex* pindexPrev, const CAmount blockSubsidy, const CAmount feeReward,
      43             :                                       std::vector<CTxOut>& voutMasternodePaymentsRet);
      44             :     [[nodiscard]] bool GetMasternodeTxOuts(const CBlockIndex* pindexPrev, const CAmount blockSubsidy, const CAmount feeReward,
      45             :                                       std::vector<CTxOut>& voutMasternodePaymentsRet);
      46             :     [[nodiscard]] bool IsTransactionValid(const CTransaction& txNew, const CBlockIndex* pindexPrev, const CAmount blockSubsidy,
      47             :                                           const CAmount feeReward);
      48             :     [[nodiscard]] bool IsOldBudgetBlockValueValid(const CBlock& block, const int nBlockHeight, const CAmount blockReward, std::string& strErrorRet);
      49             : 
      50             : public:
      51         360 :     explicit CMNPaymentsProcessor(CDeterministicMNManager& dmnman, governance::SuperblockManager& superblocks,
      52             :                                   const ChainstateManager& chainman, const Consensus::Params& consensus_params) :
      53         180 :         m_dmnman{dmnman},
      54         180 :         m_superblocks{superblocks},
      55         180 :         m_chainman{chainman},
      56         180 :         m_consensus_params{consensus_params}
      57         180 :     {
      58         360 :     }
      59             : 
      60             :     bool IsBlockValueValid(const CBlock& block, const CBlockIndex* pindexPrev, const CAmount blockReward, std::string& strErrorRet, const bool check_superblock);
      61             :     bool IsBlockPayeeValid(const CTransaction& txNew, const CBlockIndex* pindexPrev, const CAmount blockSubsidy, const CAmount feeReward, const bool check_superblock);
      62             :     void FillBlockPayments(CMutableTransaction& txNew, const CBlockIndex* pindexPrev, const CAmount blockSubsidy, const CAmount feeReward,
      63             :                            std::vector<CTxOut>& voutMasternodePaymentsRet, std::vector<CTxOut>& voutSuperblockPaymentsRet);
      64             : };
      65             : 
      66             : #endif // BITCOIN_MASTERNODE_PAYMENTS_H

Generated by: LCOV version 1.16