dash/src/evo/cbtx.h
Kittywhiskers Van Gogh 80777646d8
tests: (in)valid unit test vectors against IsTriviallyValid() evo calls (#4660)
* evo: resolve suggestions given in dash#4696

* evo: add known-good mainnet vectors for IsTriviallyValid()

* evo: add artificially malformed vectors for IsTriviallyValid()

* evo: add IsTriviallyValid() tests

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>

* Make sure we deserialize the right type of a special tx in GetTxPayload, and debug assert

Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
2022-03-06 00:54:26 -06:00

59 lines
1.8 KiB
C++

// Copyright (c) 2017-2021 The Dash Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_EVO_CBTX_H
#define BITCOIN_EVO_CBTX_H
#include <primitives/transaction.h>
#include <univalue.h>
class CBlock;
class CBlockIndex;
class CCoinsViewCache;
class CValidationState;
// coinbase transaction
class CCbTx
{
public:
static constexpr auto SPECIALTX_TYPE = TRANSACTION_COINBASE;
static constexpr uint16_t CURRENT_VERSION = 2;
uint16_t nVersion{CURRENT_VERSION};
int32_t nHeight{0};
uint256 merkleRootMNList;
uint256 merkleRootQuorums;
SERIALIZE_METHODS(CCbTx, obj)
{
READWRITE(obj.nVersion, obj.nHeight, obj.merkleRootMNList);
if (obj.nVersion >= 2) {
READWRITE(obj.merkleRootQuorums);
}
}
std::string ToString() const;
void ToJson(UniValue& obj) const
{
obj.clear();
obj.setObject();
obj.pushKV("version", (int)nVersion);
obj.pushKV("height", nHeight);
obj.pushKV("merkleRootMNList", merkleRootMNList.ToString());
if (nVersion >= 2) {
obj.pushKV("merkleRootQuorums", merkleRootQuorums.ToString());
}
}
};
bool CheckCbTx(const CTransaction& tx, const CBlockIndex* pindexPrev, CValidationState& state);
bool CheckCbTxMerkleRoots(const CBlock& block, const CBlockIndex* pindex, CValidationState& state, const CCoinsViewCache& view);
bool CalcCbTxMerkleRootMNList(const CBlock& block, const CBlockIndex* pindexPrev, uint256& merkleRootRet, CValidationState& state, const CCoinsViewCache& view);
bool CalcCbTxMerkleRootQuorums(const CBlock& block, const CBlockIndex* pindexPrev, uint256& merkleRootRet, CValidationState& state);
#endif // BITCOIN_EVO_CBTX_H