Monero C++ Library
monero_wallet_model.h
1
53#pragma once
54
55#include "daemon/monero_daemon_model.h"
56
57using namespace monero;
58
62namespace monero {
63
68 boost::optional<std::string> m_path;
69 boost::optional<std::string> m_password;
70 boost::optional<monero_network_type> m_network_type;
71 boost::optional<std::string> m_server_uri;
72 boost::optional<std::string> m_server_username;
73 boost::optional<std::string> m_server_password;
74 boost::optional<std::string> m_mnemonic;
75 boost::optional<std::string> m_seed_offset;
76 boost::optional<std::string> m_primary_address;
77 boost::optional<std::string> m_private_view_key;
78 boost::optional<std::string> m_private_spend_key;
79 boost::optional<uint64_t> m_restore_height;
80 boost::optional<std::string> m_language;
81 boost::optional<bool> m_save_current;
82 boost::optional<uint64_t> m_account_lookahead;
83 boost::optional<uint64_t> m_subaddress_lookahead;
84
87 monero_wallet_config copy() const;
88 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
89 static std::shared_ptr<monero_wallet_config> deserialize(const std::string& config_json);
90 void set_server(const monero_rpc_connection& server);
91 monero_rpc_connection get_server() const;
92 };
93
98 uint64_t m_num_blocks_fetched;
99 bool m_received_money;
101 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) {}
102
103 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
104 };
105
110 boost::optional<uint32_t> m_account_index;
111 boost::optional<uint32_t> m_index;
112 boost::optional<std::string> m_address;
113 boost::optional<std::string> m_label;
114 boost::optional<uint64_t> m_balance;
115 boost::optional<uint64_t> m_unlocked_balance;
116 boost::optional<uint64_t> m_num_unspent_outputs;
117 boost::optional<bool> m_is_used;
118 boost::optional<uint64_t> m_num_blocks_to_unlock;
119
120 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
121 };
122
127 boost::optional<uint32_t> m_index;
128 boost::optional<std::string> m_primary_address;
129 boost::optional<uint64_t> m_balance;
130 boost::optional<uint64_t> m_unlocked_balance;
131 boost::optional<std::string> m_tag;
132 std::vector<monero_subaddress> m_subaddresses;
133
134 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
135 };
136
141 boost::optional<std::string> m_address;
142 boost::optional<uint64_t> m_amount;
143
144 monero_destination(boost::optional<std::string> address = boost::none, boost::optional<uint64_t> amount = boost::none) : m_address(address), m_amount(amount) {}
145 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
146 static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr<monero_destination>& destination);
147 std::shared_ptr<monero_destination> copy(const std::shared_ptr<monero_destination>& src, const std::shared_ptr<monero_destination>& tgt) const;
148 };
149
150 // forward declarations
151 struct monero_tx_wallet;
152 struct monero_tx_query;
153 struct monero_tx_set;
154
161 std::shared_ptr<monero_tx_wallet> m_tx;
162 boost::optional<uint64_t> m_amount;
163 boost::optional<uint32_t> m_account_index;
164
165 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
166 static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr<monero_transfer>& transfer);
167 virtual boost::optional<bool> is_incoming() const = 0; // derived class must implement
168 std::shared_ptr<monero_transfer> copy(const std::shared_ptr<monero_transfer>& src, const std::shared_ptr<monero_transfer>& tgt) const;
169 boost::optional<bool> is_outgoing() const {
170 if (is_incoming() == boost::none) return boost::none;
171 return !(*is_incoming());
172 }
173 void merge(const std::shared_ptr<monero_transfer>& self, const std::shared_ptr<monero_transfer>& other);
174 };
175
180 boost::optional<uint32_t> m_subaddress_index;
181 boost::optional<std::string> m_address;
182 boost::optional<uint64_t> m_num_suggested_confirmations;
183
184 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
185 std::shared_ptr<monero_incoming_transfer> copy(const std::shared_ptr<monero_transfer>& src, const std::shared_ptr<monero_transfer>& tgt) const;
186 std::shared_ptr<monero_incoming_transfer> copy(const std::shared_ptr<monero_incoming_transfer>& src, const std::shared_ptr<monero_incoming_transfer>& tgt) const;
187 boost::optional<bool> is_incoming() const;
188 void merge(const std::shared_ptr<monero_transfer>& self, const std::shared_ptr<monero_transfer>& other);
189 void merge(const std::shared_ptr<monero_incoming_transfer>& self, const std::shared_ptr<monero_incoming_transfer>& other);
190 };
191
196 std::vector<uint32_t> m_subaddress_indices;
197 std::vector<std::string> m_addresses;
198 std::vector<std::shared_ptr<monero_destination>> m_destinations;
199
200 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
201 std::shared_ptr<monero_outgoing_transfer> copy(const std::shared_ptr<monero_transfer>& src, const std::shared_ptr<monero_transfer>& tgt) const;
202 std::shared_ptr<monero_outgoing_transfer> copy(const std::shared_ptr<monero_outgoing_transfer>& src, const std::shared_ptr<monero_outgoing_transfer>& tgt) const;
203 boost::optional<bool> is_incoming() const;
204 void merge(const std::shared_ptr<monero_transfer>& self, const std::shared_ptr<monero_transfer>& other);
205 void merge(const std::shared_ptr<monero_outgoing_transfer>& self, const std::shared_ptr<monero_outgoing_transfer>& other);
206 };
207
214 boost::optional<bool> m_is_incoming;
215 boost::optional<std::string> m_address;
216 std::vector<std::string> m_addresses;
217 boost::optional<uint32_t> m_subaddress_index;
218 std::vector<uint32_t> m_subaddress_indices;
219 std::vector<std::shared_ptr<monero_destination>> m_destinations;
220 boost::optional<bool> m_has_destinations;
221 boost::optional<std::shared_ptr<monero_tx_query>> m_tx_query;
222
223 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
224 static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr<monero_transfer_query>& transfer_query);
225 static std::shared_ptr<monero_transfer_query> deserialize_from_block(const std::string& transfer_query_json);
226 std::shared_ptr<monero_transfer_query> copy(const std::shared_ptr<monero_transfer>& src, const std::shared_ptr<monero_transfer>& tgt) const;
227 std::shared_ptr<monero_transfer_query> copy(const std::shared_ptr<monero_transfer_query>& src, const std::shared_ptr<monero_transfer_query>& tgt) const;
228 boost::optional<bool> is_incoming() const;
229 bool meets_criteria(monero_transfer* transfer, bool query_parent = true) const;
230 };
231
236 boost::optional<uint32_t> m_account_index;
237 boost::optional<uint32_t> m_subaddress_index;
238 boost::optional<bool> m_is_spent;
239 boost::optional<bool> m_is_frozen;
240
241 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
242 static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr<monero_output_wallet>& output_wallet);
243 std::shared_ptr<monero_output_wallet> copy(const std::shared_ptr<monero_output>& src, const std::shared_ptr<monero_output>& tgt) const;
244 std::shared_ptr<monero_output_wallet> copy(const std::shared_ptr<monero_output_wallet>& src, const std::shared_ptr<monero_output_wallet>& tgt) const;
245 void merge(const std::shared_ptr<monero_output>& self, const std::shared_ptr<monero_output>& other);
246 void merge(const std::shared_ptr<monero_output_wallet>& self, const std::shared_ptr<monero_output_wallet>& other);
247 };
248
256 std::vector<uint32_t> m_subaddress_indices;
257 boost::optional<uint64_t> m_min_amount;
258 boost::optional<uint64_t> m_max_amount;
259 boost::optional<std::shared_ptr<monero_tx_query>> m_tx_query;
260
261 //boost::property_tree::ptree to_property_tree() const;
262 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
263 static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr<monero_output_query>& output_query);
264 static std::shared_ptr<monero_output_query> deserialize_from_block(const std::string& output_query_json);
265 std::shared_ptr<monero_output_query> copy(const std::shared_ptr<monero_output>& src, const std::shared_ptr<monero_output>& tgt) const;
266 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?
267 std::shared_ptr<monero_output_query> copy(const std::shared_ptr<monero_output_query>& src, const std::shared_ptr<monero_output_query>& tgt) const;
268 bool meets_criteria(monero_output_wallet* output, bool query_parent = true) const;
269 };
270
274 struct monero_tx_wallet : public monero_tx {
275 boost::optional<std::shared_ptr<monero_tx_set>> m_tx_set;
276 boost::optional<bool> m_is_incoming;
277 boost::optional<bool> m_is_outgoing;
278 std::vector<std::shared_ptr<monero_incoming_transfer>> m_incoming_transfers;
279 boost::optional<std::shared_ptr<monero_outgoing_transfer>> m_outgoing_transfer;
280 boost::optional<std::string> m_note;
281 boost::optional<bool> m_is_locked;
282 boost::optional<uint64_t> m_input_sum;
283 boost::optional<uint64_t> m_output_sum;
284 boost::optional<std::string> m_change_address;
285 boost::optional<uint64_t> m_change_amount;
286 boost::optional<uint32_t> m_num_dummy_outputs;
287 boost::optional<std::string> m_extra_hex;
288
289 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
290 static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr<monero_tx_wallet>& tx_wallet);
291 std::shared_ptr<monero_tx_wallet> copy(const std::shared_ptr<monero_tx>& src, const std::shared_ptr<monero_tx>& tgt) const;
292 std::shared_ptr<monero_tx_wallet> copy(const std::shared_ptr<monero_tx_wallet>& src, const std::shared_ptr<monero_tx_wallet>& tgt) const;
293 void merge(const std::shared_ptr<monero_tx>& self, const std::shared_ptr<monero_tx>& other);
294 void merge(const std::shared_ptr<monero_tx_wallet>& self, const std::shared_ptr<monero_tx_wallet>& other);
295 std::vector<std::shared_ptr<monero_transfer>> get_transfers() const;
296 std::vector<std::shared_ptr<monero_transfer>> get_transfers(const monero_transfer_query& query) const;
297 std::vector<std::shared_ptr<monero_transfer>> filter_transfers(const monero_transfer_query& query);
298 std::vector<std::shared_ptr<monero_output_wallet>> get_outputs_wallet() const;
299 std::vector<std::shared_ptr<monero_output_wallet>> get_outputs_wallet(const monero_output_query& query) const;
300 std::vector<std::shared_ptr<monero_output_wallet>> filter_outputs_wallet(const monero_output_query& query);
301 };
302
309 boost::optional<bool> m_is_outgoing;
310 boost::optional<bool> m_is_incoming;
311 std::vector<std::string> m_hashes;
312 boost::optional<bool> m_has_payment_id;
313 std::vector<std::string> m_payment_ids;
314 boost::optional<uint64_t> m_height;
315 boost::optional<uint64_t> m_min_height;
316 boost::optional<uint64_t> m_max_height;
317 boost::optional<uint64_t> m_include_outputs;
318 boost::optional<std::shared_ptr<monero_transfer_query>> m_transfer_query;
319 boost::optional<std::shared_ptr<monero_output_query>> m_input_query;
320 boost::optional<std::shared_ptr<monero_output_query>> m_output_query;
321
322 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
323 static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr<monero_tx_query>& tx_query);
324 static std::shared_ptr<monero_tx_query> deserialize_from_block(const std::string& tx_query_json);
325 std::shared_ptr<monero_tx_query> copy(const std::shared_ptr<monero_tx>& src, const std::shared_ptr<monero_tx>& tgt) const;
326 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?
327 std::shared_ptr<monero_tx_query> copy(const std::shared_ptr<monero_tx_query>& src, const std::shared_ptr<monero_tx_query>& tgt) const;
328 bool meets_criteria(monero_tx_wallet* tx, bool query_children = true) const;
329 };
330
340 std::vector<std::shared_ptr<monero_tx_wallet>> m_txs;
341 boost::optional<std::string> m_signed_tx_hex;
342 boost::optional<std::string> m_unsigned_tx_hex;
343 boost::optional<std::string> m_multisig_tx_hex;
344
345 //boost::property_tree::ptree to_property_tree() const;
346 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
347 static monero_tx_set deserialize(const std::string& tx_set_json);
348 };
349
354 std::string m_standard_address;
355 std::string m_payment_id;
356 std::string m_integrated_address;
357
358 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
359 };
360
364 enum monero_tx_priority : uint8_t {
365 DEFAULT = 0,
366 UNIMPORTANT,
367 NORMAL,
368 ELEVATED
369 };
370
375 boost::optional<std::string> m_address;
376 boost::optional<uint64_t> m_amount;
377 std::vector<std::shared_ptr<monero_destination>> m_destinations;
378 boost::optional<std::string> m_payment_id;
379 boost::optional<monero_tx_priority> m_priority;
380 boost::optional<uint32_t> m_ring_size;
381 boost::optional<uint64_t> m_fee;
382 boost::optional<uint32_t> m_account_index;
383 std::vector<uint32_t> m_subaddress_indices;
384 boost::optional<uint64_t> m_unlock_height;
385 boost::optional<bool> m_can_split;
386 boost::optional<bool> m_relay;
387 boost::optional<std::string> m_note;
388 boost::optional<std::string> m_recipient_name;
389 boost::optional<uint64_t> m_below_amount;
390 boost::optional<bool> m_sweep_each_subaddress;
391 boost::optional<std::string> m_key_image;
392
394 monero_tx_config(const monero_tx_config& config);
395 monero_tx_config copy() const;
396 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
397 static std::shared_ptr<monero_tx_config> deserialize(const std::string& config_json);
398 std::vector<std::shared_ptr<monero_destination>> get_normalized_destinations() const;
399 };
400
405 boost::optional<uint64_t> m_height;
406 boost::optional<uint64_t> m_spent_amount;
407 boost::optional<uint64_t> m_unspent_amount;
408
409 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
410 };
411
416 SIGN_WITH_SPEND_KEY = 0,
417 SIGN_WITH_VIEW_KEY
418 };
419
424 bool m_is_good;
425 uint32_t m_version;
426 bool m_is_old;
427 monero_message_signature_type m_signature_type;
428
429 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
430 };
431
436 bool m_is_good;
437
438 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
439 };
440
445 boost::optional<bool> m_in_tx_pool;
446 boost::optional<uint64_t> m_num_confirmations;
447 boost::optional<uint64_t> m_received_amount;
448
449 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
450 };
451
456 boost::optional<uint64_t> m_total_amount;
457 boost::optional<uint64_t> m_unconfirmed_spent_amount;
458
459 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
460 };
461
466 bool m_is_multisig;
467 bool m_is_ready;
468 uint32_t m_threshold;
469 uint32_t m_num_participants;
470
471 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
472 };
473
480 boost::optional<std::string> m_address;
481 boost::optional<std::string> m_multisig_hex;
482
483 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
484 };
485
490 boost::optional<std::string> m_signed_multisig_tx_hex;
491 std::vector<std::string> m_tx_hashes;
492
493 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
494 };
495
500 boost::optional<uint64_t> m_index; // TODO: not boost::optional
501 boost::optional<std::string> m_address;
502 boost::optional<std::string> m_description;
503 boost::optional<std::string> m_payment_id;
504
506 monero_address_book_entry(uint64_t index, const std::string& address, const std::string& description) : m_index(index), m_address(address), m_description(description) {}
507 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) {}
508 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
509 };
510}
Definition: monero_daemon.cpp:58
monero_message_signature_type
Definition: monero_wallet_model.h:415
monero_tx_priority
Definition: monero_wallet_model.h:364
Definition: monero_wallet_model.h:126
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:224
Definition: monero_wallet_model.h:499
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:1552
Definition: monero_wallet_model.h:455
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:1487
Definition: monero_wallet_model.h:444
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:1468
Definition: monero_wallet_model.h:435
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:1454
Definition: monero_wallet_model.h:140
Definition: monero_wallet_model.h:179
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:811
Definition: monero_wallet_model.h:353
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:1397
Definition: monero_wallet_model.h:404
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:1414
Definition: monero_wallet_model.h:423
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:1431
Definition: monero_wallet_model.h:465
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:1503
Definition: monero_wallet_model.h:479
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:1521
Definition: monero_wallet_model.h:489
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:1535
Definition: monero_wallet_model.h:195
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:858
Definition: monero_wallet_model.h:255
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:1163
Definition: monero_wallet_model.h:235
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:1093
Definition: monero_daemon_model.h:235
Definition: monero_daemon_model.h:109
Definition: monero_wallet_model.h:109
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:249
Definition: monero_wallet_model.h:97
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:206
Definition: monero_wallet_model.h:213
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:918
Definition: monero_wallet_model.h:160
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:755
Definition: monero_wallet_model.h:374
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:1303
Definition: monero_wallet_model.h:308
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:472
Definition: monero_wallet_model.h:339
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:708
Definition: monero_wallet_model.h:274
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:277
Definition: monero_daemon_model.h:170
Definition: monero_wallet_model.h:67
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition: monero_wallet_model.cpp:118
Definition: monero_daemon_model.h:69