Monero C++ Library
Loading...
Searching...
No Matches
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<monero_rpc_connection> m_server;
72 boost::optional<std::string> m_seed;
73 boost::optional<std::string> m_seed_offset;
74 boost::optional<std::string> m_primary_address;
75 boost::optional<std::string> m_private_view_key;
76 boost::optional<std::string> m_private_spend_key;
77 boost::optional<uint64_t> m_restore_height;
78 boost::optional<std::string> m_language;
79 boost::optional<bool> m_save_current;
80 boost::optional<uint64_t> m_account_lookahead;
81 boost::optional<uint64_t> m_subaddress_lookahead;
82 boost::optional<bool> m_is_multisig;
83
86 monero_wallet_config copy() const;
87 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
88 static std::shared_ptr<monero_wallet_config> deserialize(const std::string& config_json);
89 };
90
95 uint64_t m_num_blocks_fetched;
96 bool m_received_money;
98 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) {}
99
100 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
101 };
102
107 boost::optional<uint32_t> m_account_index;
108 boost::optional<uint32_t> m_index;
109 boost::optional<std::string> m_address;
110 boost::optional<std::string> m_label;
111 boost::optional<uint64_t> m_balance;
112 boost::optional<uint64_t> m_unlocked_balance;
113 boost::optional<uint64_t> m_num_unspent_outputs;
114 boost::optional<bool> m_is_used;
115 boost::optional<uint64_t> m_num_blocks_to_unlock;
116
117 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
118 };
119
124 boost::optional<uint32_t> m_index;
125 boost::optional<std::string> m_primary_address;
126 boost::optional<uint64_t> m_balance;
127 boost::optional<uint64_t> m_unlocked_balance;
128 boost::optional<std::string> m_tag;
129 std::vector<monero_subaddress> m_subaddresses;
130
131 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
132 };
133
138 boost::optional<std::string> m_address;
139 boost::optional<uint64_t> m_amount;
140
141 monero_destination(boost::optional<std::string> address = boost::none, boost::optional<uint64_t> amount = boost::none) : m_address(address), m_amount(amount) {}
142 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
143 static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr<monero_destination>& destination);
144 std::shared_ptr<monero_destination> copy(const std::shared_ptr<monero_destination>& src, const std::shared_ptr<monero_destination>& tgt) const;
145 };
146
147 // forward declarations
148 struct monero_tx_wallet;
149 struct monero_tx_query;
150 struct monero_tx_set;
151
158 std::shared_ptr<monero_tx_wallet> m_tx;
159 boost::optional<uint64_t> m_amount;
160 boost::optional<uint32_t> m_account_index;
161
162 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
163 static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr<monero_transfer>& transfer);
164 virtual boost::optional<bool> is_incoming() const = 0; // derived class must implement
165 std::shared_ptr<monero_transfer> copy(const std::shared_ptr<monero_transfer>& src, const std::shared_ptr<monero_transfer>& tgt) const;
166 boost::optional<bool> is_outgoing() const {
167 if (is_incoming() == boost::none) return boost::none;
168 return !(*is_incoming());
169 }
170 void merge(const std::shared_ptr<monero_transfer>& self, const std::shared_ptr<monero_transfer>& other);
171 };
172
177 boost::optional<uint32_t> m_subaddress_index;
178 boost::optional<std::string> m_address;
179 boost::optional<uint64_t> m_num_suggested_confirmations;
180
181 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
182 std::shared_ptr<monero_incoming_transfer> copy(const std::shared_ptr<monero_transfer>& src, const std::shared_ptr<monero_transfer>& tgt) const;
183 std::shared_ptr<monero_incoming_transfer> copy(const std::shared_ptr<monero_incoming_transfer>& src, const std::shared_ptr<monero_incoming_transfer>& tgt) const;
184 boost::optional<bool> is_incoming() const;
185 void merge(const std::shared_ptr<monero_transfer>& self, const std::shared_ptr<monero_transfer>& other);
186 void merge(const std::shared_ptr<monero_incoming_transfer>& self, const std::shared_ptr<monero_incoming_transfer>& other);
187 };
188
193 std::vector<uint32_t> m_subaddress_indices;
194 std::vector<std::string> m_addresses;
195 std::vector<std::shared_ptr<monero_destination>> m_destinations;
196
197 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
198 std::shared_ptr<monero_outgoing_transfer> copy(const std::shared_ptr<monero_transfer>& src, const std::shared_ptr<monero_transfer>& tgt) const;
199 std::shared_ptr<monero_outgoing_transfer> copy(const std::shared_ptr<monero_outgoing_transfer>& src, const std::shared_ptr<monero_outgoing_transfer>& tgt) const;
200 boost::optional<bool> is_incoming() const;
201 void merge(const std::shared_ptr<monero_transfer>& self, const std::shared_ptr<monero_transfer>& other);
202 void merge(const std::shared_ptr<monero_outgoing_transfer>& self, const std::shared_ptr<monero_outgoing_transfer>& other);
203 };
204
211 boost::optional<bool> m_is_incoming;
212 boost::optional<std::string> m_address;
213 std::vector<std::string> m_addresses;
214 boost::optional<uint32_t> m_subaddress_index;
215 std::vector<uint32_t> m_subaddress_indices;
216 std::vector<std::shared_ptr<monero_destination>> m_destinations;
217 boost::optional<bool> m_has_destinations;
218 boost::optional<std::shared_ptr<monero_tx_query>> m_tx_query;
219
220 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
221 static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr<monero_transfer_query>& transfer_query);
222 static std::shared_ptr<monero_transfer_query> deserialize_from_block(const std::string& transfer_query_json);
223 std::shared_ptr<monero_transfer_query> copy(const std::shared_ptr<monero_transfer>& src, const std::shared_ptr<monero_transfer>& tgt) const;
224 std::shared_ptr<monero_transfer_query> copy(const std::shared_ptr<monero_transfer_query>& src, const std::shared_ptr<monero_transfer_query>& tgt) const;
225 boost::optional<bool> is_incoming() const;
226 bool meets_criteria(monero_transfer* transfer, bool query_parent = true) const;
227 };
228
233 boost::optional<uint32_t> m_account_index;
234 boost::optional<uint32_t> m_subaddress_index;
235 boost::optional<bool> m_is_spent;
236 boost::optional<bool> m_is_frozen;
237
238 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
239 static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr<monero_output_wallet>& output_wallet);
240 std::shared_ptr<monero_output_wallet> copy(const std::shared_ptr<monero_output>& src, const std::shared_ptr<monero_output>& tgt) const;
241 std::shared_ptr<monero_output_wallet> copy(const std::shared_ptr<monero_output_wallet>& src, const std::shared_ptr<monero_output_wallet>& tgt) const;
242 void merge(const std::shared_ptr<monero_output>& self, const std::shared_ptr<monero_output>& other);
243 void merge(const std::shared_ptr<monero_output_wallet>& self, const std::shared_ptr<monero_output_wallet>& other);
244 };
245
253 std::vector<uint32_t> m_subaddress_indices;
254 boost::optional<uint64_t> m_min_amount;
255 boost::optional<uint64_t> m_max_amount;
256 boost::optional<std::shared_ptr<monero_tx_query>> m_tx_query;
257
258 //boost::property_tree::ptree to_property_tree() const;
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_output_query>& output_query);
261 static std::shared_ptr<monero_output_query> deserialize_from_block(const std::string& output_query_json);
262 std::shared_ptr<monero_output_query> copy(const std::shared_ptr<monero_output>& src, const std::shared_ptr<monero_output>& tgt) const;
263 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?
264 std::shared_ptr<monero_output_query> copy(const std::shared_ptr<monero_output_query>& src, const std::shared_ptr<monero_output_query>& tgt) const;
265 bool meets_criteria(monero_output_wallet* output, bool query_parent = true) const;
266 };
267
271 struct monero_tx_wallet : public monero_tx {
272 boost::optional<std::shared_ptr<monero_tx_set>> m_tx_set;
273 boost::optional<bool> m_is_incoming;
274 boost::optional<bool> m_is_outgoing;
275 std::vector<std::shared_ptr<monero_incoming_transfer>> m_incoming_transfers;
276 boost::optional<std::shared_ptr<monero_outgoing_transfer>> m_outgoing_transfer;
277 boost::optional<std::string> m_note;
278 boost::optional<bool> m_is_locked;
279 boost::optional<uint64_t> m_input_sum;
280 boost::optional<uint64_t> m_output_sum;
281 boost::optional<std::string> m_change_address;
282 boost::optional<uint64_t> m_change_amount;
283 boost::optional<uint32_t> m_num_dummy_outputs;
284 boost::optional<std::string> m_extra_hex;
285
286 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
287 static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr<monero_tx_wallet>& tx_wallet);
288 std::shared_ptr<monero_tx_wallet> copy(const std::shared_ptr<monero_tx>& src, const std::shared_ptr<monero_tx>& tgt) const;
289 std::shared_ptr<monero_tx_wallet> copy(const std::shared_ptr<monero_tx_wallet>& src, const std::shared_ptr<monero_tx_wallet>& tgt) const;
290 void merge(const std::shared_ptr<monero_tx>& self, const std::shared_ptr<monero_tx>& other);
291 void merge(const std::shared_ptr<monero_tx_wallet>& self, const std::shared_ptr<monero_tx_wallet>& other);
292 std::vector<std::shared_ptr<monero_transfer>> get_transfers() const;
293 std::vector<std::shared_ptr<monero_transfer>> get_transfers(const monero_transfer_query& query) const;
294 std::vector<std::shared_ptr<monero_transfer>> filter_transfers(const monero_transfer_query& query);
295 std::vector<std::shared_ptr<monero_output_wallet>> get_outputs_wallet() const;
296 std::vector<std::shared_ptr<monero_output_wallet>> get_outputs_wallet(const monero_output_query& query) const;
297 std::vector<std::shared_ptr<monero_output_wallet>> filter_outputs_wallet(const monero_output_query& query);
298 };
299
306 boost::optional<bool> m_is_outgoing;
307 boost::optional<bool> m_is_incoming;
308 std::vector<std::string> m_hashes;
309 boost::optional<bool> m_has_payment_id;
310 std::vector<std::string> m_payment_ids;
311 boost::optional<uint64_t> m_height;
312 boost::optional<uint64_t> m_min_height;
313 boost::optional<uint64_t> m_max_height;
314 boost::optional<uint64_t> m_include_outputs;
315 boost::optional<std::shared_ptr<monero_transfer_query>> m_transfer_query;
316 boost::optional<std::shared_ptr<monero_output_query>> m_input_query;
317 boost::optional<std::shared_ptr<monero_output_query>> m_output_query;
318
319 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
320 static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr<monero_tx_query>& tx_query);
321 static std::shared_ptr<monero_tx_query> deserialize_from_block(const std::string& tx_query_json);
322 std::shared_ptr<monero_tx_query> copy(const std::shared_ptr<monero_tx>& src, const std::shared_ptr<monero_tx>& tgt) const;
323 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?
324 std::shared_ptr<monero_tx_query> copy(const std::shared_ptr<monero_tx_query>& src, const std::shared_ptr<monero_tx_query>& tgt) const;
325 bool meets_criteria(monero_tx_wallet* tx, bool query_children = true) const;
326 };
327
337 std::vector<std::shared_ptr<monero_tx_wallet>> m_txs;
338 boost::optional<std::string> m_signed_tx_hex;
339 boost::optional<std::string> m_unsigned_tx_hex;
340 boost::optional<std::string> m_multisig_tx_hex;
341
342 //boost::property_tree::ptree to_property_tree() const;
343 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
344 static monero_tx_set deserialize(const std::string& tx_set_json);
345 };
346
351 std::string m_standard_address;
352 std::string m_payment_id;
353 std::string m_integrated_address;
354
355 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
356 };
357
361 enum monero_tx_priority : uint8_t {
362 DEFAULT = 0,
363 UNIMPORTANT,
364 NORMAL,
365 ELEVATED
366 };
367
372 boost::optional<std::string> m_address;
373 boost::optional<uint64_t> m_amount;
374 std::vector<std::shared_ptr<monero_destination>> m_destinations;
375 std::vector<uint32_t> m_subtract_fee_from;
376 boost::optional<std::string> m_payment_id;
377 boost::optional<monero_tx_priority> m_priority;
378 boost::optional<uint32_t> m_ring_size;
379 boost::optional<uint64_t> m_fee;
380 boost::optional<uint32_t> m_account_index;
381 std::vector<uint32_t> m_subaddress_indices;
382 boost::optional<bool> m_can_split;
383 boost::optional<bool> m_relay;
384 boost::optional<std::string> m_note;
385 boost::optional<std::string> m_recipient_name;
386 boost::optional<uint64_t> m_below_amount;
387 boost::optional<bool> m_sweep_each_subaddress;
388 boost::optional<std::string> m_key_image;
389
391 monero_tx_config(const monero_tx_config& config);
392 monero_tx_config copy() const;
393 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
394 static std::shared_ptr<monero_tx_config> deserialize(const std::string& config_json);
395 std::vector<std::shared_ptr<monero_destination>> get_normalized_destinations() const;
396 };
397
402 boost::optional<uint64_t> m_height;
403 boost::optional<uint64_t> m_spent_amount;
404 boost::optional<uint64_t> m_unspent_amount;
405
406 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
407 };
408
413 SIGN_WITH_SPEND_KEY = 0,
414 SIGN_WITH_VIEW_KEY
415 };
416
421 bool m_is_good;
422 uint32_t m_version;
423 bool m_is_old;
424 monero_message_signature_type m_signature_type;
425
426 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
427 };
428
433 bool m_is_good;
434
435 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
436 };
437
442 boost::optional<bool> m_in_tx_pool;
443 boost::optional<uint64_t> m_num_confirmations;
444 boost::optional<uint64_t> m_received_amount;
445
446 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
447 };
448
453 boost::optional<uint64_t> m_total_amount;
454 boost::optional<uint64_t> m_unconfirmed_spent_amount;
455
456 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
457 };
458
463 bool m_is_multisig;
464 bool m_is_ready;
465 uint32_t m_threshold;
466 uint32_t m_num_participants;
467
468 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
469 };
470
477 boost::optional<std::string> m_address;
478 boost::optional<std::string> m_multisig_hex;
479
480 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
481 };
482
487 boost::optional<std::string> m_signed_multisig_tx_hex;
488 std::vector<std::string> m_tx_hashes;
489
490 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
491 };
492
497 boost::optional<uint64_t> m_index; // TODO: not boost::optional
498 boost::optional<std::string> m_address;
499 boost::optional<std::string> m_description;
500 boost::optional<std::string> m_payment_id;
501
503 monero_address_book_entry(uint64_t index, const std::string& address, const std::string& description) : m_index(index), m_address(address), m_description(description) {}
504 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) {}
505 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
506 };
507}
Definition monero_daemon.cpp:58
monero_message_signature_type
Definition monero_wallet_model.h:412
monero_tx_priority
Definition monero_wallet_model.h:361
Definition monero_wallet_model.h:123
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:210
Definition monero_wallet_model.h:496
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:1538
Definition monero_wallet_model.h:452
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:1473
Definition monero_wallet_model.h:441
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:1454
Definition monero_wallet_model.h:432
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:1440
Definition monero_wallet_model.h:137
Definition monero_wallet_model.h:176
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:797
Definition monero_wallet_model.h:350
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:1383
Definition monero_wallet_model.h:401
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:1400
Definition monero_wallet_model.h:420
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:1417
Definition monero_wallet_model.h:462
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:1489
Definition monero_wallet_model.h:476
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:1507
Definition monero_wallet_model.h:486
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:1521
Definition monero_wallet_model.h:192
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:844
Definition monero_wallet_model.h:252
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:1149
Definition monero_wallet_model.h:232
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:1079
Definition monero_daemon_model.h:236
Definition monero_wallet_model.h:106
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:235
Definition monero_wallet_model.h:94
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:192
Definition monero_wallet_model.h:210
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:904
Definition monero_wallet_model.h:157
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:741
Definition monero_wallet_model.h:371
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:1289
Definition monero_wallet_model.h:305
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:458
Definition monero_wallet_model.h:336
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:694
Definition monero_wallet_model.h:271
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:263
Definition monero_daemon_model.h:171
Definition monero_wallet_model.h:67
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:117
Definition monero_daemon_model.h:69