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 6126 : explicit CMNPaymentsProcessor(CDeterministicMNManager& dmnman, governance::SuperblockManager& superblocks, 52 : const ChainstateManager& chainman, const Consensus::Params& consensus_params) : 53 3063 : m_dmnman{dmnman}, 54 3063 : m_superblocks{superblocks}, 55 3063 : m_chainman{chainman}, 56 3063 : m_consensus_params{consensus_params} 57 3063 : { 58 6126 : } 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