Monero C++ Library
monero_wallet_model.h
1 
53 #pragma once
54 
55 #include "daemon/monero_daemon_model.h"
56 
57 using namespace std;
58 using namespace monero;
59 
63 namespace monero {
64 
69  uint64_t m_num_blocks_fetched;
70  bool m_received_money;
72  monero_sync_result(const uint64_t num_blocks_fetched, const bool received_money) : m_num_blocks_fetched(num_blocks_fetched), m_received_money(received_money) {}
73 
74  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
75  };
76 
81  boost::optional<uint32_t> m_account_index;
82  boost::optional<uint32_t> m_index;
83  boost::optional<string> m_address;
84  boost::optional<string> m_label;
85  boost::optional<uint64_t> m_balance;
86  boost::optional<uint64_t> m_unlocked_balance;
87  boost::optional<uint64_t> m_num_unspent_outputs;
88  boost::optional<bool> m_is_used;
89  boost::optional<uint64_t> m_num_blocks_to_unlock;
90 
91  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
92  };
93 
98  boost::optional<uint32_t> m_index;
99  boost::optional<string> m_primary_address;
100  boost::optional<uint64_t> m_balance;
101  boost::optional<uint64_t> m_unlocked_balance;
102  boost::optional<string> m_tag;
103  vector<monero_subaddress> m_subaddresses;
104 
105  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
106  };
107 
112  boost::optional<string> m_address;
113  boost::optional<uint64_t> m_amount;
114 
115  monero_destination() {}
116  monero_destination(const string& address, uint64_t amount) : m_address(address), m_amount(amount) {}
117  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
118  static void from_property_tree(const boost::property_tree::ptree& node, const shared_ptr<monero_destination>& destination);
119  shared_ptr<monero_destination> copy(const shared_ptr<monero_destination>& src, const shared_ptr<monero_destination>& tgt) const;
120  };
121 
122  // forward declarations
123  struct monero_tx_wallet;
124  struct monero_tx_query;
125  struct monero_tx_set;
126 
131  shared_ptr<monero_tx_wallet> m_tx;
132  boost::optional<uint64_t> m_amount;
133  boost::optional<uint32_t> m_account_index;
134  boost::optional<uint64_t> m_num_suggested_confirmations;
135 
136  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
137  static void from_property_tree(const boost::property_tree::ptree& node, const shared_ptr<monero_transfer>& transfer);
138  virtual boost::optional<bool> is_incoming() const = 0; // derived class must implement
139  shared_ptr<monero_transfer> copy(const shared_ptr<monero_transfer>& src, const shared_ptr<monero_transfer>& tgt) const;
140  boost::optional<bool> is_outgoing() const {
141  if (is_incoming() == boost::none) return boost::none;
142  return !(*is_incoming());
143  }
144  void merge(const shared_ptr<monero_transfer>& self, const shared_ptr<monero_transfer>& other);
145  };
146 
151  boost::optional<uint32_t> m_subaddress_index;
152  boost::optional<string> m_address;
153 
154  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
155  shared_ptr<monero_incoming_transfer> copy(const shared_ptr<monero_transfer>& src, const shared_ptr<monero_transfer>& tgt) const;
156  shared_ptr<monero_incoming_transfer> copy(const shared_ptr<monero_incoming_transfer>& src, const shared_ptr<monero_incoming_transfer>& tgt) const;
157  boost::optional<bool> is_incoming() const;
158  void merge(const shared_ptr<monero_transfer>& self, const shared_ptr<monero_transfer>& other);
159  void merge(const shared_ptr<monero_incoming_transfer>& self, const shared_ptr<monero_incoming_transfer>& other);
160  };
161 
166  vector<uint32_t> m_subaddress_indices;
167  vector<string> m_addresses;
168  vector<shared_ptr<monero_destination>> m_destinations;
169 
170  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
171  shared_ptr<monero_outgoing_transfer> copy(const shared_ptr<monero_transfer>& src, const shared_ptr<monero_transfer>& tgt) const;
172  shared_ptr<monero_outgoing_transfer> copy(const shared_ptr<monero_outgoing_transfer>& src, const shared_ptr<monero_outgoing_transfer>& tgt) const;
173  boost::optional<bool> is_incoming() const;
174  void merge(const shared_ptr<monero_transfer>& self, const shared_ptr<monero_transfer>& other);
175  void merge(const shared_ptr<monero_outgoing_transfer>& self, const shared_ptr<monero_outgoing_transfer>& other);
176  };
177 
184  boost::optional<bool> m_is_incoming;
185  boost::optional<string> m_address;
186  vector<string> m_addresses;
187  boost::optional<uint32_t> m_subaddress_index;
188  vector<uint32_t> m_subaddress_indices;
189  vector<shared_ptr<monero_destination>> m_destinations;
190  boost::optional<bool> m_has_destinations;
191  boost::optional<shared_ptr<monero_tx_query>> m_tx_query;
192 
193  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
194  static void from_property_tree(const boost::property_tree::ptree& node, const shared_ptr<monero_transfer_query>& transfer_query);
195  static shared_ptr<monero_transfer_query> deserialize_from_block(const string& transfer_query_json);
196  shared_ptr<monero_transfer_query> copy(const shared_ptr<monero_transfer>& src, const shared_ptr<monero_transfer>& tgt) const;
197  shared_ptr<monero_transfer_query> copy(const shared_ptr<monero_transfer_query>& src, const shared_ptr<monero_transfer_query>& tgt) const;
198  boost::optional<bool> is_incoming() const;
199  bool meets_criteria(monero_transfer* transfer) const;
200  };
201 
206  boost::optional<uint32_t> m_account_index;
207  boost::optional<uint32_t> m_subaddress_index;
208  boost::optional<bool> m_is_spent;
209  boost::optional<bool> m_is_frozen;
210 
211  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
212  static void from_property_tree(const boost::property_tree::ptree& node, const shared_ptr<monero_output_wallet>& output_wallet);
213  shared_ptr<monero_output_wallet> copy(const shared_ptr<monero_output>& src, const shared_ptr<monero_output>& tgt) const;
214  shared_ptr<monero_output_wallet> copy(const shared_ptr<monero_output_wallet>& src, const shared_ptr<monero_output_wallet>& tgt) const;
215  void merge(const shared_ptr<monero_output>& self, const shared_ptr<monero_output>& other);
216  void merge(const shared_ptr<monero_output_wallet>& self, const shared_ptr<monero_output_wallet>& other);
217  };
218 
226  vector<uint32_t> m_subaddress_indices;
227  boost::optional<shared_ptr<monero_tx_query>> m_tx_query;
228 
229  //boost::property_tree::ptree to_property_tree() const;
230  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
231  static void from_property_tree(const boost::property_tree::ptree& node, const shared_ptr<monero_output_query>& output_query);
232  static shared_ptr<monero_output_query> deserialize_from_block(const string& output_query_json);
233  bool is_default() const;
234  shared_ptr<monero_output_query> copy(const shared_ptr<monero_output>& src, const shared_ptr<monero_output>& tgt) const;
235  shared_ptr<monero_output_query> copy(const shared_ptr<monero_output_wallet>& src, const shared_ptr<monero_output_wallet>& tgt) const; // TODO: necessary to override all super classes?
236  shared_ptr<monero_output_query> copy(const shared_ptr<monero_output_query>& src, const shared_ptr<monero_output_query>& tgt) const;
237  bool meets_criteria(monero_output_wallet* output) const;
238 
239  private:
240  static const unique_ptr<monero_output_wallet> M_EMPTY_OUTPUT;
241  };
242 
246  struct monero_tx_wallet : public monero_tx {
247  boost::optional<shared_ptr<monero_tx_set>> m_tx_set;
248  boost::optional<bool> m_is_incoming;
249  boost::optional<bool> m_is_outgoing;
250  vector<shared_ptr<monero_incoming_transfer>> m_incoming_transfers;
251  boost::optional<shared_ptr<monero_outgoing_transfer>> m_outgoing_transfer;
252  boost::optional<string> m_note;
253  boost::optional<bool> m_is_locked;
254  boost::optional<uint64_t> m_input_sum;
255  boost::optional<uint64_t> m_output_sum;
256  boost::optional<string> m_change_address;
257  boost::optional<uint64_t> m_change_amount;
258  boost::optional<uint32_t> m_num_dummy_outputs;
259  boost::optional<string> m_extra_hex;
260 
261  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
262  static void from_property_tree(const boost::property_tree::ptree& node, const shared_ptr<monero_tx_wallet>& tx_wallet);
263  shared_ptr<monero_tx_wallet> copy(const shared_ptr<monero_tx>& src, const shared_ptr<monero_tx>& tgt) const;
264  shared_ptr<monero_tx_wallet> copy(const shared_ptr<monero_tx_wallet>& src, const shared_ptr<monero_tx_wallet>& tgt) const;
265  void merge(const shared_ptr<monero_tx>& self, const shared_ptr<monero_tx>& other);
266  void merge(const shared_ptr<monero_tx_wallet>& self, const shared_ptr<monero_tx_wallet>& other);
267  };
268 
275  boost::optional<bool> m_is_outgoing;
276  boost::optional<bool> m_is_incoming;
277  vector<string> m_tx_hashes;
278  boost::optional<bool> m_has_payment_id;
279  vector<string> m_payment_ids;
280  boost::optional<uint64_t> m_height;
281  boost::optional<uint64_t> m_min_height;
282  boost::optional<uint64_t> m_max_height;
283  boost::optional<uint64_t> m_include_outputs;
284  boost::optional<shared_ptr<monero_transfer_query>> m_transfer_query;
285  boost::optional<shared_ptr<monero_output_query>> m_output_query;
286 
287  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
288  static void from_property_tree(const boost::property_tree::ptree& node, const shared_ptr<monero_tx_query>& tx_query);
289  static shared_ptr<monero_tx_query> deserialize_from_block(const string& tx_query_json);
290  shared_ptr<monero_tx_query> copy(const shared_ptr<monero_tx>& src, const shared_ptr<monero_tx>& tgt) const;
291  shared_ptr<monero_tx_query> copy(const shared_ptr<monero_tx_wallet>& src, const shared_ptr<monero_tx_wallet>& tgt) const; // TODO: necessary to override all super classes?
292  shared_ptr<monero_tx_query> copy(const shared_ptr<monero_tx_query>& src, const shared_ptr<monero_tx_query>& tgt) const;
293  bool meets_criteria(monero_tx_wallet* tx) const;
294  };
295 
305  vector<shared_ptr<monero_tx_wallet>> m_txs;
306  boost::optional<string> m_signed_tx_hex;
307  boost::optional<string> m_unsigned_tx_hex;
308  boost::optional<string> m_multisig_tx_hex;
309 
310  //boost::property_tree::ptree to_property_tree() const;
311  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
312  static monero_tx_set deserialize(const string& tx_set_json);
313  };
314 
319  string m_standard_address;
320  string m_payment_id;
321  string m_integrated_address;
322 
323  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
324  };
325 
329  enum monero_send_priority : uint8_t {
330  DEFAULT = 0,
331  UNIMPORTANT,
332  NORMAL,
333  ELEVATED
334  };
335 
340  vector<shared_ptr<monero_destination>> m_destinations;
341  boost::optional<string> m_payment_id;
342  boost::optional<monero_send_priority> m_priority;
343  boost::optional<uint32_t> m_ring_size;
344  boost::optional<uint64_t> m_fee;
345  boost::optional<uint32_t> m_account_index;
346  vector<uint32_t> m_subaddress_indices;
347  boost::optional<uint64_t> m_unlock_time;
348  boost::optional<bool> m_can_split;
349  boost::optional<bool> m_do_not_relay;
350  boost::optional<string> m_note;
351  boost::optional<string> m_recipient_name;
352  boost::optional<uint64_t> m_below_amount;
353  boost::optional<bool> m_sweep_each_subaddress;
354  boost::optional<string> m_key_image;
355 
358  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
359  static shared_ptr<monero_send_request> deserialize(const string& send_request_json);
360  monero_send_request copy() const;
361  };
362 
367  boost::optional<uint64_t> m_height;
368  boost::optional<uint64_t> m_spent_amount;
369  boost::optional<uint64_t> m_unspent_amount;
370 
371  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
372  };
373 
378  bool m_is_good;
379 
380  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
381  };
382 
386  struct monero_check_tx : public monero_check {
387  boost::optional<bool> m_in_tx_pool;
388  boost::optional<uint64_t> m_num_confirmations;
389  boost::optional<uint64_t> m_received_amount;
390 
391  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
392  };
393 
398  boost::optional<uint64_t> m_total_amount;
399  boost::optional<uint64_t> m_unconfirmed_spent_amount;
400 
401  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
402  };
403 
408  bool m_is_multisig;
409  bool m_is_ready;
410  uint32_t m_threshold;
411  uint32_t m_num_participants;
412 
413  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
414  };
415 
422  boost::optional<string> m_address;
423  boost::optional<string> m_multisig_hex;
424 
425  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
426  };
427 
432  boost::optional<string> m_signed_multisig_tx_hex;
433  vector<string> m_tx_hashes;
434 
435  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
436  };
437 
442  boost::optional<uint64_t> m_index; // TODO: not boost::optional
443  boost::optional<string> m_address;
444  boost::optional<string> m_description;
445  boost::optional<string> m_payment_id;
446 
448  monero_address_book_entry(uint64_t index, const string& address, const string& description, const string& payment_id) : m_index(index), m_address(address), m_description(description), m_payment_id(payment_id) {}
449  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
450  };
451 }
Definition: monero_wallet_model.h:407
Definition: monero_daemon.cpp:58
Definition: monero_wallet_model.h:111
Definition: monero_wallet_model.h:318
Definition: monero_wallet_model.h:421
Definition: monero_wallet_model.h:150
Definition: monero_wallet_model.h:274
Definition: monero_daemon_model.h:71
Definition: monero_wallet_model.h:431
Definition: monero_daemon_model.h:235
Definition: monero_daemon_model.h:170
Definition: monero_wallet_model.h:246
monero_send_priority
Definition: monero_wallet_model.h:329
Definition: monero_wallet_model.h:397
Definition: monero_wallet_model.h:165
Definition: monero_wallet_model.h:68
Definition: monero_wallet_model.h:304
Definition: monero_wallet_model.h:441
Definition: monero_wallet_model.h:386
Definition: monero_wallet_model.h:225
Definition: monero_wallet_model.h:339
Definition: monero_wallet_model.h:97
Definition: monero_wallet_model.h:80
Definition: monero_wallet_model.h:205
Definition: monero_wallet_model.h:183
Definition: monero_wallet_model.h:366
Definition: monero_wallet_model.h:377
Definition: monero_wallet_model.h:130