Monero C++ Library
Loading...
Searching...
No Matches
monero_daemon_model.h
1
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
110 boost::optional<std::string> m_uri;
111 boost::optional<std::string> m_username;
112 boost::optional<std::string> m_password;
113
114 monero_rpc_connection(const std::string& uri = "", const std::string& username = "", const std::string& password = "") : m_uri(uri), m_username(username), m_password(password) {}
115 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
116 static monero_rpc_connection from_property_tree(const boost::property_tree::ptree& node);
117 };
118
119 // forward declarations
120 struct monero_tx;
121 struct monero_output;
122
129 boost::optional<std::string> m_hash;
130 boost::optional<uint64_t> m_height;
131 boost::optional<uint64_t> m_timestamp;
132 boost::optional<uint64_t> m_size;
133 boost::optional<uint64_t> m_weight;
134 boost::optional<uint64_t> m_long_term_weight;
135 boost::optional<uint64_t> m_depth;
136 boost::optional<uint64_t> m_difficulty;
137 boost::optional<uint64_t> m_cumulative_difficulty;
138 boost::optional<uint32_t> m_major_version;
139 boost::optional<uint32_t> m_minor_version;
140 boost::optional<uint32_t> m_nonce;
141 boost::optional<std::string> m_miner_tx_hash;
142 boost::optional<uint32_t> m_num_txs;
143 boost::optional<bool> m_orphan_status;
144 boost::optional<std::string> m_prev_hash;
145 boost::optional<uint64_t> m_reward;
146 boost::optional<std::string> m_pow_hash;
147
148 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
149 std::shared_ptr<monero_block_header> copy(const std::shared_ptr<monero_block_header>& src, const std::shared_ptr<monero_block_header>& tgt) const;
150 virtual void merge(const std::shared_ptr<monero_block_header>& self, const std::shared_ptr<monero_block_header>& other);
151 };
152
157 boost::optional<std::string> m_hex;
158 boost::optional<std::shared_ptr<monero_tx>> m_miner_tx;
159 std::vector<std::shared_ptr<monero_tx>> m_txs;
160 std::vector<std::string> m_tx_hashes;
161
162 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
163 std::shared_ptr<monero_block> copy(const std::shared_ptr<monero_block>& src, const std::shared_ptr<monero_block>& tgt) const;
164 void merge(const std::shared_ptr<monero_block_header>& self, const std::shared_ptr<monero_block_header>& other);
165 void merge(const std::shared_ptr<monero_block>& self, const std::shared_ptr<monero_block>& other);
166 };
167
172 static const std::string DEFAULT_PAYMENT_ID; // default payment id "0000000000000000"
173 boost::optional<std::shared_ptr<monero_block>> m_block;
174 boost::optional<std::string> m_hash;
175 boost::optional<uint32_t> m_version;
176 boost::optional<bool> m_is_miner_tx;
177 boost::optional<std::string> m_payment_id;
178 boost::optional<uint64_t> m_fee;
179 boost::optional<uint32_t> m_ring_size;
180 boost::optional<bool> m_relay;
181 boost::optional<bool> m_is_relayed;
182 boost::optional<bool> m_is_confirmed;
183 boost::optional<bool> m_in_tx_pool;
184 boost::optional<uint64_t> m_num_confirmations;
185 boost::optional<uint64_t> m_unlock_time;
186 boost::optional<uint64_t> m_last_relayed_timestamp;
187 boost::optional<uint64_t> m_received_timestamp;
188 boost::optional<bool> m_is_double_spend_seen;
189 boost::optional<std::string> m_key;
190 boost::optional<std::string> m_full_hex;
191 boost::optional<std::string> m_pruned_hex;
192 boost::optional<std::string> m_prunable_hex;
193 boost::optional<std::string> m_prunable_hash;
194 boost::optional<uint64_t> m_size;
195 boost::optional<uint64_t> m_weight;
196 std::vector<std::shared_ptr<monero_output>> m_inputs;
197 std::vector<std::shared_ptr<monero_output>> m_outputs;
198 std::vector<uint64_t> m_output_indices;
199 boost::optional<std::string> m_metadata;
200 boost::optional<std::string> m_common_tx_sets;
201 std::vector<uint8_t> m_extra;
202 boost::optional<std::string> m_rct_signatures; // TODO: implement
203 boost::optional<std::string> m_rct_sig_prunable; // TODO: implement
204 boost::optional<bool> m_is_kept_by_block;
205 boost::optional<bool> m_is_failed;
206 boost::optional<uint64_t> m_last_failed_height;
207 boost::optional<std::string> m_last_failed_hash;
208 boost::optional<uint64_t> m_max_used_block_height;
209 boost::optional<std::string> m_max_used_block_hash;
210 std::vector<std::string> m_signatures;
211
212 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
213 static void from_property_tree(const boost::property_tree::ptree& node, std::shared_ptr<monero_tx> tx);
214 std::shared_ptr<monero_tx> copy(const std::shared_ptr<monero_tx>& src, const std::shared_ptr<monero_tx>& tgt) const;
215 virtual void merge(const std::shared_ptr<monero_tx>& self, const std::shared_ptr<monero_tx>& other);
216 boost::optional<uint64_t> get_height() const;
217 };
218
223 boost::optional<std::string> m_hex;
224 boost::optional<std::string> m_signature;
225
226 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
227 static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr<monero_key_image>& key_image);
228 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
229 std::shared_ptr<monero_key_image> copy(const std::shared_ptr<monero_key_image>& src, const std::shared_ptr<monero_key_image>& tgt) const;
230 void merge(const std::shared_ptr<monero_key_image>& self, const std::shared_ptr<monero_key_image>& other);
231 };
232
237 std::shared_ptr<monero_tx> m_tx;
238 boost::optional<std::shared_ptr<monero_key_image>> m_key_image;
239 boost::optional<uint64_t> m_amount;
240 boost::optional<uint64_t> m_index;
241 std::vector<uint64_t> m_ring_output_indices;
242 boost::optional<std::string> m_stealth_public_key;
243
244 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
245 static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr<monero_output>& output);
246 std::shared_ptr<monero_output> copy(const std::shared_ptr<monero_output>& src, const std::shared_ptr<monero_output>& tgt) const;
247 virtual void merge(const std::shared_ptr<monero_output>& self, const std::shared_ptr<monero_output>& other);
248 };
249}
Definition monero_daemon.cpp:58
monero_network_type
Definition monero_daemon_model.h:90
Definition monero_daemon_model.h:128
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_daemon_model.cpp:139
Definition monero_daemon_model.h:156
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_daemon_model.cpp:223
Definition monero_daemon_model.h:222
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_daemon_model.cpp:568
Definition monero_daemon_model.h:236
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_daemon_model.cpp:632
Definition monero_daemon_model.h:109
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_daemon_model.cpp:111
Definition monero_daemon_model.h:171
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_daemon_model.cpp:304
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