2021-04-20 21:33:02 +02:00
|
|
|
// Copyright (c) 2018-2021 The Dash Core developers
|
2018-02-13 13:34:35 +01:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2018-04-02 00:30:17 +02:00
|
|
|
#ifndef BITCOIN_EVO_SPECIALTX_H
|
|
|
|
#define BITCOIN_EVO_SPECIALTX_H
|
2018-02-13 13:34:35 +01:00
|
|
|
|
2021-10-25 15:55:34 +02:00
|
|
|
#include <primitives/transaction.h>
|
2020-03-19 23:46:56 +01:00
|
|
|
#include <streams.h>
|
2021-09-08 00:33:02 +02:00
|
|
|
#include <sync.h>
|
|
|
|
#include <threadsafety.h>
|
2020-03-19 23:46:56 +01:00
|
|
|
#include <version.h>
|
2018-02-14 12:05:25 +01:00
|
|
|
|
2018-02-13 13:34:35 +01:00
|
|
|
class CBlock;
|
|
|
|
class CBlockIndex;
|
2021-04-03 19:18:50 +02:00
|
|
|
class CCoinsViewCache;
|
2018-02-13 13:34:35 +01:00
|
|
|
class CValidationState;
|
|
|
|
|
2021-09-08 00:33:02 +02:00
|
|
|
extern CCriticalSection cs_main;
|
|
|
|
|
2021-12-11 21:00:27 +01:00
|
|
|
bool CheckSpecialTx(const CTransaction& tx, const CBlockIndex* pindexPrev, CValidationState& state, const CCoinsViewCache& view) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
2021-09-08 00:33:02 +02:00
|
|
|
bool ProcessSpecialTxsInBlock(const CBlock& block, const CBlockIndex* pindex, CValidationState& state, const CCoinsViewCache& view, bool fJustCheck, bool fCheckCbTxMerleRoots) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
|
|
|
bool UndoSpecialTxsInBlock(const CBlock& block, const CBlockIndex* pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
2018-02-13 13:34:35 +01:00
|
|
|
|
2018-02-14 12:05:25 +01:00
|
|
|
template <typename T>
|
|
|
|
inline bool GetTxPayload(const std::vector<unsigned char>& payload, T& obj)
|
|
|
|
{
|
|
|
|
CDataStream ds(payload, SER_NETWORK, PROTOCOL_VERSION);
|
|
|
|
try {
|
|
|
|
ds >> obj;
|
|
|
|
} catch (std::exception& e) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return ds.empty();
|
|
|
|
}
|
|
|
|
template <typename T>
|
|
|
|
inline bool GetTxPayload(const CMutableTransaction& tx, T& obj)
|
|
|
|
{
|
|
|
|
return GetTxPayload(tx.vExtraPayload, obj);
|
|
|
|
}
|
|
|
|
template <typename T>
|
|
|
|
inline bool GetTxPayload(const CTransaction& tx, T& obj)
|
|
|
|
{
|
|
|
|
return GetTxPayload(tx.vExtraPayload, obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
void SetTxPayload(CMutableTransaction& tx, const T& payload)
|
|
|
|
{
|
|
|
|
CDataStream ds(SER_NETWORK, PROTOCOL_VERSION);
|
|
|
|
ds << payload;
|
|
|
|
tx.vExtraPayload.assign(ds.begin(), ds.end());
|
|
|
|
}
|
|
|
|
|
2018-02-13 13:34:35 +01:00
|
|
|
uint256 CalcTxInputsHash(const CTransaction& tx);
|
|
|
|
|
2018-04-02 00:30:17 +02:00
|
|
|
#endif // BITCOIN_EVO_SPECIALTX_H
|