2019-06-11 13:46:07 +02:00
|
|
|
// Copyright (c) 2017-2019 The Dash Core developers
|
2018-04-06 11:00:10 +02:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
#ifndef DASH_CBTX_H
|
|
|
|
#define DASH_CBTX_H
|
|
|
|
|
2020-03-19 23:46:56 +01:00
|
|
|
#include <consensus/validation.h>
|
|
|
|
#include <primitives/transaction.h>
|
|
|
|
#include <univalue.h>
|
2018-04-06 11:00:10 +02:00
|
|
|
|
2018-04-09 10:35:43 +02:00
|
|
|
class CBlock;
|
2018-04-06 11:00:10 +02:00
|
|
|
class CBlockIndex;
|
|
|
|
|
|
|
|
// coinbase transaction
|
|
|
|
class CCbTx
|
|
|
|
{
|
|
|
|
public:
|
2019-04-04 10:25:50 +02:00
|
|
|
static const uint16_t CURRENT_VERSION = 2;
|
2018-04-06 11:00:10 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
uint16_t nVersion{CURRENT_VERSION};
|
|
|
|
int32_t nHeight{0};
|
|
|
|
uint256 merkleRootMNList;
|
2019-04-04 10:25:50 +02:00
|
|
|
uint256 merkleRootQuorums;
|
2018-04-06 11:00:10 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
ADD_SERIALIZE_METHODS;
|
|
|
|
|
|
|
|
template <typename Stream, typename Operation>
|
|
|
|
inline void SerializationOp(Stream& s, Operation ser_action)
|
|
|
|
{
|
|
|
|
READWRITE(nVersion);
|
|
|
|
READWRITE(nHeight);
|
|
|
|
READWRITE(merkleRootMNList);
|
2019-04-04 10:25:50 +02:00
|
|
|
|
|
|
|
if (nVersion >= 2) {
|
|
|
|
READWRITE(merkleRootQuorums);
|
|
|
|
}
|
2018-04-06 11:00:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string ToString() const;
|
2019-06-11 13:42:17 +02:00
|
|
|
|
|
|
|
void ToJson(UniValue& obj) const
|
|
|
|
{
|
|
|
|
obj.clear();
|
|
|
|
obj.setObject();
|
|
|
|
obj.push_back(Pair("version", (int)nVersion));
|
|
|
|
obj.push_back(Pair("height", (int)nHeight));
|
|
|
|
obj.push_back(Pair("merkleRootMNList", merkleRootMNList.ToString()));
|
|
|
|
if (nVersion >= 2) {
|
|
|
|
obj.push_back(Pair("merkleRootQuorums", merkleRootQuorums.ToString()));
|
|
|
|
}
|
|
|
|
}
|
2018-04-06 11:00:10 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
bool CheckCbTx(const CTransaction& tx, const CBlockIndex* pindexPrev, CValidationState& state);
|
|
|
|
|
2019-04-04 10:25:50 +02:00
|
|
|
bool CheckCbTxMerkleRoots(const CBlock& block, const CBlockIndex* pindex, CValidationState& state);
|
2018-04-09 10:35:43 +02:00
|
|
|
bool CalcCbTxMerkleRootMNList(const CBlock& block, const CBlockIndex* pindexPrev, uint256& merkleRootRet, CValidationState& state);
|
2019-04-04 10:25:50 +02:00
|
|
|
bool CalcCbTxMerkleRootQuorums(const CBlock& block, const CBlockIndex* pindexPrev, uint256& merkleRootRet, CValidationState& state);
|
2018-04-09 10:35:43 +02:00
|
|
|
|
2018-11-06 09:54:23 +01:00
|
|
|
#endif //DASH_CBTX_H
|