Line data Source code
1 : // Copyright (c) 2017-2025 The Dash 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_EVO_CBTX_H 6 : #define BITCOIN_EVO_CBTX_H 7 : 8 : #include <bls/bls.h> 9 : 10 : #include <primitives/transaction.h> 11 : 12 : #include <univalue.h> 13 : 14 : #include <optional> 15 : #include <string> 16 : 17 : class BlockValidationState; 18 : class CBlock; 19 : class CBlockIndex; 20 : class CDeterministicMNList; 21 : class TxValidationState; 22 : struct RPCResult; 23 : 24 : namespace llmq { 25 : class CQuorumBlockProcessor; 26 : }// namespace llmq 27 : 28 : // coinbase transaction 29 203061 : class CCbTx 30 : { 31 : public: 32 : enum class Version : uint16_t { 33 : INVALID = 0, 34 : MERKLE_ROOT_MNLIST = 1, 35 : MERKLE_ROOT_QUORUMS = 2, 36 : CLSIG_AND_BALANCE = 3, 37 : UNKNOWN, 38 : }; 39 : 40 : static constexpr auto SPECIALTX_TYPE = TRANSACTION_COINBASE; 41 67687 : Version nVersion{Version::MERKLE_ROOT_QUORUMS}; 42 67687 : int32_t nHeight{0}; 43 : uint256 merkleRootMNList; 44 : uint256 merkleRootQuorums; 45 67687 : uint32_t bestCLHeightDiff{0}; 46 : CBLSSignature bestCLSignature; 47 67687 : CAmount creditPoolBalance{0}; 48 : 49 230304 : SERIALIZE_METHODS(CCbTx, obj) 50 : { 51 76768 : READWRITE(obj.nVersion, obj.nHeight, obj.merkleRootMNList); 52 : 53 76768 : if (obj.nVersion >= Version::MERKLE_ROOT_QUORUMS) { 54 76768 : READWRITE(obj.merkleRootQuorums); 55 76768 : if (obj.nVersion >= Version::CLSIG_AND_BALANCE) { 56 69053 : READWRITE(COMPACTSIZE(obj.bestCLHeightDiff)); 57 69053 : READWRITE(obj.bestCLSignature); 58 69053 : READWRITE(obj.creditPoolBalance); 59 69053 : } 60 76768 : } 61 : 62 76768 : } 63 : 64 : [[nodiscard]] static RPCResult GetJsonHelp(const std::string& key, bool optional); 65 : std::string ToString() const; 66 : 67 : [[nodiscard]] UniValue ToJson() const; 68 : }; 69 : template<> struct is_serializable_enum<CCbTx::Version> : std::true_type {}; 70 : 71 : bool CheckCbTx(const CCbTx& cbTx, const CBlockIndex* pindexPrev, TxValidationState& state); 72 : 73 : bool CalcCbTxMerkleRootQuorums(const CBlock& block, const CBlockIndex* pindexPrev, 74 : const llmq::CQuorumBlockProcessor& quorum_block_processor, uint256& merkleRootRet, 75 : BlockValidationState& state); 76 : 77 : std::optional<std::pair<CBLSSignature, uint32_t>> GetNonNullCoinbaseChainlock(const CBlockIndex* pindex); 78 : 79 : #endif // BITCOIN_EVO_CBTX_H