Electroneum
wallet2.h
Go to the documentation of this file.
1 // Copyrights(c) 2017-2020, The Electroneum Project
2 // Copyrights(c) 2014-2019, The Monero Project
3 //
4 // All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without modification, are
7 // permitted provided that the following conditions are met:
8 //
9 // 1. Redistributions of source code must retain the above copyright notice, this list of
10 // conditions and the following disclaimer.
11 //
12 // 2. Redistributions in binary form must reproduce the above copyright notice, this list
13 // of conditions and the following disclaimer in the documentation and/or other
14 // materials provided with the distribution.
15 //
16 // 3. Neither the name of the copyright holder nor the names of its contributors may be
17 // used to endorse or promote products derived from this software without specific
18 // prior written permission.
19 //
20 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
21 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
23 // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
28 // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
31 
32 #pragma once
33 
34 #include <memory>
35 
36 #include <boost/program_options/options_description.hpp>
37 #include <boost/program_options/variables_map.hpp>
38 #include <boost/serialization/list.hpp>
39 #include <boost/serialization/vector.hpp>
40 #include <boost/serialization/deque.hpp>
41 #include <boost/thread/lock_guard.hpp>
42 #include <atomic>
43 #include <random>
44 
45 #include "include_base_utils.h"
49 #include "net/http_client.h"
50 #include "storages/http_abstract_invoke.h"
55 #include "common/util.h"
56 #include "crypto/chacha.h"
57 #include "crypto/hash.h"
58 #include "ringct/rctTypes.h"
59 #include "ringct/rctOps.h"
61 #include "serialization/pair.h"
62 
63 #include "wallet_errors.h"
64 #include "common/password.h"
65 #include "node_rpc_proxy.h"
66 #include "message_store.h"
67 #include "wallet_light_rpc.h"
68 
69 #undef ELECTRONEUM_DEFAULT_LOG_CATEGORY
70 #define ELECTRONEUM_DEFAULT_LOG_CATEGORY "wallet.wallet2"
71 
72 class Serialization_portability_wallet_Test;
73 class wallet_accessor_test;
74 
75 namespace tools
76 {
77  class ringdb;
78  class wallet2;
79  class Notify;
80 
82  {
83  public:
84  uint64_t pick();
85  gamma_picker(const std::vector<uint64_t> &rct_offsets);
86  gamma_picker(const std::vector<uint64_t> &rct_offsets, double shape, double scale);
87 
88  private:
89  struct gamma_engine
90  {
91  typedef uint64_t result_type;
92  static constexpr result_type min() { return 0; }
93  static constexpr result_type max() { return std::numeric_limits<result_type>::max(); }
94  result_type operator()() { return crypto::rand<result_type>(); }
95  } engine;
96 
97 private:
98  std::gamma_distribution<double> gamma;
99  const std::vector<uint64_t> &rct_offsets;
100  const uint64_t *begin, *end;
101  uint64_t num_rct_outputs;
103  };
104 
106  {
107  public:
108  wallet_keys_unlocker(wallet2 &w, const boost::optional<tools::password_container> &password);
109  wallet_keys_unlocker(wallet2 &w, bool locked, const epee::wipeable_string &password);
111  private:
113  bool locked;
114  crypto::chacha_key key;
115  };
116 
118  {
119  public:
120  // Full wallet callbacks
121  virtual void on_new_block(uint64_t height, const cryptonote::block& block) {}
122  virtual void on_money_received(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t amount, const cryptonote::subaddress_index& subaddr_index, uint64_t unlock_time) {}
123  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) {}
124  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) {}
125  virtual void on_skip_transaction(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx) {}
126  virtual boost::optional<epee::wipeable_string> on_get_password(const char *reason) { return boost::none; }
127  // Light wallet callbacks
128  virtual void on_lw_new_block(uint64_t height) {}
129  virtual void on_lw_money_received(uint64_t height, const crypto::hash &txid, uint64_t amount) {}
130  virtual void on_lw_unconfirmed_money_received(uint64_t height, const crypto::hash &txid, uint64_t amount) {}
131  virtual void on_lw_money_spent(uint64_t height, const crypto::hash &txid, uint64_t amount) {}
132  // Device callbacks
133  virtual void on_device_button_request(uint64_t code) {}
134  virtual void on_device_button_pressed() {}
135  virtual boost::optional<epee::wipeable_string> on_device_pin_request() { return boost::none; }
136  virtual boost::optional<epee::wipeable_string> on_device_passphrase_request(bool on_device) { return boost::none; }
137  virtual void on_device_progress(const hw::device_progress& event) {};
138  // Common callbacks
139  virtual void on_pool_tx_removed(const crypto::hash &txid) {}
140  virtual ~i_wallet2_callback() {}
141  };
142 
144  {
145  public:
147  void on_button_request(uint64_t code=0) override;
148  void on_button_pressed() override;
149  boost::optional<epee::wipeable_string> on_pin_request() override;
150  boost::optional<epee::wipeable_string> on_passphrase_request(bool on_device) override;
151  void on_progress(const hw::device_progress& event) override;
152  private:
154  };
155 
157  {
158  uint64_t dust_threshold;
161 
162  tx_dust_policy(uint64_t a_dust_threshold = 0, bool an_add_to_fee = true, cryptonote::account_public_address an_addr_for_dust = cryptonote::account_public_address())
163  : dust_threshold(a_dust_threshold)
164  , add_to_fee(an_add_to_fee)
165  , addr_for_dust(an_addr_for_dust)
166  {
167  }
168  };
169 
170  class hashchain
171  {
172  public:
174 
175  size_t size() const { return m_blockchain.size() + m_offset; }
176  size_t offset() const { return m_offset; }
177  const crypto::hash &genesis() const { return m_genesis; }
178  void push_back(const crypto::hash &hash) { if (m_offset == 0 && m_blockchain.empty()) m_genesis = hash; m_blockchain.push_back(hash); }
179  bool is_in_bounds(size_t idx) const { return idx >= m_offset && idx < size(); }
180  const crypto::hash &operator[](size_t idx) const { return m_blockchain[idx - m_offset]; }
181  crypto::hash &operator[](size_t idx) { return m_blockchain[idx - m_offset]; }
182  void crop(size_t height) { m_blockchain.resize(height - m_offset); }
183  void clear() { m_offset = 0; m_blockchain.clear(); }
184  bool empty() const { return m_blockchain.empty() && m_offset == 0; }
185  void trim(size_t height) { while (height > m_offset && m_blockchain.size() > 1) { m_blockchain.pop_front(); ++m_offset; } m_blockchain.shrink_to_fit(); }
186  void refill(const crypto::hash &hash) { m_blockchain.push_back(hash); --m_offset; }
187 
188  template <class t_archive>
189  inline void serialize(t_archive &a, const unsigned int ver)
190  {
191  a & m_offset;
192  a & m_genesis;
193  a & m_blockchain;
194  }
195 
196  private:
197  size_t m_offset;
199  std::deque<crypto::hash> m_blockchain;
200  };
201 
202  class wallet_keys_unlocker;
203  class wallet2
204  {
205  friend class ::Serialization_portability_wallet_Test;
206  friend class ::wallet_accessor_test;
207  friend class wallet_keys_unlocker;
209  public:
210  static constexpr const std::chrono::seconds rpc_timeout = std::chrono::minutes(3) + std::chrono::seconds(30);
211 
212  enum RefreshType {
217  };
218 
223  };
224 
229  };
230 
231  static const char* tr(const char* str);
232 
233  static bool has_testnet_option(const boost::program_options::variables_map& vm);
234  static bool has_stagenet_option(const boost::program_options::variables_map& vm);
235  static std::string device_name_option(const boost::program_options::variables_map& vm);
236  static std::string device_derivation_path_option(const boost::program_options::variables_map &vm);
237  static void init_options(boost::program_options::options_description& desc_params);
238 
240  static std::pair<std::unique_ptr<wallet2>, password_container> make_from_json(const boost::program_options::variables_map& vm, bool unattended, const std::string& json_file, const std::function<boost::optional<password_container>(const char *, bool)> &password_prompter);
241 
243  static std::pair<std::unique_ptr<wallet2>, password_container>
244  make_from_file(const boost::program_options::variables_map& vm, bool unattended, const std::string& wallet_file, const std::function<boost::optional<password_container>(const char *, bool)> &password_prompter);
245 
247  static std::pair<std::unique_ptr<wallet2>, password_container> make_new(const boost::program_options::variables_map& vm, bool unattended, const std::function<boost::optional<password_container>(const char *, bool)> &password_prompter);
248 
250  static std::unique_ptr<wallet2> make_dummy(const boost::program_options::variables_map& vm, bool unattended, const std::function<boost::optional<password_container>(const char *, bool)> &password_prompter);
251 
252  static bool verify_password(const std::string& keys_file_name, const epee::wipeable_string& password, bool no_spend_key, hw::device &hwdev, uint64_t kdf_rounds);
253  static bool query_device(hw::device::device_type& device_type, const std::string& keys_file_name, const epee::wipeable_string& password, uint64_t kdf_rounds = 1);
254 
255  wallet2(cryptonote::network_type nettype = cryptonote::MAINNET, uint64_t kdf_rounds = 1, bool unattended = false);
256  ~wallet2();
257 
259  {
260  struct LR
261  {
264 
266  FIELD(m_L)
267  FIELD(m_R)
268  END_SERIALIZE()
269  };
270 
272  std::vector<LR> m_LR;
273  std::vector<crypto::key_image> m_partial_key_images; // one per key the participant has
274 
276  FIELD(m_signer)
277  FIELD(m_LR)
279  END_SERIALIZE()
280  };
281 
283  {
287  uint64_t amount;
289  bool error;
290  boost::optional<cryptonote::subaddress_receive_info> received;
291 
292  tx_scan_info_t(): amount(0), money_transfered(0), error(true) {}
293  };
294 
296  {
297  uint64_t m_block_height;
302  bool m_spent;
303  bool m_frozen;
304  uint64_t m_spent_height;
305  crypto::key_image m_key_image; //TODO: key_image stored twice :(
307  uint64_t m_amount;
308  bool m_rct;
310  bool m_key_image_request; // view wallets: we want to request it; cold wallets: it was requested
311  size_t m_pk_index;
314  std::vector<rct::key> m_multisig_k;
315  std::vector<multisig_info> m_multisig_info; // one per other participant
316  std::vector<std::pair<uint64_t, crypto::hash>> m_uses;
317 
318  bool is_rct() const { return m_rct; }
319  uint64_t amount() const { return m_amount; }
320  const crypto::public_key &get_public_key() const { return boost::get<const cryptonote::txout_to_key>(m_tx.vout[m_internal_output_index].target).key; }
321 
323  FIELD(m_block_height)
324  FIELD(m_tx)
325  FIELD(m_txid)
326  FIELD(m_internal_output_index)
327  FIELD(m_global_output_index)
328  FIELD(m_spent)
329  FIELD(m_frozen)
330  FIELD(m_spent_height)
331  FIELD(m_key_image)
332  FIELD(m_mask)
333  FIELD(m_amount)
334  FIELD(m_rct)
335  FIELD(m_key_image_known)
336  FIELD(m_key_image_request)
337  FIELD(m_pk_index)
338  FIELD(m_subaddr_index)
339  FIELD(m_key_image_partial)
340  FIELD(m_multisig_k)
341  FIELD(m_multisig_info)
342  FIELD(m_uses)
343  END_SERIALIZE()
344  };
345 
347  {
349  uint64_t m_amount;
350  uint64_t m_fee;
351  uint64_t m_block_height;
352  uint64_t m_unlock_time;
353  uint64_t m_timestamp;
356  };
357 
359  {
360  bool m_mempool;
362  };
363 
365  {
368  };
369 
371  {
373  uint64_t m_amount_in;
374  uint64_t m_amount_out;
375  uint64_t m_change;
376  time_t m_sent_time;
377  std::vector<cryptonote::tx_destination_entry> m_dests;
379  enum { pending, pending_not_in_pool, failed } m_state;
380  uint64_t m_timestamp;
381  uint32_t m_subaddr_account; // subaddress account of your wallet to be used in this transfer
382  std::set<uint32_t> m_subaddr_indices; // set of address indices used as inputs in this transfer
383  std::vector<std::pair<crypto::key_image, std::vector<uint64_t>>> m_rings; // relative
384  };
385 
387  {
388  uint64_t m_amount_in;
389  uint64_t m_amount_out;
390  uint64_t m_change;
391  uint64_t m_block_height;
392  std::vector<cryptonote::tx_destination_entry> m_dests;
394  uint64_t m_timestamp;
395  uint64_t m_unlock_time;
396  uint32_t m_subaddr_account; // subaddress account of your wallet to be used in this transfer
397  std::set<uint32_t> m_subaddr_indices; // set of address indices used as inputs in this transfer
398  std::vector<std::pair<crypto::key_image, std::vector<uint64_t>>> m_rings; // relative
399 
400  confirmed_transfer_details(): m_amount_in(0), m_amount_out(0), m_change((uint64_t)-1), m_block_height(0), m_payment_id(crypto::null_hash), m_timestamp(0), m_unlock_time(0), m_subaddr_account((uint32_t)-1) {}
402  m_amount_in(utd.m_amount_in), m_amount_out(utd.m_amount_out), m_change(utd.m_change), m_block_height(height), m_dests(utd.m_dests), m_payment_id(utd.m_payment_id), m_timestamp(utd.m_timestamp), m_unlock_time(utd.m_tx.unlock_time), m_subaddr_account(utd.m_subaddr_account), m_subaddr_indices(utd.m_subaddr_indices), m_rings(utd.m_rings) {}
403  };
404 
406  {
407  std::vector<cryptonote::tx_source_entry> sources;
409  std::vector<cryptonote::tx_destination_entry> splitted_dsts; // split, includes change
410  std::vector<size_t> selected_transfers;
411  std::vector<uint8_t> extra;
412  uint64_t unlock_time;
413  bool use_rct;
415  std::vector<cryptonote::tx_destination_entry> dests; // original setup, does not include change
416  uint32_t subaddr_account; // subaddress account of your wallet to be used in this transfer
417  std::set<uint32_t> subaddr_indices; // set of address indices used as inputs in this transfer
418 
420  FIELD(sources)
421  FIELD(change_dts)
422  FIELD(splitted_dsts)
423  FIELD(selected_transfers)
424  FIELD(extra)
425  FIELD(unlock_time)
426  FIELD(use_rct)
427  FIELD(rct_config)
428  FIELD(dests)
429  FIELD(subaddr_account)
430  FIELD(subaddr_indices)
431  END_SERIALIZE()
432  };
433 
435  typedef std::unordered_multimap<crypto::hash, payment_details> payment_container;
436 
438  {
440  std::unordered_set<crypto::public_key> ignore;
441  std::unordered_set<rct::key> used_L;
442  std::unordered_set<crypto::public_key> signing_keys;
444  };
445 
446  // The convention for destinations is:
447  // dests does not include change
448  // splitted_dsts (in construction_data) does
449  struct pending_tx
450  {
452  uint64_t dust, fee;
455  std::vector<size_t> selected_transfers;
456  std::string key_images;
458  std::vector<crypto::secret_key> additional_tx_keys;
459  std::vector<cryptonote::tx_destination_entry> dests;
460  std::vector<multisig_sig> multisig_sigs;
461 
463 
465  FIELD(tx)
466  FIELD(dust)
467  FIELD(fee)
468  FIELD(dust_added_to_fee)
469  FIELD(change_dts)
470  FIELD(selected_transfers)
471  FIELD(key_images)
472  FIELD(tx_key)
473  FIELD(additional_tx_keys)
474  FIELD(dests)
475  FIELD(construction_data)
476  FIELD(multisig_sigs)
477  END_SERIALIZE()
478  };
479 
480  // The term "Unsigned tx" is not really a tx since it's not signed yet.
481  // It doesnt have tx hash, key and the integrated address is not separated into addr + payment id.
483  {
484  std::vector<tx_construction_data> txes;
485  std::pair<size_t, wallet2::transfer_container> transfers;
486  };
487 
489  {
490  std::vector<pending_tx> ptx;
491  std::vector<crypto::key_image> key_images;
492  std::unordered_map<crypto::public_key, crypto::key_image> tx_key_images;
493  };
494 
496  {
497  std::vector<pending_tx> m_ptx;
498  std::unordered_set<crypto::public_key> m_signers;
499 
501  FIELD(m_ptx)
502  FIELD(m_signers)
503  END_SERIALIZE()
504  };
505 
507  {
508  crypto::chacha_iv iv;
509  std::string account_data;
510 
512  FIELD(iv)
513  FIELD(account_data)
514  END_SERIALIZE()
515  };
516 
518  {
519  crypto::chacha_iv iv;
520  std::string cache_data;
521 
523  FIELD(iv)
524  FIELD(cache_data)
525  END_SERIALIZE()
526  };
527 
528  // GUI Address book
530  {
533  std::string m_description;
535  };
536 
538  {
540  uint64_t index_in_tx;
545  };
546 
547  typedef std::tuple<uint64_t, crypto::public_key, rct::key> get_outs_entry;
548 
550  {
553  std::vector<cryptonote::transaction> txes;
555  bool error;
556  };
557 
558  struct is_out_data
559  {
562  std::vector<boost::optional<cryptonote::subaddress_receive_info>> received;
563  };
564 
566  {
567  std::vector<cryptonote::tx_extra_field> tx_extra_fields;
568  std::vector<is_out_data> primary;
569  std::vector<is_out_data> additional;
570 
571  bool empty() const { return tx_extra_fields.empty() && primary.empty() && additional.empty(); }
572  };
573 
581  void generate(const std::string& wallet_, const epee::wipeable_string& password,
582  const epee::wipeable_string& multisig_data, bool create_address_file = false);
583 
594  crypto::secret_key generate(const std::string& wallet, const epee::wipeable_string& password,
595  const crypto::secret_key& recovery_param = crypto::secret_key(), bool recover = false,
596  bool two_random = false, bool create_address_file = false);
606  void generate(const std::string& wallet, const epee::wipeable_string& password,
607  const cryptonote::account_public_address &account_public_address,
608  const crypto::secret_key& spendkey, const crypto::secret_key& viewkey, bool create_address_file = false);
617  void generate(const std::string& wallet, const epee::wipeable_string& password,
618  const cryptonote::account_public_address &account_public_address,
619  const crypto::secret_key& viewkey = crypto::secret_key(), bool create_address_file = false);
627  void restore(const std::string& wallet_, const epee::wipeable_string& password, const std::string &device_name, bool create_address_file = false);
628 
634  std::string make_multisig(const epee::wipeable_string &password,
635  const std::vector<std::string> &info,
636  uint32_t threshold);
642  std::string make_multisig(const epee::wipeable_string &password,
643  const std::vector<crypto::secret_key> &view_keys,
644  const std::vector<crypto::public_key> &spend_keys,
645  uint32_t threshold);
646  std::string exchange_multisig_keys(const epee::wipeable_string &password,
647  const std::vector<std::string> &info);
651  std::string exchange_multisig_keys(const epee::wipeable_string &password,
652  std::unordered_set<crypto::public_key> pkeys,
653  std::vector<crypto::public_key> signers);
657  bool finalize_multisig(const epee::wipeable_string &password, const std::vector<std::string> &info);
661  bool finalize_multisig(const epee::wipeable_string &password, const std::unordered_set<crypto::public_key> &pkeys, std::vector<crypto::public_key> signers);
665  std::string get_multisig_info() const;
669  static bool verify_multisig_info(const std::string &data, crypto::secret_key &skey, crypto::public_key &pkey);
673  static bool verify_extra_multisig_info(const std::string &data, std::unordered_set<crypto::public_key> &pkeys, crypto::public_key &signer);
683  size_t import_multisig(std::vector<cryptonote::blobdata> info);
689  void rewrite(const std::string& wallet_name, const epee::wipeable_string& password);
690  void write_watch_only_wallet(const std::string& wallet_name, const epee::wipeable_string& password, std::string &new_keys_filename);
691  void load(const std::string& wallet, const epee::wipeable_string& password);
692  void store();
698  void store_to(const std::string &path, const epee::wipeable_string &password);
699 
700  std::string path() const;
701 
705  bool verify_password(const epee::wipeable_string& password);
708 
709  void encrypt_keys(const crypto::chacha_key &key);
710  void encrypt_keys(const epee::wipeable_string &password);
711  void decrypt_keys(const crypto::chacha_key &key);
712  void decrypt_keys(const epee::wipeable_string &password);
713 
716 
719 
720  bool deinit();
721  bool init(std::string daemon_address = "http://localhost:8080",
722  boost::optional<epee::net_utils::http::login> daemon_login = boost::none,
723  boost::asio::ip::tcp::endpoint proxy = {},
724  uint64_t upper_transaction_weight_limit = 0,
725  bool trusted_daemon = true,
726  epee::net_utils::ssl_options_t ssl_options = epee::net_utils::ssl_support_t::e_ssl_support_autodetect,
727  std::string blockchain_db_path = "");
728  bool set_daemon(std::string daemon_address = "http://localhost:8080",
729  boost::optional<epee::net_utils::http::login> daemon_login = boost::none, bool trusted_daemon = true,
730  epee::net_utils::ssl_options_t ssl_options = epee::net_utils::ssl_support_t::e_ssl_support_autodetect);
731 
732  void stop() { m_run.store(false, std::memory_order_relaxed); m_message_store.stop(); }
733 
736 
737  bool is_trusted_daemon() const { return m_trusted_daemon; }
738  void set_trusted_daemon(bool trusted) { m_trusted_daemon = trusted; }
739 
743  bool is_deterministic() const;
744  bool get_seed(epee::wipeable_string& electrum_words, const epee::wipeable_string &passphrase = epee::wipeable_string()) const;
745 
749  bool light_wallet() const { return m_light_wallet; }
753 
757  const std::string &get_seed_language() const;
761  void set_seed_language(const std::string &language);
762 
763  // Subaddress scheme
766  boost::optional<cryptonote::subaddress_index> get_subaddress_index(const cryptonote::account_public_address& address) const;
768  std::vector<crypto::public_key> get_subaddress_spend_public_keys(uint32_t account, uint32_t begin, uint32_t end) const;
769  std::string get_subaddress_as_str(const cryptonote::subaddress_index& index) const;
770  std::string get_address_as_str() const { return get_subaddress_as_str({0, 0}); }
771  std::string get_integrated_address_as_str(const crypto::hash8& payment_id) const;
772  void add_subaddress_account(const std::string& label, const bool update_account_tags = true);
773  size_t get_num_subaddress_accounts() const { return m_subaddress_labels.size(); }
774  size_t get_num_subaddresses(uint32_t index_major) const { return index_major < m_subaddress_labels.size() ? m_subaddress_labels[index_major].size() : 0; }
775  void add_subaddress(uint32_t index_major, const std::string& label); // throws when index is out of bound
776  void expand_subaddresses(const cryptonote::subaddress_index& index, const bool udpate_account_tags = true);
777  std::string get_subaddress_label(const cryptonote::subaddress_index& index) const;
778  void set_subaddress_label(const cryptonote::subaddress_index &index, const std::string &label);
779  void set_subaddress_lookahead(size_t major, size_t minor);
781 
782  void account_major_offset(uint32_t offset) {m_account_major_offset = offset;}
783  uint32_t account_major_offset() const {return m_account_major_offset;}
787  bool is_deprecated() const;
788  void refresh(bool trusted_daemon);
789  void refresh(bool trusted_daemon, uint64_t start_height, uint64_t & blocks_fetched);
790  void refresh(bool trusted_daemon, uint64_t start_height, uint64_t & blocks_fetched, bool& received_money, bool check_pool = true);
791  bool refresh(bool trusted_daemon, uint64_t & blocks_fetched, bool& received_money, bool& ok);
792 
795 
797  bool watch_only() const { return m_watch_only; }
798  bool multisig(bool *ready = NULL, uint32_t *threshold = NULL, uint32_t *total = NULL) const;
799  bool has_multisig_partial_key_images() const;
800  bool has_unknown_key_images() const;
801  bool get_multisig_seed(epee::wipeable_string& seed, const epee::wipeable_string &passphrase = std::string(), bool raw = true) const;
802  bool key_on_device() const { return get_device_type() != hw::device::device_type::SOFTWARE; }
804  bool reconnect_device();
805 
806  // locked & unlocked balance of given or current subaddress account
807  uint64_t balance(uint32_t subaddr_index_major) const;
808  uint64_t unlocked_balance(uint32_t subaddr_index_major, uint64_t *blocks_to_unlock = NULL) const;
809  // locked & unlocked balance per subaddress of given or current subaddress account
810  std::map<uint32_t, uint64_t> balance_per_subaddress(uint32_t subaddr_index_major) const;
811  std::map<uint32_t, std::pair<uint64_t, uint64_t>> unlocked_balance_per_subaddress(uint32_t subaddr_index_major) const;
812  // all locked & unlocked balances of all subaddress accounts
813  uint64_t balance_all() const;
814  uint64_t unlocked_balance_all(uint64_t *blocks_to_unlock = NULL) const;
815  template<typename T>
816  void transfer_selected(const std::vector<cryptonote::tx_destination_entry>& dsts, const std::vector<size_t>& selected_transfers, size_t fake_outputs_count,
817  std::vector<std::vector<tools::wallet2::get_outs_entry>> &outs,
818  uint64_t unlock_time, uint64_t fee, const std::vector<uint8_t>& extra, T destination_split_strategy, const tx_dust_policy& dust_policy, cryptonote::transaction& tx, pending_tx &ptx);
819  void transfer_selected_rct(std::vector<cryptonote::tx_destination_entry> dsts, const std::vector<size_t>& selected_transfers, size_t fake_outputs_count,
820  std::vector<std::vector<tools::wallet2::get_outs_entry>> &outs,
821  uint64_t unlock_time, uint64_t fee, const std::vector<uint8_t>& extra, cryptonote::transaction& tx, pending_tx &ptx, const rct::RCTConfig &rct_config);
822 
823  void commit_tx(pending_tx& ptx_vector);
824  void commit_tx(std::vector<pending_tx>& ptx_vector);
825  bool save_tx(const std::vector<pending_tx>& ptx_vector, const std::string &filename) const;
826  std::string dump_tx_to_str(const std::vector<pending_tx> &ptx_vector) const;
827  std::string save_multisig_tx(multisig_tx_set txs);
828  bool save_multisig_tx(const multisig_tx_set &txs, const std::string &filename);
829  std::string save_multisig_tx(const std::vector<pending_tx>& ptx_vector);
830  bool save_multisig_tx(const std::vector<pending_tx>& ptx_vector, const std::string &filename);
831  multisig_tx_set make_multisig_tx_set(const std::vector<pending_tx>& ptx_vector) const;
832  // load unsigned tx from file and sign it. Takes confirmation callback as argument. Used by the cli wallet
833  bool sign_tx(const std::string &unsigned_filename, const std::string &signed_filename, std::vector<wallet2::pending_tx> &ptx, std::function<bool(const unsigned_tx_set&)> accept_func = NULL, bool export_raw = false);
834  // sign unsigned tx. Takes unsigned_tx_set as argument. Used by GUI
835  bool sign_tx(unsigned_tx_set &exported_txs, const std::string &signed_filename, std::vector<wallet2::pending_tx> &ptx, bool export_raw = false);
836  bool sign_tx(unsigned_tx_set &exported_txs, std::vector<wallet2::pending_tx> &ptx, signed_tx_set &signed_txs);
837  std::string sign_tx_dump_to_str(unsigned_tx_set &exported_txs, std::vector<wallet2::pending_tx> &ptx, signed_tx_set &signed_txes);
838  // load unsigned_tx_set from file.
839  bool load_unsigned_tx(const std::string &unsigned_filename, unsigned_tx_set &exported_txs) const;
840  bool parse_unsigned_tx_from_str(const std::string &unsigned_tx_st, unsigned_tx_set &exported_txs) const;
841  bool load_tx(const std::string &signed_filename, std::vector<tools::wallet2::pending_tx> &ptx, std::function<bool(const signed_tx_set&)> accept_func = NULL);
842  bool parse_tx_from_str(const std::string &signed_tx_st, std::vector<tools::wallet2::pending_tx> &ptx, std::function<bool(const signed_tx_set &)> accept_func);
843  std::vector<wallet2::pending_tx> create_transactions_2(std::vector<cryptonote::tx_destination_entry> dsts, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector<uint8_t>& extra, uint32_t subaddr_account, std::set<uint32_t> subaddr_indices); // pass subaddr_indices by value on purpose
844  std::vector<wallet2::pending_tx> create_transactions_all(uint64_t below, const cryptonote::account_public_address &address, bool is_subaddress, const size_t outputs, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector<uint8_t>& extra, uint32_t subaddr_account, std::set<uint32_t> subaddr_indices);
845  std::vector<wallet2::pending_tx> create_transactions_single(const crypto::key_image &ki, const cryptonote::account_public_address &address, bool is_subaddress, const size_t outputs, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector<uint8_t>& extra);
846  std::vector<wallet2::pending_tx> create_transactions_from(const cryptonote::account_public_address &address, bool is_subaddress, const size_t outputs, std::vector<size_t> unused_transfers_indices, std::vector<size_t> unused_dust_indices, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector<uint8_t>& extra);
847  bool sanity_check(const std::vector<wallet2::pending_tx> &ptx_vector, std::vector<cryptonote::tx_destination_entry> dsts) const;
848  void cold_tx_aux_import(const std::vector<pending_tx>& ptx, const std::vector<std::string>& tx_device_aux);
849  void cold_sign_tx(const std::vector<pending_tx>& ptx_vector, signed_tx_set &exported_txs, std::vector<cryptonote::address_parse_info> &dsts_info, std::vector<std::string> & tx_device_aux);
850  uint64_t cold_key_image_sync(uint64_t &spent, uint64_t &unspent);
851  bool parse_multisig_tx_from_str(std::string multisig_tx_st, multisig_tx_set &exported_txs) const;
852  bool load_multisig_tx(cryptonote::blobdata blob, multisig_tx_set &exported_txs, std::function<bool(const multisig_tx_set&)> accept_func = NULL);
853  bool load_multisig_tx_from_file(const std::string &filename, multisig_tx_set &exported_txs, std::function<bool(const multisig_tx_set&)> accept_func = NULL);
854  bool sign_multisig_tx_from_file(const std::string &filename, std::vector<crypto::hash> &txids, std::function<bool(const multisig_tx_set&)> accept_func);
855  bool sign_multisig_tx(multisig_tx_set &exported_txs, std::vector<crypto::hash> &txids);
856  bool sign_multisig_tx_to_file(multisig_tx_set &exported_txs, const std::string &filename, std::vector<crypto::hash> &txids);
857  std::vector<pending_tx> create_unmixable_sweep_transactions();
859  bool check_connection(uint32_t *version = NULL, bool *ssl = NULL, uint32_t timeout = 200000);
860  void get_transfers(wallet2::transfer_container& incoming_transfers) const;
861  void get_payments(const crypto::hash& payment_id, std::list<wallet2::payment_details>& payments, uint64_t min_height = 0, const boost::optional<uint32_t>& subaddr_account = boost::none, const std::set<uint32_t>& subaddr_indices = {}) const;
862  void get_payments(std::list<std::pair<crypto::hash,wallet2::payment_details>>& payments, uint64_t min_height, uint64_t max_height = (uint64_t)-1, const boost::optional<uint32_t>& subaddr_account = boost::none, const std::set<uint32_t>& subaddr_indices = {}) const;
863  void get_payments_out(std::list<std::pair<crypto::hash,wallet2::confirmed_transfer_details>>& confirmed_payments,
864  uint64_t min_height, uint64_t max_height = (uint64_t)-1, const boost::optional<uint32_t>& subaddr_account = boost::none, const std::set<uint32_t>& subaddr_indices = {}) const;
865  void get_unconfirmed_payments_out(std::list<std::pair<crypto::hash,wallet2::unconfirmed_transfer_details>>& unconfirmed_payments, const boost::optional<uint32_t>& subaddr_account = boost::none, const std::set<uint32_t>& subaddr_indices = {}) const;
866  void get_unconfirmed_payments(std::list<std::pair<crypto::hash,wallet2::pool_payment_details>>& unconfirmed_payments, const boost::optional<uint32_t>& subaddr_account = boost::none, const std::set<uint32_t>& subaddr_indices = {}) const;
867 
869  void rescan_spent();
870  void rescan_blockchain(bool hard, bool refresh = true, bool keep_key_images = false);
871  bool is_transfer_unlocked(const transfer_details& td) const;
872  bool is_transfer_unlocked(uint64_t unlock_time, uint64_t block_height) const;
873 
874  uint64_t get_last_block_reward() const { return m_last_block_reward; }
876 
877  template <class t_archive>
878  inline void serialize(t_archive &a, const unsigned int ver)
879  {
880  uint64_t dummy_refresh_height = 0; // moved to keys file
881  if(ver < 5)
882  return;
883  if (ver < 19)
884  {
885  std::vector<crypto::hash> blockchain;
886  a & blockchain;
887  for (const auto &b: blockchain)
888  {
890  }
891  }
892  else
893  {
894  a & m_blockchain;
895  }
896  a & m_transfers;
898  a & m_key_images;
899  if(ver < 6)
900  return;
902  if(ver < 7)
903  return;
904  a & m_payments;
905  if(ver < 8)
906  return;
907  a & m_tx_keys;
908  if(ver < 9)
909  return;
910  a & m_confirmed_txs;
911  if(ver < 11)
912  return;
913  a & dummy_refresh_height;
914  if(ver < 12)
915  return;
916  a & m_tx_notes;
917  if(ver < 13)
918  return;
919  if (ver < 17)
920  {
921  // we're loading an old version, where m_unconfirmed_payments was a std::map
922  std::unordered_map<crypto::hash, payment_details> m;
923  a & m;
924  for (std::unordered_map<crypto::hash, payment_details>::const_iterator i = m.begin(); i != m.end(); ++i)
925  m_unconfirmed_payments.insert(std::make_pair(i->first, pool_payment_details{i->second, false}));
926  }
927  if(ver < 14)
928  return;
929  if(ver < 15)
930  {
931  // we're loading an older wallet without a pubkey map, rebuild it
932  for (size_t i = 0; i < m_transfers.size(); ++i)
933  {
934  const transfer_details &td = m_transfers[i];
936  const cryptonote::txout_to_key &o = boost::get<const cryptonote::txout_to_key>(out.target);
937  m_pub_keys.emplace(o.key, i);
938  }
939  return;
940  }
941  a & m_pub_keys;
942  if(ver < 16)
943  return;
944  a & m_address_book;
945  if(ver < 17)
946  return;
947  if (ver < 22)
948  {
949  // we're loading an old version, where m_unconfirmed_payments payload was payment_details
950  std::unordered_multimap<crypto::hash, payment_details> m;
951  a & m;
952  for (const auto &i: m)
953  m_unconfirmed_payments.insert(std::make_pair(i.first, pool_payment_details{i.second, false}));
954  }
955  if(ver < 18)
956  return;
957  a & m_scanned_pool_txs[0];
958  a & m_scanned_pool_txs[1];
959  if (ver < 20)
960  return;
961  a & m_subaddresses;
962  std::unordered_map<cryptonote::subaddress_index, crypto::public_key> dummy_subaddresses_inv;
963  a & dummy_subaddresses_inv;
966  if(ver < 21)
967  return;
968  a & m_attributes;
969  if(ver < 22)
970  return;
972  if(ver < 23)
973  return;
974  a & m_account_tags;
975  if(ver < 24)
976  return;
978  if(ver < 25)
979  return;
981  if(ver < 26)
982  return;
983  a & m_tx_device;
984  if(ver < 27)
985  return;
987  if(ver < 28)
988  return;
990  }
991 
998  static void wallet_exists(const std::string& file_path, bool& keys_file_exists, bool& wallet_file_exists);
1004  static std::string get_human_readable_timestamp(uint64_t ts)
1005  {
1006  char buffer[64];
1007  if (ts < 1234567890)
1008  return "<unknown>";
1009  time_t tt = ts;
1010  struct tm tm;
1011  #ifdef WIN32
1012  gmtime_s(&tm, &tt);
1013  #else
1014  gmtime_r(&tt, &tm);
1015  #endif
1016  uint64_t now = time(NULL);
1017  uint64_t diff = ts > now ? ts - now : now - ts;
1018  if (diff > 24*3600)
1019  strftime(buffer, sizeof(buffer), "%Y-%m-%d", &tm);
1020  else
1021  strftime(buffer, sizeof(buffer), "%I:%M:%S %p", &tm);
1022  return std::string(buffer);
1023 }
1024 //----------------------------------------------------------------------------------------------------
1025  static bool wallet_valid_path_format(const std::string& file_path);
1026  static bool parse_long_payment_id(const std::string& payment_id_str, crypto::hash& payment_id);
1027  static bool parse_short_payment_id(const std::string& payment_id_str, crypto::hash8& payment_id);
1028  static bool parse_payment_id(const std::string& payment_id_str, crypto::hash& payment_id);
1029 
1032  bool print_ring_members() const { return m_print_ring_members; }
1033  void print_ring_members(bool value) { m_print_ring_members = value; }
1034  bool store_tx_info() const { return m_store_tx_info; }
1036  uint32_t default_mixin() const { return m_default_mixin; }
1037  void default_mixin(uint32_t m) { m_default_mixin = m; }
1038  uint32_t get_default_priority() const { return m_default_priority; }
1039  void set_default_priority(uint32_t p) { m_default_priority = p; }
1040  bool auto_refresh() const { return m_auto_refresh; }
1041  void auto_refresh(bool r) { m_auto_refresh = r; }
1047  uint32_t get_min_output_count() const { return m_min_output_count; }
1048  void set_min_output_value(uint64_t value) { m_min_output_value = value; }
1049  uint64_t get_min_output_value() const { return m_min_output_value; }
1050  void merge_destinations(bool merge) { m_merge_destinations = merge; }
1051  bool merge_destinations() const { return m_merge_destinations; }
1052  bool confirm_backlog() const { return m_confirm_backlog; }
1053  void confirm_backlog(bool always) { m_confirm_backlog = always; }
1058  bool auto_low_priority() const { return m_auto_low_priority; }
1059  void auto_low_priority(bool value) { m_auto_low_priority = value; }
1063  void key_reuse_mitigation2(bool value) { m_key_reuse_mitigation2 = value; }
1064  uint64_t segregation_height() const { return m_segregation_height; }
1070  bool track_uses() const { return m_track_uses; }
1071  void track_uses(bool value) { m_track_uses = value; }
1074  const std::string & device_name() const { return m_device_name; }
1075  void device_name(const std::string & device_name) { m_device_name = device_name; }
1076  const std::string & device_derivation_path() const { return m_device_derivation_path; }
1078 
1079  bool get_tx_key_cached(const crypto::hash &txid, crypto::secret_key &tx_key, std::vector<crypto::secret_key> &additional_tx_keys) const;
1080  void set_tx_key(const crypto::hash &txid, const crypto::secret_key &tx_key, const std::vector<crypto::secret_key> &additional_tx_keys);
1081  bool get_tx_key(const crypto::hash &txid, crypto::secret_key &tx_key, std::vector<crypto::secret_key> &additional_tx_keys);
1082  void check_tx_key(const crypto::hash &txid, const crypto::secret_key &tx_key, const std::vector<crypto::secret_key> &additional_tx_keys, const cryptonote::account_public_address &address, uint64_t &received, bool &in_pool, uint64_t &confirmations);
1083  void check_tx_key_helper(const crypto::hash &txid, const crypto::key_derivation &derivation, const std::vector<crypto::key_derivation> &additional_derivations, const cryptonote::account_public_address &address, uint64_t &received, bool &in_pool, uint64_t &confirmations);
1084  void check_tx_key_helper(const cryptonote::transaction &tx, const crypto::key_derivation &derivation, const std::vector<crypto::key_derivation> &additional_derivations, const cryptonote::account_public_address &address, uint64_t &received) const;
1085  std::string get_tx_proof(const crypto::hash &txid, const cryptonote::account_public_address &address, bool is_subaddress, const std::string &message);
1086  std::string get_tx_proof(const cryptonote::transaction &tx, const crypto::secret_key &tx_key, const std::vector<crypto::secret_key> &additional_tx_keys, const cryptonote::account_public_address &address, bool is_subaddress, const std::string &message) const;
1087  bool check_tx_proof(const crypto::hash &txid, const cryptonote::account_public_address &address, bool is_subaddress, const std::string &message, const std::string &sig_str, uint64_t &received, bool &in_pool, uint64_t &confirmations);
1088  bool check_tx_proof(const cryptonote::transaction &tx, const cryptonote::account_public_address &address, bool is_subaddress, const std::string &message, const std::string &sig_str, uint64_t &received) const;
1089 
1090  std::string get_spend_proof(const crypto::hash &txid, const std::string &message);
1091  bool check_spend_proof(const crypto::hash &txid, const std::string &message, const std::string &sig_str);
1092 
1100  std::string get_reserve_proof(const boost::optional<std::pair<uint32_t, uint64_t>> &account_minreserve, const std::string &message);
1110  bool check_reserve_proof(const cryptonote::account_public_address &address, const std::string &message, const std::string &sig_str, uint64_t &total, uint64_t &spent);
1111 
1115  std::vector<address_book_row> get_address_book() const { return m_address_book; }
1116  bool add_address_book_row(const cryptonote::account_public_address &address, const crypto::hash &payment_id, const std::string &description, bool is_subaddress);
1117  bool delete_address_book_row(std::size_t row_id);
1118 
1119  uint64_t get_num_rct_outputs();
1120  size_t get_num_transfer_details() const { return m_transfers.size(); }
1121  const transfer_details &get_transfer_details(size_t idx) const;
1122 
1123  void get_hard_fork_info(uint8_t version, uint64_t &earliest_height) const;
1124  bool use_fork_rules(uint8_t version, int64_t early_blocks = 0) const;
1125  int get_fee_algorithm() const;
1126 
1127  std::string get_wallet_file() const;
1128  std::string get_keys_file() const;
1129  std::string get_daemon_address() const;
1130  const boost::optional<epee::net_utils::http::login>& get_daemon_login() const { return m_daemon_login; }
1131  uint64_t get_daemon_blockchain_height(std::string& err) const;
1132  uint64_t get_daemon_blockchain_target_height(std::string& err);
1136  uint64_t get_approximate_blockchain_height() const;
1137  uint64_t estimate_blockchain_height();
1138  std::vector<size_t> select_available_outputs_from_histogram(uint64_t count, bool atleast, bool unlocked, bool allow_rct);
1139  std::vector<size_t> select_available_outputs(const std::function<bool(const transfer_details &td)> &f) const;
1140  std::vector<size_t> select_available_unmixable_outputs();
1141  std::vector<size_t> select_available_mixable_outputs();
1142 
1143  size_t pop_best_value_from(const transfer_container &transfers, std::vector<size_t> &unused_dust_indices, const std::vector<size_t>& selected_transfers, bool smallest = false) const;
1144  size_t pop_best_value(std::vector<size_t> &unused_dust_indices, const std::vector<size_t>& selected_transfers, bool smallest = false) const;
1145 
1146  void set_tx_note(const crypto::hash &txid, const std::string &note);
1147  std::string get_tx_note(const crypto::hash &txid) const;
1148 
1149  void set_tx_device_aux(const crypto::hash &txid, const std::string &aux);
1150  std::string get_tx_device_aux(const crypto::hash &txid) const;
1151 
1152  void set_description(const std::string &description);
1153  std::string get_description() const;
1154 
1159  const std::pair<std::map<std::string, std::string>, std::vector<std::string>>& get_account_tags();
1165  void set_account_tag(const std::set<uint32_t> &account_indices, const std::string& tag);
1171  void set_account_tag_description(const std::string& tag, const std::string& description);
1172 
1173  std::string sign(const std::string &data) const;
1174  bool verify(const std::string &data, const cryptonote::account_public_address &address, const std::string &signature) const;
1175 
1182  std::string sign_multisig_participant(const std::string& data) const;
1190  bool verify_with_public_key(const std::string &data, const crypto::public_key &public_key, const std::string &signature) const;
1191 
1192  // Import/Export wallet data
1193  std::pair<size_t, std::vector<tools::wallet2::transfer_details>> export_outputs(bool all = false) const;
1194  std::string export_outputs_to_str(bool all = false) const;
1195  size_t import_outputs(const std::pair<size_t, std::vector<tools::wallet2::transfer_details>> &outputs);
1196  size_t import_outputs_from_str(const std::string &outputs_st);
1198  void import_payments(const payment_container &payments);
1199  void import_payments_out(const std::list<std::pair<crypto::hash,wallet2::confirmed_transfer_details>> &confirmed_payments);
1200  std::tuple<size_t, crypto::hash, std::vector<crypto::hash>> export_blockchain() const;
1201  void import_blockchain(const std::tuple<size_t, crypto::hash, std::vector<crypto::hash>> &bc);
1202  bool export_key_images(const std::string &filename) const;
1203  std::pair<size_t, std::vector<std::pair<crypto::key_image, crypto::signature>>> export_key_images(bool all = false) const;
1204  uint64_t import_key_images(const std::vector<std::pair<crypto::key_image, crypto::signature>> &signed_key_images, size_t offset, uint64_t &spent, uint64_t &unspent, bool check_spent = true);
1205  uint64_t import_key_images(const std::string &filename, uint64_t &spent, uint64_t &unspent);
1206  bool import_key_images(std::vector<crypto::key_image> key_images, size_t offset=0, boost::optional<std::unordered_set<size_t>> selected_transfers=boost::none);
1207  bool import_key_images(signed_tx_set & signed_tx, size_t offset=0, bool only_selected_transfers=false);
1209 
1210  void update_pool_state(bool refreshed = false);
1211  void remove_obsolete_pool_txs(const std::vector<crypto::hash> &tx_hashes);
1212 
1213  std::string encrypt(const char *plaintext, size_t len, const crypto::secret_key &skey, bool authenticated = true) const;
1214  std::string encrypt(const epee::span<char> &span, const crypto::secret_key &skey, bool authenticated = true) const;
1215  std::string encrypt(const std::string &plaintext, const crypto::secret_key &skey, bool authenticated = true) const;
1216  std::string encrypt(const epee::wipeable_string &plaintext, const crypto::secret_key &skey, bool authenticated = true) const;
1217  std::string encrypt_with_view_secret_key(const std::string &plaintext, bool authenticated = true) const;
1218  template<typename T=std::string> T decrypt(const std::string &ciphertext, const crypto::secret_key &skey, bool authenticated = true) const;
1219  std::string decrypt_with_view_secret_key(const std::string &ciphertext, bool authenticated = true) const;
1220 
1221  std::string make_uri(const std::string &address, const std::string &payment_id, uint64_t amount, const std::string &tx_description, const std::string &recipient_name, std::string &error) const;
1222  bool parse_uri(const std::string &uri, std::string &address, std::string &payment_id, uint64_t &amount, std::string &tx_description, std::string &recipient_name, std::vector<std::string> &unknown_parameters, std::string &error);
1223 
1224  uint64_t get_blockchain_height_by_date(uint16_t year, uint8_t month, uint8_t day); // 1<=month<=12, 1<=day<=31
1225 
1226  bool is_synced() const;
1227 
1228  std::vector<std::pair<uint64_t, uint64_t>> estimate_backlog(const std::vector<std::pair<double, double>> &fee_levels);
1229  std::vector<std::pair<uint64_t, uint64_t>> estimate_backlog(uint64_t min_tx_weight, uint64_t max_tx_weight, const std::vector<uint64_t> &fees);
1230 
1231  uint64_t get_fee_multiplier(uint32_t priority, int fee_algorithm = -1) const;
1232  uint64_t get_base_fee() const;
1233  uint64_t get_fee_quantization_mask() const;
1234  uint64_t get_min_ring_size() const;
1235  uint64_t get_max_ring_size() const;
1236  uint64_t adjust_mixin(uint64_t mixin) const;
1237  uint32_t adjust_priority(uint32_t priority);
1238 
1239  bool is_unattended() const { return m_unattended; }
1240 
1241  // Light wallet specific functions
1242  // fetch unspent outs from lw node and store in m_transfers
1244  // fetch txs and store in m_payments
1246  // get_address_info
1248  // Login. new_address is true if address hasn't been used on lw node before.
1249  bool light_wallet_login(bool &new_address);
1250  // Send an import request to lw node. returns info about import fee, address and payment_id
1252  // get random outputs from light wallet server
1253  void light_wallet_get_outs(std::vector<std::vector<get_outs_entry>> &outs, const std::vector<size_t> &selected_transfers, size_t fake_outputs_count);
1254  // Parse rct string
1255  bool light_wallet_parse_rct_str(const std::string& rct_string, const crypto::public_key& tx_pub_key, uint64_t internal_output_index, rct::key& decrypted_mask, rct::key& rct_commit, bool decrypt) const;
1256  // check if key image is ours
1257  bool light_wallet_key_image_is_ours(const crypto::key_image& key_image, const crypto::public_key& tx_public_key, uint64_t out_index);
1258 
1259  /*
1260  * "attributes" are a mechanism to store an arbitrary number of string values
1261  * on the level of the wallet as a whole, identified by keys. Their introduction,
1262  * technically the unordered map m_attributes stored as part of a wallet file,
1263  * led to a new wallet file version, but now new singular pieces of info may be added
1264  * without the need for a new version.
1265  *
1266  * The first and so far only value stored as such an attribute is the description.
1267  * It's stored under the standard key ATTRIBUTE_DESCRIPTION (see method set_description).
1268  *
1269  * The mechanism is open to all clients and allows them to use it for storing basically any
1270  * single string values in a wallet. To avoid the problem that different clients possibly
1271  * overwrite or misunderstand each other's attributes, a two-part key scheme is
1272  * proposed: <client name>.<value name>
1273  */
1274  const char* const ATTRIBUTE_DESCRIPTION = "wallet2.description";
1275  void set_attribute(const std::string &key, const std::string &value);
1276  std::string get_attribute(const std::string &key) const;
1277 
1282 
1283  template<class t_request, class t_response>
1284  inline bool invoke_http_json(const boost::string_ref uri, const t_request& req, t_response& res, std::chrono::milliseconds timeout = std::chrono::seconds(15), const boost::string_ref http_method = "GET")
1285  {
1286  if (m_offline) return false;
1287  boost::lock_guard<boost::recursive_mutex> lock(m_daemon_rpc_mutex);
1288  return epee::net_utils::invoke_http_json(uri, req, res, m_http_client, timeout, http_method);
1289  }
1290  template<class t_request, class t_response>
1291  inline bool invoke_http_bin(const boost::string_ref uri, const t_request& req, t_response& res, std::chrono::milliseconds timeout = std::chrono::seconds(15), const boost::string_ref http_method = "GET")
1292  {
1293  if (m_offline) return false;
1294  boost::lock_guard<boost::recursive_mutex> lock(m_daemon_rpc_mutex);
1295  return epee::net_utils::invoke_http_bin(uri, req, res, m_http_client, timeout, http_method);
1296  }
1297  template<class t_request, class t_response>
1298  inline bool invoke_http_json_rpc(const boost::string_ref uri, const std::string& method_name, const t_request& req, t_response& res, std::chrono::milliseconds timeout = std::chrono::seconds(15), const boost::string_ref http_method = "GET", const std::string& req_id = "0")
1299  {
1300  if (m_offline) return false;
1301  boost::lock_guard<boost::recursive_mutex> lock(m_daemon_rpc_mutex);
1302  return epee::net_utils::invoke_http_json_rpc(uri, method_name, req, res, m_http_client, timeout, http_method, req_id);
1303  }
1304 
1305  bool set_ring_database(const std::string &filename);
1306  const std::string get_ring_database() const { return m_ring_database; }
1307  bool get_ring(const crypto::key_image &key_image, std::vector<uint64_t> &outs);
1308  bool get_rings(const crypto::hash &txid, std::vector<std::pair<crypto::key_image, std::vector<uint64_t>>> &outs);
1309  bool set_ring(const crypto::key_image &key_image, const std::vector<uint64_t> &outs, bool relative);
1310  bool unset_ring(const std::vector<crypto::key_image> &key_images);
1311  bool unset_ring(const crypto::hash &txid);
1312  bool find_and_save_rings(bool force = true);
1313 
1314  bool blackball_output(const std::pair<uint64_t, uint64_t> &output);
1315  bool set_blackballed_outputs(const std::vector<std::pair<uint64_t, uint64_t>> &outputs, bool add = false);
1316  bool unblackball_output(const std::pair<uint64_t, uint64_t> &output);
1317  bool is_output_blackballed(const std::pair<uint64_t, uint64_t> &output) const;
1318 
1319  void freeze(size_t idx);
1320  void thaw(size_t idx);
1321  bool frozen(size_t idx) const;
1322  void freeze(const crypto::key_image &ki);
1323  void thaw(const crypto::key_image &ki);
1324  bool frozen(const crypto::key_image &ki) const;
1325  bool frozen(const transfer_details &td) const;
1326 
1327  uint64_t get_bytes_sent() const;
1328  uint64_t get_bytes_received() const;
1329  void add_checkpoint(uint64_t height, std::string hash);
1330 
1331  // MMS -------------------------------------------------------------------------------------------------
1335 
1336  bool lock_keys_file();
1337  bool unlock_keys_file();
1338  bool is_keys_file_locked() const;
1339 
1340  void change_password(const std::string &filename, const epee::wipeable_string &original_password, const epee::wipeable_string &new_password);
1341 
1342  void set_tx_notify(const std::shared_ptr<tools::Notify> &notify) { m_tx_notify = notify; }
1343 
1344  bool is_tx_spendtime_unlocked(uint64_t unlock_time, uint64_t block_height) const;
1345  void hash_m_transfer(const transfer_details & transfer, crypto::hash &hash) const;
1346  uint64_t hash_m_transfers(int64_t transfer_height, crypto::hash &hash) const;
1347  void finish_rescan_bc_keep_key_images(uint64_t transfer_height, const crypto::hash &hash);
1348  void enable_dns(bool enable) { m_use_dns = enable; }
1349  void set_offline(bool offline = true);
1350 
1351  private:
1359  bool store_keys(const std::string& keys_file_name, const epee::wipeable_string& password, bool watch_only = false);
1365  bool load_keys(const std::string& keys_file_name, const epee::wipeable_string& password);
1366  void process_new_transaction(const crypto::hash &txid, const cryptonote::transaction& tx, const std::vector<uint64_t> &o_indices, uint64_t height, uint64_t ts, bool miner_tx, bool pool, bool double_spend_seen, const tx_cache_data &tx_cache_data, std::map<std::pair<uint64_t, uint64_t>, size_t> *output_tracker_cache = NULL);
1367  bool should_skip_block(const cryptonote::block &b, uint64_t height) const;
1368  void process_new_blockchain_entry(const cryptonote::block& b, const cryptonote::block_complete_entry& bche, const parsed_block &parsed_block, const crypto::hash& bl_id, uint64_t height, const std::vector<tx_cache_data> &tx_cache_data, size_t tx_cache_data_offset, std::map<std::pair<uint64_t, uint64_t>, size_t> *output_tracker_cache = NULL);
1369  void detach_blockchain(uint64_t height, std::map<std::pair<uint64_t, uint64_t>, size_t> *output_tracker_cache = NULL);
1370  void get_short_chain_history(std::list<crypto::hash>& ids, uint64_t granularity = 1) const;
1371  bool clear();
1372  void clear_soft(bool keep_key_images=false);
1373  void pull_blocks(uint64_t start_height, uint64_t& blocks_start_height, const std::list<crypto::hash> &short_chain_history, std::vector<cryptonote::block_complete_entry> &blocks, std::vector<cryptonote::COMMAND_RPC_GET_BLOCKS_FAST::block_output_indices> &o_indices);
1374  void pull_hashes(uint64_t start_height, uint64_t& blocks_start_height, const std::list<crypto::hash> &short_chain_history, std::vector<crypto::hash> &hashes);
1375  void fast_refresh(uint64_t stop_height, uint64_t &blocks_start_height, std::list<crypto::hash> &short_chain_history, bool force = false);
1376  void pull_and_parse_next_blocks(uint64_t start_height, uint64_t &blocks_start_height, std::list<crypto::hash> &short_chain_history, const std::vector<cryptonote::block_complete_entry> &prev_blocks, const std::vector<parsed_block> &prev_parsed_blocks, std::vector<cryptonote::block_complete_entry> &blocks, std::vector<parsed_block> &parsed_blocks, bool &error);
1377  void process_parsed_blocks(uint64_t start_height, const std::vector<cryptonote::block_complete_entry> &blocks, const std::vector<parsed_block> &parsed_blocks, uint64_t& blocks_added, std::map<std::pair<uint64_t, uint64_t>, size_t> *output_tracker_cache = NULL);
1378  uint64_t select_transfers(uint64_t needed_money, std::vector<size_t> unused_transfers_indices, std::vector<size_t>& selected_transfers) const;
1379  bool prepare_file_names(const std::string& file_path);
1380  void process_unconfirmed(const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t height);
1381  void process_outgoing(const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t height, uint64_t ts, uint64_t spent, uint64_t received, uint32_t subaddr_account, const std::set<uint32_t>& subaddr_indices);
1382  void add_unconfirmed_tx(const cryptonote::transaction& tx, uint64_t amount_in, const std::vector<cryptonote::tx_destination_entry> &dests, const crypto::hash &payment_id, uint64_t change_amount, uint32_t subaddr_account, const std::set<uint32_t>& subaddr_indices);
1383  void generate_genesis(cryptonote::block& b) const;
1384  void check_genesis(const crypto::hash& genesis_hash) const; //throws
1385  bool generate_chacha_key_from_secret_keys(crypto::chacha_key &key) const;
1386  void generate_chacha_key_from_password(const epee::wipeable_string &pass, crypto::chacha_key &key) const;
1387  crypto::hash get_payment_id(const pending_tx &ptx) const;
1388  void check_acc_out_precomp(const cryptonote::tx_out &o, const crypto::key_derivation &derivation, const std::vector<crypto::key_derivation> &additional_derivations, size_t i, tx_scan_info_t &tx_scan_info) const;
1389  void check_acc_out_precomp(const cryptonote::tx_out &o, const crypto::key_derivation &derivation, const std::vector<crypto::key_derivation> &additional_derivations, size_t i, const is_out_data *is_out_data, tx_scan_info_t &tx_scan_info) const;
1390  void check_acc_out_precomp_once(const cryptonote::tx_out &o, const crypto::key_derivation &derivation, const std::vector<crypto::key_derivation> &additional_derivations, size_t i, const is_out_data *is_out_data, tx_scan_info_t &tx_scan_info, bool &already_seen) const;
1391  void parse_block_round(const cryptonote::blobdata &blob, cryptonote::block &bl, crypto::hash &bl_id, bool &error) const;
1392  uint64_t get_upper_transaction_weight_limit() const;
1393  std::vector<uint64_t> get_unspent_amounts_vector() const;
1394  uint64_t get_dynamic_base_fee_estimate() const;
1395  float get_output_relatedness(const transfer_details &td0, const transfer_details &td1) const;
1396  std::vector<size_t> pick_preferred_rct_inputs(uint64_t needed_money, uint32_t subaddr_account, const std::set<uint32_t> &subaddr_indices) const;
1397  void set_spent(size_t idx, uint64_t height);
1398  void set_unspent(size_t idx);
1399  void get_outs(std::vector<std::vector<get_outs_entry>> &outs, const std::vector<size_t> &selected_transfers, size_t fake_outputs_count);
1400  bool tx_add_fake_output(std::vector<std::vector<tools::wallet2::get_outs_entry>> &outs, uint64_t global_index, const crypto::public_key& tx_public_key, const rct::key& mask, uint64_t real_index, bool unlocked) const;
1401  bool should_pick_a_second_output(bool use_rct, size_t n_transfers, const std::vector<size_t> &unused_transfers_indices, const std::vector<size_t> &unused_dust_indices) const;
1402  std::vector<size_t> get_only_rct(const std::vector<size_t> &unused_dust_indices, const std::vector<size_t> &unused_transfers_indices) const;
1403  void scan_output(const cryptonote::transaction &tx, bool miner_tx, const crypto::public_key &tx_pub_key, size_t i, tx_scan_info_t &tx_scan_info, int &num_vouts_received, std::unordered_map<cryptonote::subaddress_index, uint64_t> &tx_money_got_in_outs, std::vector<size_t> &outs, bool pool);
1404  void trim_hashchain();
1406  rct::multisig_kLRki get_multisig_composite_kLRki(size_t n, const std::unordered_set<crypto::public_key> &ignore_set, std::unordered_set<rct::key> &used_L, std::unordered_set<rct::key> &new_used_L) const;
1407  rct::multisig_kLRki get_multisig_kLRki(size_t n, const rct::key &k) const;
1408  rct::key get_multisig_k(size_t idx, const std::unordered_set<rct::key> &used_L) const;
1409  void update_multisig_rescan_info(const std::vector<std::vector<rct::key>> &multisig_k, const std::vector<std::vector<tools::wallet2::multisig_info>> &info, size_t n);
1410  bool add_rings(const crypto::chacha_key &key, const cryptonote::transaction_prefix &tx);
1411  bool add_rings(const cryptonote::transaction_prefix &tx);
1413  bool get_ring(const crypto::chacha_key &key, const crypto::key_image &key_image, std::vector<uint64_t> &outs);
1414  crypto::chacha_key get_ringdb_key();
1415  void setup_keys(const epee::wipeable_string &password);
1416  size_t get_transfer_details(const crypto::key_image &ki) const;
1417 
1418  void register_devices();
1419  hw::device& lookup_device(const std::string & device_descriptor);
1420 
1421  bool get_rct_distribution(uint64_t &start_height, std::vector<uint64_t> &distribution);
1422 
1423  uint64_t get_segregation_fork_height() const;
1424  void unpack_multisig_info(const std::vector<std::string>& info,
1425  std::vector<crypto::public_key> &public_keys,
1426  std::vector<crypto::secret_key> &secret_keys) const;
1427  bool unpack_extra_multisig_info(const std::vector<std::string>& info,
1428  std::vector<crypto::public_key> &signers,
1429  std::unordered_set<crypto::public_key> &pkeys) const;
1430 
1431  void cache_tx_data(const cryptonote::transaction& tx, const crypto::hash &txid, tx_cache_data &tx_cache_data) const;
1432  std::shared_ptr<std::map<std::pair<uint64_t, uint64_t>, size_t>> create_output_tracker_cache() const;
1433 
1434  void init_type(hw::device::device_type device_type);
1435  void setup_new_blockchain();
1436  void create_keys_file(const std::string &wallet_, bool watch_only, const epee::wipeable_string &password, bool create_address_file);
1437 
1439  void on_device_button_request(uint64_t code);
1440  void on_device_button_pressed();
1441  boost::optional<epee::wipeable_string> on_device_pin_request();
1442  boost::optional<epee::wipeable_string> on_device_passphrase_request(bool on_device);
1443  void on_device_progress(const hw::device_progress& event);
1444 
1445  std::string get_rpc_status(const std::string &s) const;
1446  void throw_on_rpc_response_error(const boost::optional<std::string> &status, const char *method) const;
1447 
1449 
1450 
1452  boost::optional<epee::net_utils::http::login> m_daemon_login;
1453  std::string m_daemon_address;
1454  std::string m_wallet_file;
1455  std::string m_keys_file;
1456  std::string m_mms_file;
1457  epee::net_utils::http::http_simple_client m_http_client;
1459  std::unordered_map<crypto::hash, unconfirmed_transfer_details> m_unconfirmed_txs;
1460  std::unordered_map<crypto::hash, confirmed_transfer_details> m_confirmed_txs;
1461  std::unordered_multimap<crypto::hash, pool_payment_details> m_unconfirmed_payments;
1462  std::unordered_map<crypto::hash, crypto::secret_key> m_tx_keys;
1466  std::unordered_map<crypto::hash, std::vector<crypto::secret_key>> m_additional_tx_keys;
1467 
1470  std::unordered_map<crypto::key_image, size_t> m_key_images;
1471  std::unordered_map<crypto::public_key, size_t> m_pub_keys;
1473  std::unordered_map<crypto::public_key, cryptonote::subaddress_index> m_subaddresses;
1474  std::vector<std::vector<std::string>> m_subaddress_labels;
1475  std::unordered_map<crypto::hash, std::string> m_tx_notes;
1476  std::unordered_map<std::string, std::string> m_attributes;
1477  std::vector<tools::wallet2::address_book_row> m_address_book;
1478  std::pair<std::map<std::string, std::string>, std::vector<std::string>> m_account_tags;
1479  uint64_t m_upper_transaction_weight_limit; //TODO: auto-calc this value or request from daemon, now use some fixed value
1480  const std::vector<std::vector<tools::wallet2::multisig_info>> *m_multisig_rescan_info;
1481  const std::vector<std::vector<rct::key>> *m_multisig_rescan_k;
1482  std::unordered_map<crypto::public_key, crypto::key_image> m_cold_key_images;
1483 
1484  std::atomic<bool> m_run;
1485 
1486  boost::recursive_mutex m_daemon_rpc_mutex;
1487 
1492  uint64_t m_kdf_rounds;
1493  std::string seed_language;
1496  bool m_multisig;
1498  std::vector<crypto::public_key> m_multisig_signers;
1499  //in case of general M/N multisig wallet we should perform N - M + 1 key exchange rounds and remember how many rounds are passed.
1501  std::vector<crypto::public_key> m_multisig_derivations;
1511  // If m_refresh_from_block_height is explicitly set to zero we need this to differentiate it from the case that
1512  // m_refresh_from_block_height was defaulted to zero.*/
1532  std::unordered_set<crypto::hash> m_scanned_pool_txs[2];
1534  std::string m_device_name;
1539 
1540  // Aux transaction data from device
1541  std::unordered_map<crypto::hash, std::string> m_tx_device;
1542 
1543  // Light wallet
1544  bool m_light_wallet; /* sends view key to daemon for scanning */
1551  // Light wallet info needed to populate m_payment requires 2 separate api calls (get_address_txs and get_unspent_outs)
1552  // We save the info from the first call in m_light_wallet_address_txs for easier lookup.
1553  std::unordered_map<crypto::hash, address_tx> m_light_wallet_address_txs;
1554  // store calculated key image for faster lookup
1555  std::unordered_map<crypto::public_key, std::map<uint64_t, crypto::key_image> > m_key_image_cache;
1556 
1557  std::string m_ring_database;
1559  std::unique_ptr<ringdb> m_ringdb;
1560  boost::optional<crypto::chacha_key> m_ringdb_key;
1561 
1563  std::unique_ptr<tools::file_locker> m_keys_file_locker;
1564 
1569 
1570  crypto::chacha_key m_cache_key;
1571  boost::optional<epee::wipeable_string> m_encrypt_keys_after_refresh;
1572 
1575 
1576  std::shared_ptr<tools::Notify> m_tx_notify;
1577  std::unique_ptr<wallet_device_callback> m_device_callback;
1578 
1580 
1582  };
1583 }
1585 BOOST_CLASS_VERSION(tools::wallet2::transfer_details, 12)
1586 BOOST_CLASS_VERSION(tools::wallet2::multisig_info, 1)
1587 BOOST_CLASS_VERSION(tools::wallet2::multisig_info::LR, 0)
1588 BOOST_CLASS_VERSION(tools::wallet2::multisig_tx_set, 1)
1589 BOOST_CLASS_VERSION(tools::wallet2::payment_details, 4)
1590 BOOST_CLASS_VERSION(tools::wallet2::pool_payment_details, 1)
1591 BOOST_CLASS_VERSION(tools::wallet2::unconfirmed_transfer_details, 8)
1592 BOOST_CLASS_VERSION(tools::wallet2::confirmed_transfer_details, 6)
1593 BOOST_CLASS_VERSION(tools::wallet2::address_book_row, 17)
1594 BOOST_CLASS_VERSION(tools::wallet2::reserve_proof_entry, 0)
1596 BOOST_CLASS_VERSION(tools::wallet2::signed_tx_set, 1)
1598 BOOST_CLASS_VERSION(tools::wallet2::pending_tx, 3)
1599 BOOST_CLASS_VERSION(tools::wallet2::multisig_sig, 0)
1600 
1601 namespace boost
1602 {
1603  namespace serialization
1604  {
1605  template <class Archive>
1606  inline typename std::enable_if<!Archive::is_loading::value, void>::type initialize_transfer_details(Archive &a, tools::wallet2::transfer_details &x, const boost::serialization::version_type ver)
1607  {
1608  }
1609  template <class Archive>
1610  inline typename std::enable_if<Archive::is_loading::value, void>::type initialize_transfer_details(Archive &a, tools::wallet2::transfer_details &x, const boost::serialization::version_type ver)
1611  {
1612  if (ver < 1)
1613  {
1614  x.m_mask = rct::identity();
1615  x.m_amount = x.m_tx.vout[x.m_internal_output_index].amount;
1616  }
1617  if (ver < 2)
1618  {
1619  x.m_spent_height = 0;
1620  }
1621  if (ver < 4)
1622  {
1623  x.m_rct = x.m_tx.vout[x.m_internal_output_index].amount == 0;
1624  }
1625  if (ver < 6)
1626  {
1627  x.m_key_image_known = true;
1628  }
1629  if (ver < 7)
1630  {
1631  x.m_pk_index = 0;
1632  }
1633  if (ver < 8)
1634  {
1635  x.m_subaddr_index = {};
1636  }
1637  if (ver < 9)
1638  {
1639  x.m_key_image_partial = false;
1640  x.m_multisig_k.clear();
1641  x.m_multisig_info.clear();
1642  }
1643  if (ver < 10)
1644  {
1645  x.m_key_image_request = false;
1646  }
1647  if (ver < 12)
1648  {
1649  x.m_frozen = false;
1650  }
1651  }
1652 
1653  template <class Archive>
1654  inline void serialize(Archive &a, tools::wallet2::transfer_details &x, const boost::serialization::version_type ver)
1655  {
1656  a & x.m_block_height;
1659  if (ver < 3)
1660  {
1662  a & tx;
1663  x.m_tx = (const cryptonote::transaction_prefix&)tx;
1665  }
1666  else
1667  {
1668  a & x.m_tx;
1669  }
1670  a & x.m_spent;
1671  a & x.m_key_image;
1672  if (ver < 1)
1673  {
1674  // ensure mask and amount are set
1675  initialize_transfer_details(a, x, ver);
1676  return;
1677  }
1678  a & x.m_mask;
1679  a & x.m_amount;
1680  if (ver < 2)
1681  {
1682  initialize_transfer_details(a, x, ver);
1683  return;
1684  }
1685  a & x.m_spent_height;
1686  if (ver < 3)
1687  {
1688  initialize_transfer_details(a, x, ver);
1689  return;
1690  }
1691  a & x.m_txid;
1692  if (ver < 4)
1693  {
1694  initialize_transfer_details(a, x, ver);
1695  return;
1696  }
1697  a & x.m_rct;
1698  if (ver < 5)
1699  {
1700  initialize_transfer_details(a, x, ver);
1701  return;
1702  }
1703  if (ver < 6)
1704  {
1705  // v5 did not properly initialize
1706  uint8_t u;
1707  a & u;
1708  x.m_key_image_known = true;
1709  return;
1710  }
1711  a & x.m_key_image_known;
1712  if (ver < 7)
1713  {
1714  initialize_transfer_details(a, x, ver);
1715  return;
1716  }
1717  a & x.m_pk_index;
1718  if (ver < 8)
1719  {
1720  initialize_transfer_details(a, x, ver);
1721  return;
1722  }
1723  a & x.m_subaddr_index;
1724  if (ver < 9)
1725  {
1726  initialize_transfer_details(a, x, ver);
1727  return;
1728  }
1729  a & x.m_multisig_info;
1730  a & x.m_multisig_k;
1731  a & x.m_key_image_partial;
1732  if (ver < 10)
1733  {
1734  initialize_transfer_details(a, x, ver);
1735  return;
1736  }
1737  a & x.m_key_image_request;
1738  if (ver < 11)
1739  {
1740  initialize_transfer_details(a, x, ver);
1741  return;
1742  }
1743  a & x.m_uses;
1744  if (ver < 12)
1745  {
1746  initialize_transfer_details(a, x, ver);
1747  return;
1748  }
1749  a & x.m_frozen;
1750  }
1751 
1752  template <class Archive>
1753  inline void serialize(Archive &a, tools::wallet2::multisig_info::LR &x, const boost::serialization::version_type ver)
1754  {
1755  a & x.m_L;
1756  a & x.m_R;
1757  }
1758 
1759  template <class Archive>
1760  inline void serialize(Archive &a, tools::wallet2::multisig_info &x, const boost::serialization::version_type ver)
1761  {
1762  a & x.m_signer;
1763  a & x.m_LR;
1764  a & x.m_partial_key_images;
1765  }
1766 
1767  template <class Archive>
1768  inline void serialize(Archive &a, tools::wallet2::multisig_tx_set &x, const boost::serialization::version_type ver)
1769  {
1770  a & x.m_ptx;
1771  a & x.m_signers;
1772  }
1773 
1774  template <class Archive>
1775  inline void serialize(Archive &a, tools::wallet2::unconfirmed_transfer_details &x, const boost::serialization::version_type ver)
1776  {
1777  a & x.m_change;
1778  a & x.m_sent_time;
1779  if (ver < 5)
1780  {
1782  a & tx;
1783  x.m_tx = (const cryptonote::transaction_prefix&)tx;
1784  }
1785  else
1786  {
1787  a & x.m_tx;
1788  }
1789  if (ver < 1)
1790  return;
1791  a & x.m_dests;
1792  a & x.m_payment_id;
1793  if (ver < 2)
1794  return;
1795  a & x.m_state;
1796  if (ver < 3)
1797  return;
1798  a & x.m_timestamp;
1799  if (ver < 4)
1800  return;
1801  a & x.m_amount_in;
1802  a & x.m_amount_out;
1803  if (ver < 6)
1804  {
1805  // v<6 may not have change accumulated in m_amount_out, which is a pain,
1806  // as it's readily understood to be sum of outputs.
1807  // We convert it to include change from v6
1808  if (!typename Archive::is_saving() && x.m_change != (uint64_t)-1)
1809  x.m_amount_out += x.m_change;
1810  }
1811  if (ver < 7)
1812  {
1813  x.m_subaddr_account = 0;
1814  return;
1815  }
1816  a & x.m_subaddr_account;
1817  a & x.m_subaddr_indices;
1818  if (ver < 8)
1819  return;
1820  a & x.m_rings;
1821  }
1822 
1823  template <class Archive>
1824  inline void serialize(Archive &a, tools::wallet2::confirmed_transfer_details &x, const boost::serialization::version_type ver)
1825  {
1826  a & x.m_amount_in;
1827  a & x.m_amount_out;
1828  a & x.m_change;
1829  a & x.m_block_height;
1830  if (ver < 1)
1831  return;
1832  a & x.m_dests;
1833  a & x.m_payment_id;
1834  if (ver < 2)
1835  return;
1836  a & x.m_timestamp;
1837  if (ver < 3)
1838  {
1839  // v<3 may not have change accumulated in m_amount_out, which is a pain,
1840  // as it's readily understood to be sum of outputs. Whether it got added
1841  // or not depends on whether it came from a unconfirmed_transfer_details
1842  // (not included) or not (included). We can't reliably tell here, so we
1843  // check whether either yields a "negative" fee, or use the other if so.
1844  // We convert it to include change from v3
1845  if (!typename Archive::is_saving() && x.m_change != (uint64_t)-1)
1846  {
1847  if (x.m_amount_in > (x.m_amount_out + x.m_change))
1848  x.m_amount_out += x.m_change;
1849  }
1850  }
1851  if (ver < 4)
1852  {
1853  if (!typename Archive::is_saving())
1854  x.m_unlock_time = 0;
1855  return;
1856  }
1857  a & x.m_unlock_time;
1858  if (ver < 5)
1859  {
1860  x.m_subaddr_account = 0;
1861  return;
1862  }
1863  a & x.m_subaddr_account;
1864  a & x.m_subaddr_indices;
1865  if (ver < 6)
1866  return;
1867  a & x.m_rings;
1868  }
1869 
1870  template <class Archive>
1871  inline void serialize(Archive& a, tools::wallet2::payment_details& x, const boost::serialization::version_type ver)
1872  {
1873  a & x.m_tx_hash;
1874  a & x.m_amount;
1875  a & x.m_block_height;
1876  a & x.m_unlock_time;
1877  if (ver < 1)
1878  return;
1879  a & x.m_timestamp;
1880  if (ver < 2)
1881  {
1882  x.m_coinbase = false;
1883  x.m_subaddr_index = {};
1884  return;
1885  }
1886  a & x.m_subaddr_index;
1887  if (ver < 3)
1888  {
1889  x.m_coinbase = false;
1890  x.m_fee = 0;
1891  return;
1892  }
1893  a & x.m_fee;
1894  if (ver < 4)
1895  {
1896  x.m_coinbase = false;
1897  return;
1898  }
1899  a & x.m_coinbase;
1900  }
1901 
1902  template <class Archive>
1903  inline void serialize(Archive& a, tools::wallet2::pool_payment_details& x, const boost::serialization::version_type ver)
1904  {
1905  a & x.m_pd;
1906  a & x.m_double_spend_seen;
1907  }
1908 
1909  template <class Archive>
1910  inline void serialize(Archive& a, tools::wallet2::address_book_row& x, const boost::serialization::version_type ver)
1911  {
1912  a & x.m_address;
1913  a & x.m_payment_id;
1914  a & x.m_description;
1915  if (ver < 17)
1916  {
1917  x.m_is_subaddress = false;
1918  return;
1919  }
1920  a & x.m_is_subaddress;
1921  }
1922 
1923  template <class Archive>
1924  inline void serialize(Archive& a, tools::wallet2::reserve_proof_entry& x, const boost::serialization::version_type ver)
1925  {
1926  a & x.txid;
1927  a & x.index_in_tx;
1928  a & x.shared_secret;
1929  a & x.key_image;
1930  a & x.shared_secret_sig;
1931  a & x.key_image_sig;
1932  }
1933 
1934  template <class Archive>
1935  inline void serialize(Archive &a, tools::wallet2::unsigned_tx_set &x, const boost::serialization::version_type ver)
1936  {
1937  a & x.txes;
1938  a & x.transfers;
1939  }
1940 
1941  template <class Archive>
1942  inline void serialize(Archive &a, tools::wallet2::signed_tx_set &x, const boost::serialization::version_type ver)
1943  {
1944  a & x.ptx;
1945  a & x.key_images;
1946  if (ver < 1)
1947  return;
1948  a & x.tx_key_images;
1949  }
1950 
1951  template <class Archive>
1952  inline void serialize(Archive &a, tools::wallet2::tx_construction_data &x, const boost::serialization::version_type ver)
1953  {
1954  a & x.sources;
1955  a & x.change_dts;
1956  a & x.splitted_dsts;
1957  if (ver < 2)
1958  {
1959  // load list to vector
1960  std::list<size_t> selected_transfers;
1961  a & selected_transfers;
1962  x.selected_transfers.clear();
1963  x.selected_transfers.reserve(selected_transfers.size());
1964  for (size_t t: selected_transfers)
1965  x.selected_transfers.push_back(t);
1966  }
1967  a & x.extra;
1968  a & x.unlock_time;
1969  a & x.use_rct;
1970  a & x.dests;
1971  if (ver < 1)
1972  {
1973  x.subaddr_account = 0;
1974  return;
1975  }
1976  a & x.subaddr_account;
1977  a & x.subaddr_indices;
1978  if (ver < 2)
1979  {
1980  if (!typename Archive::is_saving())
1982  return;
1983  }
1984  a & x.selected_transfers;
1985  if (ver < 3)
1986  {
1987  if (!typename Archive::is_saving())
1989  return;
1990  }
1991  if (ver < 4)
1992  {
1993  bool use_bulletproofs = x.rct_config.range_proof_type != rct::RangeProofBorromean;
1994  a & use_bulletproofs;
1995  if (!typename Archive::is_saving())
1996  x.rct_config = { use_bulletproofs ? rct::RangeProofBulletproof : rct::RangeProofBorromean, 0 };
1997  return;
1998  }
1999  a & x.rct_config;
2000  }
2001 
2002  template <class Archive>
2003  inline void serialize(Archive &a, tools::wallet2::multisig_sig &x, const boost::serialization::version_type ver)
2004  {
2005  a & x.sigs;
2006  a & x.ignore;
2007  a & x.used_L;
2008  a & x.signing_keys;
2009  a & x.msout;
2010  }
2011 
2012  template <class Archive>
2013  inline void serialize(Archive &a, tools::wallet2::pending_tx &x, const boost::serialization::version_type ver)
2014  {
2015  a & x.tx;
2016  a & x.dust;
2017  a & x.fee;
2018  a & x.dust_added_to_fee;
2019  a & x.change_dts;
2020  if (ver < 2)
2021  {
2022  // load list to vector
2023  std::list<size_t> selected_transfers;
2024  a & selected_transfers;
2025  x.selected_transfers.clear();
2026  x.selected_transfers.reserve(selected_transfers.size());
2027  for (size_t t: selected_transfers)
2028  x.selected_transfers.push_back(t);
2029  }
2030  a & x.key_images;
2031  a & x.tx_key;
2032  a & x.dests;
2033  a & x.construction_data;
2034  if (ver < 1)
2035  return;
2036  a & x.additional_tx_keys;
2037  if (ver < 2)
2038  return;
2039  a & x.selected_transfers;
2040  if (ver < 3)
2041  return;
2042  a & x.multisig_sigs;
2043  }
2044  }
2045 }
2046 
2047 namespace tools
2048 {
2049 
2050  namespace detail
2051  {
2052  //----------------------------------------------------------------------------------------------------
2053  inline void digit_split_strategy(const std::vector<cryptonote::tx_destination_entry>& dsts,
2054  const cryptonote::tx_destination_entry& change_dst, uint64_t dust_threshold,
2055  std::vector<cryptonote::tx_destination_entry>& splitted_dsts, std::vector<cryptonote::tx_destination_entry> &dust_dsts)
2056  {
2057  splitted_dsts.clear();
2058  dust_dsts.clear();
2059 
2060  for(auto& de: dsts)
2061  {
2063  [&](uint64_t chunk) { splitted_dsts.push_back(cryptonote::tx_destination_entry(chunk, de.addr, de.is_subaddress)); },
2064  [&](uint64_t a_dust) { splitted_dsts.push_back(cryptonote::tx_destination_entry(a_dust, de.addr, de.is_subaddress)); } );
2065  }
2066 
2068  [&](uint64_t chunk) {
2069  if (chunk <= dust_threshold)
2070  dust_dsts.push_back(cryptonote::tx_destination_entry(chunk, change_dst.addr, false));
2071  else
2072  splitted_dsts.push_back(cryptonote::tx_destination_entry(chunk, change_dst.addr, false));
2073  },
2074  [&](uint64_t a_dust) { dust_dsts.push_back(cryptonote::tx_destination_entry(a_dust, change_dst.addr, false)); } );
2075  }
2076  //----------------------------------------------------------------------------------------------------
2077  inline void null_split_strategy(const std::vector<cryptonote::tx_destination_entry>& dsts,
2078  const cryptonote::tx_destination_entry& change_dst, uint64_t dust_threshold,
2079  std::vector<cryptonote::tx_destination_entry>& splitted_dsts, std::vector<cryptonote::tx_destination_entry> &dust_dsts)
2080  {
2081  splitted_dsts = dsts;
2082 
2083  dust_dsts.clear();
2084  uint64_t change = change_dst.amount;
2085 
2086  if (0 != change)
2087  {
2088  splitted_dsts.push_back(cryptonote::tx_destination_entry(change, change_dst.addr, false));
2089  }
2090  }
2091  //----------------------------------------------------------------------------------------------------
2093  {
2094  std::string indexes;
2095  std::for_each(src.outputs.begin(), src.outputs.end(), [&](const cryptonote::tx_source_entry::output_entry& s_e) { indexes += boost::to_string(s_e.first) + " "; });
2096  LOG_PRINT_L0("amount=" << cryptonote::print_money(src.amount) << ", real_output=" <<src.real_output << ", real_output_in_tx_index=" << src.real_output_in_tx_index << ", indexes: " << indexes);
2097  }
2098  //----------------------------------------------------------------------------------------------------
2099  }
2100  //----------------------------------------------------------------------------------------------------
2101 }
#define s(x, c)
Definition: aesb.c:47
uint64_t height
Definition: blockchain.cpp:91
uint8_t version
Definition: blockchain.cpp:90
time_t time
Definition: blockchain.cpp:93
uint8_t threshold
Definition: blockchain.cpp:92
Definition: account.h:77
A container for blockchain checkpoints.
Definition: checkpoints.h:52
Definition: cryptonote_basic.h:171
std::vector< tx_out > vout
Definition: cryptonote_basic.h:179
Definition: cryptonote_basic.h:205
Definition: device.hpp:71
Definition: device.hpp:87
device_type
Definition: device.hpp:105
Definition: device.hpp:77
Definition: message_store.h:203
void stop()
Definition: message_store.h:280
Definition: node_rpc_proxy.h:41
Definition: wallet2.h:82
const std::vector< uint64_t > & rct_offsets
Definition: wallet2.h:99
uint64_t num_rct_outputs
Definition: wallet2.h:101
double average_output_time
Definition: wallet2.h:102
const uint64_t * end
Definition: wallet2.h:100
std::gamma_distribution< double > gamma
Definition: wallet2.h:98
struct tools::gamma_picker::gamma_engine engine
const uint64_t * begin
Definition: wallet2.h:100
gamma_picker(const std::vector< uint64_t > &rct_offsets)
Definition: wallet2.cpp:1004
uint64_t pick()
Definition: wallet2.cpp:1006
Definition: wallet2.h:171
void crop(size_t height)
Definition: wallet2.h:182
void clear()
Definition: wallet2.h:183
bool is_in_bounds(size_t idx) const
Definition: wallet2.h:179
size_t offset() const
Definition: wallet2.h:176
crypto::hash & operator[](size_t idx)
Definition: wallet2.h:181
size_t m_offset
Definition: wallet2.h:197
void trim(size_t height)
Definition: wallet2.h:185
const crypto::hash & operator[](size_t idx) const
Definition: wallet2.h:180
void push_back(const crypto::hash &hash)
Definition: wallet2.h:178
bool empty() const
Definition: wallet2.h:184
hashchain()
Definition: wallet2.h:173
void serialize(t_archive &a, const unsigned int ver)
Definition: wallet2.h:189
void refill(const crypto::hash &hash)
Definition: wallet2.h:186
crypto::hash m_genesis
Definition: wallet2.h:198
const crypto::hash & genesis() const
Definition: wallet2.h:177
std::deque< crypto::hash > m_blockchain
Definition: wallet2.h:199
size_t size() const
Definition: wallet2.h:175
Definition: wallet2.h:118
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)
Definition: wallet2.h:124
virtual void on_device_button_pressed()
Definition: wallet2.h:134
virtual void on_money_received(uint64_t height, const crypto::hash &txid, const cryptonote::transaction &tx, uint64_t amount, const cryptonote::subaddress_index &subaddr_index, uint64_t unlock_time)
Definition: wallet2.h:122
virtual boost::optional< epee::wipeable_string > on_get_password(const char *reason)
Definition: wallet2.h:126
virtual void on_pool_tx_removed(const crypto::hash &txid)
Definition: wallet2.h:139
virtual void on_lw_unconfirmed_money_received(uint64_t height, const crypto::hash &txid, uint64_t amount)
Definition: wallet2.h:130
virtual void on_device_button_request(uint64_t code)
Definition: wallet2.h:133
virtual void on_lw_money_spent(uint64_t height, const crypto::hash &txid, uint64_t amount)
Definition: wallet2.h:131
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)
Definition: wallet2.h:123
virtual void on_new_block(uint64_t height, const cryptonote::block &block)
Definition: wallet2.h:121
virtual ~i_wallet2_callback()
Definition: wallet2.h:140
virtual boost::optional< epee::wipeable_string > on_device_passphrase_request(bool on_device)
Definition: wallet2.h:136
virtual boost::optional< epee::wipeable_string > on_device_pin_request()
Definition: wallet2.h:135
virtual void on_skip_transaction(uint64_t height, const crypto::hash &txid, const cryptonote::transaction &tx)
Definition: wallet2.h:125
virtual void on_lw_money_received(uint64_t height, const crypto::hash &txid, uint64_t amount)
Definition: wallet2.h:129
virtual void on_lw_new_block(uint64_t height)
Definition: wallet2.h:128
virtual void on_device_progress(const hw::device_progress &event)
Definition: wallet2.h:137
Definition: password.h:42
Definition: wallet2.h:204
uint64_t m_segregation_height
Definition: wallet2.h:1526
transfer_container m_transfers
Definition: wallet2.h:1468
void process_new_transaction(const crypto::hash &txid, const cryptonote::transaction &tx, const std::vector< uint64_t > &o_indices, uint64_t height, uint64_t ts, bool miner_tx, bool pool, bool double_spend_seen, const tx_cache_data &tx_cache_data, std::map< std::pair< uint64_t, uint64_t >, size_t > *output_tracker_cache=NULL)
Definition: wallet2.cpp:1776
bool get_multisig_seed(epee::wipeable_string &seed, const epee::wipeable_string &passphrase=std::string(), bool raw=true) const
Definition: wallet2.cpp:1320
bool m_confirm_non_default_ring_size
Definition: wallet2.h:1515
BackgroundMiningSetupType m_setup_background_mining
Definition: wallet2.h:1529
std::unordered_map< crypto::hash, std::string > m_tx_device
Definition: wallet2.h:1541
uint64_t fallback_to_pow_checkpoint_height
Definition: wallet2.h:1464
void expand_subaddresses(const cryptonote::subaddress_index &index, const bool udpate_account_tags=true)
Definition: wallet2.cpp:1471
float get_output_relatedness(const transfer_details &td0, const transfer_details &td1) const
Definition: wallet2.cpp:5969
void add_unconfirmed_tx(const cryptonote::transaction &tx, uint64_t amount_in, const std::vector< cryptonote::tx_destination_entry > &dests, const crypto::hash &payment_id, uint64_t change_amount, uint32_t subaddr_account, const std::set< uint32_t > &subaddr_indices)
Definition: wallet2.cpp:6070
bool should_skip_block(const cryptonote::block &b, uint64_t height) const
Definition: wallet2.cpp:2386
void on_device_progress(const hw::device_progress &event)
Definition: wallet2.cpp:13130
uint64_t get_max_ring_size() const
Definition: wallet2.cpp:7045
std::string exchange_multisig_keys(const epee::wipeable_string &password, const std::vector< std::string > &info)
Definition: wallet2.cpp:4730
cryptonote::account_base m_account
Definition: wallet2.h:1451
bool add_address_book_row(const cryptonote::account_public_address &address, const crypto::hash &payment_id, const std::string &description, bool is_subaddress)
Definition: wallet2.cpp:3071
bool sanity_check(const std::vector< wallet2::pending_tx > &ptx_vector, std::vector< cryptonote::tx_destination_entry > dsts) const
Definition: wallet2.cpp:9749
bool unlock_keys_file()
Definition: wallet2.cpp:7416
void pull_and_parse_next_blocks(uint64_t start_height, uint64_t &blocks_start_height, std::list< crypto::hash > &short_chain_history, const std::vector< cryptonote::block_complete_entry > &prev_blocks, const std::vector< parsed_block > &prev_parsed_blocks, std::vector< cryptonote::block_complete_entry > &blocks, std::vector< parsed_block > &parsed_blocks, bool &error)
Definition: wallet2.cpp:2692
std::map< uint32_t, std::pair< uint64_t, uint64_t > > unlocked_balance_per_subaddress(uint32_t subaddr_index_major) const
Definition: wallet2.cpp:5667
bool parse_unsigned_tx_from_str(const std::string &unsigned_tx_st, unsigned_tx_set &exported_txs) const
Definition: wallet2.cpp:6271
NodeRPCProxy m_node_rpc_proxy
Definition: wallet2.h:1531
static const char * tr(const char *str)
Definition: wallet2.cpp:987
uint32_t get_confirm_backlog_threshold() const
Definition: wallet2.h:1055
static bool has_testnet_option(const boost::program_options::variables_map &vm)
Definition: wallet2.cpp:1166
bool set_daemon(std::string daemon_address="http://localhost:8080", boost::optional< epee::net_utils::http::login > daemon_login=boost::none, bool trusted_daemon=true, epee::net_utils::ssl_options_t ssl_options=epee::net_utils::ssl_support_t::e_ssl_support_autodetect)
Definition: wallet2.cpp:1261
cryptonote::blobdata export_multisig()
Definition: wallet2.cpp:12453
bool segregate_pre_fork_outputs() const
Definition: wallet2.h:1060
bool is_tx_spendtime_unlocked(uint64_t unlock_time, uint64_t block_height) const
Definition: wallet2.cpp:5889
void auto_refresh(bool r)
Definition: wallet2.h:1041
void key_reuse_mitigation2(bool value)
Definition: wallet2.h:1063
bool m_merge_destinations
Definition: wallet2.h:1519
bool is_unattended() const
Definition: wallet2.h:1239
bool load_unsigned_tx(const std::string &unsigned_filename, unsigned_tx_set &exported_txs) const
Definition: wallet2.cpp:6252
const std::vector< std::vector< rct::key > > * m_multisig_rescan_k
Definition: wallet2.h:1481
std::vector< size_t > pick_preferred_rct_inputs(uint64_t needed_money, uint32_t subaddr_account, const std::set< uint32_t > &subaddr_indices) const
Definition: wallet2.cpp:8585
bool m_explicit_refresh_from_block_height
Definition: wallet2.h:1513
crypto::public_key get_multisig_signing_public_key(size_t idx) const
Definition: wallet2.cpp:12373
bool watch_only() const
Definition: wallet2.h:797
std::vector< wallet2::pending_tx > create_transactions_2(std::vector< cryptonote::tx_destination_entry > dsts, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector< uint8_t > &extra, uint32_t subaddr_account, std::set< uint32_t > subaddr_indices)
Definition: wallet2.cpp:9184
boost::optional< epee::net_utils::http::login > m_daemon_login
Definition: wallet2.h:1452
std::string m_device_derivation_path
Definition: wallet2.h:1535
void parse_block_round(const cryptonote::blobdata &blob, cryptonote::block &bl, crypto::hash &bl_id, bool &error) const
Definition: wallet2.cpp:2463
boost::optional< crypto::chacha_key > m_ringdb_key
Definition: wallet2.h:1560
uint64_t get_base_fee() const
Definition: wallet2.cpp:6985
void set_trusted_daemon(bool trusted)
Definition: wallet2.h:738
bool m_confirm_backlog
Definition: wallet2.h:1520
bool merge_destinations() const
Definition: wallet2.h:1051
void always_confirm_transfers(bool always)
Definition: wallet2.h:1031
bool sign_multisig_tx_to_file(multisig_tx_set &exported_txs, const std::string &filename, std::vector< crypto::hash > &txids)
Definition: wallet2.cpp:6910
void light_wallet_get_address_txs()
Definition: wallet2.cpp:8913
size_t import_multisig(std::vector< cryptonote::blobdata > info)
Definition: wallet2.cpp:12526
void load(const std::string &wallet, const epee::wipeable_string &password)
Definition: wallet2.cpp:5283
const std::vector< std::vector< tools::wallet2::multisig_info > > * m_multisig_rescan_info
Definition: wallet2.h:1480
bool invoke_http_json(const boost::string_ref uri, const t_request &req, t_response &res, std::chrono::milliseconds timeout=std::chrono::seconds(15), const boost::string_ref http_method="GET")
Definition: wallet2.h:1284
void scan_output(const cryptonote::transaction &tx, bool miner_tx, const crypto::public_key &tx_pub_key, size_t i, tx_scan_info_t &tx_scan_info, int &num_vouts_received, std::unordered_map< cryptonote::subaddress_index, uint64_t > &tx_money_got_in_outs, std::vector< size_t > &outs, bool pool)
Definition: wallet2.cpp:1688
std::map< uint32_t, uint64_t > balance_per_subaddress(uint32_t subaddr_index_major) const
Definition: wallet2.cpp:5638
bool m_original_keys_available
Definition: wallet2.h:1566
std::unordered_map< crypto::public_key, cryptonote::subaddress_index > m_subaddresses
Definition: wallet2.h:1473
uint64_t balance(uint32_t subaddr_index_major) const
Definition: wallet2.cpp:5612
std::string export_outputs_to_str(bool all=false) const
Definition: wallet2.cpp:12203
void default_mixin(uint32_t m)
Definition: wallet2.h:1037
std::string encrypt(const char *plaintext, size_t len, const crypto::secret_key &skey, bool authenticated=true) const
Definition: wallet2.cpp:12640
uint64_t get_num_rct_outputs()
Definition: wallet2.cpp:10285
void rescan_blockchain(bool hard, bool refresh=true, bool keep_key_images=false)
Definition: wallet2.cpp:5845
hw::device::device_type m_key_device_type
Definition: wallet2.h:1490
uint64_t cold_key_image_sync(uint64_t &spent, uint64_t &unspent)
Definition: wallet2.cpp:10153
rct::multisig_kLRki get_multisig_composite_kLRki(size_t n, const std::unordered_set< crypto::public_key > &ignore_set, std::unordered_set< rct::key > &used_L, std::unordered_set< rct::key > &new_used_L) const
Definition: wallet2.cpp:12405
void add_checkpoint(uint64_t height, std::string hash)
Definition: wallet2.cpp:13225
std::vector< wallet2::pending_tx > create_transactions_single(const crypto::key_image &ki, const cryptonote::account_public_address &address, bool is_subaddress, const size_t outputs, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector< uint8_t > &extra)
Definition: wallet2.cpp:9870
void get_payments_out(std::list< std::pair< crypto::hash, wallet2::confirmed_transfer_details >> &confirmed_payments, uint64_t min_height, uint64_t max_height=(uint64_t) -1, const boost::optional< uint32_t > &subaddr_account=boost::none, const std::set< uint32_t > &subaddr_indices={}) const
Definition: wallet2.cpp:5759
uint64_t m_last_block_reward
Definition: wallet2.h:1562
static std::pair< std::unique_ptr< wallet2 >, password_container > make_new(const boost::program_options::variables_map &vm, bool unattended, const std::function< boost::optional< password_container >(const char *, bool)> &password_prompter)
Uses stdin and stdout. Returns a wallet2 and password for wallet with no file if no errors.
Definition: wallet2.cpp:1243
void track_uses(bool value)
Definition: wallet2.h:1071
void refresh(bool trusted_daemon)
Definition: wallet2.cpp:2680
void set_tx_note(const crypto::hash &txid, const std::string &note)
Definition: wallet2.cpp:11457
std::vector< size_t > select_available_outputs_from_histogram(uint64_t count, bool atleast, bool unlocked, bool allow_rct)
Definition: wallet2.cpp:10246
void set_default_priority(uint32_t p)
Definition: wallet2.h:1039
std::string seed_language
Definition: wallet2.h:1493
bool invoke_http_bin(const boost::string_ref uri, const t_request &req, t_response &res, std::chrono::milliseconds timeout=std::chrono::seconds(15), const boost::string_ref http_method="GET")
Definition: wallet2.h:1291
bool m_ignore_fractional_outputs
Definition: wallet2.h:1527
bool add_rings(const crypto::chacha_key &key, const cryptonote::transaction_prefix &tx)
Definition: wallet2.cpp:7195
void set_tx_device_aux(const crypto::hash &txid, const std::string &aux)
Definition: wallet2.cpp:11470
bool m_print_ring_members
Definition: wallet2.h:1503
void enable_dns(bool enable)
Definition: wallet2.h:1348
void freeze(size_t idx)
Definition: wallet2.cpp:1560
void store()
Definition: wallet2.cpp:5482
const std::string & device_derivation_path() const
Definition: wallet2.h:1076
void callback(i_wallet2_callback *callback)
Definition: wallet2.h:735
void update_multisig_rescan_info(const std::vector< std::vector< rct::key >> &multisig_k, const std::vector< std::vector< tools::wallet2::multisig_info >> &info, size_t n)
Definition: wallet2.cpp:12504
static bool parse_payment_id(const std::string &payment_id_str, crypto::hash &payment_id)
Definition: wallet2.cpp:5188
bool load_multisig_tx_from_file(const std::string &filename, multisig_tx_set &exported_txs, std::function< bool(const multisig_tx_set &)> accept_func=NULL)
Definition: wallet2.cpp:6783
std::string make_uri(const std::string &address, const std::string &payment_id, uint64_t amount, const std::string &tx_description, const std::string &recipient_name, std::string &error) const
Definition: wallet2.cpp:12714
void merge_destinations(bool merge)
Definition: wallet2.h:1050
uint32_t m_multisig_rounds_passed
Definition: wallet2.h:1500
void store_to(const std::string &path, const epee::wipeable_string &password)
store_to Stores wallet to another file(s), deleting old ones
Definition: wallet2.cpp:5488
void set_tx_notify(const std::shared_ptr< tools::Notify > &notify)
Definition: wallet2.h:1342
std::vector< tools::wallet2::address_book_row > m_address_book
Definition: wallet2.h:1477
wallet2(cryptonote::network_type nettype=cryptonote::MAINNET, uint64_t kdf_rounds=1, bool unattended=false)
Definition: wallet2.cpp:1095
i_wallet2_callback * callback() const
Definition: wallet2.h:734
void remove_obsolete_pool_txs(const std::vector< crypto::hash > &tx_hashes)
Definition: wallet2.cpp:2756
std::pair< size_t, size_t > get_subaddress_lookahead() const
Definition: wallet2.h:780
std::vector< size_t > select_available_outputs(const std::function< bool(const transfer_details &td)> &f) const
Definition: wallet2.cpp:10209
bool m_track_uses
Definition: wallet2.h:1528
uint64_t m_light_wallet_unlocked_balance
Definition: wallet2.h:1550
bool m_key_reuse_mitigation2
Definition: wallet2.h:1525
uint32_t m_multisig_threshold
Definition: wallet2.h:1497
const transfer_details & get_transfer_details(size_t idx) const
Definition: wallet2.cpp:10306
bool set_blackballed_outputs(const std::vector< std::pair< uint64_t, uint64_t >> &outputs, bool add=false)
Definition: wallet2.cpp:7374
void generate_chacha_key_from_password(const epee::wipeable_string &pass, crypto::chacha_key &key) const
Definition: wallet2.cpp:5278
std::atomic< bool > m_run
Definition: wallet2.h:1484
void on_device_button_request(uint64_t code)
Definition: wallet2.cpp:13104
std::vector< std::pair< uint64_t, uint64_t > > estimate_backlog(const std::vector< std::pair< double, double >> &fee_levels)
Definition: wallet2.cpp:12948
uint64_t get_daemon_blockchain_height(std::string &err) const
Definition: wallet2.cpp:11401
uint64_t get_min_output_value() const
Definition: wallet2.h:1049
std::vector< pending_tx > create_unmixable_sweep_transactions()
Definition: wallet2.cpp:10324
uint32_t m_min_output_count
Definition: wallet2.h:1517
crypto::public_key get_tx_pub_key_from_received_outs(const tools::wallet2::transfer_details &td) const
Definition: wallet2.cpp:11613
bool delete_address_book_row(std::size_t row_id)
Definition: wallet2.cpp:3086
void check_tx_key_helper(const crypto::hash &txid, const crypto::key_derivation &derivation, const std::vector< crypto::key_derivation > &additional_derivations, const cryptonote::account_public_address &address, uint64_t &received, bool &in_pool, uint64_t &confirmations)
Definition: wallet2.cpp:10795
void on_device_button_pressed()
Definition: wallet2.cpp:13110
void explicit_refresh_from_block_height(bool expl)
Definition: wallet2.h:717
bool load_tx(const std::string &signed_filename, std::vector< tools::wallet2::pending_tx > &ptx, std::function< bool(const signed_tx_set &)> accept_func=NULL)
Definition: wallet2.cpp:6531
uint64_t segregation_height() const
Definition: wallet2.h:1064
void transfer_selected_rct(std::vector< cryptonote::tx_destination_entry > dsts, const std::vector< size_t > &selected_transfers, size_t fake_outputs_count, std::vector< std::vector< tools::wallet2::get_outs_entry >> &outs, uint64_t unlock_time, uint64_t fee, const std::vector< uint8_t > &extra, cryptonote::transaction &tx, pending_tx &ptx, const rct::RCTConfig &rct_config)
Definition: wallet2.cpp:8302
void add_subaddress(uint32_t index_major, const std::string &label)
Definition: wallet2.cpp:1463
uint64_t balance_all() const
Definition: wallet2.cpp:5705
bool ignore_fractional_outputs() const
Definition: wallet2.h:1066
bool check_connection(uint32_t *version=NULL, bool *ssl=NULL, uint32_t timeout=200000)
Definition: wallet2.cpp:5208
void decrypt_keys(const crypto::chacha_key &key)
Definition: wallet2.cpp:4202
uint64_t m_device_last_key_image_sync
Definition: wallet2.h:1536
bool is_synced() const
Definition: wallet2.cpp:12939
bool light_wallet_import_wallet_request(tools::COMMAND_RPC_IMPORT_WALLET_REQUEST::response &response)
Definition: wallet2.cpp:8728
uint64_t unlocked_balance_all(uint64_t *blocks_to_unlock=NULL) const
Definition: wallet2.cpp:5713
void update_pool_state(bool refreshed=false)
Definition: wallet2.cpp:2784
void ask_password(AskPasswordType ask)
Definition: wallet2.h:1045
std::string get_daemon_address() const
Definition: wallet2.cpp:11396
bool m_unattended
Definition: wallet2.h:1573
BackgroundMiningSetupType setup_background_mining() const
Definition: wallet2.h:1072
void confirm_missing_payment_id(bool always)
Definition: wallet2.h:1043
uint64_t get_segregation_fork_height() const
Definition: wallet2.cpp:13019
crypto::secret_key m_original_view_secret_key
Definition: wallet2.h:1568
static std::string device_derivation_path_option(const boost::program_options::variables_map &vm)
Definition: wallet2.cpp:1181
bool get_seed(epee::wipeable_string &electrum_words, const epee::wipeable_string &passphrase=epee::wipeable_string()) const
Definition: wallet2.cpp:1294
std::pair< size_t, std::vector< tools::wallet2::transfer_details > > export_outputs(bool all=false) const
Definition: wallet2.cpp:12182
std::vector< size_t > select_available_mixable_outputs()
Definition: wallet2.cpp:10318
std::tuple< uint64_t, crypto::public_key, rct::key > get_outs_entry
Definition: wallet2.h:547
std::string m_daemon_address
Definition: wallet2.h:1453
rct::multisig_kLRki get_multisig_kLRki(size_t n, const rct::key &k) const
Definition: wallet2.cpp:12395
void restore(const std::string &wallet_, const epee::wipeable_string &password, const std::string &device_name, bool create_address_file=false)
Restore a wallet hold by an HW.
Definition: wallet2.cpp:4560
void generate_genesis(cryptonote::block &b) const
Definition: wallet2.cpp:13070
std::string sign(const std::string &data) const
Definition: wallet2.cpp:11546
size_t get_num_subaddress_accounts() const
Definition: wallet2.h:773
bool light_wallet_parse_rct_str(const std::string &rct_string, const crypto::public_key &tx_pub_key, uint64_t internal_output_index, rct::key &decrypted_mask, rct::key &rct_commit, bool decrypt) const
Definition: wallet2.cpp:9101
void setup_keys(const epee::wipeable_string &password)
Definition: wallet2.cpp:3750
std::string m_wallet_file
Definition: wallet2.h:1454
void set_spent(size_t idx, uint64_t height)
Definition: wallet2.cpp:1544
bool load_multisig_tx(cryptonote::blobdata blob, multisig_tx_set &exported_txs, std::function< bool(const multisig_tx_set &)> accept_func=NULL)
Definition: wallet2.cpp:6749
payment_container m_payments
Definition: wallet2.h:1469
void light_wallet_get_unspent_outs()
Definition: wallet2.cpp:8743
std::unordered_map< crypto::public_key, std::map< uint64_t, crypto::key_image > > m_key_image_cache
Definition: wallet2.h:1555
bool parse_tx_from_str(const std::string &signed_tx_st, std::vector< tools::wallet2::pending_tx > &ptx, std::function< bool(const signed_tx_set &)> accept_func)
Definition: wallet2.cpp:6552
static bool query_device(hw::device::device_type &device_type, const std::string &keys_file_name, const epee::wipeable_string &password, uint64_t kdf_rounds=1)
determine the key storage for the specified wallet file
Definition: wallet2.cpp:4257
hashchain m_blockchain
Definition: wallet2.h:1458
void throw_on_rpc_response_error(const boost::optional< std::string > &status, const char *method) const
Definition: wallet2.cpp:13143
std::string get_attribute(const std::string &key) const
Definition: wallet2.cpp:11488
bool is_keys_file_locked() const
Definition: wallet2.cpp:7427
size_t import_outputs(const std::pair< size_t, std::vector< tools::wallet2::transfer_details >> &outputs)
Definition: wallet2.cpp:12222
void device_name(const std::string &device_name)
Definition: wallet2.h:1075
void add_subaddress_account(const std::string &label, const bool update_account_tags=true)
Definition: wallet2.cpp:1456
void hash_m_transfer(const transfer_details &transfer, crypto::hash &hash) const
Definition: wallet2.cpp:13158
bool confirm_backlog() const
Definition: wallet2.h:1052
bool m_segregate_pre_fork_outputs
Definition: wallet2.h:1524
bool sign_multisig_tx(multisig_tx_set &exported_txs, std::vector< crypto::hash > &txids)
Definition: wallet2.cpp:6807
void cold_sign_tx(const std::vector< pending_tx > &ptx_vector, signed_tx_set &exported_txs, std::vector< cryptonote::address_parse_info > &dsts_info, std::vector< std::string > &tx_device_aux)
Definition: wallet2.cpp:10124
void set_description(const std::string &description)
Definition: wallet2.cpp:11496
AskPasswordType
Definition: wallet2.h:219
@ AskPasswordToDecrypt
Definition: wallet2.h:222
@ AskPasswordOnAction
Definition: wallet2.h:221
@ AskPasswordNever
Definition: wallet2.h:220
void set_min_output_count(uint32_t count)
Definition: wallet2.h:1046
static std::pair< std::unique_ptr< wallet2 >, password_container > make_from_json(const boost::program_options::variables_map &vm, bool unattended, const std::string &json_file, const std::function< boost::optional< password_container >(const char *, bool)> &password_prompter)
Uses stdin and stdout. Returns a wallet2 if no errors.
Definition: wallet2.cpp:1220
std::string get_subaddress_label(const cryptonote::subaddress_index &index) const
Definition: wallet2.cpp:1511
boost::optional< epee::wipeable_string > on_device_passphrase_request(bool on_device)
Definition: wallet2.cpp:13123
std::unordered_map< crypto::hash, crypto::secret_key > m_tx_keys
Definition: wallet2.h:1462
void fast_refresh(uint64_t stop_height, uint64_t &blocks_start_height, std::list< crypto::hash > &short_chain_history, bool force=false)
Definition: wallet2.cpp:3006
void setup_background_mining(BackgroundMiningSetupType value)
Definition: wallet2.h:1073
void pull_blocks(uint64_t start_height, uint64_t &blocks_start_height, const std::list< crypto::hash > &short_chain_history, std::vector< cryptonote::block_complete_entry > &blocks, std::vector< cryptonote::COMMAND_RPC_GET_BLOCKS_FAST::block_output_indices > &o_indices)
Definition: wallet2.cpp:2468
bool store_keys(const std::string &keys_file_name, const epee::wipeable_string &password, bool watch_only=false)
Stores wallet information to wallet file.
Definition: wallet2.cpp:3540
bool verify(const std::string &data, const cryptonote::account_public_address &address, const std::string &signature) const
Definition: wallet2.cpp:11556
std::string m_device_name
Definition: wallet2.h:1534
bool confirm_non_default_ring_size() const
Definition: wallet2.h:1068
void transfer_selected(const std::vector< cryptonote::tx_destination_entry > &dsts, const std::vector< size_t > &selected_transfers, size_t fake_outputs_count, std::vector< std::vector< tools::wallet2::get_outs_entry >> &outs, uint64_t unlock_time, uint64_t fee, const std::vector< uint8_t > &extra, T destination_split_strategy, const tx_dust_policy &dust_policy, cryptonote::transaction &tx, pending_tx &ptx)
void check_genesis(const crypto::hash &genesis_hash) const
Definition: wallet2.cpp:5471
static std::string device_name_option(const boost::program_options::variables_map &vm)
Definition: wallet2.cpp:1176
std::vector< std::vector< std::string > > m_subaddress_labels
Definition: wallet2.h:1474
uint64_t get_bytes_sent() const
Definition: wallet2.cpp:13215
void set_subaddress_label(const cryptonote::subaddress_index &index, const std::string &label)
Definition: wallet2.cpp:1521
void set_light_wallet(bool light_wallet)
Definition: wallet2.h:750
size_t get_num_transfer_details() const
Definition: wallet2.h:1120
bool m_light_wallet_connected
Definition: wallet2.h:1548
std::vector< address_book_row > get_address_book() const
GUI Address book get/store.
Definition: wallet2.h:1115
const mms::message_store & get_message_store() const
Definition: wallet2.h:1333
uint64_t get_min_ring_size() const
Definition: wallet2.cpp:7030
void light_wallet_get_outs(std::vector< std::vector< get_outs_entry >> &outs, const std::vector< size_t > &selected_transfers, size_t fake_outputs_count)
Definition: wallet2.cpp:7459
cryptonote::account_public_address m_original_address
Definition: wallet2.h:1567
uint64_t get_fee_multiplier(uint32_t priority, int fee_algorithm=-1) const
Definition: wallet2.cpp:6932
int get_fee_algorithm() const
Definition: wallet2.cpp:7018
void set_refresh_from_block_height(uint64_t height)
Definition: wallet2.h:714
void get_unconfirmed_payments_out(std::list< std::pair< crypto::hash, wallet2::unconfirmed_transfer_details >> &unconfirmed_payments, const boost::optional< uint32_t > &subaddr_account=boost::none, const std::set< uint32_t > &subaddr_indices={}) const
Definition: wallet2.cpp:5773
bool print_ring_members() const
Definition: wallet2.h:1032
bool init(std::string daemon_address="http://localhost:8080", boost::optional< epee::net_utils::http::login > daemon_login=boost::none, boost::asio::ip::tcp::endpoint proxy={}, uint64_t upper_transaction_weight_limit=0, bool trusted_daemon=true, epee::net_utils::ssl_options_t ssl_options=epee::net_utils::ssl_support_t::e_ssl_support_autodetect, std::string blockchain_db_path="")
Definition: wallet2.cpp:1275
std::unordered_map< crypto::hash, confirmed_transfer_details > m_confirmed_txs
Definition: wallet2.h:1460
uint32_t account_major_offset() const
Definition: wallet2.h:783
cryptonote::account_public_address m_account_public_address
Definition: wallet2.h:1472
uint64_t m_kdf_rounds
Definition: wallet2.h:1492
void get_payments(const crypto::hash &payment_id, std::list< wallet2::payment_details > &payments, uint64_t min_height=0, const boost::optional< uint32_t > &subaddr_account=boost::none, const std::set< uint32_t > &subaddr_indices={}) const
Definition: wallet2.cpp:5733
payment_container export_payments() const
Definition: wallet2.cpp:12124
bool use_fork_rules(uint8_t version, int64_t early_blocks=0) const
Definition: wallet2.cpp:10179
bool unpack_extra_multisig_info(const std::vector< std::string > &info, std::vector< crypto::public_key > &signers, std::unordered_set< crypto::public_key > &pkeys) const
Definition: wallet2.cpp:4949
bool reconnect_device()
Definition: wallet2.cpp:1383
void check_acc_out_precomp(const cryptonote::tx_out &o, const crypto::key_derivation &derivation, const std::vector< crypto::key_derivation > &additional_derivations, size_t i, tx_scan_info_t &tx_scan_info) const
Definition: wallet2.cpp:1612
void thaw(size_t idx)
Definition: wallet2.cpp:1567
bool has_multisig_partial_key_images() const
Definition: wallet2.cpp:5097
std::shared_ptr< tools::Notify > m_tx_notify
Definition: wallet2.h:1576
void clear_soft(bool keep_key_images=false)
Definition: wallet2.cpp:3513
void get_transfers(wallet2::transfer_container &incoming_transfers) const
Definition: wallet2.cpp:5728
std::string get_tx_device_aux(const crypto::hash &txid) const
Definition: wallet2.cpp:11475
AskPasswordType ask_password() const
Definition: wallet2.h:1044
bool light_wallet_get_address_info(tools::COMMAND_RPC_GET_ADDRESS_INFO::response &response)
Definition: wallet2.cpp:8897
uint64_t get_blockchain_height_by_date(uint16_t year, uint8_t month, uint8_t day)
Definition: wallet2.cpp:12852
static bool verify_multisig_info(const std::string &data, crypto::secret_key &skey, crypto::public_key &pkey)
Definition: wallet2.cpp:4998
uint64_t m_light_wallet_scanned_block_height
Definition: wallet2.h:1545
uint64_t hash_m_transfers(int64_t transfer_height, crypto::hash &hash) const
Definition: wallet2.cpp:13169
uint64_t m_light_wallet_blockchain_height
Definition: wallet2.h:1546
void device_derivation_path(const std::string &device_derivation_path)
Definition: wallet2.h:1077
std::vector< transfer_details > transfer_container
Definition: wallet2.h:434
size_t import_outputs_from_str(const std::string &outputs_st)
Definition: wallet2.cpp:12287
void confirm_non_default_ring_size(bool always)
Definition: wallet2.h:1069
void change_password(const std::string &filename, const epee::wipeable_string &original_password, const epee::wipeable_string &new_password)
Definition: wallet2.cpp:3770
std::unordered_map< crypto::public_key, crypto::key_image > m_cold_key_images
Definition: wallet2.h:1482
bool always_confirm_transfers() const
Definition: wallet2.h:1030
std::string sign_multisig_participant(const std::string &data) const
sign_multisig_participant signs given message with the multisig public signer key
Definition: wallet2.cpp:11579
uint64_t get_light_wallet_blockchain_height() const
Definition: wallet2.h:752
bool m_is_initialized
Definition: wallet2.h:1530
static std::string get_human_readable_timestamp(uint64_t ts)
Check if wallet file path is valid format.
Definition: wallet2.h:1004
wallet_device_callback * get_device_callback()
Definition: wallet2.cpp:13097
bool get_rct_distribution(uint64_t &start_height, std::vector< uint64_t > &distribution)
Definition: wallet2.cpp:3338
bool track_uses() const
Definition: wallet2.h:1070
std::string m_ring_database
Definition: wallet2.h:1557
boost::recursive_mutex m_daemon_rpc_mutex
Definition: wallet2.h:1486
bool is_old_file_format
Definition: wallet2.h:1494
bool m_multisig
Definition: wallet2.h:1496
std::unique_ptr< tools::file_locker > m_keys_file_locker
Definition: wallet2.h:1563
void check_tx_key(const crypto::hash &txid, const crypto::secret_key &tx_key, const std::vector< crypto::secret_key > &additional_tx_keys, const cryptonote::account_public_address &address, uint64_t &received, bool &in_pool, uint64_t &confirmations)
Definition: wallet2.cpp:10729
uint64_t unlocked_balance(uint32_t subaddr_index_major, uint64_t *blocks_to_unlock=NULL) const
Definition: wallet2.cpp:5622
bool set_ring(const crypto::key_image &key_image, const std::vector< uint64_t > &outs, bool relative)
Definition: wallet2.cpp:7254
std::string make_multisig(const epee::wipeable_string &password, const std::vector< std::string > &info, uint32_t threshold)
Creates a multisig wallet.
Definition: wallet2.cpp:4916
void import_payments_out(const std::list< std::pair< crypto::hash, wallet2::confirmed_transfer_details >> &confirmed_payments)
Definition: wallet2.cpp:12141
bool lock_keys_file()
Definition: wallet2.cpp:7405
std::unique_ptr< ringdb > m_ringdb
Definition: wallet2.h:1559
uint64_t get_last_block_reward() const
Definition: wallet2.h:874
RefreshType
Definition: wallet2.h:212
@ RefreshFull
Definition: wallet2.h:213
@ RefreshDefault
Definition: wallet2.h:216
@ RefreshOptimizeCoinbase
Definition: wallet2.h:214
@ RefreshNoCoinbase
Definition: wallet2.h:215
const std::string & device_name() const
Definition: wallet2.h:1074
void init_type(hw::device::device_type device_type)
Definition: wallet2.cpp:4301
cryptonote::checkpoints m_checkpoints
Definition: wallet2.h:1463
void set_seed_language(const std::string &language)
Sets the seed language.
Definition: wallet2.cpp:1418
void confirm_backlog(bool always)
Definition: wallet2.h:1053
void stop()
Definition: wallet2.h:732
void set_refresh_type(RefreshType refresh_type)
Definition: wallet2.h:793
static std::unique_ptr< wallet2 > make_dummy(const boost::program_options::variables_map &vm, bool unattended, const std::function< boost::optional< password_container >(const char *, bool)> &password_prompter)
Just parses variables.
Definition: wallet2.cpp:1254
const char *const ATTRIBUTE_DESCRIPTION
Definition: wallet2.h:1274
std::string get_description() const
Definition: wallet2.cpp:11501
boost::optional< epee::wipeable_string > m_encrypt_keys_after_refresh
Definition: wallet2.h:1571
bool m_confirm_missing_payment_id
Definition: wallet2.h:1514
void trim_hashchain()
Definition: wallet2.cpp:5435
const std::string get_ring_database() const
Definition: wallet2.h:1306
RefreshType m_refresh_type
Definition: wallet2.h:1507
hw::device & lookup_device(const std::string &device_descriptor)
Definition: wallet2.cpp:7186
bool m_trusted_daemon
Definition: wallet2.h:1488
std::unordered_set< crypto::hash > m_scanned_pool_txs[2]
Definition: wallet2.h:1532
uint32_t m_default_mixin
Definition: wallet2.h:1505
uint64_t get_bytes_received() const
Definition: wallet2.cpp:13220
void set_attribute(const std::string &key, const std::string &value)
Definition: wallet2.cpp:11483
void import_payments(const payment_container &payments)
Definition: wallet2.cpp:12133
bool key_reuse_mitigation2() const
Definition: wallet2.h:1062
epee::net_utils::http::http_simple_client m_http_client
Definition: wallet2.h:1457
bool unblackball_output(const std::pair< uint64_t, uint64_t > &output)
Definition: wallet2.cpp:7389
void encrypt_keys(const crypto::chacha_key &key)
Definition: wallet2.cpp:4196
size_t m_subaddress_lookahead_minor
Definition: wallet2.h:1533
bool get_ring(const crypto::key_image &key_image, std::vector< uint64_t > &outs)
Definition: wallet2.cpp:7248
const std::pair< std::map< std::string, std::string >, std::vector< std::string > > & get_account_tags()
Get the list of registered account tags.
Definition: wallet2.cpp:11506
void process_outgoing(const crypto::hash &txid, const cryptonote::transaction &tx, uint64_t height, uint64_t ts, uint64_t spent, uint64_t received, uint32_t subaddr_account, const std::set< uint32_t > &subaddr_indices)
Definition: wallet2.cpp:2343
bool m_offline
Definition: wallet2.h:1538
std::unique_ptr< wallet_device_callback > m_device_callback
Definition: wallet2.h:1577
uint64_t m_min_output_value
Definition: wallet2.h:1518
bool sign_tx(const std::string &unsigned_filename, const std::string &signed_filename, std::vector< wallet2::pending_tx > &ptx, std::function< bool(const unsigned_tx_set &)> accept_func=NULL, bool export_raw=false)
Definition: wallet2.cpp:6330
void auto_low_priority(bool value)
Definition: wallet2.h:1059
std::vector< wallet2::pending_tx > create_transactions_from(const cryptonote::account_public_address &address, bool is_subaddress, const size_t outputs, std::vector< size_t > unused_transfers_indices, std::vector< size_t > unused_dust_indices, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector< uint8_t > &extra)
Definition: wallet2.cpp:9891
mms::multisig_wallet_state get_multisig_wallet_state() const
Definition: wallet2.cpp:13074
uint64_t get_daemon_blockchain_target_height(std::string &err)
Definition: wallet2.cpp:11419
std::unordered_map< crypto::hash, unconfirmed_transfer_details > m_unconfirmed_txs
Definition: wallet2.h:1459
static std::pair< std::unique_ptr< wallet2 >, password_container > make_from_file(const boost::program_options::variables_map &vm, bool unattended, const std::string &wallet_file, const std::function< boost::optional< password_container >(const char *, bool)> &password_prompter)
Uses stdin and stdout. Returns a wallet2 and password for wallet_file if no errors.
Definition: wallet2.cpp:1226
uint32_t get_default_priority() const
Definition: wallet2.h:1038
uint64_t m_light_wallet_balance
Definition: wallet2.h:1549
std::string m_mms_file
Definition: wallet2.h:1456
uint64_t get_device_last_key_image_sync() const
Definition: wallet2.h:875
void process_parsed_blocks(uint64_t start_height, const std::vector< cryptonote::block_complete_entry > &blocks, const std::vector< parsed_block > &parsed_blocks, uint64_t &blocks_added, std::map< std::pair< uint64_t, uint64_t >, size_t > *output_tracker_cache=NULL)
Definition: wallet2.cpp:2533
bool load_keys(const std::string &keys_file_name, const epee::wipeable_string &password)
Load wallet information from wallet file.
Definition: wallet2.cpp:3785
void process_unconfirmed(const crypto::hash &txid, const cryptonote::transaction &tx, uint64_t height)
Definition: wallet2.cpp:2323
crypto::public_key get_multisig_signer_public_key() const
Definition: wallet2.cpp:12357
uint64_t m_upper_transaction_weight_limit
Definition: wallet2.h:1479
uint32_t get_min_output_count() const
Definition: wallet2.h:1047
bool m_confirm_export_overwrite
Definition: wallet2.h:1522
void set_subaddress_lookahead(size_t major, size_t minor)
Definition: wallet2.cpp:1528
uint64_t get_fee_quantization_mask() const
Definition: wallet2.cpp:7001
boost::optional< cryptonote::subaddress_index > get_subaddress_index(const cryptonote::account_public_address &address) const
Definition: wallet2.cpp:1430
bool check_tx_proof(const crypto::hash &txid, const cryptonote::account_public_address &address, bool is_subaddress, const std::string &message, const std::string &sig_str, uint64_t &received, bool &in_pool, uint64_t &confirmations)
Definition: wallet2.cpp:10998
bool finalize_multisig(const epee::wipeable_string &password, const std::vector< std::string > &info)
Finalizes creation of a multisig wallet.
Definition: wallet2.cpp:4966
std::vector< crypto::public_key > get_subaddress_spend_public_keys(uint32_t account, uint32_t begin, uint32_t end) const
uint32_t m_default_priority
Definition: wallet2.h:1506
std::string get_integrated_address_as_str(const crypto::hash8 &payment_id) const
Definition: wallet2.cpp:1451
uint32_t m_confirm_backlog_threshold
Definition: wallet2.h:1521
bool save_tx(const std::vector< pending_tx > &ptx_vector, const std::string &filename) const
Definition: wallet2.cpp:6214
std::string decrypt_with_view_secret_key(const std::string &ciphertext, bool authenticated=true) const
Definition: wallet2.cpp:12709
std::string get_spend_proof(const crypto::hash &txid, const std::string &message)
Definition: wallet2.cpp:10500
bool tx_add_fake_output(std::vector< std::vector< tools::wallet2::get_outs_entry >> &outs, uint64_t global_index, const crypto::public_key &tx_public_key, const rct::key &mask, uint64_t real_index, bool unlocked) const
Definition: wallet2.cpp:7432
void set_account_tag(const std::set< uint32_t > &account_indices, const std::string &tag)
Set a tag to the given accounts.
Definition: wallet2.cpp:11526
std::unordered_map< crypto::hash, std::string > m_tx_notes
Definition: wallet2.h:1475
bool m_first_refresh_done
Definition: wallet2.h:1509
size_t get_num_subaddresses(uint32_t index_major) const
Definition: wallet2.h:774
void setup_new_blockchain()
Definition: wallet2.cpp:4222
cryptonote::network_type m_nettype
Definition: wallet2.h:1491
uint64_t get_blockchain_current_height() const
Definition: wallet2.h:868
mms::message_store m_message_store
Definition: wallet2.h:1565
std::string get_rpc_status(const std::string &s) const
Definition: wallet2.cpp:13136
crypto::chacha_key m_cache_key
Definition: wallet2.h:1570
void set_account_tag_description(const std::string &tag, const std::string &description)
Set the label of the given tag.
Definition: wallet2.cpp:11539
std::string get_wallet_file() const
Definition: wallet2.cpp:11386
bool is_deterministic() const
Checks if deterministic wallet.
Definition: wallet2.cpp:1286
static bool parse_long_payment_id(const std::string &payment_id_str, crypto::hash &payment_id)
Definition: wallet2.cpp:5162
std::vector< size_t > get_only_rct(const std::vector< size_t > &unused_dust_indices, const std::vector< size_t > &unused_transfers_indices) const
Definition: wallet2.cpp:8678
bool store_tx_info() const
Definition: wallet2.h:1034
void serialize(t_archive &a, const unsigned int ver)
Definition: wallet2.h:878
std::vector< crypto::public_key > m_multisig_signers
Definition: wallet2.h:1498
void get_unconfirmed_payments(std::list< std::pair< crypto::hash, wallet2::pool_payment_details >> &unconfirmed_payments, const boost::optional< uint32_t > &subaddr_account=boost::none, const std::set< uint32_t > &subaddr_indices={}) const
Definition: wallet2.cpp:5784
std::unordered_map< crypto::hash, address_tx > m_light_wallet_address_txs
Definition: wallet2.h:1553
bool parse_uri(const std::string &uri, std::string &address, std::string &payment_id, uint64_t &amount, std::string &tx_description, std::string &recipient_name, std::vector< std::string > &unknown_parameters, std::string &error)
Definition: wallet2.cpp:12768
void check_acc_out_precomp_once(const cryptonote::tx_out &o, const crypto::key_derivation &derivation, const std::vector< crypto::key_derivation > &additional_derivations, size_t i, const is_out_data *is_out_data, tx_scan_info_t &tx_scan_info, bool &already_seen) const
Definition: wallet2.cpp:1652
std::vector< size_t > select_available_unmixable_outputs()
Definition: wallet2.cpp:10312
bool blackball_output(const std::pair< uint64_t, uint64_t > &output)
Definition: wallet2.cpp:7366
bool sign_multisig_tx_from_file(const std::string &filename, std::vector< crypto::hash > &txids, std::function< bool(const multisig_tx_set &)> accept_func)
Definition: wallet2.cpp:6918
std::vector< crypto::public_key > m_multisig_derivations
Definition: wallet2.h:1501
bool multisig(bool *ready=NULL, uint32_t *threshold=NULL, uint32_t *total=NULL) const
Definition: wallet2.cpp:5084
bool m_light_wallet
Definition: wallet2.h:1544
RefreshType get_refresh_type() const
Definition: wallet2.h:794
bool verify_with_public_key(const std::string &data, const crypto::public_key &public_key, const std::string &signature) const
verify_with_public_key verifies message was signed with given public key
Definition: wallet2.cpp:11591
size_t m_subaddress_lookahead_major
Definition: wallet2.h:1533
uint32_t adjust_priority(uint32_t priority)
Definition: wallet2.cpp:7071
std::string save_multisig_tx(multisig_tx_set txs)
Definition: wallet2.cpp:6631
void pull_hashes(uint64_t start_height, uint64_t &blocks_start_height, const std::list< crypto::hash > &short_chain_history, std::vector< crypto::hash > &hashes)
Definition: wallet2.cpp:2512
bool clear()
Definition: wallet2.cpp:3491
T decrypt(const std::string &ciphertext, const crypto::secret_key &skey, bool authenticated=true) const
Definition: wallet2.cpp:12682
AskPasswordType m_ask_password
Definition: wallet2.h:1516
uint64_t select_transfers(uint64_t needed_money, std::vector< size_t > unused_transfers_indices, std::vector< size_t > &selected_transfers) const
Definition: wallet2.cpp:6054
void set_unspent(size_t idx)
Definition: wallet2.cpp:1552
void generate(const std::string &wallet_, const epee::wipeable_string &password, const epee::wipeable_string &multisig_data, bool create_address_file=false)
Generates a wallet or restores one.
Definition: wallet2.cpp:4319
bool has_unknown_key_images() const
Definition: wallet2.cpp:5107
static bool parse_short_payment_id(const std::string &payment_id_str, crypto::hash8 &payment_id)
Definition: wallet2.cpp:5175
uint64_t get_refresh_from_block_height() const
Definition: wallet2.h:715
BackgroundMiningSetupType
Definition: wallet2.h:225
@ BackgroundMiningNo
Definition: wallet2.h:228
@ BackgroundMiningMaybe
Definition: wallet2.h:226
@ BackgroundMiningYes
Definition: wallet2.h:227
bool check_reserve_proof(const cryptonote::account_public_address &address, const std::string &message, const std::string &sig_str, uint64_t &total, uint64_t &spent)
Verifies a proof of reserve.
Definition: wallet2.cpp:11260
bool key_on_device() const
Definition: wallet2.h:802
std::tuple< size_t, crypto::hash, std::vector< crypto::hash > > export_blockchain() const
Definition: wallet2.cpp:12150
cryptonote::account_public_address get_subaddress(const cryptonote::subaddress_index &index) const
Definition: wallet2.cpp:1423
boost::optional< epee::wipeable_string > on_device_pin_request()
Definition: wallet2.cpp:13116
cryptonote::blobdata get_pruned_tx_blob(const cryptonote::blobdata &blobdata)
Definition: wallet2.cpp:2495
bool confirm_missing_payment_id() const
Definition: wallet2.h:1042
void set_tx_key(const crypto::hash &txid, const crypto::secret_key &tx_key, const std::vector< crypto::secret_key > &additional_tx_keys)
Definition: wallet2.cpp:10453
void confirm_export_overwrite(bool always)
Definition: wallet2.h:1057
void get_hard_fork_info(uint8_t version, uint64_t &earliest_height) const
Definition: wallet2.cpp:10173
bool check_spend_proof(const crypto::hash &txid, const std::string &message, const std::string &sig_str)
Definition: wallet2.cpp:10616
multisig_tx_set make_multisig_tx_set(const std::vector< pending_tx > &ptx_vector) const
Definition: wallet2.cpp:6677
bool is_output_blackballed(const std::pair< uint64_t, uint64_t > &output) const
Definition: wallet2.cpp:7397
void rewrite(const std::string &wallet_name, const epee::wipeable_string &password)
Rewrites to the wallet file for wallet upgrade (doesn't generate key, assumes it's already there)
Definition: wallet2.cpp:5120
bool light_wallet_key_image_is_ours(const crypto::key_image &key_image, const crypto::public_key &tx_public_key, uint64_t out_index)
Definition: wallet2.cpp:9126
bool m_use_dns
Definition: wallet2.h:1537
bool get_tx_key(const crypto::hash &txid, crypto::secret_key &tx_key, std::vector< crypto::secret_key > &additional_tx_keys)
Definition: wallet2.cpp:10377
bool auto_refresh() const
Definition: wallet2.h:1040
static bool has_stagenet_option(const boost::program_options::variables_map &vm)
Definition: wallet2.cpp:1171
void unpack_multisig_info(const std::vector< std::string > &info, std::vector< crypto::public_key > &public_keys, std::vector< crypto::secret_key > &secret_keys) const
Definition: wallet2.cpp:4864
bool remove_rings(const cryptonote::transaction_prefix &tx)
Definition: wallet2.cpp:7209
bool get_rings(const crypto::hash &txid, std::vector< std::pair< crypto::key_image, std::vector< uint64_t >>> &outs)
Definition: wallet2.cpp:7225
size_t pop_best_value_from(const transfer_container &transfers, std::vector< size_t > &unused_dust_indices, const std::vector< size_t > &selected_transfers, bool smallest=false) const
Definition: wallet2.cpp:5996
bool is_trusted_daemon() const
Definition: wallet2.h:737
std::unordered_map< std::string, std::string > m_attributes
Definition: wallet2.h:1476
void segregation_height(uint64_t height)
Definition: wallet2.h:1065
void import_blockchain(const std::tuple< size_t, crypto::hash, std::vector< crypto::hash >> &bc)
Definition: wallet2.cpp:12162
bool unset_ring(const std::vector< crypto::key_image > &key_images)
Definition: wallet2.cpp:7263
uint64_t get_approximate_blockchain_height() const
Calculates the approximate blockchain height from current date/time.
Definition: wallet2.cpp:11435
std::unordered_multimap< crypto::hash, pool_payment_details > m_unconfirmed_payments
Definition: wallet2.h:1461
bool explicit_refresh_from_block_height() const
Definition: wallet2.h:718
bool set_ring_database(const std::string &filename)
Definition: wallet2.cpp:7147
bool confirm_export_overwrite() const
Definition: wallet2.h:1056
bool get_tx_key_cached(const crypto::hash &txid, crypto::secret_key &tx_key, std::vector< crypto::secret_key > &additional_tx_keys) const
Definition: wallet2.cpp:10364
std::string get_subaddress_as_str(const cryptonote::subaddress_index &index) const
Definition: wallet2.cpp:1445
std::string get_reserve_proof(const boost::optional< std::pair< uint32_t, uint64_t >> &account_minreserve, const std::string &message)
Generates a proof that proves the reserve of unspent funds.
Definition: wallet2.cpp:11139
void segregate_pre_fork_outputs(bool value)
Definition: wallet2.h:1061
~wallet2()
Definition: wallet2.cpp:1162
void store_tx_info(bool store)
Definition: wallet2.h:1035
const std::string & get_seed_language() const
Gets the seed language.
Definition: wallet2.cpp:1410
bool deinit()
Definition: wallet2.cpp:3483
hw::device::device_type get_device_type() const
Definition: wallet2.h:803
void get_outs(std::vector< std::vector< get_outs_entry >> &outs, const std::vector< size_t > &selected_transfers, size_t fake_outputs_count)
Definition: wallet2.cpp:7563
std::shared_ptr< std::map< std::pair< uint64_t, uint64_t >, size_t > > create_output_tracker_cache() const
Definition: wallet2.cpp:3096
bool export_key_images(const std::string &filename) const
Definition: wallet2.cpp:11661
void set_confirm_backlog_threshold(uint32_t threshold)
Definition: wallet2.h:1054
void write_watch_only_wallet(const std::string &wallet_name, const epee::wipeable_string &password, std::string &new_keys_filename)
Writes to a file named based on the normal wallet (doesn't generate key, assumes it's already there)
Definition: wallet2.cpp:5136
static bool verify_extra_multisig_info(const std::string &data, std::unordered_set< crypto::public_key > &pkeys, crypto::public_key &signer)
Definition: wallet2.cpp:5036
std::string dump_tx_to_str(const std::vector< pending_tx > &ptx_vector) const
Definition: wallet2.cpp:6223
bool light_wallet_login(bool &new_address)
Definition: wallet2.cpp:8699
bool m_devices_registered
Definition: wallet2.h:1574
i_wallet2_callback * m_callback
Definition: wallet2.h:1489
std::string encrypt_with_view_secret_key(const std::string &plaintext, bool authenticated=true) const
Definition: wallet2.cpp:12676
bool auto_low_priority() const
Definition: wallet2.h:1058
bool parse_multisig_tx_from_str(std::string multisig_tx_st, multisig_tx_set &exported_txs) const
Definition: wallet2.cpp:6705
bool should_pick_a_second_output(bool use_rct, size_t n_transfers, const std::vector< size_t > &unused_transfers_indices, const std::vector< size_t > &unused_dust_indices) const
Definition: wallet2.cpp:8645
crypto::chacha_key get_ringdb_key()
Definition: wallet2.cpp:7170
bool find_and_save_rings(bool force=true)
Definition: wallet2.cpp:7300
void process_new_blockchain_entry(const cryptonote::block &b, const cryptonote::block_complete_entry &bche, const parsed_block &parsed_block, const crypto::hash &bl_id, uint64_t height, const std::vector< tx_cache_data > &tx_cache_data, size_t tx_cache_data_offset, std::map< std::pair< uint64_t, uint64_t >, size_t > *output_tracker_cache=NULL)
Definition: wallet2.cpp:2392
uint64_t import_key_images(const std::vector< std::pair< crypto::key_image, crypto::signature >> &signed_key_images, size_t offset, uint64_t &spent, uint64_t &unspent, bool check_spent=true)
Definition: wallet2.cpp:11803
uint64_t m_light_wallet_per_kb_fee
Definition: wallet2.h:1547
std::vector< uint64_t > get_unspent_amounts_vector() const
Definition: wallet2.cpp:10229
std::unordered_multimap< crypto::hash, payment_details > payment_container
Definition: wallet2.h:435
rct::key get_multisig_k(size_t idx, const std::unordered_set< rct::key > &used_L) const
Definition: wallet2.cpp:12380
std::string fallback_to_pow_checkpoint_hash
Definition: wallet2.h:1465
bool m_store_tx_info
Definition: wallet2.h:1504
static bool wallet_valid_path_format(const std::string &file_path)
Definition: wallet2.cpp:5157
bool frozen(size_t idx) const
Definition: wallet2.cpp:1574
cryptonote::account_base & get_account()
Definition: wallet2.h:706
bool is_transfer_unlocked(const transfer_details &td) const
Definition: wallet2.cpp:5870
void register_devices()
Definition: wallet2.cpp:7182
void cold_tx_aux_import(const std::vector< pending_tx > &ptx, const std::vector< std::string > &tx_device_aux)
Definition: wallet2.cpp:10114
std::unordered_map< crypto::public_key, size_t > m_pub_keys
Definition: wallet2.h:1471
uint64_t adjust_mixin(uint64_t mixin) const
Definition: wallet2.cpp:7054
static constexpr const std::chrono::seconds rpc_timeout
Definition: wallet2.h:210
void commit_tx(pending_tx &ptx_vector)
Definition: wallet2.cpp:6128
static void init_options(boost::program_options::options_description &desc_params)
Definition: wallet2.cpp:1186
uint64_t get_upper_transaction_weight_limit() const
Definition: wallet2.cpp:10198
void account_major_offset(uint32_t offset)
Definition: wallet2.h:782
void print_ring_members(bool value)
Definition: wallet2.h:1033
void create_keys_file(const std::string &wallet_, bool watch_only, const epee::wipeable_string &password, bool create_address_file)
Definition: wallet2.cpp:4231
uint64_t m_refresh_from_block_height
Definition: wallet2.h:1510
mms::message_store & get_message_store()
Definition: wallet2.h:1332
bool is_deprecated() const
Tells if the wallet file is deprecated.
Definition: wallet2.cpp:1539
bool generate_chacha_key_from_secret_keys(crypto::chacha_key &key) const
Definition: wallet2.cpp:5272
bool m_auto_refresh
Definition: wallet2.h:1508
std::string get_address_as_str() const
Definition: wallet2.h:770
bool m_ring_history_saved
Definition: wallet2.h:1558
const cryptonote::account_base & get_account() const
Definition: wallet2.h:707
std::string get_tx_proof(const crypto::hash &txid, const cryptonote::account_public_address &address, bool is_subaddress, const std::string &message)
Definition: wallet2.cpp:10843
std::unordered_map< crypto::hash, std::vector< crypto::secret_key > > m_additional_tx_keys
Definition: wallet2.h:1466
std::string sign_tx_dump_to_str(unsigned_tx_set &exported_txs, std::vector< wallet2::pending_tx > &ptx, signed_tx_set &signed_txes)
Definition: wallet2.cpp:6505
void discard_unmixable_outputs()
Definition: wallet2.cpp:10354
uint32_t m_account_major_offset
Definition: wallet2.h:1581
uint32_t default_mixin() const
Definition: wallet2.h:1036
bool m_watch_only
Definition: wallet2.h:1495
void finish_rescan_bc_keep_key_images(uint64_t transfer_height, const crypto::hash &hash)
Definition: wallet2.cpp:13193
std::string get_tx_note(const crypto::hash &txid) const
Definition: wallet2.cpp:11462
uint64_t get_light_wallet_scanned_block_height() const
Definition: wallet2.h:751
void set_min_output_value(uint64_t value)
Definition: wallet2.h:1048
std::string get_keys_file() const
Definition: wallet2.cpp:11391
std::string path() const
Definition: wallet2.cpp:5477
bool prepare_file_names(const std::string &file_path)
Definition: wallet2.cpp:5202
std::vector< wallet2::pending_tx > create_transactions_all(uint64_t below, const cryptonote::account_public_address &address, bool is_subaddress, const size_t outputs, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector< uint8_t > &extra, uint32_t subaddr_account, std::set< uint32_t > subaddr_indices)
Definition: wallet2.cpp:9816
static void wallet_exists(const std::string &file_path, bool &keys_file_exists, bool &wallet_file_exists)
Check if wallet keys and bin files exist.
Definition: wallet2.cpp:5147
crypto::hash get_payment_id(const pending_tx &ptx) const
Definition: wallet2.cpp:6097
cryptonote::network_type nettype() const
Definition: wallet2.h:796
std::pair< std::map< std::string, std::string >, std::vector< std::string > > m_account_tags
Definition: wallet2.h:1478
size_t pop_best_value(std::vector< size_t > &unused_dust_indices, const std::vector< size_t > &selected_transfers, bool smallest=false) const
Definition: wallet2.cpp:6045
void detach_blockchain(uint64_t height, std::map< std::pair< uint64_t, uint64_t >, size_t > *output_tracker_cache=NULL)
Definition: wallet2.cpp:3409
void cache_tx_data(const cryptonote::transaction &tx, const crypto::hash &txid, tx_cache_data &tx_cache_data) const
Definition: wallet2.cpp:1740
void rescan_spent()
Definition: wallet2.cpp:5793
uint64_t get_dynamic_base_fee_estimate() const
Definition: wallet2.cpp:6974
bool light_wallet() const
Checks if light wallet. A light wallet sends view key to a server where the blockchain is scanned.
Definition: wallet2.h:749
std::string m_keys_file
Definition: wallet2.h:1455
uint64_t estimate_blockchain_height()
Definition: wallet2.cpp:4440
bool m_auto_low_priority
Definition: wallet2.h:1523
bool invoke_http_json_rpc(const boost::string_ref uri, const std::string &method_name, const t_request &req, t_response &res, std::chrono::milliseconds timeout=std::chrono::seconds(15), const boost::string_ref http_method="GET", const std::string &req_id="0")
Definition: wallet2.h:1298
cryptonote::account_public_address get_address() const
Definition: wallet2.h:765
crypto::public_key get_subaddress_spend_public_key(const cryptonote::subaddress_index &index) const
Definition: wallet2.cpp:1438
bool m_always_confirm_transfers
Definition: wallet2.h:1502
std::unordered_map< crypto::key_image, size_t > m_key_images
Definition: wallet2.h:1470
void get_short_chain_history(std::list< crypto::hash > &ids, uint64_t granularity=1) const
Definition: wallet2.cpp:2430
std::string get_multisig_info() const
Definition: wallet2.cpp:4979
crypto::key_image get_multisig_composite_key_image(size_t n) const
Definition: wallet2.cpp:12436
void ignore_fractional_outputs(bool value)
Definition: wallet2.h:1067
const boost::optional< epee::net_utils::http::login > & get_daemon_login() const
Definition: wallet2.h:1130
static bool verify_password(const std::string &keys_file_name, const epee::wipeable_string &password, bool no_spend_key, hw::device &hwdev, uint64_t kdf_rounds)
verify password for specified wallet keys file.
Definition: wallet2.cpp:4149
void set_offline(bool offline=true)
Definition: wallet2.cpp:5260
bool m_display_progress_indicator
Definition: wallet2.h:1579
Definition: wallet2.h:144
boost::optional< epee::wipeable_string > on_passphrase_request(bool on_device) override
Definition: wallet2.cpp:1082
void on_button_pressed() override
Definition: wallet2.cpp:1069
wallet2 * wallet
Definition: wallet2.h:153
void on_button_request(uint64_t code=0) override
Definition: wallet2.cpp:1063
wallet_device_callback(wallet2 *wallet)
Definition: wallet2.h:146
void on_progress(const hw::device_progress &event) override
Definition: wallet2.cpp:1089
boost::optional< epee::wipeable_string > on_pin_request() override
Definition: wallet2.cpp:1075
Definition: wallet2.h:106
crypto::chacha_key key
Definition: wallet2.h:114
bool locked
Definition: wallet2.h:113
~wallet_keys_unlocker()
Definition: wallet2.cpp:1051
wallet2 & w
Definition: wallet2.h:112
wallet_keys_unlocker(wallet2 &w, const boost::optional< tools::password_container > &password)
Definition: wallet2.cpp:1027
#define FEE_PER_KB
Definition: cryptonote_config.h:75
const uint32_t T[512]
Definition: groestl_tables.h:37
string a
Definition: MakeCryptoOps.py:15
boost::optional< tools::password_container > password_prompter(const char *prompt, bool verify)
Definition: simplewallet.cpp:300
tools::wallet2::RefreshType refresh_type
Definition: simplewallet.cpp:401
int b
Definition: base.py:1
Definition: blocks.cpp:13
std::enable_if< Archive::is_loading::value, void >::type initialize_transfer_details(Archive &a, tools::wallet2::transfer_details &x, const boost::serialization::version_type ver)
Definition: wallet2.h:1610
Definition: unordered_containers_boost_serialization.h:39
crypto namespace.
Definition: crypto.cpp:58
static const crypto::hash null_hash
Definition: hash.h:101
POD_CLASS signature
Definition: crypto.h:108
epee::mlocked< tools::scrubbed< ec_scalar > > secret_key
Definition: crypto.h:82
POD_CLASS hash8
Definition: hash.h:53
POD_CLASS key_derivation
Definition: crypto.h:98
POD_CLASS public_key
Definition: crypto.h:76
POD_CLASS key_image
Definition: crypto.h:102
POD_CLASS hash
Definition: hash.h:50
network_type
Definition: cryptonote_config.h:243
@ MAINNET
Definition: cryptonote_config.h:244
void decompose_amount_into_digits(uint64_t amount, uint64_t dust_threshold, const chunk_handler_t &chunk_handler, const dust_handler_t &dust_handler)
Definition: cryptonote_format_utils.h:208
std::string print_money(uint64_t amount, unsigned int decimal_point)
Definition: cryptonote_format_utils.cpp:940
crypto::hash get_transaction_hash(const transaction &t)
Definition: cryptonote_format_utils.cpp:968
std::string blobdata
Definition: blobdatatype.h:39
declaration and default definition for the functions used the API
Definition: expect.cpp:34
tools::wallet2::tx_construction_data tx_construction_data
Definition: protocol.hpp:156
tools::wallet2::unsigned_tx_set unsigned_tx_set
Definition: protocol.hpp:157
mdb_size_t count(MDB_cursor *cur)
Definition: value_stream.cpp:39
error
Tracks LMDB error codes.
Definition: error.h:45
static void add(ge_p3 &p3, const ge_cached &other)
Definition: multiexp.cc:143
@ RangeProofBorromean
Definition: rctTypes.h:235
@ RangeProofBulletproof
Definition: rctTypes.h:235
key identity()
Definition: rctOps.h:73
Definition: binary_utils.h:37
Definition: blockchain_ancestry.cpp:73
void print_source_entry(const cryptonote::tx_source_entry &src)
Definition: wallet2.h:2092
void digit_split_strategy(const std::vector< cryptonote::tx_destination_entry > &dsts, const cryptonote::tx_destination_entry &change_dst, uint64_t dust_threshold, std::vector< cryptonote::tx_destination_entry > &splitted_dsts, std::vector< cryptonote::tx_destination_entry > &dust_dsts)
Definition: wallet2.h:2053
void null_split_strategy(const std::vector< cryptonote::tx_destination_entry > &dsts, const cryptonote::tx_destination_entry &change_dst, uint64_t dust_threshold, std::vector< cryptonote::tx_destination_entry > &splitted_dsts, std::vector< cryptonote::tx_destination_entry > &dust_dsts)
Definition: wallet2.h:2077
Various Tools.
Definition: apply_permutation.h:40
BOOST_CLASS_VERSION(nodetool::peerlist_types, nodetool::CURRENT_PEERLIST_STORAGE_ARCHIVE_VER)
#define BEGIN_SERIALIZE_OBJECT()
begins the environment of the DSL \detailed for described the serialization of an object
Definition: serialization.h:190
#define FIELD(f)
tags the field with the variable name and then serializes it
Definition: serialization.h:243
#define END_SERIALIZE()
self-explanatory
Definition: serialization.h:214
static const unsigned char iv[64]
Definition: sha512-hash.c:13
#define ts
Definition: skein.c:522
CXA_THROW_INFO_T * info
Definition: stack_trace.cpp:91
#define true
Definition: stdbool.h:37
Definition: core_rpc_server_commands_defs.h:146
Definition: cryptonote_basic.h:453
Definition: cryptonote_protocol_defs.h:118
Definition: cryptonote_basic.h:410
Definition: cryptonote_basic.h:480
Definition: subaddress_index.h:39
Definition: cryptonote_tx_utils.h:76
uint64_t amount
Definition: cryptonote_tx_utils.h:78
account_public_address addr
Definition: cryptonote_tx_utils.h:79
Definition: cryptonote_basic.h:144
Definition: cryptonote_tx_utils.h:44
uint64_t amount
Definition: cryptonote_tx_utils.h:52
size_t real_output
Definition: cryptonote_tx_utils.h:48
std::vector< output_entry > outputs
Definition: cryptonote_tx_utils.h:47
std::pair< uint64_t, rct::ctkey > output_entry
Definition: cryptonote_tx_utils.h:45
size_t real_output_in_tx_index
Definition: cryptonote_tx_utils.h:51
Definition: cryptonote_basic.h:78
crypto::public_key key
Definition: cryptonote_basic.h:81
Definition: message_store.h:190
Definition: rctTypes.h:236
RangeProofType range_proof_type
Definition: rctTypes.h:237
Definition: rctTypes.h:78
Definition: rctTypes.h:104
Definition: rctTypes.h:111
Definition: rctTypes.h:436
epee::misc_utils::struct_init< response_t > response
Definition: wallet_light_rpc.h:179
epee::misc_utils::struct_init< response_t > response
Definition: wallet_light_rpc.h:317
Definition: wallet2.h:90
static constexpr result_type min()
Definition: wallet2.h:92
result_type operator()()
Definition: wallet2.h:94
uint64_t result_type
Definition: wallet2.h:91
static constexpr result_type max()
Definition: wallet2.h:93
Definition: wallet2.h:157
bool add_to_fee
Definition: wallet2.h:159
cryptonote::account_public_address addr_for_dust
Definition: wallet2.h:160
tx_dust_policy(uint64_t a_dust_threshold=0, bool an_add_to_fee=true, cryptonote::account_public_address an_addr_for_dust=cryptonote::account_public_address())
Definition: wallet2.h:162
uint64_t dust_threshold
Definition: wallet2.h:158
Definition: wallet2.h:530
bool m_is_subaddress
Definition: wallet2.h:534
std::string m_description
Definition: wallet2.h:533
crypto::hash m_payment_id
Definition: wallet2.h:532
cryptonote::account_public_address m_address
Definition: wallet2.h:531
Definition: wallet2.h:359
bool m_incoming
Definition: wallet2.h:361
bool m_mempool
Definition: wallet2.h:360
Definition: wallet2.h:518
crypto::chacha_iv iv
Definition: wallet2.h:519
std::string cache_data
Definition: wallet2.h:520
uint64_t m_amount_out
Definition: wallet2.h:389
std::vector< std::pair< crypto::key_image, std::vector< uint64_t > > > m_rings
Definition: wallet2.h:398
uint64_t m_block_height
Definition: wallet2.h:391
uint64_t m_change
Definition: wallet2.h:390
uint32_t m_subaddr_account
Definition: wallet2.h:396
uint64_t m_amount_in
Definition: wallet2.h:388
confirmed_transfer_details(const unconfirmed_transfer_details &utd, uint64_t height)
Definition: wallet2.h:401
crypto::hash m_payment_id
Definition: wallet2.h:393
confirmed_transfer_details()
Definition: wallet2.h:400
uint64_t m_timestamp
Definition: wallet2.h:394
std::set< uint32_t > m_subaddr_indices
Definition: wallet2.h:397
std::vector< cryptonote::tx_destination_entry > m_dests
Definition: wallet2.h:392
uint64_t m_unlock_time
Definition: wallet2.h:395
Definition: wallet2.h:559
std::vector< boost::optional< cryptonote::subaddress_receive_info > > received
Definition: wallet2.h:562
crypto::public_key pkey
Definition: wallet2.h:560
crypto::key_derivation derivation
Definition: wallet2.h:561
Definition: wallet2.h:507
std::string account_data
Definition: wallet2.h:509
crypto::chacha_iv iv
Definition: wallet2.h:508
Definition: wallet2.h:261
rct::key m_R
Definition: wallet2.h:263
rct::key m_L
Definition: wallet2.h:262
Definition: wallet2.h:259
crypto::public_key m_signer
Definition: wallet2.h:271
std::vector< crypto::key_image > m_partial_key_images
Definition: wallet2.h:273
std::vector< LR > m_LR
Definition: wallet2.h:272
Definition: wallet2.h:438
std::unordered_set< crypto::public_key > ignore
Definition: wallet2.h:440
rct::multisig_out msout
Definition: wallet2.h:443
rct::rctSig sigs
Definition: wallet2.h:439
std::unordered_set< crypto::public_key > signing_keys
Definition: wallet2.h:442
std::unordered_set< rct::key > used_L
Definition: wallet2.h:441
Definition: wallet2.h:496
std::unordered_set< crypto::public_key > m_signers
Definition: wallet2.h:498
std::vector< pending_tx > m_ptx
Definition: wallet2.h:497
Definition: wallet2.h:550
bool error
Definition: wallet2.h:555
cryptonote::COMMAND_RPC_GET_BLOCKS_FAST::block_output_indices o_indices
Definition: wallet2.h:554
cryptonote::block block
Definition: wallet2.h:552
std::vector< cryptonote::transaction > txes
Definition: wallet2.h:553
crypto::hash hash
Definition: wallet2.h:551
Definition: wallet2.h:347
bool m_coinbase
Definition: wallet2.h:354
crypto::hash m_tx_hash
Definition: wallet2.h:348
uint64_t m_fee
Definition: wallet2.h:350
uint64_t m_timestamp
Definition: wallet2.h:353
uint64_t m_unlock_time
Definition: wallet2.h:352
uint64_t m_amount
Definition: wallet2.h:349
uint64_t m_block_height
Definition: wallet2.h:351
cryptonote::subaddress_index m_subaddr_index
Definition: wallet2.h:355
Definition: wallet2.h:450
tx_construction_data construction_data
Definition: wallet2.h:462
std::vector< size_t > selected_transfers
Definition: wallet2.h:455
bool dust_added_to_fee
Definition: wallet2.h:453
crypto::secret_key tx_key
Definition: wallet2.h:457
std::vector< cryptonote::tx_destination_entry > dests
Definition: wallet2.h:459
std::vector< multisig_sig > multisig_sigs
Definition: wallet2.h:460
cryptonote::transaction tx
Definition: wallet2.h:451
std::vector< crypto::secret_key > additional_tx_keys
Definition: wallet2.h:458
std::string key_images
Definition: wallet2.h:456
uint64_t fee
Definition: wallet2.h:452
cryptonote::tx_destination_entry change_dts
Definition: wallet2.h:454
uint64_t dust
Definition: wallet2.h:452
Definition: wallet2.h:365
bool m_double_spend_seen
Definition: wallet2.h:367
payment_details m_pd
Definition: wallet2.h:366
Definition: wallet2.h:538
crypto::public_key shared_secret
Definition: wallet2.h:541
crypto::signature key_image_sig
Definition: wallet2.h:544
crypto::signature shared_secret_sig
Definition: wallet2.h:543
uint64_t index_in_tx
Definition: wallet2.h:540
crypto::key_image key_image
Definition: wallet2.h:542
crypto::hash txid
Definition: wallet2.h:539
Definition: wallet2.h:489
std::unordered_map< crypto::public_key, crypto::key_image > tx_key_images
Definition: wallet2.h:492
std::vector< crypto::key_image > key_images
Definition: wallet2.h:491
std::vector< pending_tx > ptx
Definition: wallet2.h:490
Definition: wallet2.h:296
uint64_t m_amount
Definition: wallet2.h:307
bool m_key_image_request
Definition: wallet2.h:310
bool m_frozen
Definition: wallet2.h:303
rct::key m_mask
Definition: wallet2.h:306
bool m_spent
Definition: wallet2.h:302
uint64_t m_global_output_index
Definition: wallet2.h:301
crypto::key_image m_key_image
Definition: wallet2.h:305
uint64_t amount() const
Definition: wallet2.h:319
std::vector< std::pair< uint64_t, crypto::hash > > m_uses
Definition: wallet2.h:316
std::vector< multisig_info > m_multisig_info
Definition: wallet2.h:315
cryptonote::subaddress_index m_subaddr_index
Definition: wallet2.h:312
uint64_t m_spent_height
Definition: wallet2.h:304
uint64_t m_block_height
Definition: wallet2.h:297
const crypto::public_key & get_public_key() const
Definition: wallet2.h:320
size_t m_pk_index
Definition: wallet2.h:311
crypto::hash m_txid
Definition: wallet2.h:299
bool m_rct
Definition: wallet2.h:308
cryptonote::transaction_prefix m_tx
Definition: wallet2.h:298
bool is_rct() const
Definition: wallet2.h:318
bool m_key_image_partial
Definition: wallet2.h:313
bool m_key_image_known
Definition: wallet2.h:309
std::vector< rct::key > m_multisig_k
Definition: wallet2.h:314
size_t m_internal_output_index
Definition: wallet2.h:300
Definition: wallet2.h:566
std::vector< cryptonote::tx_extra_field > tx_extra_fields
Definition: wallet2.h:567
std::vector< is_out_data > primary
Definition: wallet2.h:568
bool empty() const
Definition: wallet2.h:571
std::vector< is_out_data > additional
Definition: wallet2.h:569
Definition: wallet2.h:406
std::vector< uint8_t > extra
Definition: wallet2.h:411
std::vector< cryptonote::tx_source_entry > sources
Definition: wallet2.h:407
std::vector< cryptonote::tx_destination_entry > splitted_dsts
Definition: wallet2.h:409
rct::RCTConfig rct_config
Definition: wallet2.h:414
std::vector< cryptonote::tx_destination_entry > dests
Definition: wallet2.h:415
uint64_t unlock_time
Definition: wallet2.h:412
std::vector< size_t > selected_transfers
Definition: wallet2.h:410
std::set< uint32_t > subaddr_indices
Definition: wallet2.h:417
uint32_t subaddr_account
Definition: wallet2.h:416
bool use_rct
Definition: wallet2.h:413
cryptonote::tx_destination_entry change_dts
Definition: wallet2.h:408
Definition: wallet2.h:283
boost::optional< cryptonote::subaddress_receive_info > received
Definition: wallet2.h:290
uint64_t amount
Definition: wallet2.h:287
rct::key mask
Definition: wallet2.h:286
cryptonote::keypair in_ephemeral
Definition: wallet2.h:284
uint64_t money_transfered
Definition: wallet2.h:288
tx_scan_info_t()
Definition: wallet2.h:292
bool error
Definition: wallet2.h:289
crypto::key_image ki
Definition: wallet2.h:285
uint32_t m_subaddr_account
Definition: wallet2.h:381
time_t m_sent_time
Definition: wallet2.h:376
uint64_t m_amount_out
Definition: wallet2.h:374
uint64_t m_timestamp
Definition: wallet2.h:380
crypto::hash m_payment_id
Definition: wallet2.h:378
enum tools::wallet2::unconfirmed_transfer_details::@16 m_state
cryptonote::transaction_prefix m_tx
Definition: wallet2.h:372
std::vector< std::pair< crypto::key_image, std::vector< uint64_t > > > m_rings
Definition: wallet2.h:383
std::vector< cryptonote::tx_destination_entry > m_dests
Definition: wallet2.h:377
uint64_t m_amount_in
Definition: wallet2.h:373
std::set< uint32_t > m_subaddr_indices
Definition: wallet2.h:382
uint64_t m_change
Definition: wallet2.h:375
Definition: wallet2.h:483
std::vector< tx_construction_data > txes
Definition: wallet2.h:484
std::pair< size_t, wallet2::transfer_container > transfers
Definition: wallet2.h:485