// Copyright (c) 2018-2022 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_SPECIALTX_H #define BITCOIN_EVO_SPECIALTX_H #include #include #include #include #include #include template inline bool GetTxPayload(const std::vector& payload, T& obj) { CDataStream ds(payload, SER_NETWORK, PROTOCOL_VERSION); try { ds >> obj; } catch (const std::exception& e) { return false; } return ds.empty(); } template inline bool GetTxPayload(const CMutableTransaction& tx, T& obj, bool assert_type = true) { if (assert_type) { ASSERT_IF_DEBUG(tx.nType == obj.SPECIALTX_TYPE); } return tx.nType == obj.SPECIALTX_TYPE && GetTxPayload(tx.vExtraPayload, obj); } template inline bool GetTxPayload(const CTransaction& tx, T& obj, bool assert_type = true) { if (assert_type) { ASSERT_IF_DEBUG(tx.nType == obj.SPECIALTX_TYPE); } return tx.nType == obj.SPECIALTX_TYPE && GetTxPayload(tx.vExtraPayload, obj); } template void SetTxPayload(CMutableTransaction& tx, const T& payload) { CDataStream ds(SER_NETWORK, PROTOCOL_VERSION); ds << payload; tx.vExtraPayload.assign(ds.begin(), ds.end()); } uint256 CalcTxInputsHash(const CTransaction& tx); #endif // BITCOIN_EVO_SPECIALTX_H