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 
58 using namespace std;
59 
63 namespace monero {
64 
69 
75  string serialize() const;
76 
82  virtual boost::property_tree::ptree to_property_tree() const = 0;
83  };
84 
88  enum monero_network_type : uint8_t {
89  MAINNET = 0,
90  TESTNET,
91  STAGENET
92  };
93 
100  string m_uri;
101  boost::optional<string> m_username;
102  boost::optional<string> m_password;
103  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) {}
104  };
105 
106  // forward declarations
107  struct monero_tx;
108  struct monero_output;
109 
116  boost::optional<string> m_id;
117  boost::optional<uint64_t> m_height;
118  boost::optional<uint64_t> m_timestamp;
119  boost::optional<uint64_t> m_size;
120  boost::optional<uint64_t> m_weight;
121  boost::optional<uint64_t> m_long_term_weight;
122  boost::optional<uint64_t> m_depth;
123  boost::optional<uint64_t> m_difficulty;
124  boost::optional<uint64_t> m_cumulative_difficulty;
125  boost::optional<uint32_t> m_major_version;
126  boost::optional<uint32_t> m_minor_version;
127  boost::optional<uint64_t> m_nonce;
128  boost::optional<string> m_miner_tx_id;
129  boost::optional<uint32_t> m_num_txs;
130  boost::optional<bool> m_orphan_status;
131  boost::optional<string> m_prev_id;
132  boost::optional<uint64_t> m_reward;
133  boost::optional<string> m_pow_hash;
134 
135  boost::property_tree::ptree to_property_tree() const;
136  virtual void merge(const shared_ptr<monero_block_header>& self, const shared_ptr<monero_block_header>& other);
137  };
138 
143  boost::optional<string> m_hex;
144  boost::optional<shared_ptr<monero_tx>> m_miner_tx;
145  vector<shared_ptr<monero_tx>> m_txs;
146  vector<string> m_tx_ids;
147 
148  boost::property_tree::ptree to_property_tree() const;
149  void merge(const shared_ptr<monero_block_header>& self, const shared_ptr<monero_block_header>& other);
150  void merge(const shared_ptr<monero_block>& self, const shared_ptr<monero_block>& other);
151  };
152 
156  struct monero_tx : public serializable_struct {
157  static const string DEFAULT_PAYMENT_ID; // default payment id "0000000000000000"
158  boost::optional<shared_ptr<monero_block>> m_block;
159  boost::optional<string> m_id;
160  boost::optional<uint32_t> m_version;
161  boost::optional<bool> m_is_miner_tx;
162  boost::optional<string> m_payment_id;
163  boost::optional<uint64_t> m_fee;
164  boost::optional<uint32_t> m_mixin;
165  boost::optional<bool> m_do_not_relay;
166  boost::optional<bool> m_is_relayed;
167  boost::optional<bool> m_is_confirmed;
168  boost::optional<bool> m_in_tx_pool;
169  boost::optional<uint64_t> m_num_confirmations;
170  boost::optional<uint64_t> m_unlock_time;
171  boost::optional<uint64_t> m_last_relayed_timestamp;
172  boost::optional<uint64_t> m_received_timestamp;
173  boost::optional<bool> m_is_double_spend_seen;
174  boost::optional<string> m_key;
175  boost::optional<string> m_full_hex;
176  boost::optional<string> m_pruned_hex;
177  boost::optional<string> m_prunable_hex;
178  boost::optional<string> m_prunable_hash;
179  boost::optional<uint32_t> m_size;
180  boost::optional<uint32_t> m_weight;
181  vector<shared_ptr<monero_output>> m_vins;
182  vector<shared_ptr<monero_output>> m_vouts;
183  vector<uint32_t> m_output_indices;
184  boost::optional<string> m_metadata;
185  boost::optional<string> m_common_tx_sets;
186  vector<uint8_t> m_extra;
187  boost::optional<string> m_rct_signatures; // TODO: implement
188  boost::optional<string> m_rct_sig_prunable; // TODO: implement
189  boost::optional<bool> m_is_kept_by_block;
190  boost::optional<bool> m_is_failed;
191  boost::optional<uint32_t> m_last_failed_height;
192  boost::optional<string> m_last_failed_id;
193  boost::optional<uint32_t> m_max_used_block_height;
194  boost::optional<string> m_max_used_block_id;
195  vector<string> m_signatures;
196 
197  shared_ptr<monero_tx> copy(const shared_ptr<monero_tx>& src, const shared_ptr<monero_tx>& tgt) const;
198  boost::property_tree::ptree to_property_tree() const;
199  virtual void merge(const shared_ptr<monero_tx>& self, const shared_ptr<monero_tx>& other);
200  boost::optional<uint64_t> get_height() const;
201  };
202 
207  boost::optional<string> m_hex;
208  boost::optional<string> m_signature;
209 
210  shared_ptr<monero_key_image> copy(const shared_ptr<monero_key_image>& src, const shared_ptr<monero_key_image>& tgt) const;
211  boost::property_tree::ptree to_property_tree() const;
212  void merge(const shared_ptr<monero_key_image>& self, const shared_ptr<monero_key_image>& other);
213  };
214 
219  shared_ptr<monero_tx> m_tx;
220  boost::optional<shared_ptr<monero_key_image>> m_key_image;
221  boost::optional<uint64_t> m_amount;
222  boost::optional<uint64_t> m_index;
223  vector<uint64_t> m_ring_output_indices;
224  boost::optional<string> m_stealth_public_key;
225 
226  shared_ptr<monero_output> copy(const shared_ptr<monero_output>& src, const shared_ptr<monero_output>& tgt) const;
227  boost::property_tree::ptree to_property_tree() const;
228  virtual void merge(const shared_ptr<monero_output>& self, const shared_ptr<monero_output>& other);
229  };
230 }
Definition: monero_daemon.cpp:58
Definition: monero_daemon_model.h:115
Definition: monero_daemon_model.h:142
Definition: monero_daemon_model.h:68
Definition: monero_daemon_model.h:218
Definition: monero_daemon_model.h:156
Definition: monero_daemon_model.h:99
Definition: monero_daemon_model.h:206
monero_network_type
Definition: monero_daemon_model.h:88