6#ifndef ALT_INTEGRATION_INCLUDE_VERIBLOCK_ENTITIES_VBKTX_HPP_
7#define ALT_INTEGRATION_INCLUDE_VERIBLOCK_ENTITIES_VBKTX_HPP_
13#include <veriblock/pop/hashutil.hpp>
14#include <veriblock/pop/serde.hpp>
15#include <veriblock/pop/slice.hpp>
16#include <veriblock/pop/uint.hpp>
21#include "publication_data.hpp"
22#include "veriblock/pop/blob.hpp"
23#include "veriblock/pop/entities/network_byte_pair.hpp"
24#include "veriblock/pop/json.hpp"
25#include "veriblock/pop/strutil.hpp"
31template <
class ElementType>
46 std::vector<Output> outputs{};
47 int64_t signatureIndex{};
49 std::vector<uint8_t> signature{};
50 std::vector<uint8_t> publicKey{};
64 size_t estimateSize()
const;
78 friend bool operator==(
const VbkTx& a,
const VbkTx& b) {
82 friend bool operator!=(
const VbkTx& a,
const VbkTx& b) {
return !(a == b); }
90 void toRaw(WriteStream& stream)
const;
94template <
typename JsonValue>
95JsonValue ToJSON(
const VbkTx& tx) {
96 JsonValue obj = json::makeEmptyObject<JsonValue>();
97 tx.networkOrType.
networkType.template putJson<JsonValue>(obj);
98 json::putStringKV(obj,
"hash", tx.
getHash().toHex());
99 json::putIntKV(obj,
"type", tx.networkOrType.typeId);
100 json::putStringKV(obj,
"sourceAddress", tx.sourceAddress.
toString());
101 json::putIntKV(obj,
"sourceAmount", tx.sourceAmount.units);
102 json::putArrayKV(obj,
"outputs", tx.outputs);
103 json::putIntKV(obj,
"signatureIndex", tx.signatureIndex);
104 json::putKV(obj,
"publicationData", ToJSON<JsonValue>(tx.publicationData));
105 json::putStringKV(obj,
"signature",
HexStr(tx.signature));
106 json::putStringKV(obj,
"publicKey",
HexStr(tx.publicKey));
Class that is used for storing validation state.
Binary writer that is useful for binary serialization.
All constants in alt-cpp.
bool DeserializeFromRaw(ReadStream &stream, AltBlock &out, ValidationState &state, const AltBlock::hash_t &=AltBlock::hash_t{})
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool DeserializeFromVbkEncoding(ReadStream &stream, AltBlockAddon &out, ValidationState &state)
This is an overloaded member function, provided for convenience. It differs from the above function o...
std::string HexStr(const T itbegin, const T itend)
Convert bytes to hex.
Blob< SHA256_HASH_SIZE > uint256
This is an overloaded member function, provided for convenience. It differs from the above function o...
VbkNetworkType networkType
< works as std::optional. if hasNetworkByte is true, networkByte is set
Stores pair of TxType and VBK network byte.
Represents address on VBK chain.
std::string toString() const noexcept
Convert VBK address to text representation.
represents VBK atomic units
Publication data about ALT block inside VBK blockchain.
Binary reading stream, that is useful during binary deserialization.
Non-owning contiguous array.
Veriblock transaction, which endorses ALT block in VBK blockchain.
void toVbkEncoding(WriteStream &stream) const
Convert VbkTx to data stream using VbkTx VBK byte format.
Coin calculateTxFee() const
Calculate the fee of the VBK transaction.
uint256 getHash() const
Calculate the hash of the VBK transaction.
std::vector< uint8_t > toVbkEncoding() const
Convert VbkTx to raw bytes data using VBK byte format.