Monero C++ Library
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 
61 using namespace std;
62 
66 namespace monero {
67 
72 
78  string serialize() const;
79 
86  virtual rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const = 0;
87  };
88 
92  enum monero_network_type : uint8_t {
93  MAINNET = 0,
94  TESTNET,
95  STAGENET
96  };
97 
102  boost::optional<uint32_t> m_number;
103  boost::optional<bool> m_is_release;
104 
105  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
106  };
107 
114  string m_uri;
115  boost::optional<string> m_username;
116  boost::optional<string> m_password;
117  monero_rpc_connection(const string& uri = "", const boost::optional<string>& username = boost::none, const boost::optional<string>& password = boost::none) : m_uri(uri), m_username(username), m_password(password) {}
118  };
119 
120  // forward declarations
121  struct monero_tx;
122  struct monero_output;
123 
130  boost::optional<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<string> m_miner_tx_hash;
143  boost::optional<uint32_t> m_num_txs;
144  boost::optional<bool> m_orphan_status;
145  boost::optional<string> m_prev_hash;
146  boost::optional<uint64_t> m_reward;
147  boost::optional<string> m_pow_hash;
148 
149  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
150  virtual void merge(const shared_ptr<monero_block_header>& self, const shared_ptr<monero_block_header>& other);
151  };
152 
157  boost::optional<string> m_hex;
158  boost::optional<shared_ptr<monero_tx>> m_miner_tx;
159  vector<shared_ptr<monero_tx>> m_txs;
160  vector<string> m_tx_hashes;
161 
162  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
163  void merge(const shared_ptr<monero_block_header>& self, const shared_ptr<monero_block_header>& other);
164  void merge(const shared_ptr<monero_block>& self, const shared_ptr<monero_block>& other);
165  };
166 
170  struct monero_tx : public serializable_struct {
171  static const string DEFAULT_PAYMENT_ID; // default payment id "0000000000000000"
172  boost::optional<shared_ptr<monero_block>> m_block;
173  boost::optional<string> m_hash;
174  boost::optional<uint32_t> m_version;
175  boost::optional<bool> m_is_miner_tx;
176  boost::optional<string> m_payment_id;
177  boost::optional<uint64_t> m_fee;
178  boost::optional<uint32_t> m_ring_size;
179  boost::optional<bool> m_do_not_relay;
180  boost::optional<bool> m_is_relayed;
181  boost::optional<bool> m_is_confirmed;
182  boost::optional<bool> m_in_tx_pool;
183  boost::optional<uint64_t> m_num_confirmations;
184  boost::optional<uint64_t> m_unlock_time;
185  boost::optional<uint64_t> m_last_relayed_timestamp;
186  boost::optional<uint64_t> m_received_timestamp;
187  boost::optional<bool> m_is_double_spend_seen;
188  boost::optional<string> m_key;
189  boost::optional<string> m_full_hex;
190  boost::optional<string> m_pruned_hex;
191  boost::optional<string> m_prunable_hex;
192  boost::optional<string> m_prunable_hash;
193  boost::optional<uint64_t> m_size;
194  boost::optional<uint64_t> m_weight;
195  vector<shared_ptr<monero_output>> m_inputs;
196  vector<shared_ptr<monero_output>> m_outputs;
197  vector<uint32_t> m_output_indices;
198  boost::optional<string> m_metadata;
199  boost::optional<string> m_common_tx_sets;
200  vector<uint8_t> m_extra;
201  boost::optional<string> m_rct_signatures; // TODO: implement
202  boost::optional<string> m_rct_sig_prunable; // TODO: implement
203  boost::optional<bool> m_is_kept_by_block;
204  boost::optional<bool> m_is_failed;
205  boost::optional<uint64_t> m_last_failed_height;
206  boost::optional<string> m_last_failed_hash;
207  boost::optional<uint64_t> m_max_used_block_height;
208  boost::optional<string> m_max_used_block_hash;
209  vector<string> m_signatures;
210 
211  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
212  static void from_property_tree(const boost::property_tree::ptree& node, shared_ptr<monero_tx> tx);
213  shared_ptr<monero_tx> copy(const shared_ptr<monero_tx>& src, const shared_ptr<monero_tx>& tgt) const;
214  virtual void merge(const shared_ptr<monero_tx>& self, const shared_ptr<monero_tx>& other);
215  boost::optional<uint64_t> get_height() const;
216  };
217 
222  boost::optional<string> m_hex;
223  boost::optional<string> m_signature;
224 
225  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
226  static void from_property_tree(const boost::property_tree::ptree& node, const shared_ptr<monero_key_image>& key_image);
227  static vector<shared_ptr<monero_key_image>> deserialize_key_images(const string& key_images_json); // TODO: remove this specialty util used once
228  shared_ptr<monero_key_image> copy(const shared_ptr<monero_key_image>& src, const shared_ptr<monero_key_image>& tgt) const;
229  void merge(const shared_ptr<monero_key_image>& self, const shared_ptr<monero_key_image>& other);
230  };
231 
236  shared_ptr<monero_tx> m_tx;
237  boost::optional<shared_ptr<monero_key_image>> m_key_image;
238  boost::optional<uint64_t> m_amount;
239  boost::optional<uint64_t> m_index;
240  vector<uint64_t> m_ring_output_indices;
241  boost::optional<string> m_stealth_public_key;
242 
243  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
244  static void from_property_tree(const boost::property_tree::ptree& node, const shared_ptr<monero_output>& output);
245  shared_ptr<monero_output> copy(const shared_ptr<monero_output>& src, const shared_ptr<monero_output>& tgt) const;
246  virtual void merge(const shared_ptr<monero_output>& self, const shared_ptr<monero_output>& other);
247  };
248 }
Definition: monero_daemon.cpp:58
Definition: monero_daemon_model.h:129
Definition: monero_daemon_model.h:156
Definition: monero_daemon_model.h:71
Definition: monero_daemon_model.h:235
Definition: monero_daemon_model.h:101
Definition: monero_daemon_model.h:170
Definition: monero_daemon_model.h:113
Definition: monero_daemon_model.h:221
monero_network_type
Definition: monero_daemon_model.h:92