Monero C++ Library
Loading...
Searching...
No Matches
monero_daemon_model.h
1
52
53#pragma once
54
55#include <boost/property_tree/ptree.hpp>
56#include <boost/property_tree/json_parser.hpp>
57#include "rapidjson/document.h"
58#include "rapidjson/writer.h"
59#include "rapidjson/stringbuffer.h"
60
64namespace monero {
65
70
76 std::string serialize() const;
77
84 virtual rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const = 0;
85 };
86
90 enum monero_network_type : uint8_t {
91 MAINNET = 0,
92 TESTNET,
93 STAGENET
94 };
95
100 boost::optional<uint32_t> m_number;
101 boost::optional<bool> m_is_release;
102
103 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
104 };
105
109 struct monero_rpc_connection : public serializable_struct {
110 boost::optional<std::string> m_uri;
111 boost::optional<std::string> m_username;
112 boost::optional<std::string> m_password;
113 boost::optional<std::string> m_proxy_uri;
114
115 monero_rpc_connection(const std::string& uri = "", const std::string& username = "", const std::string& password = "", const std::string& proxy_uri = "") : m_uri(uri), m_username(username), m_password(password), m_proxy_uri(proxy_uri) {}
116 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
117 static monero_rpc_connection from_property_tree(const boost::property_tree::ptree& node);
118 };
119
120 // forward declarations
121 struct monero_tx;
122 struct monero_output;
123
130 boost::optional<std::string> m_hash;
131 boost::optional<uint64_t> m_height;
132 boost::optional<uint64_t> m_timestamp;
133 boost::optional<uint64_t> m_size;
134 boost::optional<uint64_t> m_weight;
135 boost::optional<uint64_t> m_long_term_weight;
136 boost::optional<uint64_t> m_depth;
137 boost::optional<uint64_t> m_difficulty;
138 boost::optional<uint64_t> m_cumulative_difficulty;
139 boost::optional<uint32_t> m_major_version;
140 boost::optional<uint32_t> m_minor_version;
141 boost::optional<uint32_t> m_nonce;
142 boost::optional<std::string> m_miner_tx_hash;
143 boost::optional<uint32_t> m_num_txs;
144 boost::optional<bool> m_orphan_status;
145 boost::optional<std::string> m_prev_hash;
146 boost::optional<uint64_t> m_reward;
147 boost::optional<std::string> m_pow_hash;
148
149 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
150 std::shared_ptr<monero_block_header> copy(const std::shared_ptr<monero_block_header>& src, const std::shared_ptr<monero_block_header>& tgt) const;
151 virtual void merge(const std::shared_ptr<monero_block_header>& self, const std::shared_ptr<monero_block_header>& other);
152 };
153
158 boost::optional<std::string> m_hex;
159 boost::optional<std::shared_ptr<monero_tx>> m_miner_tx;
160 std::vector<std::shared_ptr<monero_tx>> m_txs;
161 std::vector<std::string> m_tx_hashes;
162
163 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
164 std::shared_ptr<monero_block> copy(const std::shared_ptr<monero_block>& src, const std::shared_ptr<monero_block>& tgt) const;
165 void merge(const std::shared_ptr<monero_block_header>& self, const std::shared_ptr<monero_block_header>& other);
166 void merge(const std::shared_ptr<monero_block>& self, const std::shared_ptr<monero_block>& other);
167 };
168
173 static const std::string DEFAULT_PAYMENT_ID; // default payment id "0000000000000000"
174 boost::optional<std::shared_ptr<monero_block>> m_block;
175 boost::optional<std::string> m_hash;
176 boost::optional<uint32_t> m_version;
177 boost::optional<bool> m_is_miner_tx;
178 boost::optional<std::string> m_payment_id;
179 boost::optional<uint64_t> m_fee;
180 boost::optional<uint32_t> m_ring_size;
181 boost::optional<bool> m_relay;
182 boost::optional<bool> m_is_relayed;
183 boost::optional<bool> m_is_confirmed;
184 boost::optional<bool> m_in_tx_pool;
185 boost::optional<uint64_t> m_num_confirmations;
186 boost::optional<uint64_t> m_unlock_time;
187 boost::optional<uint64_t> m_last_relayed_timestamp;
188 boost::optional<uint64_t> m_received_timestamp;
189 boost::optional<bool> m_is_double_spend_seen;
190 boost::optional<std::string> m_key;
191 boost::optional<std::string> m_full_hex;
192 boost::optional<std::string> m_pruned_hex;
193 boost::optional<std::string> m_prunable_hex;
194 boost::optional<std::string> m_prunable_hash;
195 boost::optional<uint64_t> m_size;
196 boost::optional<uint64_t> m_weight;
197 std::vector<std::shared_ptr<monero_output>> m_inputs;
198 std::vector<std::shared_ptr<monero_output>> m_outputs;
199 std::vector<uint64_t> m_output_indices;
200 boost::optional<std::string> m_metadata;
201 boost::optional<std::string> m_common_tx_sets;
202 std::vector<uint8_t> m_extra;
203 boost::optional<std::string> m_rct_signatures; // TODO: implement
204 boost::optional<std::string> m_rct_sig_prunable; // TODO: implement
205 boost::optional<bool> m_is_kept_by_block;
206 boost::optional<bool> m_is_failed;
207 boost::optional<uint64_t> m_last_failed_height;
208 boost::optional<std::string> m_last_failed_hash;
209 boost::optional<uint64_t> m_max_used_block_height;
210 boost::optional<std::string> m_max_used_block_hash;
211 std::vector<std::string> m_signatures;
212
213 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
214 static void from_property_tree(const boost::property_tree::ptree& node, std::shared_ptr<monero_tx> tx);
215 std::shared_ptr<monero_tx> copy(const std::shared_ptr<monero_tx>& src, const std::shared_ptr<monero_tx>& tgt) const;
216 virtual void merge(const std::shared_ptr<monero_tx>& self, const std::shared_ptr<monero_tx>& other);
217 boost::optional<uint64_t> get_height() const;
218 };
219
224 boost::optional<std::string> m_hex;
225 boost::optional<std::string> m_signature;
226
227 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
228 static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr<monero_key_image>& key_image);
229 static std::vector<std::shared_ptr<monero_key_image>> deserialize_key_images(const std::string& key_images_json); // TODO: remove this specialty util used once
230 std::shared_ptr<monero_key_image> copy(const std::shared_ptr<monero_key_image>& src, const std::shared_ptr<monero_key_image>& tgt) const;
231 void merge(const std::shared_ptr<monero_key_image>& self, const std::shared_ptr<monero_key_image>& other);
232 };
233
238 std::shared_ptr<monero_tx> m_tx;
239 boost::optional<std::shared_ptr<monero_key_image>> m_key_image;
240 boost::optional<uint64_t> m_amount;
241 boost::optional<uint64_t> m_index;
242 std::vector<uint64_t> m_ring_output_indices;
243 boost::optional<std::string> m_stealth_public_key;
244
245 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
246 static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr<monero_output>& output);
247 std::shared_ptr<monero_output> copy(const std::shared_ptr<monero_output>& src, const std::shared_ptr<monero_output>& tgt) const;
248 virtual void merge(const std::shared_ptr<monero_output>& self, const std::shared_ptr<monero_output>& other);
249 };
250}
Definition monero_daemon.cpp:58
monero_network_type
Definition monero_daemon_model.h:90
Definition monero_daemon_model.h:129
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_daemon_model.cpp:141
Definition monero_daemon_model.h:157
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_daemon_model.cpp:225
Definition monero_daemon_model.h:223
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_daemon_model.cpp:570
Definition monero_daemon_model.h:237
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_daemon_model.cpp:634
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_daemon_model.cpp:111
Definition monero_daemon_model.h:172
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_daemon_model.cpp:306
Definition monero_daemon_model.h:99
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_daemon_model.cpp:93
Definition monero_daemon_model.h:69
virtual rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const =0
std::string serialize() const
Definition monero_daemon_model.cpp:83