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 
79  boost::optional<uint32_t> m_account_index;
80  boost::optional<uint32_t> m_index;
81  boost::optional<string> m_address;
82  boost::optional<string> m_label;
83  boost::optional<uint64_t> m_balance;
84  boost::optional<uint64_t> m_unlocked_balance;
85  boost::optional<uint32_t> m_num_unspent_outputs;
86  boost::optional<bool> m_is_used;
87  boost::optional<uint32_t> m_num_blocks_to_unlock;
88 // BEGIN_KV_SERIALIZE_MAP()
89 // KV_SERIALIZE(m_account_index)
90 // KV_SERIALIZE(index)
91 // KV_SERIALIZE(address)
92 // KV_SERIALIZE(label)
93 // KV_SERIALIZE(balance)
94 // KV_SERIALIZE(m_unlocked_balance)
95 // KV_SERIALIZE(m_num_unspent_outputs)
96 // KV_SERIALIZE(m_is_used)
97 // KV_SERIALIZE(m_num_blocks_to_unlock)
98 // END_KV_SERIALIZE_MAP()
99 
100  boost::property_tree::ptree to_property_tree() const;
101  //void merge(const shared_ptr<monero_subaddress>& self, const shared_ptr<monero_subaddress>& other);
102  };
103 
108  boost::optional<uint32_t> m_index;
109  boost::optional<string> m_primary_address;
110  boost::optional<uint64_t> m_balance;
111  boost::optional<uint64_t> m_unlocked_balance;
112  boost::optional<string> m_tag;
113  vector<monero_subaddress> m_subaddresses;
114 // BEGIN_KV_SERIALIZE_MAP()
115 // KV_SERIALIZE(index)
116 // KV_SERIALIZE(m_primary_address)
117 // KV_SERIALIZE(label)
118 // KV_SERIALIZE(balance)
119 // KV_SERIALIZE(m_unlocked_balance)
120 // KV_SERIALIZE(tag)
121 // KV_SERIALIZE(subaddresses)
122 // END_KV_SERIALIZE_MAP()
123 
124  boost::property_tree::ptree to_property_tree() const;
125  };
126 
131  boost::optional<string> m_address;
132  boost::optional<uint64_t> m_amount;
133 
134  monero_destination() {}
135  monero_destination(const string& address, uint64_t amount) : m_address(address), m_amount(amount) {}
136  shared_ptr<monero_destination> copy(const shared_ptr<monero_destination>& src, const shared_ptr<monero_destination>& tgt) const;
137  boost::property_tree::ptree to_property_tree() const;
138  };
139 
140  // forward declarations
141  struct monero_tx_wallet;
142  struct monero_tx_query;
143  struct monero_tx_set;
144 
149  shared_ptr<monero_tx_wallet> m_tx;
150  boost::optional<uint64_t> m_amount;
151  boost::optional<uint32_t> m_account_index;
152  boost::optional<uint32_t> m_num_suggested_confirmations;
153 
154  virtual boost::optional<bool> is_incoming() const = 0; // derived class must implement
155  shared_ptr<monero_transfer> copy(const shared_ptr<monero_transfer>& src, const shared_ptr<monero_transfer>& tgt) const;
156  boost::optional<bool> is_outgoing() const {
157  if (is_incoming() == boost::none) return boost::none;
158  return !(*is_incoming());
159  }
160  boost::property_tree::ptree to_property_tree() const;
161  void merge(const shared_ptr<monero_transfer>& self, const shared_ptr<monero_transfer>& other);
162  };
163 
168  boost::optional<uint32_t> m_subaddress_index;
169  boost::optional<string> m_address;
170 
171  shared_ptr<monero_incoming_transfer> copy(const shared_ptr<monero_transfer>& src, const shared_ptr<monero_transfer>& tgt) const;
172  shared_ptr<monero_incoming_transfer> copy(const shared_ptr<monero_incoming_transfer>& src, const shared_ptr<monero_incoming_transfer>& tgt) const;
173  boost::optional<bool> is_incoming() const;
174  boost::property_tree::ptree to_property_tree() const;
175  void merge(const shared_ptr<monero_transfer>& self, const shared_ptr<monero_transfer>& other);
176  void merge(const shared_ptr<monero_incoming_transfer>& self, const shared_ptr<monero_incoming_transfer>& other);
177  };
178 
183  vector<uint32_t> m_subaddress_indices;
184  vector<string> m_addresses;
185  vector<shared_ptr<monero_destination>> m_destinations;
186 
187  shared_ptr<monero_outgoing_transfer> copy(const shared_ptr<monero_transfer>& src, const shared_ptr<monero_transfer>& tgt) const;
188  shared_ptr<monero_outgoing_transfer> copy(const shared_ptr<monero_outgoing_transfer>& src, const shared_ptr<monero_outgoing_transfer>& tgt) const;
189  boost::optional<bool> is_incoming() const;
190  boost::property_tree::ptree to_property_tree() const;
191  void merge(const shared_ptr<monero_transfer>& self, const shared_ptr<monero_transfer>& other);
192  void merge(const shared_ptr<monero_outgoing_transfer>& self, const shared_ptr<monero_outgoing_transfer>& other);
193  };
194 
201  boost::optional<bool> m_is_incoming;
202  boost::optional<string> m_address;
203  vector<string> m_addresses;
204  boost::optional<uint32_t> m_subaddress_index;
205  vector<uint32_t> m_subaddress_indices;
206  vector<shared_ptr<monero_destination>> m_destinations;
207  boost::optional<bool> m_has_destinations;
208  boost::optional<shared_ptr<monero_tx_query>> m_tx_query;
209 
210  shared_ptr<monero_transfer_query> copy(const shared_ptr<monero_transfer>& src, const shared_ptr<monero_transfer>& tgt) const;
211  shared_ptr<monero_transfer_query> copy(const shared_ptr<monero_transfer_query>& src, const shared_ptr<monero_transfer_query>& tgt) const;
212  boost::optional<bool> is_incoming() const;
213  boost::property_tree::ptree to_property_tree() const;
214  bool meets_criteria(monero_transfer* transfer) const;
215  };
216 
221  boost::optional<uint32_t> m_account_index;
222  boost::optional<uint32_t> m_subaddress_index;
223  boost::optional<bool> m_is_spent;
224  boost::optional<bool> m_is_unlocked;
225  boost::optional<bool> m_is_frozen;
226 
227  shared_ptr<monero_output_wallet> copy(const shared_ptr<monero_output>& src, const shared_ptr<monero_output>& tgt) const;
228  shared_ptr<monero_output_wallet> copy(const shared_ptr<monero_output_wallet>& src, const shared_ptr<monero_output_wallet>& tgt) const;
229  boost::property_tree::ptree to_property_tree() const;
230  void merge(const shared_ptr<monero_output>& self, const shared_ptr<monero_output>& other);
231  void merge(const shared_ptr<monero_output_wallet>& self, const shared_ptr<monero_output_wallet>& other);
232  };
233 
241  vector<uint32_t> m_subaddress_indices;
242  boost::optional<shared_ptr<monero_tx_query>> m_tx_query;
243 
244  // TODO: necessary to override all super classes?
245  shared_ptr<monero_output_query> copy(const shared_ptr<monero_output>& src, const shared_ptr<monero_output>& tgt) const;
246  shared_ptr<monero_output_query> copy(const shared_ptr<monero_output_wallet>& src, const shared_ptr<monero_output_wallet>& tgt) const;
247  shared_ptr<monero_output_query> copy(const shared_ptr<monero_output_query>& src, const shared_ptr<monero_output_query>& tgt) const;
248  boost::property_tree::ptree to_property_tree() const;
249  bool meets_criteria(monero_output_wallet* output) const;
250  };
251 
252 
256  struct monero_tx_wallet : public monero_tx {
257  boost::optional<shared_ptr<monero_tx_set>> m_tx_set;
258  vector<shared_ptr<monero_incoming_transfer>> m_incoming_transfers;
259  boost::optional<shared_ptr<monero_outgoing_transfer>> m_outgoing_transfer;
260  boost::optional<string> m_note;
261 
262  shared_ptr<monero_tx_wallet> copy(const shared_ptr<monero_tx>& src, const shared_ptr<monero_tx>& tgt) const;
263  shared_ptr<monero_tx_wallet> copy(const shared_ptr<monero_tx_wallet>& src, const shared_ptr<monero_tx_wallet>& tgt) const;
264  bool is_incoming() const;
265  bool is_outgoing() const;
266  boost::property_tree::ptree to_property_tree() const;
267  void merge(const shared_ptr<monero_tx>& self, const shared_ptr<monero_tx>& other);
268  void merge(const shared_ptr<monero_tx_wallet>& self, const shared_ptr<monero_tx_wallet>& other);
269  };
270 
277  boost::optional<bool> m_is_outgoing;
278  boost::optional<bool> m_is_incoming;
279  vector<string> m_tx_ids;
280  boost::optional<bool> m_has_payment_id;
281  vector<string> m_payment_ids;
282  boost::optional<uint64_t> m_height;
283  boost::optional<uint64_t> m_min_height;
284  boost::optional<uint64_t> m_max_height;
285  boost::optional<uint64_t> m_include_outputs;
286  boost::optional<shared_ptr<monero_transfer_query>> m_transfer_query;
287  boost::optional<shared_ptr<monero_output_query>> m_output_query;
288 
289  // TODO: necessary to override all super classes?
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;
292  shared_ptr<monero_tx_query> copy(const shared_ptr<monero_tx_query>& src, const shared_ptr<monero_tx_query>& tgt) const;
293  boost::property_tree::ptree to_property_tree() const;
294  bool meets_criteria(monero_tx_wallet* tx) const;
295  };
296 
306  vector<shared_ptr<monero_tx_wallet>> m_txs;
307  boost::optional<string> m_signed_tx_hex;
308  boost::optional<string> m_unsigned_tx_hex;
309  boost::optional<string> m_multisig_tx_hex;
310 
311  boost::property_tree::ptree to_property_tree() const;
312  };
313 
318  string m_standard_address;
319  string m_payment_id;
320  string m_integrated_address;
321 
322  boost::property_tree::ptree to_property_tree() const;
323  };
324 
328  enum monero_send_priority : uint8_t {
329  DEFAULT = 0,
330  UNIMPORTANT,
331  NORMAL,
332  ELEVATED
333  };
334 
339  vector<shared_ptr<monero_destination>> m_destinations;
340  boost::optional<string> m_payment_id;
341  boost::optional<monero_send_priority> m_priority;
342  boost::optional<uint32_t> m_mixin;
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  monero_send_request copy() const;
359  boost::property_tree::ptree to_property_tree() const;
360  };
361 
366  boost::optional<uint64_t> m_height;
367  boost::optional<uint64_t> m_spent_amount;
368  boost::optional<uint64_t> m_unspent_amount;
369 
370  boost::property_tree::ptree to_property_tree() const;
371  };
372 
377  bool m_is_good;
378 
379  boost::property_tree::ptree to_property_tree() const;
380  };
381 
385  struct monero_check_tx : public monero_check {
386  boost::optional<bool> m_in_tx_pool;
387  boost::optional<uint64_t> m_num_confirmations;
388  boost::optional<uint64_t> m_received_amount;
389 
390  boost::property_tree::ptree to_property_tree() const;
391  };
392 
397  boost::optional<uint64_t> m_total_amount;
398  boost::optional<uint64_t> m_unconfirmed_spent_amount;
399 
400  boost::property_tree::ptree to_property_tree() const;
401  };
402 
407  bool m_is_multisig;
408  bool m_is_ready;
409  uint32_t m_threshold;
410  uint32_t m_num_participants;
411 
412  boost::property_tree::ptree to_property_tree() const;
413  };
414 
421  boost::optional<string> m_address;
422  boost::optional<string> m_multisig_hex;
423 
424  boost::property_tree::ptree to_property_tree() const;
425  };
426 
431  boost::optional<string> m_signed_multisig_tx_hex;
432  vector<string> m_tx_ids;
433 
434  boost::property_tree::ptree to_property_tree() const;
435  };
436 }
Definition: monero_wallet_model.h:406
Definition: monero_daemon.cpp:58
Definition: monero_wallet_model.h:130
Definition: monero_wallet_model.h:317
Definition: monero_wallet_model.h:420
Definition: monero_wallet_model.h:167
Definition: monero_wallet_model.h:276
Definition: monero_daemon_model.h:68
Definition: monero_wallet_model.h:430
Definition: monero_daemon_model.h:218
Definition: monero_daemon_model.h:156
Definition: monero_wallet_model.h:256
monero_send_priority
Definition: monero_wallet_model.h:328
Definition: monero_wallet_model.h:396
Definition: monero_wallet_model.h:182
Definition: monero_wallet_model.h:68
Definition: monero_wallet_model.h:305
Definition: monero_wallet_model.h:385
Definition: monero_wallet_model.h:240
Definition: monero_wallet_model.h:338
Definition: monero_wallet_model.h:107
Definition: monero_wallet_model.h:78
Definition: monero_wallet_model.h:220
Definition: monero_wallet_model.h:200
Definition: monero_wallet_model.h:365
Definition: monero_wallet_model.h:376
Definition: monero_wallet_model.h:148