Monero C++ Library
monero_wallet_model.h
1 
53 #pragma once
54 
55 #include "daemon/monero_daemon_model.h"
56 
57 using namespace monero;
58 
62 namespace monero {
63 
68  uint64_t m_num_blocks_fetched;
69  bool m_received_money;
71  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) {}
72 
73  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
74  };
75 
80  boost::optional<uint32_t> m_account_index;
81  boost::optional<uint32_t> m_index;
82  boost::optional<std::string> m_address;
83  boost::optional<std::string> m_label;
84  boost::optional<uint64_t> m_balance;
85  boost::optional<uint64_t> m_unlocked_balance;
86  boost::optional<uint64_t> m_num_unspent_outputs;
87  boost::optional<bool> m_is_used;
88  boost::optional<uint64_t> m_num_blocks_to_unlock;
89 
90  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
91  };
92 
97  boost::optional<uint32_t> m_index;
98  boost::optional<std::string> m_primary_address;
99  boost::optional<uint64_t> m_balance;
100  boost::optional<uint64_t> m_unlocked_balance;
101  boost::optional<std::string> m_tag;
102  std::vector<monero_subaddress> m_subaddresses;
103 
104  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
105  };
106 
111  boost::optional<std::string> m_address;
112  boost::optional<uint64_t> m_amount;
113 
114  monero_destination(boost::optional<std::string> address = boost::none, boost::optional<uint64_t> amount = boost::none) : m_address(address), m_amount(amount) {}
115  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
116  static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr<monero_destination>& destination);
117  std::shared_ptr<monero_destination> copy(const std::shared_ptr<monero_destination>& src, const std::shared_ptr<monero_destination>& tgt) const;
118  };
119 
120  // forward declarations
121  struct monero_tx_wallet;
122  struct monero_tx_query;
123  struct monero_tx_set;
124 
131  std::shared_ptr<monero_tx_wallet> m_tx;
132  boost::optional<uint64_t> m_amount;
133  boost::optional<uint32_t> m_account_index;
134 
135  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
136  static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr<monero_transfer>& transfer);
137  virtual boost::optional<bool> is_incoming() const = 0; // derived class must implement
138  std::shared_ptr<monero_transfer> copy(const std::shared_ptr<monero_transfer>& src, const std::shared_ptr<monero_transfer>& tgt) const;
139  boost::optional<bool> is_outgoing() const {
140  if (is_incoming() == boost::none) return boost::none;
141  return !(*is_incoming());
142  }
143  void merge(const std::shared_ptr<monero_transfer>& self, const std::shared_ptr<monero_transfer>& other);
144  };
145 
150  boost::optional<uint32_t> m_subaddress_index;
151  boost::optional<std::string> m_address;
152  boost::optional<uint64_t> m_num_suggested_confirmations;
153 
154  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
155  std::shared_ptr<monero_incoming_transfer> copy(const std::shared_ptr<monero_transfer>& src, const std::shared_ptr<monero_transfer>& tgt) const;
156  std::shared_ptr<monero_incoming_transfer> copy(const std::shared_ptr<monero_incoming_transfer>& src, const std::shared_ptr<monero_incoming_transfer>& tgt) const;
157  boost::optional<bool> is_incoming() const;
158  void merge(const std::shared_ptr<monero_transfer>& self, const std::shared_ptr<monero_transfer>& other);
159  void merge(const std::shared_ptr<monero_incoming_transfer>& self, const std::shared_ptr<monero_incoming_transfer>& other);
160  };
161 
166  std::vector<uint32_t> m_subaddress_indices;
167  std::vector<std::string> m_addresses;
168  std::vector<std::shared_ptr<monero_destination>> m_destinations;
169 
170  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
171  std::shared_ptr<monero_outgoing_transfer> copy(const std::shared_ptr<monero_transfer>& src, const std::shared_ptr<monero_transfer>& tgt) const;
172  std::shared_ptr<monero_outgoing_transfer> copy(const std::shared_ptr<monero_outgoing_transfer>& src, const std::shared_ptr<monero_outgoing_transfer>& tgt) const;
173  boost::optional<bool> is_incoming() const;
174  void merge(const std::shared_ptr<monero_transfer>& self, const std::shared_ptr<monero_transfer>& other);
175  void merge(const std::shared_ptr<monero_outgoing_transfer>& self, const std::shared_ptr<monero_outgoing_transfer>& other);
176  };
177 
184  boost::optional<bool> m_is_incoming;
185  boost::optional<std::string> m_address;
186  std::vector<std::string> m_addresses;
187  boost::optional<uint32_t> m_subaddress_index;
188  std::vector<uint32_t> m_subaddress_indices;
189  std::vector<std::shared_ptr<monero_destination>> m_destinations;
190  boost::optional<bool> m_has_destinations;
191  boost::optional<std::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 std::shared_ptr<monero_transfer_query>& transfer_query);
195  static std::shared_ptr<monero_transfer_query> deserialize_from_block(const std::string& transfer_query_json);
196  std::shared_ptr<monero_transfer_query> copy(const std::shared_ptr<monero_transfer>& src, const std::shared_ptr<monero_transfer>& tgt) const;
197  std::shared_ptr<monero_transfer_query> copy(const std::shared_ptr<monero_transfer_query>& src, const std::shared_ptr<monero_transfer_query>& tgt) const;
198  boost::optional<bool> is_incoming() const;
199  bool meets_criteria(monero_transfer* transfer, bool query_parent = true) 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 std::shared_ptr<monero_output_wallet>& output_wallet);
213  std::shared_ptr<monero_output_wallet> copy(const std::shared_ptr<monero_output>& src, const std::shared_ptr<monero_output>& tgt) const;
214  std::shared_ptr<monero_output_wallet> copy(const std::shared_ptr<monero_output_wallet>& src, const std::shared_ptr<monero_output_wallet>& tgt) const;
215  void merge(const std::shared_ptr<monero_output>& self, const std::shared_ptr<monero_output>& other);
216  void merge(const std::shared_ptr<monero_output_wallet>& self, const std::shared_ptr<monero_output_wallet>& other);
217  };
218 
226  std::vector<uint32_t> m_subaddress_indices;
227  boost::optional<uint64_t> m_min_amount;
228  boost::optional<uint64_t> m_max_amount;
229  boost::optional<std::shared_ptr<monero_tx_query>> m_tx_query;
230 
231  //boost::property_tree::ptree to_property_tree() const;
232  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
233  static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr<monero_output_query>& output_query);
234  static std::shared_ptr<monero_output_query> deserialize_from_block(const std::string& output_query_json);
235  std::shared_ptr<monero_output_query> copy(const std::shared_ptr<monero_output>& src, const std::shared_ptr<monero_output>& tgt) const;
236  std::shared_ptr<monero_output_query> copy(const std::shared_ptr<monero_output_wallet>& src, const std::shared_ptr<monero_output_wallet>& tgt) const; // TODO: necessary to override all super classes?
237  std::shared_ptr<monero_output_query> copy(const std::shared_ptr<monero_output_query>& src, const std::shared_ptr<monero_output_query>& tgt) const;
238  bool meets_criteria(monero_output_wallet* output, bool query_parent = true) const;
239  };
240 
244  struct monero_tx_wallet : public monero_tx {
245  boost::optional<std::shared_ptr<monero_tx_set>> m_tx_set;
246  boost::optional<bool> m_is_incoming;
247  boost::optional<bool> m_is_outgoing;
248  std::vector<std::shared_ptr<monero_incoming_transfer>> m_incoming_transfers;
249  boost::optional<std::shared_ptr<monero_outgoing_transfer>> m_outgoing_transfer;
250  boost::optional<std::string> m_note;
251  boost::optional<bool> m_is_locked;
252  boost::optional<uint64_t> m_input_sum;
253  boost::optional<uint64_t> m_output_sum;
254  boost::optional<std::string> m_change_address;
255  boost::optional<uint64_t> m_change_amount;
256  boost::optional<uint32_t> m_num_dummy_outputs;
257  boost::optional<std::string> m_extra_hex;
258 
259  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
260  static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr<monero_tx_wallet>& tx_wallet);
261  std::shared_ptr<monero_tx_wallet> copy(const std::shared_ptr<monero_tx>& src, const std::shared_ptr<monero_tx>& tgt) const;
262  std::shared_ptr<monero_tx_wallet> copy(const std::shared_ptr<monero_tx_wallet>& src, const std::shared_ptr<monero_tx_wallet>& tgt) const;
263  void merge(const std::shared_ptr<monero_tx>& self, const std::shared_ptr<monero_tx>& other);
264  void merge(const std::shared_ptr<monero_tx_wallet>& self, const std::shared_ptr<monero_tx_wallet>& other);
265  std::vector<std::shared_ptr<monero_transfer>> get_transfers() const;
266  std::vector<std::shared_ptr<monero_transfer>> get_transfers(const monero_transfer_query& query) const;
267  std::vector<std::shared_ptr<monero_transfer>> filter_transfers(const monero_transfer_query& query);
268  std::vector<std::shared_ptr<monero_output_wallet>> get_outputs_wallet() const;
269  std::vector<std::shared_ptr<monero_output_wallet>> get_outputs_wallet(const monero_output_query& query) const;
270  std::vector<std::shared_ptr<monero_output_wallet>> filter_outputs_wallet(const monero_output_query& query);
271  };
272 
279  boost::optional<bool> m_is_outgoing;
280  boost::optional<bool> m_is_incoming;
281  std::vector<std::string> m_hashes;
282  boost::optional<bool> m_has_payment_id;
283  std::vector<std::string> m_payment_ids;
284  boost::optional<uint64_t> m_height;
285  boost::optional<uint64_t> m_min_height;
286  boost::optional<uint64_t> m_max_height;
287  boost::optional<uint64_t> m_include_outputs;
288  boost::optional<std::shared_ptr<monero_transfer_query>> m_transfer_query;
289  boost::optional<std::shared_ptr<monero_output_query>> m_output_query;
290 
291  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
292  static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr<monero_tx_query>& tx_query);
293  static std::shared_ptr<monero_tx_query> deserialize_from_block(const std::string& tx_query_json);
294  std::shared_ptr<monero_tx_query> copy(const std::shared_ptr<monero_tx>& src, const std::shared_ptr<monero_tx>& tgt) const;
295  std::shared_ptr<monero_tx_query> copy(const std::shared_ptr<monero_tx_wallet>& src, const std::shared_ptr<monero_tx_wallet>& tgt) const; // TODO: necessary to override all super classes?
296  std::shared_ptr<monero_tx_query> copy(const std::shared_ptr<monero_tx_query>& src, const std::shared_ptr<monero_tx_query>& tgt) const;
297  bool meets_criteria(monero_tx_wallet* tx, bool query_children = true) const;
298  };
299 
309  std::vector<std::shared_ptr<monero_tx_wallet>> m_txs;
310  boost::optional<std::string> m_signed_tx_hex;
311  boost::optional<std::string> m_unsigned_tx_hex;
312  boost::optional<std::string> m_multisig_tx_hex;
313 
314  //boost::property_tree::ptree to_property_tree() const;
315  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
316  static monero_tx_set deserialize(const std::string& tx_set_json);
317  };
318 
323  std::string m_standard_address;
324  std::string m_payment_id;
325  std::string m_integrated_address;
326 
327  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
328  };
329 
333  enum monero_tx_priority : uint8_t {
334  DEFAULT = 0,
335  UNIMPORTANT,
336  NORMAL,
337  ELEVATED
338  };
339 
344  boost::optional<std::string> m_address;
345  boost::optional<uint64_t> m_amount;
346  std::vector<std::shared_ptr<monero_destination>> m_destinations;
347  boost::optional<std::string> m_payment_id;
348  boost::optional<monero_tx_priority> m_priority;
349  boost::optional<uint32_t> m_ring_size;
350  boost::optional<uint64_t> m_fee;
351  boost::optional<uint32_t> m_account_index;
352  std::vector<uint32_t> m_subaddress_indices;
353  boost::optional<uint64_t> m_unlock_height;
354  boost::optional<bool> m_can_split;
355  boost::optional<bool> m_relay;
356  boost::optional<std::string> m_note;
357  boost::optional<std::string> m_recipient_name;
358  boost::optional<uint64_t> m_below_amount;
359  boost::optional<bool> m_sweep_each_subaddress;
360  boost::optional<std::string> m_key_image;
361 
362  monero_tx_config() {}
363  monero_tx_config(const monero_tx_config& config);
364  monero_tx_config copy() const;
365  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
366  static std::shared_ptr<monero_tx_config> deserialize(const std::string& config_json);
367  std::vector<std::shared_ptr<monero_destination>> get_normalized_destinations() const;
368  };
369 
374  boost::optional<uint64_t> m_height;
375  boost::optional<uint64_t> m_spent_amount;
376  boost::optional<uint64_t> m_unspent_amount;
377 
378  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
379  };
380 
385  bool m_is_good;
386 
387  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
388  };
389 
393  struct monero_check_tx : public monero_check {
394  boost::optional<bool> m_in_tx_pool;
395  boost::optional<uint64_t> m_num_confirmations;
396  boost::optional<uint64_t> m_received_amount;
397 
398  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
399  };
400 
405  boost::optional<uint64_t> m_total_amount;
406  boost::optional<uint64_t> m_unconfirmed_spent_amount;
407 
408  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
409  };
410 
415  bool m_is_multisig;
416  bool m_is_ready;
417  uint32_t m_threshold;
418  uint32_t m_num_participants;
419 
420  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
421  };
422 
429  boost::optional<std::string> m_address;
430  boost::optional<std::string> m_multisig_hex;
431 
432  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
433  };
434 
439  boost::optional<std::string> m_signed_multisig_tx_hex;
440  std::vector<std::string> m_tx_hashes;
441 
442  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
443  };
444 
449  boost::optional<uint64_t> m_index; // TODO: not boost::optional
450  boost::optional<std::string> m_address;
451  boost::optional<std::string> m_description;
452  boost::optional<std::string> m_payment_id;
453 
455  monero_address_book_entry(uint64_t index, const std::string& address, const std::string& description) : m_index(index), m_address(address), m_description(description) {}
456  monero_address_book_entry(uint64_t index, const std::string& address, const std::string& description, const std::string& payment_id) : m_index(index), m_address(address), m_description(description), m_payment_id(payment_id) {}
457  rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
458  };
459 }
monero::monero_tx_set
Definition: monero_wallet_model.h:308
monero
Definition: monero_daemon.cpp:58
monero::monero_transfer_query::to_rapidjson_val
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:751
monero::monero_tx_query
Definition: monero_wallet_model.h:278
monero::monero_tx_wallet
Definition: monero_wallet_model.h:244
monero::serializable_struct
Definition: monero_daemon_model.h:69
monero::monero_account
Definition: monero_wallet_model.h:96
monero::monero_check::to_rapidjson_val
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:1261
monero::monero_multisig_info
Definition: monero_wallet_model.h:414
monero::monero_check_tx
Definition: monero_wallet_model.h:393
monero::monero_multisig_sign_result
Definition: monero_wallet_model.h:438
monero::monero_output_wallet::to_rapidjson_val
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:926
monero::monero_destination
Definition: monero_wallet_model.h:110
monero::monero_key_image_import_result
Definition: monero_wallet_model.h:373
monero::monero_multisig_sign_result::to_rapidjson_val
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:1342
monero::monero_account::to_rapidjson_val
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:113
monero::monero_incoming_transfer::to_rapidjson_val
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:669
monero::monero_multisig_init_result::to_rapidjson_val
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:1328
monero::monero_check_tx::to_rapidjson_val
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:1275
monero::monero_tx_config
Definition: monero_wallet_model.h:343
monero::monero_address_book_entry::to_rapidjson_val
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:1359
monero::monero_output_query::to_rapidjson_val
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:996
monero::monero_outgoing_transfer
Definition: monero_wallet_model.h:165
monero::monero_output_query
Definition: monero_wallet_model.h:225
monero::monero_subaddress
Definition: monero_wallet_model.h:79
monero::monero_sync_result::to_rapidjson_val
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:95
monero::monero_sync_result
Definition: monero_wallet_model.h:67
monero::monero_integrated_address::to_rapidjson_val
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:1227
monero::monero_tx
Definition: monero_daemon_model.h:168
monero::monero_check_reserve
Definition: monero_wallet_model.h:404
monero::monero_integrated_address
Definition: monero_wallet_model.h:322
monero::monero_transfer::to_rapidjson_val
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:615
monero::monero_address_book_entry
Definition: monero_wallet_model.h:448
monero::monero_tx_query::to_rapidjson_val
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:353
monero::monero_output
Definition: monero_daemon_model.h:233
monero::monero_transfer_query
Definition: monero_wallet_model.h:183
monero::monero_check_reserve::to_rapidjson_val
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:1294
monero::monero_tx_wallet::to_rapidjson_val
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:166
monero::monero_output_wallet
Definition: monero_wallet_model.h:205
monero::monero_multisig_init_result
Definition: monero_wallet_model.h:428
monero::monero_multisig_info::to_rapidjson_val
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:1310
monero::monero_check
Definition: monero_wallet_model.h:384
monero::monero_tx_priority
monero_tx_priority
Definition: monero_wallet_model.h:333
monero::monero_tx_config::to_rapidjson_val
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:1133
monero::monero_subaddress::to_rapidjson_val
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:138
monero::monero_tx_set::to_rapidjson_val
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:568
monero::monero_transfer
Definition: monero_wallet_model.h:130
monero::monero_incoming_transfer
Definition: monero_wallet_model.h:149
monero::monero_key_image_import_result::to_rapidjson_val
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:1244
monero::monero_outgoing_transfer::to_rapidjson_val
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:712