Debian Codegraph @

src/simplewallet/simplewallet.h

raw symbols SCIP
1 // Copyright (c) 2014-2022, The Monero Project
2 //
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification, are
6 // permitted provided that the following conditions are met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice, this list of
9 // conditions and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 // of conditions and the following disclaimer in the documentation and/or other
13 // materials provided with the distribution.
14 //
15 // 3. Neither the name of the copyright holder nor the names of its contributors may be
16 // used to endorse or promote products derived from this software without specific
17 // prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27 // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 //
29 // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
30
31 /*!
32 * \file simplewallet.h
33 *
34 * \brief Header file that declares simple_wallet class.
35 */
36 #pragma once
37
38 #include <memory>
39
40 #include <boost/optional/optional.hpp>
41 #include <boost/program_options/variables_map.hpp>
42
43 #include "cryptonote_basic/account.h"
44 #include "cryptonote_basic/cryptonote_basic_impl.h"
45 #include "wallet/wallet2.h"
46 #include "console_handler.h"
47 #include "math_helper.h"
48 #include "wipeable_string.h"
49 #include "common/i18n.h"
50 #include "common/password.h"
51 #include "crypto/crypto.h" // for definition of crypto::secret_key
52
53 #undef MONERO_DEFAULT_LOG_CATEGORY
54 #define MONERO_DEFAULT_LOG_CATEGORY "wallet.simplewallet"
55 // Hardcode Monero's donation address (see #1447)
56 constexpr const char MONERO_DONATION_ADDR[] = "888tNkZrPN6JsEgekjMnABU4TBzc2Dt29EPAvkRxbANsAnjyPbb3iQ1YBRk1UXcdRsiKc9dhwMVgN5S9cQUiyoogDavup3H";
57
58 /*!
59 * \namespace cryptonote
60 * \brief Holds cryptonote related classes and helpers.
61 */
62 namespace cryptonote
63 {
64 /*!
65 * \brief Manages wallet operations. This is the most abstracted wallet class.
66 */
67 class simple_wallet : public tools::i_wallet2_callback
68 {
69 public:
70 static const char *tr(const char *str) { return i18n_translate(str, "cryptonote::simple_wallet"); }
71
72 public:
73 typedef std::vector<std::string> command_type;
74
75 simple_wallet();
76 bool init(const boost::program_options::variables_map& vm);
77 bool deinit();
78 bool run();
79 void stop();
80 void interrupt();
81
82 //wallet *create_wallet();
83 bool process_command(const std::vector<std::string> &args);
84 std::string get_commands_str();
85 std::string get_command_usage(const std::vector<std::string> &args);
86 private:
87
88 enum ResetType { ResetNone, ResetSoft, ResetHard, ResetSoftKeepKI };
89
90 bool handle_command_line(const boost::program_options::variables_map& vm);
91
92 bool run_console_handler();
93
94 void wallet_idle_thread();
95
96 //! \return Prompts user for password and verifies against local file. Logs on error and returns `none`
97 boost::optional<tools::password_container> get_and_verify_password() const;
98
99 boost::optional<epee::wipeable_string> new_wallet(const boost::program_options::variables_map& vm, const crypto::secret_key& recovery_key,
100 bool recover, bool two_random, const std::string &old_language);
101 boost::optional<epee::wipeable_string> new_wallet(const boost::program_options::variables_map& vm, const cryptonote::account_public_address& address,
102 const boost::optional<crypto::secret_key>& spendkey, const crypto::secret_key& viewkey);
103 boost::optional<epee::wipeable_string> new_wallet(const boost::program_options::variables_map& vm,
104 const epee::wipeable_string &multisig_keys, const epee::wipeable_string &seed_pass, const std::string &old_language);
105 boost::optional<epee::wipeable_string> new_wallet(const boost::program_options::variables_map& vm);
106 boost::optional<epee::wipeable_string> open_wallet(const boost::program_options::variables_map& vm);
107 bool close_wallet();
108
109 bool viewkey(const std::vector<std::string> &args = std::vector<std::string>());
110 bool spendkey(const std::vector<std::string> &args = std::vector<std::string>());
111 bool seed(const std::vector<std::string> &args = std::vector<std::string>());
112 bool encrypted_seed(const std::vector<std::string> &args = std::vector<std::string>());
113 bool restore_height(const std::vector<std::string> &args = std::vector<std::string>());
114
115 /*!
116 * \brief Sets seed language.
117 *
118 * interactive
119 * - prompts for password so wallet can be rewritten
120 * - calls get_mnemonic_language() which prompts for language
121 *
122 * \return success status
123 */
124 bool seed_set_language(const std::vector<std::string> &args = std::vector<std::string>());
125 bool set_always_confirm_transfers(const std::vector<std::string> &args = std::vector<std::string>());
126 bool set_print_ring_members(const std::vector<std::string> &args = std::vector<std::string>());
127 bool set_store_tx_info(const std::vector<std::string> &args = std::vector<std::string>());
128 bool set_auto_refresh(const std::vector<std::string> &args = std::vector<std::string>());
129 bool set_refresh_type(const std::vector<std::string> &args = std::vector<std::string>());
130 bool set_confirm_missing_payment_id(const std::vector<std::string> &args = std::vector<std::string>());
131 bool set_ask_password(const std::vector<std::string> &args = std::vector<std::string>());
132 bool set_unit(const std::vector<std::string> &args = std::vector<std::string>());
133 bool set_max_reorg_depth(const std::vector<std::string> &args = std::vector<std::string>());
134 bool set_min_output_count(const std::vector<std::string> &args = std::vector<std::string>());
135 bool set_min_output_value(const std::vector<std::string> &args = std::vector<std::string>());
136 bool set_merge_destinations(const std::vector<std::string> &args = std::vector<std::string>());
137 bool set_confirm_backlog(const std::vector<std::string> &args = std::vector<std::string>());
138 bool set_confirm_backlog_threshold(const std::vector<std::string> &args = std::vector<std::string>());
139 bool set_confirm_export_overwrite(const std::vector<std::string> &args = std::vector<std::string>());
140 bool set_refresh_from_block_height(const std::vector<std::string> &args = std::vector<std::string>());
141 bool set_auto_low_priority(const std::vector<std::string> &args = std::vector<std::string>());
142 bool set_segregate_pre_fork_outputs(const std::vector<std::string> &args = std::vector<std::string>());
143 bool set_key_reuse_mitigation2(const std::vector<std::string> &args = std::vector<std::string>());
144 bool set_subaddress_lookahead(const std::vector<std::string> &args = std::vector<std::string>());
145 bool set_segregation_height(const std::vector<std::string> &args = std::vector<std::string>());
146 bool set_ignore_fractional_outputs(const std::vector<std::string> &args = std::vector<std::string>());
147 bool set_ignore_outputs_above(const std::vector<std::string> &args = std::vector<std::string>());
148 bool set_ignore_outputs_below(const std::vector<std::string> &args = std::vector<std::string>());
149 bool set_track_uses(const std::vector<std::string> &args = std::vector<std::string>());
150 bool setup_background_sync(const std::vector<std::string> &args = std::vector<std::string>());
151 bool set_show_wallet_name_when_locked(const std::vector<std::string> &args = std::vector<std::string>());
152 bool set_inactivity_lock_timeout(const std::vector<std::string> &args = std::vector<std::string>());
153 bool set_setup_background_mining(const std::vector<std::string> &args = std::vector<std::string>());
154 bool set_device_name(const std::vector<std::string> &args = std::vector<std::string>());
155 bool set_export_format(const std::vector<std::string> &args = std::vector<std::string>());
156 bool set_load_deprecated_formats(const std::vector<std::string> &args = std::vector<std::string>());
157 bool set_enable_multisig(const std::vector<std::string> &args = std::vector<std::string>());
158 bool set_persistent_rpc_client_id(const std::vector<std::string> &args = std::vector<std::string>());
159 bool set_auto_mine_for_rpc_payment_threshold(const std::vector<std::string> &args = std::vector<std::string>());
160 bool set_credits_target(const std::vector<std::string> &args = std::vector<std::string>());
161 bool help(const std::vector<std::string> &args = std::vector<std::string>());
162 bool apropos(const std::vector<std::string> &args);
163 bool scan_tx(const std::vector<std::string> &args);
164 bool start_mining(const std::vector<std::string> &args);
165 bool stop_mining(const std::vector<std::string> &args);
166 bool set_daemon(const std::vector<std::string> &args);
167 bool save_bc(const std::vector<std::string> &args);
168 bool refresh(const std::vector<std::string> &args);
169 bool show_balance_unlocked(bool detailed = false);
170 bool show_balance(const std::vector<std::string> &args = std::vector<std::string>());
171 bool show_incoming_transfers(const std::vector<std::string> &args);
172 bool show_payments(const std::vector<std::string> &args);
173 bool show_blockchain_height(const std::vector<std::string> &args);
174 bool transfer_main(const std::vector<std::string> &args, bool called_by_mms);
175 bool transfer(const std::vector<std::string> &args);
176 bool sweep_main(uint32_t account, uint64_t below, const std::vector<std::string> &args);
177 bool sweep_all(const std::vector<std::string> &args);
178 bool sweep_account(const std::vector<std::string> &args);
179 bool sweep_below(const std::vector<std::string> &args);
180 bool sweep_single(const std::vector<std::string> &args);
181 bool sweep_unmixable(const std::vector<std::string> &args);
182 bool donate(const std::vector<std::string> &args);
183 bool sign_transfer(const std::vector<std::string> &args);
184 bool submit_transfer(const std::vector<std::string> &args);
185 std::vector<std::vector<cryptonote::tx_destination_entry>> split_amounts(
186 std::vector<cryptonote::tx_destination_entry> dsts, size_t num_splits
187 );
188 bool account(const std::vector<std::string> &args = std::vector<std::string>());
189 void print_accounts();
190 void print_accounts(const std::string& tag);
191 bool print_address(const std::vector<std::string> &args = std::vector<std::string>());
192 bool print_integrated_address(const std::vector<std::string> &args = std::vector<std::string>());
193 bool address_book(const std::vector<std::string> &args = std::vector<std::string>());
194 bool save(const std::vector<std::string> &args);
195 bool save_watch_only(const std::vector<std::string> &args);
196 bool set_variable(const std::vector<std::string> &args);
197 bool rescan_spent(const std::vector<std::string> &args);
198 bool set_log(const std::vector<std::string> &args);
199 bool get_tx_key(const std::vector<std::string> &args);
200 bool set_tx_key(const std::vector<std::string> &args);
201 bool check_tx_key(const std::vector<std::string> &args);
202 bool get_tx_proof(const std::vector<std::string> &args);
203 bool check_tx_proof(const std::vector<std::string> &args);
204 bool get_spend_proof(const std::vector<std::string> &args);
205 bool check_spend_proof(const std::vector<std::string> &args);
206 bool get_reserve_proof(const std::vector<std::string> &args);
207 bool check_reserve_proof(const std::vector<std::string> &args);
208 bool show_transfers(const std::vector<std::string> &args);
209 bool export_transfers(const std::vector<std::string> &args);
210 bool unspent_outputs(const std::vector<std::string> &args);
211 bool rescan_blockchain(const std::vector<std::string> &args);
212 bool refresh_main(uint64_t start_height, ResetType reset, bool is_init = false);
213 bool set_tx_note(const std::vector<std::string> &args);
214 bool get_tx_note(const std::vector<std::string> &args);
215 bool set_description(const std::vector<std::string> &args);
216 bool get_description(const std::vector<std::string> &args);
217 bool status(const std::vector<std::string> &args);
218 bool wallet_info(const std::vector<std::string> &args);
219 bool set_default_priority(const std::vector<std::string> &args);
220 bool sign(const std::vector<std::string> &args);
221 bool verify(const std::vector<std::string> &args);
222 bool export_key_images(const std::vector<std::string> &args);
223 bool import_key_images(const std::vector<std::string> &args);
224 bool hw_key_images_sync(const std::vector<std::string> &args);
225 bool hw_reconnect(const std::vector<std::string> &args);
226 bool export_outputs(const std::vector<std::string> &args);
227 bool import_outputs(const std::vector<std::string> &args);
228 bool show_transfer(const std::vector<std::string> &args);
229 bool change_password(const std::vector<std::string>& args);
230 bool payment_id(const std::vector<std::string> &args);
231 bool print_fee_info(const std::vector<std::string> &args);
232 bool prepare_multisig(const std::vector<std::string>& args);
233 bool prepare_multisig_main(const std::vector<std::string>& args, bool called_by_mms);
234 bool make_multisig(const std::vector<std::string>& args);
235 bool make_multisig_main(const std::vector<std::string>& args, bool called_by_mms);
236 bool exchange_multisig_keys(const std::vector<std::string> &args);
237 bool exchange_multisig_keys_main(const std::vector<std::string> &args, const bool force_update_use_with_caution, const bool called_by_mms);
238 bool export_multisig(const std::vector<std::string>& args);
239 bool export_multisig_main(const std::vector<std::string>& args, bool called_by_mms);
240 bool import_multisig(const std::vector<std::string>& args);
241 bool import_multisig_main(const std::vector<std::string>& args, bool called_by_mms);
242 bool accept_loaded_tx(const tools::wallet2::multisig_tx_set &txs);
243 bool sign_multisig(const std::vector<std::string>& args);
244 bool sign_multisig_main(const std::vector<std::string>& args, bool called_by_mms);
245 bool submit_multisig(const std::vector<std::string>& args);
246 bool submit_multisig_main(const std::vector<std::string>& args, bool called_by_mms);
247 bool export_raw_multisig(const std::vector<std::string>& args);
248 bool mms(const std::vector<std::string>& args);
249 bool print_ring(const std::vector<std::string>& args);
250 bool set_ring(const std::vector<std::string>& args);
251 bool unset_ring(const std::vector<std::string>& args);
252 bool save_known_rings(const std::vector<std::string>& args);
253 bool blackball(const std::vector<std::string>& args);
254 bool unblackball(const std::vector<std::string>& args);
255 bool blackballed(const std::vector<std::string>& args);
256 bool freeze(const std::vector<std::string>& args);
257 bool thaw(const std::vector<std::string>& args);
258 bool frozen(const std::vector<std::string>& args);
259 bool lock(const std::vector<std::string>& args);
260 bool rpc_payment_info(const std::vector<std::string> &args);
261 bool start_mining_for_rpc(const std::vector<std::string> &args);
262 bool stop_mining_for_rpc(const std::vector<std::string> &args);
263 bool show_qr_code(const std::vector<std::string> &args);
264 bool net_stats(const std::vector<std::string>& args);
265 bool public_nodes(const std::vector<std::string>& args);
266 bool welcome(const std::vector<std::string>& args);
267 bool version(const std::vector<std::string>& args);
268 bool on_unknown_command(const std::vector<std::string>& args);
269
270 bool cold_sign_tx(const std::vector<tools::wallet2::pending_tx>& ptx_vector, tools::wallet2::signed_tx_set &exported_txs, std::vector<cryptonote::address_parse_info> &dsts_info, std::function<bool(const tools::wallet2::signed_tx_set &)> accept_func);
271 uint64_t get_daemon_blockchain_height(std::string& err);
272 bool try_connect_to_daemon(bool silent = false, uint32_t* version = nullptr);
273 bool ask_wallet_create_if_needed();
274 bool accept_loaded_tx(const std::function<size_t()> get_num_txes, const std::function<const tools::wallet2::tx_construction_data&(size_t)> &get_tx, const std::string &extra_message = std::string());
275 bool accept_loaded_tx(const tools::wallet2::unsigned_tx_set &txs);
276 bool accept_loaded_tx(const tools::wallet2::signed_tx_set &txs);
277 bool process_ring_members(const std::vector<tools::wallet2::pending_tx>& ptx_vector, std::ostream& ostr, bool verbose);
278 std::string get_prompt() const;
279 bool print_seed(bool encrypted);
280 void key_images_sync_intern();
281 void on_refresh_finished(uint64_t start_height, uint64_t fetched_blocks, bool is_init, bool received_money);
282 std::pair<std::string, std::string> show_outputs_line(const std::vector<uint64_t> &heights, uint64_t blockchain_height, uint64_t highlight_idx = std::numeric_limits<uint64_t>::max()) const;
283 bool freeze_thaw(const std::vector<std::string>& args, bool freeze);
284 bool prompt_if_old(const std::vector<tools::wallet2::pending_tx> &ptx_vector);
285 bool on_command(bool (simple_wallet::*cmd)(const std::vector<std::string>&), const std::vector<std::string> &args);
286 bool on_empty_command();
287 bool on_cancelled_command();
288 void check_for_inactivity_lock(bool user);
289
290 struct transfer_view
291 {
292 std::string type;
293 boost::variant<uint64_t, std::string> block;
294 uint64_t timestamp;
295 std::string direction;
296 bool confirmed;
297 uint64_t amount;
298 crypto::hash hash;
299 std::string payment_id;
300 uint64_t fee;
301 std::vector<std::pair<std::string, uint64_t>> outputs;
302 std::set<uint32_t> index;
303 std::string note;
304 std::string unlocked;
305 };
306 bool get_transfers(std::vector<std::string>& args_, std::vector<transfer_view>& transfers);
307
308 /*!
309 * \brief Prints the seed with a nice message
310 * \param seed seed to print
311 */
312 void print_seed(const epee::wipeable_string &seed);
313
314 /*!
315 * \brief Gets the word seed language from the user.
316 *
317 * User is asked to choose from a list of supported languages.
318 *
319 * \return The chosen language.
320 */
321 std::string get_mnemonic_language();
322
323 /*!
324 * \brief When --do-not-relay option is specified, save the raw tx hex blob to a file instead of calling m_wallet->commit_tx(ptx).
325 * \param ptx_vector Pending tx(es) created by transfer/sweep_all
326 */
327 void commit_or_save(std::vector<tools::wallet2::pending_tx>& ptx_vector, bool do_not_relay);
328
329 /*!
330 * \brief checks whether background mining is enabled, and asks to configure it if not
331 */
332 void check_background_mining(const epee::wipeable_string &password);
333 void start_background_mining();
334 void stop_background_mining();
335
336 // idle thread workers
337 bool check_inactivity();
338 bool check_refresh();
339 bool check_mms();
340 bool check_rpc_payment();
341
342 void handle_transfer_exception(const std::exception_ptr &e, bool trusted_daemon);
343
344 bool check_daemon_rpc_prices(const std::string &daemon_url, uint32_t &actual_cph, uint32_t &claimed_cph);
345
346 //----------------- i_wallet2_callback ---------------------
347 virtual void on_new_block(uint64_t height, const cryptonote::block& block);
348 virtual void on_money_received(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t amount, uint64_t burnt, const cryptonote::subaddress_index& subaddr_index, bool is_change, uint64_t unlock_time);
349 virtual void on_unconfirmed_money_received(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t amount, const cryptonote::subaddress_index& subaddr_index);
350 virtual void on_money_spent(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& in_tx, uint64_t amount, const cryptonote::transaction& spend_tx, const cryptonote::subaddress_index& subaddr_index);
351 virtual void on_skip_transaction(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx);
352 virtual boost::optional<epee::wipeable_string> on_get_password(const char *reason);
353 virtual void on_device_button_request(uint64_t code);
354 virtual boost::optional<epee::wipeable_string> on_device_pin_request();
355 virtual boost::optional<epee::wipeable_string> on_device_passphrase_request(bool & on_device);
356 //----------------------------------------------------------
357
358 friend class refresh_progress_reporter_t;
359
360 class refresh_progress_reporter_t
361 {
362 public:
363 refresh_progress_reporter_t(cryptonote::simple_wallet& simple_wallet)
364 : m_simple_wallet(simple_wallet)
365 , m_blockchain_height(0)
366 , m_blockchain_height_update_time()
367 , m_print_time()
368 {
369 }
370
371 void update(uint64_t height, bool force = false)
372 {
373 auto current_time = std::chrono::system_clock::now();
374 const auto node_update_threshold = std::chrono::seconds(DIFFICULTY_TARGET_V1 / 2); // use min of V1/V2
375 if (node_update_threshold < current_time - m_blockchain_height_update_time || m_blockchain_height <= height)
376 {
377 update_blockchain_height();
378 m_blockchain_height = (std::max)(m_blockchain_height, height);
379 }
380
381 if (std::chrono::milliseconds(20) < current_time - m_print_time || force)
382 {
383 std::cout << QT_TRANSLATE_NOOP("cryptonote::simple_wallet", "Height ") << height << " / " << m_blockchain_height << '\r' << std::flush;
384 m_print_time = current_time;
385 }
386 }
387
388 private:
389 void update_blockchain_height()
390 {
391 std::string err;
392 uint64_t blockchain_height = m_simple_wallet.get_daemon_blockchain_height(err);
393 if (err.empty())
394 {
395 m_blockchain_height = blockchain_height;
396 m_blockchain_height_update_time = std::chrono::system_clock::now();
397 }
398 else
399 {
400 LOG_ERROR("Failed to get current blockchain height: " << err);
401 }
402 }
403
404 private:
405 cryptonote::simple_wallet& m_simple_wallet;
406 uint64_t m_blockchain_height;
407 std::chrono::system_clock::time_point m_blockchain_height_update_time;
408 std::chrono::system_clock::time_point m_print_time;
409 };
410
411 private:
412 std::string m_wallet_file;
413 std::string m_generate_new;
414 std::string m_generate_from_device;
415 std::string m_generate_from_view_key;
416 std::string m_generate_from_spend_key;
417 std::string m_generate_from_keys;
418 std::string m_generate_from_multisig_keys;
419 std::string m_generate_from_json;
420 std::string m_mnemonic_language;
421 std::string m_import_path;
422 std::string m_subaddress_lookahead;
423 std::string m_restore_date; // optional - converted to m_restore_height
424
425 epee::wipeable_string m_electrum_seed; // electrum-style seed parameter
426
427 crypto::secret_key m_recovery_key; // recovery key (used as random for wallet gen)
428 bool m_restore_deterministic_wallet; // recover flag
429 bool m_restore_multisig_wallet; // recover flag
430 bool m_non_deterministic; // old 2-random generation
431 bool m_restoring; // are we restoring, by whatever method?
432 uint64_t m_restore_height; // optional
433 bool m_do_not_relay;
434 bool m_use_english_language_names;
435
436 epee::console_handlers_binder m_cmd_binder;
437
438 std::unique_ptr<tools::wallet2> m_wallet;
439 refresh_progress_reporter_t m_refresh_progress_reporter;
440
441 std::atomic<bool> m_idle_run;
442 boost::thread m_idle_thread;
443 boost::mutex m_idle_mutex;
444 boost::condition_variable m_idle_cond;
445
446 std::atomic<bool> m_auto_refresh_enabled;
447 bool m_auto_refresh_refreshing;
448 std::atomic<bool> m_in_manual_refresh;
449 uint32_t m_current_subaddress_account;
450
451 std::atomic<time_t> m_last_activity_time;
452 std::atomic<bool> m_locked;
453 std::atomic<bool> m_in_command;
454
455 template<uint64_t mini, uint64_t maxi> struct get_random_interval { public: uint64_t operator()() const { return crypto::rand_range(mini, maxi); } };
456
457 epee::math_helper::once_a_time_seconds<1> m_inactivity_checker;
458 epee::math_helper::once_a_time_seconds_range<get_random_interval<80 * 1000000, 100 * 1000000>> m_refresh_checker;
459 epee::math_helper::once_a_time_seconds_range<get_random_interval<90 * 1000000, 110 * 1000000>> m_mms_checker;
460 epee::math_helper::once_a_time_seconds_range<get_random_interval<90 * 1000000, 115 * 1000000>> m_rpc_payment_checker;
461
462 std::atomic<bool> m_need_payment;
463 boost::posix_time::ptime m_last_rpc_payment_mining_time;
464 bool m_rpc_payment_mining_requested;
465 uint32_t m_rpc_payment_threads = 0;
466 bool m_daemon_rpc_payment_message_displayed;
467 float m_rpc_payment_hash_rate;
468 std::atomic<bool> m_suspend_rpc_payment_mining;
469
470 std::unordered_map<std::string, uint32_t> m_claimed_cph;
471
472 // MMS
473 mms::message_store& get_message_store() const { return m_wallet->get_message_store(); };
474 mms::multisig_wallet_state get_multisig_wallet_state() const { return m_wallet->get_multisig_wallet_state(); };
475 bool mms_active() const { return get_message_store().get_active(); };
476 bool choose_mms_processing(const std::vector<mms::processing_data> &data_list, uint32_t &choice);
477 void list_mms_messages(const std::vector<mms::message> &messages);
478 void list_signers(const std::vector<mms::authorized_signer> &signers);
479 void add_signer_config_messages();
480 void show_message(const mms::message &m);
481 void ask_send_all_ready_messages();
482 void check_for_messages();
483 bool user_confirms(const std::string &question);
484 bool user_confirms_auto_config();
485 bool get_message_from_arg(const std::string &arg, mms::message &m);
486 bool get_number_from_arg(const std::string &arg, uint32_t &number, const uint32_t lower_bound, const uint32_t upper_bound);
487
488 void mms_init(const std::vector<std::string> &args);
489 void mms_info(const std::vector<std::string> &args);
490 void mms_signer(const std::vector<std::string> &args);
491 void mms_list(const std::vector<std::string> &args);
492 void mms_next(const std::vector<std::string> &args);
493 void mms_sync(const std::vector<std::string> &args);
494 void mms_transfer(const std::vector<std::string> &args);
495 void mms_delete(const std::vector<std::string> &args);
496 void mms_send(const std::vector<std::string> &args);
497 void mms_receive(const std::vector<std::string> &args);
498 void mms_export(const std::vector<std::string> &args);
499 void mms_note(const std::vector<std::string> &args);
500 void mms_show(const std::vector<std::string> &args);
501 void mms_set(const std::vector<std::string> &args);
502 void mms_help(const std::vector<std::string> &args);
503 void mms_send_signer_config(const std::vector<std::string> &args);
504 void mms_start_auto_config(const std::vector<std::string> &args);
505 void mms_config_checksum(const std::vector<std::string> &args);
506 void mms_stop_auto_config(const std::vector<std::string> &args);
507 void mms_auto_config(const std::vector<std::string> &args);
508 };
509 }