veriblock-pop-cpp
C++11 Libraries for leveraging VeriBlock Proof-Of-Proof blockchain technology.
output.hpp
1// Copyright (c) 2019-2022 Xenios SEZC
2// https://www.veriblock.org
3// Distributed under the MIT software license, see the accompanying
4// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
5
6#ifndef ALT_INTEGRATION_INCLUDE_VERIBLOCK_ENTITIES_OUTPUT_HPP_
7#define ALT_INTEGRATION_INCLUDE_VERIBLOCK_ENTITIES_OUTPUT_HPP_
8
9#include <cstddef>
10#include <string>
11#include <utility>
12#include <veriblock/pop/json.hpp>
13
14#include "address.hpp"
15#include "coin.hpp"
16
17namespace altintegration {
18class ValidationState;
19class WriteStream;
20struct ReadStream;
21
27struct Output {
28 Address address{};
29 Coin coin{};
30
31 Output() = default;
32
33 Output(Address _address, Coin _coin)
34 : address(std::move(_address)), coin(_coin) {}
35
41 bool operator==(const Output& other) const noexcept;
42
47 void toVbkEncoding(WriteStream& stream) const;
48
49 size_t estimateSize() const;
50
51 std::string toPrettyString() const;
52};
53
55template <typename JsonValue>
56JsonValue ToJSON(const Output& o) {
57 JsonValue obj = json::makeEmptyObject<JsonValue>();
58 json::putStringKV(obj, "address", o.address.toString());
59 json::putIntKV(obj, "coin", o.coin.units);
60 return obj;
61}
62
65 Output& out,
66 ValidationState& state);
67
68} // namespace altintegration
69
70#endif // ALT_INTEGRATION_INCLUDE_VERIBLOCK_ENTITIES_OUTPUT_HPP_
Class that is used for storing validation state.
Binary writer that is useful for binary serialization.
Defines logging helpers.
Definition: block.hpp:14
bool DeserializeFromVbkEncoding(ReadStream &stream, AltBlockAddon &out, ValidationState &state)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Represents address on VBK chain.
Definition: address.hpp:28
std::string toString() const noexcept
Convert VBK address to text representation.
represents VBK atomic units
Definition: coin.hpp:21
Single spending output.
Definition: output.hpp:27
void toVbkEncoding(WriteStream &stream) const
Convert Output to data stream using Output VBK byte format.
bool operator==(const Output &other) const noexcept
Compare two Outputs for equality.
Binary reading stream, that is useful during binary deserialization.
Definition: read_stream.hpp:22