Monero C++ Library
Loading...
Searching...
No Matches
monero_wallet_model.h
1
52
53#pragma once
54
55#include "daemon/monero_daemon_model.h"
56
57using namespace monero;
58
62namespace monero {
63
67 struct monero_wallet_config : public serializable_struct {
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 boost::optional<bool> m_regtest;
84
85 monero_wallet_config() {}
86 monero_wallet_config(const monero_wallet_config& config);
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 };
91
95 struct monero_sync_result : public serializable_struct {
96 uint64_t m_num_blocks_fetched;
97 bool m_received_money;
98 monero_sync_result() {}
99 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) {}
100
101 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
102 };
103
108 boost::optional<uint32_t> m_account_index;
109 boost::optional<uint32_t> m_index;
110 boost::optional<std::string> m_address;
111 boost::optional<std::string> m_label;
112 boost::optional<uint64_t> m_balance;
113 boost::optional<uint64_t> m_unlocked_balance;
114 boost::optional<uint64_t> m_num_unspent_outputs;
115 boost::optional<bool> m_is_used;
116 boost::optional<uint64_t> m_num_blocks_to_unlock;
117
118 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
119 };
120
125 boost::optional<uint32_t> m_index;
126 boost::optional<std::string> m_primary_address;
127 boost::optional<uint64_t> m_balance;
128 boost::optional<uint64_t> m_unlocked_balance;
129 boost::optional<std::string> m_tag;
130 std::vector<monero_subaddress> m_subaddresses;
131
132 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
133 };
134
138 struct monero_destination : public serializable_struct {
139 boost::optional<std::string> m_address;
140 boost::optional<uint64_t> m_amount;
141
142 monero_destination(boost::optional<std::string> address = boost::none, boost::optional<uint64_t> amount = boost::none) : m_address(address), m_amount(amount) {}
143 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
144 static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr<monero_destination>& destination);
145 std::shared_ptr<monero_destination> copy(const std::shared_ptr<monero_destination>& src, const std::shared_ptr<monero_destination>& tgt) const;
146 };
147
148 // forward declarations
149 struct monero_tx_wallet;
150 struct monero_tx_query;
151 struct monero_tx_set;
152
159 std::shared_ptr<monero_tx_wallet> m_tx;
160 boost::optional<uint64_t> m_amount;
161 boost::optional<uint32_t> m_account_index;
162
163 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
164 static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr<monero_transfer>& transfer);
165 virtual boost::optional<bool> is_incoming() const = 0; // derived class must implement
166 std::shared_ptr<monero_transfer> copy(const std::shared_ptr<monero_transfer>& src, const std::shared_ptr<monero_transfer>& tgt) const;
167 boost::optional<bool> is_outgoing() const {
168 if (is_incoming() == boost::none) return boost::none;
169 return !(*is_incoming());
170 }
171 void merge(const std::shared_ptr<monero_transfer>& self, const std::shared_ptr<monero_transfer>& other);
172 };
173
178 boost::optional<uint32_t> m_subaddress_index;
179 boost::optional<std::string> m_address;
180 boost::optional<uint64_t> m_num_suggested_confirmations;
181
182 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
183 std::shared_ptr<monero_incoming_transfer> copy(const std::shared_ptr<monero_transfer>& src, const std::shared_ptr<monero_transfer>& tgt) const;
184 std::shared_ptr<monero_incoming_transfer> copy(const std::shared_ptr<monero_incoming_transfer>& src, const std::shared_ptr<monero_incoming_transfer>& tgt) const;
185 boost::optional<bool> is_incoming() const;
186 void merge(const std::shared_ptr<monero_transfer>& self, const std::shared_ptr<monero_transfer>& other);
187 void merge(const std::shared_ptr<monero_incoming_transfer>& self, const std::shared_ptr<monero_incoming_transfer>& other);
188 };
189
194 std::vector<uint32_t> m_subaddress_indices;
195 std::vector<std::string> m_addresses;
196 std::vector<std::shared_ptr<monero_destination>> m_destinations;
197
198 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
199 std::shared_ptr<monero_outgoing_transfer> copy(const std::shared_ptr<monero_transfer>& src, const std::shared_ptr<monero_transfer>& tgt) const;
200 std::shared_ptr<monero_outgoing_transfer> copy(const std::shared_ptr<monero_outgoing_transfer>& src, const std::shared_ptr<monero_outgoing_transfer>& tgt) const;
201 boost::optional<bool> is_incoming() const;
202 void merge(const std::shared_ptr<monero_transfer>& self, const std::shared_ptr<monero_transfer>& other);
203 void merge(const std::shared_ptr<monero_outgoing_transfer>& self, const std::shared_ptr<monero_outgoing_transfer>& other);
204 };
205
212 boost::optional<bool> m_is_incoming;
213 boost::optional<std::string> m_address;
214 std::vector<std::string> m_addresses;
215 boost::optional<uint32_t> m_subaddress_index;
216 std::vector<uint32_t> m_subaddress_indices;
217 std::vector<std::shared_ptr<monero_destination>> m_destinations;
218 boost::optional<bool> m_has_destinations;
219 boost::optional<std::shared_ptr<monero_tx_query>> m_tx_query;
220
221 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
222 static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr<monero_transfer_query>& transfer_query);
223 static std::shared_ptr<monero_transfer_query> deserialize_from_block(const std::string& transfer_query_json);
224 std::shared_ptr<monero_transfer_query> copy(const std::shared_ptr<monero_transfer>& src, const std::shared_ptr<monero_transfer>& tgt) const;
225 std::shared_ptr<monero_transfer_query> copy(const std::shared_ptr<monero_transfer_query>& src, const std::shared_ptr<monero_transfer_query>& tgt) const;
226 boost::optional<bool> is_incoming() const;
227 bool meets_criteria(monero_transfer* transfer, bool query_parent = true) const;
228 };
229
234 boost::optional<uint32_t> m_account_index;
235 boost::optional<uint32_t> m_subaddress_index;
236 boost::optional<bool> m_is_spent;
237 boost::optional<bool> m_is_frozen;
238
239 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
240 static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr<monero_output_wallet>& output_wallet);
241 std::shared_ptr<monero_output_wallet> copy(const std::shared_ptr<monero_output>& src, const std::shared_ptr<monero_output>& tgt) const;
242 std::shared_ptr<monero_output_wallet> copy(const std::shared_ptr<monero_output_wallet>& src, const std::shared_ptr<monero_output_wallet>& tgt) const;
243 void merge(const std::shared_ptr<monero_output>& self, const std::shared_ptr<monero_output>& other);
244 void merge(const std::shared_ptr<monero_output_wallet>& self, const std::shared_ptr<monero_output_wallet>& other);
245 };
246
254 std::vector<uint32_t> m_subaddress_indices;
255 boost::optional<uint64_t> m_min_amount;
256 boost::optional<uint64_t> m_max_amount;
257 boost::optional<std::shared_ptr<monero_tx_query>> m_tx_query;
258
259 //boost::property_tree::ptree to_property_tree() const;
260 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
261 static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr<monero_output_query>& output_query);
262 static std::shared_ptr<monero_output_query> deserialize_from_block(const std::string& output_query_json);
263 std::shared_ptr<monero_output_query> copy(const std::shared_ptr<monero_output>& src, const std::shared_ptr<monero_output>& tgt) const;
264 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?
265 std::shared_ptr<monero_output_query> copy(const std::shared_ptr<monero_output_query>& src, const std::shared_ptr<monero_output_query>& tgt) const;
266 bool meets_criteria(monero_output_wallet* output, bool query_parent = true) const;
267 };
268
272 struct monero_tx_wallet : public monero_tx {
273 boost::optional<std::shared_ptr<monero_tx_set>> m_tx_set;
274 boost::optional<bool> m_is_incoming;
275 boost::optional<bool> m_is_outgoing;
276 std::vector<std::shared_ptr<monero_incoming_transfer>> m_incoming_transfers;
277 boost::optional<std::shared_ptr<monero_outgoing_transfer>> m_outgoing_transfer;
278 boost::optional<std::string> m_note;
279 boost::optional<bool> m_is_locked;
280 boost::optional<uint64_t> m_input_sum;
281 boost::optional<uint64_t> m_output_sum;
282 boost::optional<std::string> m_change_address;
283 boost::optional<uint64_t> m_change_amount;
284 boost::optional<uint32_t> m_num_dummy_outputs;
285 boost::optional<std::string> m_extra_hex;
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 std::shared_ptr<monero_tx_wallet>& tx_wallet);
289 std::shared_ptr<monero_tx_wallet> copy(const std::shared_ptr<monero_tx>& src, const std::shared_ptr<monero_tx>& tgt) const;
290 std::shared_ptr<monero_tx_wallet> copy(const std::shared_ptr<monero_tx_wallet>& src, const std::shared_ptr<monero_tx_wallet>& tgt) const;
291 void merge(const std::shared_ptr<monero_tx>& self, const std::shared_ptr<monero_tx>& other);
292 void merge(const std::shared_ptr<monero_tx_wallet>& self, const std::shared_ptr<monero_tx_wallet>& other);
293 std::vector<std::shared_ptr<monero_transfer>> get_transfers() const;
294 std::vector<std::shared_ptr<monero_transfer>> get_transfers(const monero_transfer_query& query) const;
295 std::vector<std::shared_ptr<monero_transfer>> filter_transfers(const monero_transfer_query& query);
296 std::vector<std::shared_ptr<monero_output_wallet>> get_outputs_wallet() const;
297 std::vector<std::shared_ptr<monero_output_wallet>> get_outputs_wallet(const monero_output_query& query) const;
298 std::vector<std::shared_ptr<monero_output_wallet>> filter_outputs_wallet(const monero_output_query& query);
299 };
300
307 boost::optional<bool> m_is_outgoing;
308 boost::optional<bool> m_is_incoming;
309 std::vector<std::string> m_hashes;
310 boost::optional<bool> m_has_payment_id;
311 std::vector<std::string> m_payment_ids;
312 boost::optional<uint64_t> m_height;
313 boost::optional<uint64_t> m_min_height;
314 boost::optional<uint64_t> m_max_height;
315 boost::optional<uint64_t> m_include_outputs;
316 boost::optional<std::shared_ptr<monero_transfer_query>> m_transfer_query;
317 boost::optional<std::shared_ptr<monero_output_query>> m_input_query;
318 boost::optional<std::shared_ptr<monero_output_query>> m_output_query;
319
320 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
321 static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr<monero_tx_query>& tx_query);
322 static std::shared_ptr<monero_tx_query> deserialize_from_block(const std::string& tx_query_json);
323 std::shared_ptr<monero_tx_query> copy(const std::shared_ptr<monero_tx>& src, const std::shared_ptr<monero_tx>& tgt) const;
324 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?
325 std::shared_ptr<monero_tx_query> copy(const std::shared_ptr<monero_tx_query>& src, const std::shared_ptr<monero_tx_query>& tgt) const;
326 bool meets_criteria(monero_tx_wallet* tx, bool query_children = true) const;
327 };
328
338 std::vector<std::shared_ptr<monero_tx_wallet>> m_txs;
339 boost::optional<std::string> m_signed_tx_hex;
340 boost::optional<std::string> m_unsigned_tx_hex;
341 boost::optional<std::string> m_multisig_tx_hex;
342
343 //boost::property_tree::ptree to_property_tree() const;
344 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
345 static monero_tx_set deserialize(const std::string& tx_set_json);
346 };
347
352 std::string m_standard_address;
353 std::string m_payment_id;
354 std::string m_integrated_address;
355
356 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
357 };
358
362 enum monero_tx_priority : uint8_t {
363 DEFAULT = 0,
364 UNIMPORTANT,
365 NORMAL,
366 ELEVATED
367 };
368
372 struct monero_tx_config : public serializable_struct {
373 boost::optional<std::string> m_address;
374 boost::optional<uint64_t> m_amount;
375 std::vector<std::shared_ptr<monero_destination>> m_destinations;
376 std::vector<uint32_t> m_subtract_fee_from;
377 boost::optional<std::string> m_payment_id;
378 boost::optional<monero_tx_priority> m_priority;
379 boost::optional<uint32_t> m_ring_size;
380 boost::optional<uint64_t> m_fee;
381 boost::optional<uint32_t> m_account_index;
382 std::vector<uint32_t> m_subaddress_indices;
383 boost::optional<bool> m_can_split;
384 boost::optional<bool> m_relay;
385 boost::optional<std::string> m_note;
386 boost::optional<std::string> m_recipient_name;
387 boost::optional<uint64_t> m_below_amount;
388 boost::optional<bool> m_sweep_each_subaddress;
389 boost::optional<std::string> m_key_image;
390
391 monero_tx_config() {}
392 monero_tx_config(const monero_tx_config& config);
393 monero_tx_config copy() const;
394 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
395 static std::shared_ptr<monero_tx_config> deserialize(const std::string& config_json);
396 std::vector<std::shared_ptr<monero_destination>> get_normalized_destinations() const;
397 };
398
403 boost::optional<uint64_t> m_height;
404 boost::optional<uint64_t> m_spent_amount;
405 boost::optional<uint64_t> m_unspent_amount;
406
407 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
408 };
409
414 SIGN_WITH_SPEND_KEY = 0,
415 SIGN_WITH_VIEW_KEY
416 };
417
422 bool m_is_good;
423 uint32_t m_version;
424 bool m_is_old;
425 monero_message_signature_type m_signature_type;
426
427 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
428 };
429
434 bool m_is_good;
435
436 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
437 };
438
443 boost::optional<bool> m_in_tx_pool;
444 boost::optional<uint64_t> m_num_confirmations;
445 boost::optional<uint64_t> m_received_amount;
446
447 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
448 };
449
454 boost::optional<uint64_t> m_total_amount;
455 boost::optional<uint64_t> m_unconfirmed_spent_amount;
456
457 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
458 };
459
464 bool m_is_multisig;
465 bool m_is_ready;
466 uint32_t m_threshold;
467 uint32_t m_num_participants;
468
469 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
470 };
471
478 boost::optional<std::string> m_address;
479 boost::optional<std::string> m_multisig_hex;
480
481 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
482 };
483
488 boost::optional<std::string> m_signed_multisig_tx_hex;
489 std::vector<std::string> m_tx_hashes;
490
491 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
492 };
493
497 struct monero_address_book_entry : public serializable_struct {
498 boost::optional<uint64_t> m_index; // TODO: not boost::optional
499 boost::optional<std::string> m_address;
500 boost::optional<std::string> m_description;
501 boost::optional<std::string> m_payment_id;
502
503 monero_address_book_entry() {}
504 monero_address_book_entry(uint64_t index, const std::string& address, const std::string& description) : m_index(index), m_address(address), m_description(description) {}
505 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) {}
506 rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
507 };
508}
Definition monero_daemon.cpp:58
monero_message_signature_type
Definition monero_wallet_model.h:413
monero_tx_priority
Definition monero_wallet_model.h:362
Definition monero_wallet_model.h:124
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:213
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:1541
Definition monero_wallet_model.h:453
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:1476
Definition monero_wallet_model.h:442
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:1457
Definition monero_wallet_model.h:433
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:1443
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:663
Definition monero_wallet_model.h:177
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:800
Definition monero_wallet_model.h:351
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:1386
Definition monero_wallet_model.h:402
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:1403
Definition monero_wallet_model.h:421
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:1420
Definition monero_wallet_model.h:463
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:1492
Definition monero_wallet_model.h:477
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:1510
Definition monero_wallet_model.h:487
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:1524
Definition monero_wallet_model.h:193
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:847
Definition monero_wallet_model.h:253
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:1152
Definition monero_wallet_model.h:233
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:1082
Definition monero_daemon_model.h:239
Definition monero_wallet_model.h:107
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:238
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:195
Definition monero_wallet_model.h:211
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:907
Definition monero_wallet_model.h:158
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:744
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:1292
Definition monero_wallet_model.h:306
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:461
Definition monero_wallet_model.h:337
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:697
Definition monero_wallet_model.h:272
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:266
Definition monero_daemon_model.h:174
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType &allocator) const
Definition monero_wallet_model.cpp:118
Definition monero_daemon_model.h:69