// 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 #include #include template std::optional GetTxPayload(const std::vector& payload) { CDataStream ds(payload, SER_NETWORK, PROTOCOL_VERSION); try { T obj; ds >> obj; return ds.empty() ? std::make_optional(std::move(obj)) : std::nullopt; } catch (const std::exception& e) { return std::nullopt; } } template std::optional GetTxPayload(const TxType& tx, bool assert_type = true) { if (assert_type) { ASSERT_IF_DEBUG(tx.nType == T::SPECIALTX_TYPE); } if (tx.nType != T::SPECIALTX_TYPE) return std::nullopt; return GetTxPayload(tx.vExtraPayload); } 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