Monero
wallet2.h
Go to the documentation of this file.
1 // Copyright (c) 2014-2018, The Monero Project
2 //
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification, are
6 // permitted provided that the following conditions are met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice, this list of
9 // conditions and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 // of conditions and the following disclaimer in the documentation and/or other
13 // materials provided with the distribution.
14 //
15 // 3. Neither the name of the copyright holder nor the names of its contributors may be
16 // used to endorse or promote products derived from this software without specific
17 // prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27 // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 //
29 // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
30 
31 #pragma once
32 
33 #include <memory>
34 
35 #include <boost/program_options/options_description.hpp>
36 #include <boost/program_options/variables_map.hpp>
37 #include <boost/serialization/list.hpp>
38 #include <boost/serialization/vector.hpp>
39 #include <boost/serialization/deque.hpp>
40 #include <atomic>
41 
42 #include "include_base_utils.h"
46 #include "net/http_client.h"
47 #include "storages/http_abstract_invoke.h"
52 #include "crypto/chacha.h"
53 #include "crypto/hash.h"
54 #include "ringct/rctTypes.h"
55 #include "ringct/rctOps.h"
57 
58 #include "wallet_errors.h"
59 #include "common/password.h"
60 #include "node_rpc_proxy.h"
61 
62 #undef MONERO_DEFAULT_LOG_CATEGORY
63 #define MONERO_DEFAULT_LOG_CATEGORY "wallet.wallet2"
64 
65 class Serialization_portability_wallet_Test;
66 
67 namespace tools
68 {
69  class ringdb;
70  class wallet2;
71  class Notify;
72 
74  {
75  public:
76  wallet_keys_unlocker(wallet2 &w, const boost::optional<tools::password_container> &password);
77  wallet_keys_unlocker(wallet2 &w, bool locked, const epee::wipeable_string &password);
79  private:
81  bool locked;
82  crypto::chacha_key key;
83  };
84 
86  {
87  public:
88  // Full wallet callbacks
89  virtual void on_new_block(uint64_t height, const cryptonote::block& block) {}
90  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) {}
91  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) {}
92  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) {}
93  virtual void on_skip_transaction(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx) {}
94  virtual boost::optional<epee::wipeable_string> on_get_password(const char *reason) { return boost::none; }
95  // Light wallet callbacks
96  virtual void on_lw_new_block(uint64_t height) {}
97  virtual void on_lw_money_received(uint64_t height, const crypto::hash &txid, uint64_t amount) {}
98  virtual void on_lw_unconfirmed_money_received(uint64_t height, const crypto::hash &txid, uint64_t amount) {}
99  virtual void on_lw_money_spent(uint64_t height, const crypto::hash &txid, uint64_t amount) {}
100  // Common callbacks
101  virtual void on_pool_tx_removed(const crypto::hash &txid) {}
102  virtual ~i_wallet2_callback() {}
103  };
104 
106  {
107  uint64_t dust_threshold;
110 
111  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())
112  : dust_threshold(a_dust_threshold)
113  , add_to_fee(an_add_to_fee)
114  , addr_for_dust(an_addr_for_dust)
115  {
116  }
117  };
118 
119  class hashchain
120  {
121  public:
123 
124  size_t size() const { return m_blockchain.size() + m_offset; }
125  size_t offset() const { return m_offset; }
126  const crypto::hash &genesis() const { return m_genesis; }
127  void push_back(const crypto::hash &hash) { if (m_offset == 0 && m_blockchain.empty()) m_genesis = hash; m_blockchain.push_back(hash); }
128  bool is_in_bounds(size_t idx) const { return idx >= m_offset && idx < size(); }
129  const crypto::hash &operator[](size_t idx) const { return m_blockchain[idx - m_offset]; }
130  crypto::hash &operator[](size_t idx) { return m_blockchain[idx - m_offset]; }
131  void crop(size_t height) { m_blockchain.resize(height - m_offset); }
132  void clear() { m_offset = 0; m_blockchain.clear(); }
133  bool empty() const { return m_blockchain.empty() && m_offset == 0; }
134  void trim(size_t height) { while (height > m_offset && m_blockchain.size() > 1) { m_blockchain.pop_front(); ++m_offset; } m_blockchain.shrink_to_fit(); }
135  void refill(const crypto::hash &hash) { m_blockchain.push_back(hash); --m_offset; }
136 
137  template <class t_archive>
138  inline void serialize(t_archive &a, const unsigned int ver)
139  {
140  a & m_offset;
141  a & m_genesis;
142  a & m_blockchain;
143  }
144 
145  private:
146  size_t m_offset;
148  std::deque<crypto::hash> m_blockchain;
149  };
150 
151  class wallet_keys_unlocker;
152  class wallet2
153  {
154  friend class ::Serialization_portability_wallet_Test;
155  friend class wallet_keys_unlocker;
156  public:
157  static constexpr const std::chrono::seconds rpc_timeout = std::chrono::minutes(3) + std::chrono::seconds(30);
158 
159  enum RefreshType {
164  };
165 
170  };
171 
172  static const char* tr(const char* str);
173 
174  static bool has_testnet_option(const boost::program_options::variables_map& vm);
175  static bool has_stagenet_option(const boost::program_options::variables_map& vm);
176  static std::string device_name_option(const boost::program_options::variables_map& vm);
177  static void init_options(boost::program_options::options_description& desc_params);
178 
180  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);
181 
183  static std::pair<std::unique_ptr<wallet2>, password_container>
184  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);
185 
187  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);
188 
190  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);
191 
192  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);
193  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);
194 
195  wallet2(cryptonote::network_type nettype = cryptonote::MAINNET, uint64_t kdf_rounds = 1, bool unattended = false);
196  ~wallet2();
197 
199  {
200  struct LR
201  {
204 
206  FIELD(m_L)
207  FIELD(m_R)
208  END_SERIALIZE()
209  };
210 
212  std::vector<LR> m_LR;
213  std::vector<crypto::key_image> m_partial_key_images; // one per key the participant has
214 
216  FIELD(m_signer)
217  FIELD(m_LR)
219  END_SERIALIZE()
220  };
221 
223  {
227  uint64_t amount;
229  bool error;
230  boost::optional<cryptonote::subaddress_receive_info> received;
231 
232  tx_scan_info_t(): money_transfered(0), error(true) {}
233  };
234 
236  {
237  uint64_t m_block_height;
242  bool m_spent;
243  uint64_t m_spent_height;
244  crypto::key_image m_key_image; //TODO: key_image stored twice :(
246  uint64_t m_amount;
247  bool m_rct;
249  size_t m_pk_index;
252  std::vector<rct::key> m_multisig_k;
253  std::vector<multisig_info> m_multisig_info; // one per other participant
254 
255  bool is_rct() const { return m_rct; }
256  uint64_t amount() const { return m_amount; }
257  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; }
258 
260  FIELD(m_block_height)
261  FIELD(m_tx)
262  FIELD(m_txid)
263  FIELD(m_internal_output_index)
264  FIELD(m_global_output_index)
265  FIELD(m_spent)
266  FIELD(m_spent_height)
267  FIELD(m_key_image)
268  FIELD(m_mask)
269  FIELD(m_amount)
270  FIELD(m_rct)
271  FIELD(m_key_image_known)
272  FIELD(m_pk_index)
273  FIELD(m_subaddr_index)
274  FIELD(m_key_image_partial)
275  FIELD(m_multisig_k)
276  FIELD(m_multisig_info)
277  END_SERIALIZE()
278  };
279 
281  {
283  uint64_t m_amount;
284  uint64_t m_fee;
285  uint64_t m_block_height;
286  uint64_t m_unlock_time;
287  uint64_t m_timestamp;
290  };
291 
293  {
294  bool m_mempool;
296  };
297 
299  {
302  };
303 
305  {
307  uint64_t m_amount_in;
308  uint64_t m_amount_out;
309  uint64_t m_change;
310  time_t m_sent_time;
311  std::vector<cryptonote::tx_destination_entry> m_dests;
313  enum { pending, pending_not_in_pool, failed } m_state;
314  uint64_t m_timestamp;
315  uint32_t m_subaddr_account; // subaddress account of your wallet to be used in this transfer
316  std::set<uint32_t> m_subaddr_indices; // set of address indices used as inputs in this transfer
317  std::vector<std::pair<crypto::key_image, std::vector<uint64_t>>> m_rings; // relative
318  };
319 
321  {
322  uint64_t m_amount_in;
323  uint64_t m_amount_out;
324  uint64_t m_change;
325  uint64_t m_block_height;
326  std::vector<cryptonote::tx_destination_entry> m_dests;
328  uint64_t m_timestamp;
329  uint64_t m_unlock_time;
330  uint32_t m_subaddr_account; // subaddress account of your wallet to be used in this transfer
331  std::set<uint32_t> m_subaddr_indices; // set of address indices used as inputs in this transfer
332  std::vector<std::pair<crypto::key_image, std::vector<uint64_t>>> m_rings; // relative
333 
334  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) {}
336  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) {}
337  };
338 
340  {
341  std::vector<cryptonote::tx_source_entry> sources;
343  std::vector<cryptonote::tx_destination_entry> splitted_dsts; // split, includes change
344  std::vector<size_t> selected_transfers;
345  std::vector<uint8_t> extra;
346  uint64_t unlock_time;
347  bool use_rct;
349  std::vector<cryptonote::tx_destination_entry> dests; // original setup, does not include change
350  uint32_t subaddr_account; // subaddress account of your wallet to be used in this transfer
351  std::set<uint32_t> subaddr_indices; // set of address indices used as inputs in this transfer
352 
354  FIELD(sources)
355  FIELD(change_dts)
356  FIELD(splitted_dsts)
357  FIELD(selected_transfers)
358  FIELD(extra)
359  FIELD(unlock_time)
360  FIELD(use_rct)
361  FIELD(use_bulletproofs)
362  FIELD(dests)
363  FIELD(subaddr_account)
364  FIELD(subaddr_indices)
365  END_SERIALIZE()
366  };
367 
369  typedef std::unordered_multimap<crypto::hash, payment_details> payment_container;
370 
372  {
375  std::unordered_set<rct::key> used_L;
376  std::unordered_set<crypto::public_key> signing_keys;
378  };
379 
380  // The convention for destinations is:
381  // dests does not include change
382  // splitted_dsts (in construction_data) does
383  struct pending_tx
384  {
386  uint64_t dust, fee;
389  std::vector<size_t> selected_transfers;
390  std::string key_images;
392  std::vector<crypto::secret_key> additional_tx_keys;
393  std::vector<cryptonote::tx_destination_entry> dests;
394  std::vector<multisig_sig> multisig_sigs;
395 
397 
399  FIELD(tx)
400  FIELD(dust)
401  FIELD(fee)
402  FIELD(dust_added_to_fee)
403  FIELD(change_dts)
404  FIELD(selected_transfers)
405  FIELD(key_images)
406  FIELD(tx_key)
407  FIELD(additional_tx_keys)
408  FIELD(dests)
409  FIELD(construction_data)
410  FIELD(multisig_sigs)
411  END_SERIALIZE()
412  };
413 
414  // The term "Unsigned tx" is not really a tx since it's not signed yet.
415  // It doesnt have tx hash, key and the integrated address is not separated into addr + payment id.
417  {
418  std::vector<tx_construction_data> txes;
420  };
421 
423  {
424  std::vector<pending_tx> ptx;
425  std::vector<crypto::key_image> key_images;
426  };
427 
429  {
430  std::vector<pending_tx> m_ptx;
431  std::unordered_set<crypto::public_key> m_signers;
432 
434  FIELD(m_ptx)
435  FIELD(m_signers)
436  END_SERIALIZE()
437  };
438 
440  {
441  crypto::chacha_iv iv;
442  std::string account_data;
443 
445  FIELD(iv)
446  FIELD(account_data)
447  END_SERIALIZE()
448  };
449 
451  {
452  crypto::chacha_iv iv;
453  std::string cache_data;
454 
456  FIELD(iv)
457  FIELD(cache_data)
458  END_SERIALIZE()
459  };
460 
461  // GUI Address book
463  {
466  std::string m_description;
468  };
469 
471  {
473  uint64_t index_in_tx;
478  };
479 
480  typedef std::tuple<uint64_t, crypto::public_key, rct::key> get_outs_entry;
481 
483  {
486  std::vector<cryptonote::transaction> txes;
488  bool error;
489  };
490 
491  struct is_out_data
492  {
495  std::vector<boost::optional<cryptonote::subaddress_receive_info>> received;
496  };
497 
499  {
500  std::vector<cryptonote::tx_extra_field> tx_extra_fields;
501  std::vector<is_out_data> primary;
502  std::vector<is_out_data> additional;
503  };
504 
512  void generate(const std::string& wallet_, const epee::wipeable_string& password,
513  const epee::wipeable_string& multisig_data, bool create_address_file = false);
514 
525  crypto::secret_key generate(const std::string& wallet, const epee::wipeable_string& password,
526  const crypto::secret_key& recovery_param = crypto::secret_key(), bool recover = false,
527  bool two_random = false, bool create_address_file = false);
537  void generate(const std::string& wallet, const epee::wipeable_string& password,
538  const cryptonote::account_public_address &account_public_address,
539  const crypto::secret_key& spendkey, const crypto::secret_key& viewkey, bool create_address_file = false);
548  void generate(const std::string& wallet, const epee::wipeable_string& password,
549  const cryptonote::account_public_address &account_public_address,
550  const crypto::secret_key& viewkey = crypto::secret_key(), bool create_address_file = false);
558  void restore(const std::string& wallet_, const epee::wipeable_string& password, const std::string &device_name, bool create_address_file = false);
559 
565  std::string make_multisig(const epee::wipeable_string &password,
566  const std::vector<std::string> &info,
567  uint32_t threshold);
573  std::string make_multisig(const epee::wipeable_string &password,
574  const std::vector<crypto::secret_key> &view_keys,
575  const std::vector<crypto::public_key> &spend_keys,
576  uint32_t threshold);
577  std::string exchange_multisig_keys(const epee::wipeable_string &password,
578  const std::vector<std::string> &info);
582  std::string exchange_multisig_keys(const epee::wipeable_string &password,
583  std::unordered_set<crypto::public_key> pkeys,
584  std::vector<crypto::public_key> signers);
588  bool finalize_multisig(const epee::wipeable_string &password, const std::vector<std::string> &info);
592  bool finalize_multisig(const epee::wipeable_string &password, std::unordered_set<crypto::public_key> pkeys, std::vector<crypto::public_key> signers);
596  std::string get_multisig_info() const;
600  static bool verify_multisig_info(const std::string &data, crypto::secret_key &skey, crypto::public_key &pkey);
604  static bool verify_extra_multisig_info(const std::string &data, std::unordered_set<crypto::public_key> &pkeys, crypto::public_key &signer);
614  size_t import_multisig(std::vector<cryptonote::blobdata> info);
620  void rewrite(const std::string& wallet_name, const epee::wipeable_string& password);
621  void write_watch_only_wallet(const std::string& wallet_name, const epee::wipeable_string& password, std::string &new_keys_filename);
622  void load(const std::string& wallet, const epee::wipeable_string& password);
623  void store();
629  void store_to(const std::string &path, const epee::wipeable_string &password);
630 
631  std::string path() const;
632 
636  bool verify_password(const epee::wipeable_string& password);
639 
640  void encrypt_keys(const crypto::chacha_key &key);
641  void encrypt_keys(const epee::wipeable_string &password);
642  void decrypt_keys(const crypto::chacha_key &key);
643  void decrypt_keys(const epee::wipeable_string &password);
644 
647 
650 
651  bool deinit();
652  bool init(std::string daemon_address = "http://localhost:8080",
653  boost::optional<epee::net_utils::http::login> daemon_login = boost::none, uint64_t upper_transaction_weight_limit = 0, bool ssl = false, bool trusted_daemon = false);
654 
655  void stop() { m_run.store(false, std::memory_order_relaxed); }
656 
659 
660  bool is_trusted_daemon() const { return m_trusted_daemon; }
661  void set_trusted_daemon(bool trusted) { m_trusted_daemon = trusted; }
662 
666  bool is_deterministic() const;
667  bool get_seed(epee::wipeable_string& electrum_words, const epee::wipeable_string &passphrase = epee::wipeable_string()) const;
668 
672  bool light_wallet() const { return m_light_wallet; }
676 
680  const std::string &get_seed_language() const;
684  void set_seed_language(const std::string &language);
685 
686  // Subaddress scheme
689  boost::optional<cryptonote::subaddress_index> get_subaddress_index(const cryptonote::account_public_address& address) const;
691  std::vector<crypto::public_key> get_subaddress_spend_public_keys(uint32_t account, uint32_t begin, uint32_t end) const;
692  std::string get_subaddress_as_str(const cryptonote::subaddress_index& index) const;
693  std::string get_address_as_str() const { return get_subaddress_as_str({0, 0}); }
694  std::string get_integrated_address_as_str(const crypto::hash8& payment_id) const;
695  void add_subaddress_account(const std::string& label);
696  size_t get_num_subaddress_accounts() const { return m_subaddress_labels.size(); }
697  size_t get_num_subaddresses(uint32_t index_major) const { return index_major < m_subaddress_labels.size() ? m_subaddress_labels[index_major].size() : 0; }
698  void add_subaddress(uint32_t index_major, const std::string& label); // throws when index is out of bound
700  std::string get_subaddress_label(const cryptonote::subaddress_index& index) const;
701  void set_subaddress_label(const cryptonote::subaddress_index &index, const std::string &label);
702  void set_subaddress_lookahead(size_t major, size_t minor);
707  bool is_deprecated() const;
708  void refresh(bool trusted_daemon);
709  void refresh(bool trusted_daemon, uint64_t start_height, uint64_t & blocks_fetched);
710  void refresh(bool trusted_daemon, uint64_t start_height, uint64_t & blocks_fetched, bool& received_money);
711  bool refresh(bool trusted_daemon, uint64_t & blocks_fetched, bool& received_money, bool& ok);
712 
715 
717  bool watch_only() const { return m_watch_only; }
718  bool multisig(bool *ready = NULL, uint32_t *threshold = NULL, uint32_t *total = NULL) const;
719  bool has_multisig_partial_key_images() const;
720  bool has_unknown_key_images() const;
721  bool get_multisig_seed(epee::wipeable_string& seed, const epee::wipeable_string &passphrase = std::string(), bool raw = true) const;
722  bool key_on_device() const { return get_device_type() != hw::device::device_type::SOFTWARE; }
724  bool reconnect_device();
725 
726  // locked & unlocked balance of given or current subaddress account
727  uint64_t balance(uint32_t subaddr_index_major) const;
728  uint64_t unlocked_balance(uint32_t subaddr_index_major) const;
729  // locked & unlocked balance per subaddress of given or current subaddress account
730  std::map<uint32_t, uint64_t> balance_per_subaddress(uint32_t subaddr_index_major) const;
731  std::map<uint32_t, uint64_t> unlocked_balance_per_subaddress(uint32_t subaddr_index_major) const;
732  // all locked & unlocked balances of all subaddress accounts
733  uint64_t balance_all() const;
734  uint64_t unlocked_balance_all() const;
735  template<typename T>
736  void transfer_selected(const std::vector<cryptonote::tx_destination_entry>& dsts, const std::vector<size_t>& selected_transfers, size_t fake_outputs_count,
737  std::vector<std::vector<tools::wallet2::get_outs_entry>> &outs,
738  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);
739  void transfer_selected_rct(std::vector<cryptonote::tx_destination_entry> dsts, const std::vector<size_t>& selected_transfers, size_t fake_outputs_count,
740  std::vector<std::vector<tools::wallet2::get_outs_entry>> &outs,
741  uint64_t unlock_time, uint64_t fee, const std::vector<uint8_t>& extra, cryptonote::transaction& tx, pending_tx &ptx, const rct::RCTConfig &rct_config);
742 
743  void commit_tx(pending_tx& ptx_vector);
744  void commit_tx(std::vector<pending_tx>& ptx_vector);
745  bool save_tx(const std::vector<pending_tx>& ptx_vector, const std::string &filename) const;
746  std::string dump_tx_to_str(const std::vector<pending_tx> &ptx_vector) const;
747  std::string save_multisig_tx(multisig_tx_set txs);
748  bool save_multisig_tx(const multisig_tx_set &txs, const std::string &filename);
749  std::string save_multisig_tx(const std::vector<pending_tx>& ptx_vector);
750  bool save_multisig_tx(const std::vector<pending_tx>& ptx_vector, const std::string &filename);
751  multisig_tx_set make_multisig_tx_set(const std::vector<pending_tx>& ptx_vector) const;
752  // load unsigned tx from file and sign it. Takes confirmation callback as argument. Used by the cli wallet
753  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);
754  // sign unsigned tx. Takes unsigned_tx_set as argument. Used by GUI
755  bool sign_tx(unsigned_tx_set &exported_txs, const std::string &signed_filename, std::vector<wallet2::pending_tx> &ptx, bool export_raw = false);
756  bool sign_tx(unsigned_tx_set &exported_txs, std::vector<wallet2::pending_tx> &ptx, signed_tx_set &signed_txs);
757  std::string sign_tx_dump_to_str(unsigned_tx_set &exported_txs, std::vector<wallet2::pending_tx> &ptx, signed_tx_set &signed_txes);
758  // load unsigned_tx_set from file.
759  bool load_unsigned_tx(const std::string &unsigned_filename, unsigned_tx_set &exported_txs) const;
760  bool parse_unsigned_tx_from_str(const std::string &unsigned_tx_st, unsigned_tx_set &exported_txs) const;
761  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);
762  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);
763  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
764  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);
765  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);
766  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);
767  bool load_multisig_tx(cryptonote::blobdata blob, multisig_tx_set &exported_txs, std::function<bool(const multisig_tx_set&)> accept_func = NULL);
768  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);
769  bool sign_multisig_tx_from_file(const std::string &filename, std::vector<crypto::hash> &txids, std::function<bool(const multisig_tx_set&)> accept_func);
770  bool sign_multisig_tx(multisig_tx_set &exported_txs, std::vector<crypto::hash> &txids);
771  bool sign_multisig_tx_to_file(multisig_tx_set &exported_txs, const std::string &filename, std::vector<crypto::hash> &txids);
772  std::vector<pending_tx> create_unmixable_sweep_transactions();
774  bool check_connection(uint32_t *version = NULL, uint32_t timeout = 200000);
775  void get_transfers(wallet2::transfer_container& incoming_transfers) const;
776  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;
777  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;
778  void get_payments_out(std::list<std::pair<crypto::hash,wallet2::confirmed_transfer_details>>& confirmed_payments,
779  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;
780  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;
781  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;
782 
784  void rescan_spent();
785  void rescan_blockchain(bool refresh = true);
786  bool is_transfer_unlocked(const transfer_details& td) const;
787  bool is_transfer_unlocked(uint64_t unlock_time, uint64_t block_height) const;
788 
789  uint64_t get_last_block_reward() const { return m_last_block_reward; }
790 
791  template <class t_archive>
792  inline void serialize(t_archive &a, const unsigned int ver)
793  {
794  uint64_t dummy_refresh_height = 0; // moved to keys file
795  if(ver < 5)
796  return;
797  if (ver < 19)
798  {
799  std::vector<crypto::hash> blockchain;
800  a & blockchain;
801  for (const auto &b: blockchain)
802  {
804  }
805  }
806  else
807  {
808  a & m_blockchain;
809  }
810  a & m_transfers;
812  a & m_key_images;
813  if(ver < 6)
814  return;
816  if(ver < 7)
817  return;
818  a & m_payments;
819  if(ver < 8)
820  return;
821  a & m_tx_keys;
822  if(ver < 9)
823  return;
824  a & m_confirmed_txs;
825  if(ver < 11)
826  return;
827  a & dummy_refresh_height;
828  if(ver < 12)
829  return;
830  a & m_tx_notes;
831  if(ver < 13)
832  return;
833  if (ver < 17)
834  {
835  // we're loading an old version, where m_unconfirmed_payments was a std::map
836  std::unordered_map<crypto::hash, payment_details> m;
837  a & m;
838  for (std::unordered_map<crypto::hash, payment_details>::const_iterator i = m.begin(); i != m.end(); ++i)
839  m_unconfirmed_payments.insert(std::make_pair(i->first, pool_payment_details{i->second, false}));
840  }
841  if(ver < 14)
842  return;
843  if(ver < 15)
844  {
845  // we're loading an older wallet without a pubkey map, rebuild it
846  for (size_t i = 0; i < m_transfers.size(); ++i)
847  {
848  const transfer_details &td = m_transfers[i];
850  const cryptonote::txout_to_key &o = boost::get<const cryptonote::txout_to_key>(out.target);
851  m_pub_keys.emplace(o.key, i);
852  }
853  return;
854  }
855  a & m_pub_keys;
856  if(ver < 16)
857  return;
858  a & m_address_book;
859  if(ver < 17)
860  return;
861  if (ver < 22)
862  {
863  // we're loading an old version, where m_unconfirmed_payments payload was payment_details
864  std::unordered_multimap<crypto::hash, payment_details> m;
865  a & m;
866  for (const auto &i: m)
867  m_unconfirmed_payments.insert(std::make_pair(i.first, pool_payment_details{i.second, false}));
868  }
869  if(ver < 18)
870  return;
871  a & m_scanned_pool_txs[0];
872  a & m_scanned_pool_txs[1];
873  if (ver < 20)
874  return;
875  a & m_subaddresses;
876  std::unordered_map<cryptonote::subaddress_index, crypto::public_key> dummy_subaddresses_inv;
877  a & dummy_subaddresses_inv;
880  if(ver < 21)
881  return;
882  a & m_attributes;
883  if(ver < 22)
884  return;
886  if(ver < 23)
887  return;
888  a & m_account_tags;
889  if(ver < 24)
890  return;
892  if(ver < 25)
893  return;
895  }
896 
903  static void wallet_exists(const std::string& file_path, bool& keys_file_exists, bool& wallet_file_exists);
909  static bool wallet_valid_path_format(const std::string& file_path);
910  static bool parse_long_payment_id(const std::string& payment_id_str, crypto::hash& payment_id);
911  static bool parse_short_payment_id(const std::string& payment_id_str, crypto::hash8& payment_id);
912  static bool parse_payment_id(const std::string& payment_id_str, crypto::hash& payment_id);
913 
915  void always_confirm_transfers(bool always) { m_always_confirm_transfers = always; }
916  bool print_ring_members() const { return m_print_ring_members; }
917  void print_ring_members(bool value) { m_print_ring_members = value; }
918  bool store_tx_info() const { return m_store_tx_info; }
920  uint32_t default_mixin() const { return m_default_mixin; }
921  void default_mixin(uint32_t m) { m_default_mixin = m; }
922  uint32_t get_default_priority() const { return m_default_priority; }
923  void set_default_priority(uint32_t p) { m_default_priority = p; }
924  bool auto_refresh() const { return m_auto_refresh; }
925  void auto_refresh(bool r) { m_auto_refresh = r; }
930  void set_min_output_count(uint32_t count) { m_min_output_count = count; }
931  uint32_t get_min_output_count() const { return m_min_output_count; }
932  void set_min_output_value(uint64_t value) { m_min_output_value = value; }
933  uint64_t get_min_output_value() const { return m_min_output_value; }
934  void merge_destinations(bool merge) { m_merge_destinations = merge; }
935  bool merge_destinations() const { return m_merge_destinations; }
936  bool confirm_backlog() const { return m_confirm_backlog; }
937  void confirm_backlog(bool always) { m_confirm_backlog = always; }
941  void confirm_export_overwrite(bool always) { m_confirm_export_overwrite = always; }
942  bool auto_low_priority() const { return m_auto_low_priority; }
943  void auto_low_priority(bool value) { m_auto_low_priority = value; }
947  void key_reuse_mitigation2(bool value) { m_key_reuse_mitigation2 = value; }
948  uint64_t segregation_height() const { return m_segregation_height; }
954  const std::string & device_name() const { return m_device_name; }
955  void device_name(const std::string & device_name) { m_device_name = device_name; }
956 
957  bool get_tx_key(const crypto::hash &txid, crypto::secret_key &tx_key, std::vector<crypto::secret_key> &additional_tx_keys) const;
958  void set_tx_key(const crypto::hash &txid, const crypto::secret_key &tx_key, const std::vector<crypto::secret_key> &additional_tx_keys);
959  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);
960  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);
961  std::string get_tx_proof(const crypto::hash &txid, const cryptonote::account_public_address &address, bool is_subaddress, const std::string &message);
962  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);
963 
964  std::string get_spend_proof(const crypto::hash &txid, const std::string &message);
965  bool check_spend_proof(const crypto::hash &txid, const std::string &message, const std::string &sig_str);
966 
974  std::string get_reserve_proof(const boost::optional<std::pair<uint32_t, uint64_t>> &account_minreserve, const std::string &message);
984  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);
985 
989  std::vector<address_book_row> get_address_book() const { return m_address_book; }
990  bool add_address_book_row(const cryptonote::account_public_address &address, const crypto::hash &payment_id, const std::string &description, bool is_subaddress);
991  bool delete_address_book_row(std::size_t row_id);
992 
993  uint64_t get_num_rct_outputs();
994  size_t get_num_transfer_details() const { return m_transfers.size(); }
995  const transfer_details &get_transfer_details(size_t idx) const;
996 
997  void get_hard_fork_info(uint8_t version, uint64_t &earliest_height) const;
998  bool use_fork_rules(uint8_t version, int64_t early_blocks = 0) const;
999  int get_fee_algorithm() const;
1000 
1001  std::string get_wallet_file() const;
1002  std::string get_keys_file() const;
1003  std::string get_daemon_address() const;
1004  const boost::optional<epee::net_utils::http::login>& get_daemon_login() const { return m_daemon_login; }
1005  uint64_t get_daemon_blockchain_height(std::string& err) const;
1006  uint64_t get_daemon_blockchain_target_height(std::string& err);
1010  uint64_t get_approximate_blockchain_height() const;
1011  uint64_t estimate_blockchain_height();
1012  std::vector<size_t> select_available_outputs_from_histogram(uint64_t count, bool atleast, bool unlocked, bool allow_rct);
1013  std::vector<size_t> select_available_outputs(const std::function<bool(const transfer_details &td)> &f) const;
1014  std::vector<size_t> select_available_unmixable_outputs();
1015  std::vector<size_t> select_available_mixable_outputs();
1016 
1017  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;
1018  size_t pop_best_value(std::vector<size_t> &unused_dust_indices, const std::vector<size_t>& selected_transfers, bool smallest = false) const;
1019 
1020  void set_tx_note(const crypto::hash &txid, const std::string &note);
1021  std::string get_tx_note(const crypto::hash &txid) const;
1022 
1023  void set_description(const std::string &description);
1024  std::string get_description() const;
1025 
1030  const std::pair<std::map<std::string, std::string>, std::vector<std::string>>& get_account_tags();
1036  void set_account_tag(const std::set<uint32_t> account_indices, const std::string& tag);
1042  void set_account_tag_description(const std::string& tag, const std::string& description);
1043 
1044  std::string sign(const std::string &data) const;
1045  bool verify(const std::string &data, const cryptonote::account_public_address &address, const std::string &signature) const;
1046 
1053  std::string sign_multisig_participant(const std::string& data) const;
1061  bool verify_with_public_key(const std::string &data, const crypto::public_key &public_key, const std::string &signature) const;
1062 
1063  // Import/Export wallet data
1064  std::vector<tools::wallet2::transfer_details> export_outputs() const;
1065  std::string export_outputs_to_str() const;
1066  size_t import_outputs(const std::vector<tools::wallet2::transfer_details> &outputs);
1067  size_t import_outputs_from_str(const std::string &outputs_st);
1069  void import_payments(const payment_container &payments);
1070  void import_payments_out(const std::list<std::pair<crypto::hash,wallet2::confirmed_transfer_details>> &confirmed_payments);
1071  std::tuple<size_t, crypto::hash, std::vector<crypto::hash>> export_blockchain() const;
1072  void import_blockchain(const std::tuple<size_t, crypto::hash, std::vector<crypto::hash>> &bc);
1073  bool export_key_images(const std::string &filename) const;
1074  std::vector<std::pair<crypto::key_image, crypto::signature>> export_key_images() const;
1075  uint64_t import_key_images(const std::vector<std::pair<crypto::key_image, crypto::signature>> &signed_key_images, uint64_t &spent, uint64_t &unspent, bool check_spent = true);
1076  uint64_t import_key_images(const std::string &filename, uint64_t &spent, uint64_t &unspent);
1077 
1078  void update_pool_state(bool refreshed = false);
1079  void remove_obsolete_pool_txs(const std::vector<crypto::hash> &tx_hashes);
1080 
1081  std::string encrypt(const char *plaintext, size_t len, const crypto::secret_key &skey, bool authenticated = true) const;
1082  std::string encrypt(const epee::span<char> &span, const crypto::secret_key &skey, bool authenticated = true) const;
1083  std::string encrypt(const std::string &plaintext, const crypto::secret_key &skey, bool authenticated = true) const;
1084  std::string encrypt(const epee::wipeable_string &plaintext, const crypto::secret_key &skey, bool authenticated = true) const;
1085  std::string encrypt_with_view_secret_key(const std::string &plaintext, bool authenticated = true) const;
1086  template<typename T=std::string> T decrypt(const std::string &ciphertext, const crypto::secret_key &skey, bool authenticated = true) const;
1087  std::string decrypt_with_view_secret_key(const std::string &ciphertext, bool authenticated = true) const;
1088 
1089  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;
1090  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);
1091 
1092  uint64_t get_blockchain_height_by_date(uint16_t year, uint8_t month, uint8_t day); // 1<=month<=12, 1<=day<=31
1093 
1094  bool is_synced() const;
1095 
1096  std::vector<std::pair<uint64_t, uint64_t>> estimate_backlog(const std::vector<std::pair<double, double>> &fee_levels);
1097  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);
1098 
1099  uint64_t get_fee_multiplier(uint32_t priority, int fee_algorithm = -1) const;
1100  uint64_t get_base_fee() const;
1101  uint64_t get_fee_quantization_mask() const;
1102  uint64_t get_min_ring_size() const;
1103  uint64_t get_max_ring_size() const;
1104  uint64_t adjust_mixin(uint64_t mixin) const;
1105  uint32_t adjust_priority(uint32_t priority);
1106 
1107  bool is_unattended() const { return m_unattended; }
1108 
1109  // Light wallet specific functions
1110  // fetch unspent outs from lw node and store in m_transfers
1112  // fetch txs and store in m_payments
1114  // get_address_info
1116  // Login. new_address is true if address hasn't been used on lw node before.
1117  bool light_wallet_login(bool &new_address);
1118  // Send an import request to lw node. returns info about import fee, address and payment_id
1120  // get random outputs from light wallet server
1121  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);
1122  // Parse rct string
1123  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;
1124  // check if key image is ours
1125  bool light_wallet_key_image_is_ours(const crypto::key_image& key_image, const crypto::public_key& tx_public_key, uint64_t out_index);
1126 
1127  /*
1128  * "attributes" are a mechanism to store an arbitrary number of string values
1129  * on the level of the wallet as a whole, identified by keys. Their introduction,
1130  * technically the unordered map m_attributes stored as part of a wallet file,
1131  * led to a new wallet file version, but now new singular pieces of info may be added
1132  * without the need for a new version.
1133  *
1134  * The first and so far only value stored as such an attribute is the description.
1135  * It's stored under the standard key ATTRIBUTE_DESCRIPTION (see method set_description).
1136  *
1137  * The mechanism is open to all clients and allows them to use it for storing basically any
1138  * single string values in a wallet. To avoid the problem that different clients possibly
1139  * overwrite or misunderstand each other's attributes, a two-part key scheme is
1140  * proposed: <client name>.<value name>
1141  */
1142  const char* const ATTRIBUTE_DESCRIPTION = "wallet2.description";
1143  void set_attribute(const std::string &key, const std::string &value);
1144  std::string get_attribute(const std::string &key) const;
1145 
1150 
1151  template<class t_request, class t_response>
1152  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")
1153  {
1154  boost::lock_guard<boost::mutex> lock(m_daemon_rpc_mutex);
1155  return epee::net_utils::invoke_http_json(uri, req, res, m_http_client, timeout, http_method);
1156  }
1157  template<class t_request, class t_response>
1158  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")
1159  {
1160  boost::lock_guard<boost::mutex> lock(m_daemon_rpc_mutex);
1161  return epee::net_utils::invoke_http_bin(uri, req, res, m_http_client, timeout, http_method);
1162  }
1163  template<class t_request, class t_response>
1164  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")
1165  {
1166  boost::lock_guard<boost::mutex> lock(m_daemon_rpc_mutex);
1167  return epee::net_utils::invoke_http_json_rpc(uri, method_name, req, res, m_http_client, timeout, http_method, req_id);
1168  }
1169 
1170  bool set_ring_database(const std::string &filename);
1171  const std::string get_ring_database() const { return m_ring_database; }
1172  bool get_ring(const crypto::key_image &key_image, std::vector<uint64_t> &outs);
1173  bool get_rings(const crypto::hash &txid, std::vector<std::pair<crypto::key_image, std::vector<uint64_t>>> &outs);
1174  bool set_ring(const crypto::key_image &key_image, const std::vector<uint64_t> &outs, bool relative);
1175  bool find_and_save_rings(bool force = true);
1176 
1177  bool blackball_output(const std::pair<uint64_t, uint64_t> &output);
1178  bool set_blackballed_outputs(const std::vector<std::pair<uint64_t, uint64_t>> &outputs, bool add = false);
1179  bool unblackball_output(const std::pair<uint64_t, uint64_t> &output);
1180  bool is_output_blackballed(const std::pair<uint64_t, uint64_t> &output) const;
1181 
1182  bool lock_keys_file();
1183  bool unlock_keys_file();
1184  bool is_keys_file_locked() const;
1185 
1186  void change_password(const std::string &filename, const epee::wipeable_string &original_password, const epee::wipeable_string &new_password);
1187 
1188  void set_tx_notify(const std::shared_ptr<tools::Notify> &notify) { m_tx_notify = notify; }
1189 
1190  private:
1198  bool store_keys(const std::string& keys_file_name, const epee::wipeable_string& password, bool watch_only = false);
1204  bool load_keys(const std::string& keys_file_name, const epee::wipeable_string& password);
1205  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);
1206  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);
1207  void detach_blockchain(uint64_t height);
1208  void get_short_chain_history(std::list<crypto::hash>& ids, uint64_t granularity = 1) const;
1209  bool is_tx_spendtime_unlocked(uint64_t unlock_time, uint64_t block_height) const;
1210  bool clear();
1211  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);
1212  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);
1213  void fast_refresh(uint64_t stop_height, uint64_t &blocks_start_height, std::list<crypto::hash> &short_chain_history, bool force = false);
1214  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);
1215  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);
1216  uint64_t select_transfers(uint64_t needed_money, std::vector<size_t> unused_transfers_indices, std::vector<size_t>& selected_transfers) const;
1217  bool prepare_file_names(const std::string& file_path);
1218  void process_unconfirmed(const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t height);
1219  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);
1220  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);
1221  void generate_genesis(cryptonote::block& b) const;
1222  void check_genesis(const crypto::hash& genesis_hash) const; //throws
1223  bool generate_chacha_key_from_secret_keys(crypto::chacha_key &key) const;
1224  void generate_chacha_key_from_password(const epee::wipeable_string &pass, crypto::chacha_key &key) const;
1225  crypto::hash get_payment_id(const pending_tx &ptx) const;
1226  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;
1227  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;
1228  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;
1229  void parse_block_round(const cryptonote::blobdata &blob, cryptonote::block &bl, crypto::hash &bl_id, bool &error) const;
1230  uint64_t get_upper_transaction_weight_limit() const;
1231  std::vector<uint64_t> get_unspent_amounts_vector() const;
1232  uint64_t get_dynamic_base_fee_estimate() const;
1233  float get_output_relatedness(const transfer_details &td0, const transfer_details &td1) const;
1234  std::vector<size_t> pick_preferred_rct_inputs(uint64_t needed_money, uint32_t subaddr_account, const std::set<uint32_t> &subaddr_indices) const;
1235  void set_spent(size_t idx, uint64_t height);
1236  void set_unspent(size_t idx);
1237  void get_outs(std::vector<std::vector<get_outs_entry>> &outs, const std::vector<size_t> &selected_transfers, size_t fake_outputs_count);
1238  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;
1240  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;
1241  std::vector<size_t> get_only_rct(const std::vector<size_t> &unused_dust_indices, const std::vector<size_t> &unused_transfers_indices) const;
1242  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);
1243  void trim_hashchain();
1245  rct::multisig_kLRki get_multisig_composite_kLRki(size_t n, const crypto::public_key &ignore, std::unordered_set<rct::key> &used_L, std::unordered_set<rct::key> &new_used_L) const;
1246  rct::multisig_kLRki get_multisig_kLRki(size_t n, const rct::key &k) const;
1247  rct::key get_multisig_k(size_t idx, const std::unordered_set<rct::key> &used_L) const;
1248  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);
1249  bool add_rings(const crypto::chacha_key &key, const cryptonote::transaction_prefix &tx);
1250  bool add_rings(const cryptonote::transaction_prefix &tx);
1252  bool get_ring(const crypto::chacha_key &key, const crypto::key_image &key_image, std::vector<uint64_t> &outs);
1253  crypto::chacha_key get_ringdb_key();
1254  void setup_keys(const epee::wipeable_string &password);
1255 
1256  bool get_rct_distribution(uint64_t &start_height, std::vector<uint64_t> &distribution);
1257 
1258  uint64_t get_segregation_fork_height() const;
1259  void unpack_multisig_info(const std::vector<std::string>& info,
1260  std::vector<crypto::public_key> &public_keys,
1261  std::vector<crypto::secret_key> &secret_keys) const;
1262  bool unpack_extra_multisig_info(const std::vector<std::string>& info,
1263  std::vector<crypto::public_key> &signers,
1264  std::unordered_set<crypto::public_key> &pkeys) const;
1265 
1266  void cache_tx_data(const cryptonote::transaction& tx, const crypto::hash &txid, tx_cache_data &tx_cache_data) const;
1267 
1268  void setup_new_blockchain();
1269  void create_keys_file(const std::string &wallet_, bool watch_only, const epee::wipeable_string &password, bool create_address_file);
1270 
1272  boost::optional<epee::net_utils::http::login> m_daemon_login;
1273  std::string m_daemon_address;
1274  std::string m_wallet_file;
1275  std::string m_keys_file;
1276  epee::net_utils::http::http_simple_client m_http_client;
1278  std::unordered_map<crypto::hash, unconfirmed_transfer_details> m_unconfirmed_txs;
1279  std::unordered_map<crypto::hash, confirmed_transfer_details> m_confirmed_txs;
1280  std::unordered_multimap<crypto::hash, pool_payment_details> m_unconfirmed_payments;
1281  std::unordered_map<crypto::hash, crypto::secret_key> m_tx_keys;
1283  std::unordered_map<crypto::hash, std::vector<crypto::secret_key>> m_additional_tx_keys;
1284 
1287  std::unordered_map<crypto::key_image, size_t> m_key_images;
1288  std::unordered_map<crypto::public_key, size_t> m_pub_keys;
1290  std::unordered_map<crypto::public_key, cryptonote::subaddress_index> m_subaddresses;
1291  std::vector<std::vector<std::string>> m_subaddress_labels;
1292  std::unordered_map<crypto::hash, std::string> m_tx_notes;
1293  std::unordered_map<std::string, std::string> m_attributes;
1294  std::vector<tools::wallet2::address_book_row> m_address_book;
1295  std::pair<std::map<std::string, std::string>, std::vector<std::string>> m_account_tags;
1296  uint64_t m_upper_transaction_weight_limit; //TODO: auto-calc this value or request from daemon, now use some fixed value
1297  const std::vector<std::vector<tools::wallet2::multisig_info>> *m_multisig_rescan_info;
1298  const std::vector<std::vector<rct::key>> *m_multisig_rescan_k;
1299 
1300  std::atomic<bool> m_run;
1301 
1302  boost::mutex m_daemon_rpc_mutex;
1303 
1308  uint64_t m_kdf_rounds;
1309  std::string seed_language;
1312  bool m_multisig;
1314  std::vector<crypto::public_key> m_multisig_signers;
1315  //in case of general M/N multisig wallet we should perform N - M + 1 key exchange rounds and remember how many rounds are passed.
1317  std::vector<crypto::public_key> m_multisig_derivations;
1327  // If m_refresh_from_block_height is explicitly set to zero we need this to differentiate it from the case that
1328  // m_refresh_from_block_height was defaulted to zero.*/
1346  std::unordered_set<crypto::hash> m_scanned_pool_txs[2];
1348  std::string m_device_name;
1349 
1350  // Light wallet
1351  bool m_light_wallet; /* sends view key to daemon for scanning */
1358  // Light wallet info needed to populate m_payment requires 2 separate api calls (get_address_txs and get_unspent_outs)
1359  // We save the info from the first call in m_light_wallet_address_txs for easier lookup.
1360  std::unordered_map<crypto::hash, address_tx> m_light_wallet_address_txs;
1361  // store calculated key image for faster lookup
1362  std::unordered_map<crypto::public_key, std::map<uint64_t, crypto::key_image> > m_key_image_cache;
1363 
1364  std::string m_ring_database;
1366  std::unique_ptr<ringdb> m_ringdb;
1367  boost::optional<crypto::chacha_key> m_ringdb_key;
1368 
1370  std::unique_ptr<tools::file_locker> m_keys_file_locker;
1371 
1372  crypto::chacha_key m_cache_key;
1373  boost::optional<epee::wipeable_string> m_encrypt_keys_after_refresh;
1374 
1376 
1377  std::shared_ptr<tools::Notify> m_tx_notify;
1378  };
1379 }
1381 BOOST_CLASS_VERSION(tools::wallet2::transfer_details, 9)
1382 BOOST_CLASS_VERSION(tools::wallet2::multisig_info, 1)
1383 BOOST_CLASS_VERSION(tools::wallet2::multisig_info::LR, 0)
1384 BOOST_CLASS_VERSION(tools::wallet2::multisig_tx_set, 1)
1385 BOOST_CLASS_VERSION(tools::wallet2::payment_details, 4)
1386 BOOST_CLASS_VERSION(tools::wallet2::pool_payment_details, 1)
1387 BOOST_CLASS_VERSION(tools::wallet2::unconfirmed_transfer_details, 8)
1388 BOOST_CLASS_VERSION(tools::wallet2::confirmed_transfer_details, 6)
1389 BOOST_CLASS_VERSION(tools::wallet2::address_book_row, 17)
1390 BOOST_CLASS_VERSION(tools::wallet2::reserve_proof_entry, 0)
1391 BOOST_CLASS_VERSION(tools::wallet2::unsigned_tx_set, 0)
1392 BOOST_CLASS_VERSION(tools::wallet2::signed_tx_set, 0)
1393 BOOST_CLASS_VERSION(tools::wallet2::tx_construction_data, 3)
1394 BOOST_CLASS_VERSION(tools::wallet2::pending_tx, 3)
1395 BOOST_CLASS_VERSION(tools::wallet2::multisig_sig, 0)
1396 
1397 namespace boost
1398 {
1399  namespace serialization
1400  {
1401  template <class Archive>
1402  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)
1403  {
1404  }
1405  template <class Archive>
1406  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)
1407  {
1408  if (ver < 1)
1409  {
1410  x.m_mask = rct::identity();
1411  x.m_amount = x.m_tx.vout[x.m_internal_output_index].amount;
1412  }
1413  if (ver < 2)
1414  {
1415  x.m_spent_height = 0;
1416  }
1417  if (ver < 4)
1418  {
1419  x.m_rct = x.m_tx.vout[x.m_internal_output_index].amount == 0;
1420  }
1421  if (ver < 6)
1422  {
1423  x.m_key_image_known = true;
1424  }
1425  if (ver < 7)
1426  {
1427  x.m_pk_index = 0;
1428  }
1429  if (ver < 8)
1430  {
1431  x.m_subaddr_index = {};
1432  }
1433  if (ver < 9)
1434  {
1435  x.m_key_image_partial = false;
1436  x.m_multisig_k.clear();
1437  x.m_multisig_info.clear();
1438  }
1439  }
1440 
1441  template <class Archive>
1442  inline void serialize(Archive &a, tools::wallet2::transfer_details &x, const boost::serialization::version_type ver)
1443  {
1444  a & x.m_block_height;
1447  if (ver < 3)
1448  {
1450  a & tx;
1451  x.m_tx = (const cryptonote::transaction_prefix&)tx;
1453  }
1454  else
1455  {
1456  a & x.m_tx;
1457  }
1458  a & x.m_spent;
1459  a & x.m_key_image;
1460  if (ver < 1)
1461  {
1462  // ensure mask and amount are set
1463  initialize_transfer_details(a, x, ver);
1464  return;
1465  }
1466  a & x.m_mask;
1467  a & x.m_amount;
1468  if (ver < 2)
1469  {
1470  initialize_transfer_details(a, x, ver);
1471  return;
1472  }
1473  a & x.m_spent_height;
1474  if (ver < 3)
1475  {
1476  initialize_transfer_details(a, x, ver);
1477  return;
1478  }
1479  a & x.m_txid;
1480  if (ver < 4)
1481  {
1482  initialize_transfer_details(a, x, ver);
1483  return;
1484  }
1485  a & x.m_rct;
1486  if (ver < 5)
1487  {
1488  initialize_transfer_details(a, x, ver);
1489  return;
1490  }
1491  if (ver < 6)
1492  {
1493  // v5 did not properly initialize
1494  uint8_t u;
1495  a & u;
1496  x.m_key_image_known = true;
1497  return;
1498  }
1499  a & x.m_key_image_known;
1500  if (ver < 7)
1501  {
1502  initialize_transfer_details(a, x, ver);
1503  return;
1504  }
1505  a & x.m_pk_index;
1506  if (ver < 8)
1507  {
1508  initialize_transfer_details(a, x, ver);
1509  return;
1510  }
1511  a & x.m_subaddr_index;
1512  if (ver < 9)
1513  {
1514  initialize_transfer_details(a, x, ver);
1515  return;
1516  }
1517  a & x.m_multisig_info;
1518  a & x.m_multisig_k;
1519  a & x.m_key_image_partial;
1520  }
1521 
1522  template <class Archive>
1523  inline void serialize(Archive &a, tools::wallet2::multisig_info::LR &x, const boost::serialization::version_type ver)
1524  {
1525  a & x.m_L;
1526  a & x.m_R;
1527  }
1528 
1529  template <class Archive>
1530  inline void serialize(Archive &a, tools::wallet2::multisig_info &x, const boost::serialization::version_type ver)
1531  {
1532  a & x.m_signer;
1533  a & x.m_LR;
1534  a & x.m_partial_key_images;
1535  }
1536 
1537  template <class Archive>
1538  inline void serialize(Archive &a, tools::wallet2::multisig_tx_set &x, const boost::serialization::version_type ver)
1539  {
1540  a & x.m_ptx;
1541  a & x.m_signers;
1542  }
1543 
1544  template <class Archive>
1545  inline void serialize(Archive &a, tools::wallet2::unconfirmed_transfer_details &x, const boost::serialization::version_type ver)
1546  {
1547  a & x.m_change;
1548  a & x.m_sent_time;
1549  if (ver < 5)
1550  {
1552  a & tx;
1553  x.m_tx = (const cryptonote::transaction_prefix&)tx;
1554  }
1555  else
1556  {
1557  a & x.m_tx;
1558  }
1559  if (ver < 1)
1560  return;
1561  a & x.m_dests;
1562  a & x.m_payment_id;
1563  if (ver < 2)
1564  return;
1565  a & x.m_state;
1566  if (ver < 3)
1567  return;
1568  a & x.m_timestamp;
1569  if (ver < 4)
1570  return;
1571  a & x.m_amount_in;
1572  a & x.m_amount_out;
1573  if (ver < 6)
1574  {
1575  // v<6 may not have change accumulated in m_amount_out, which is a pain,
1576  // as it's readily understood to be sum of outputs.
1577  // We convert it to include change from v6
1578  if (!typename Archive::is_saving() && x.m_change != (uint64_t)-1)
1579  x.m_amount_out += x.m_change;
1580  }
1581  if (ver < 7)
1582  {
1583  x.m_subaddr_account = 0;
1584  return;
1585  }
1586  a & x.m_subaddr_account;
1587  a & x.m_subaddr_indices;
1588  if (ver < 8)
1589  return;
1590  a & x.m_rings;
1591  }
1592 
1593  template <class Archive>
1594  inline void serialize(Archive &a, tools::wallet2::confirmed_transfer_details &x, const boost::serialization::version_type ver)
1595  {
1596  a & x.m_amount_in;
1597  a & x.m_amount_out;
1598  a & x.m_change;
1599  a & x.m_block_height;
1600  if (ver < 1)
1601  return;
1602  a & x.m_dests;
1603  a & x.m_payment_id;
1604  if (ver < 2)
1605  return;
1606  a & x.m_timestamp;
1607  if (ver < 3)
1608  {
1609  // v<3 may not have change accumulated in m_amount_out, which is a pain,
1610  // as it's readily understood to be sum of outputs. Whether it got added
1611  // or not depends on whether it came from a unconfirmed_transfer_details
1612  // (not included) or not (included). We can't reliably tell here, so we
1613  // check whether either yields a "negative" fee, or use the other if so.
1614  // We convert it to include change from v3
1615  if (!typename Archive::is_saving() && x.m_change != (uint64_t)-1)
1616  {
1617  if (x.m_amount_in > (x.m_amount_out + x.m_change))
1618  x.m_amount_out += x.m_change;
1619  }
1620  }
1621  if (ver < 4)
1622  {
1623  if (!typename Archive::is_saving())
1624  x.m_unlock_time = 0;
1625  return;
1626  }
1627  a & x.m_unlock_time;
1628  if (ver < 5)
1629  {
1630  x.m_subaddr_account = 0;
1631  return;
1632  }
1633  a & x.m_subaddr_account;
1634  a & x.m_subaddr_indices;
1635  if (ver < 6)
1636  return;
1637  a & x.m_rings;
1638  }
1639 
1640  template <class Archive>
1641  inline void serialize(Archive& a, tools::wallet2::payment_details& x, const boost::serialization::version_type ver)
1642  {
1643  a & x.m_tx_hash;
1644  a & x.m_amount;
1645  a & x.m_block_height;
1646  a & x.m_unlock_time;
1647  if (ver < 1)
1648  return;
1649  a & x.m_timestamp;
1650  if (ver < 2)
1651  {
1652  x.m_coinbase = false;
1653  x.m_subaddr_index = {};
1654  return;
1655  }
1656  a & x.m_subaddr_index;
1657  if (ver < 3)
1658  {
1659  x.m_coinbase = false;
1660  x.m_fee = 0;
1661  return;
1662  }
1663  a & x.m_fee;
1664  if (ver < 4)
1665  {
1666  x.m_coinbase = false;
1667  return;
1668  }
1669  a & x.m_coinbase;
1670  }
1671 
1672  template <class Archive>
1673  inline void serialize(Archive& a, tools::wallet2::pool_payment_details& x, const boost::serialization::version_type ver)
1674  {
1675  a & x.m_pd;
1676  a & x.m_double_spend_seen;
1677  }
1678 
1679  template <class Archive>
1680  inline void serialize(Archive& a, tools::wallet2::address_book_row& x, const boost::serialization::version_type ver)
1681  {
1682  a & x.m_address;
1683  a & x.m_payment_id;
1684  a & x.m_description;
1685  if (ver < 17)
1686  {
1687  x.m_is_subaddress = false;
1688  return;
1689  }
1690  a & x.m_is_subaddress;
1691  }
1692 
1693  template <class Archive>
1694  inline void serialize(Archive& a, tools::wallet2::reserve_proof_entry& x, const boost::serialization::version_type ver)
1695  {
1696  a & x.txid;
1697  a & x.index_in_tx;
1698  a & x.shared_secret;
1699  a & x.key_image;
1700  a & x.shared_secret_sig;
1701  a & x.key_image_sig;
1702  }
1703 
1704  template <class Archive>
1705  inline void serialize(Archive &a, tools::wallet2::unsigned_tx_set &x, const boost::serialization::version_type ver)
1706  {
1707  a & x.txes;
1708  a & x.transfers;
1709  }
1710 
1711  template <class Archive>
1712  inline void serialize(Archive &a, tools::wallet2::signed_tx_set &x, const boost::serialization::version_type ver)
1713  {
1714  a & x.ptx;
1715  a & x.key_images;
1716  }
1717 
1718  template <class Archive>
1719  inline void serialize(Archive &a, tools::wallet2::tx_construction_data &x, const boost::serialization::version_type ver)
1720  {
1721  a & x.sources;
1722  a & x.change_dts;
1723  a & x.splitted_dsts;
1724  if (ver < 2)
1725  {
1726  // load list to vector
1727  std::list<size_t> selected_transfers;
1728  a & selected_transfers;
1729  x.selected_transfers.clear();
1730  x.selected_transfers.reserve(selected_transfers.size());
1731  for (size_t t: selected_transfers)
1732  x.selected_transfers.push_back(t);
1733  }
1734  a & x.extra;
1735  a & x.unlock_time;
1736  a & x.use_rct;
1737  a & x.dests;
1738  if (ver < 1)
1739  {
1740  x.subaddr_account = 0;
1741  return;
1742  }
1743  a & x.subaddr_account;
1744  a & x.subaddr_indices;
1745  if (ver < 2)
1746  return;
1747  a & x.selected_transfers;
1748  if (ver < 3)
1749  return;
1750  a & x.use_bulletproofs;
1751  }
1752 
1753  template <class Archive>
1754  inline void serialize(Archive &a, tools::wallet2::multisig_sig &x, const boost::serialization::version_type ver)
1755  {
1756  a & x.sigs;
1757  a & x.ignore;
1758  a & x.used_L;
1759  a & x.signing_keys;
1760  a & x.msout;
1761  }
1762 
1763  template <class Archive>
1764  inline void serialize(Archive &a, tools::wallet2::pending_tx &x, const boost::serialization::version_type ver)
1765  {
1766  a & x.tx;
1767  a & x.dust;
1768  a & x.fee;
1769  a & x.dust_added_to_fee;
1770  a & x.change_dts;
1771  if (ver < 2)
1772  {
1773  // load list to vector
1774  std::list<size_t> selected_transfers;
1775  a & selected_transfers;
1776  x.selected_transfers.clear();
1777  x.selected_transfers.reserve(selected_transfers.size());
1778  for (size_t t: selected_transfers)
1779  x.selected_transfers.push_back(t);
1780  }
1781  a & x.key_images;
1782  a & x.tx_key;
1783  a & x.dests;
1784  a & x.construction_data;
1785  if (ver < 1)
1786  return;
1787  a & x.additional_tx_keys;
1788  if (ver < 2)
1789  return;
1790  a & x.selected_transfers;
1791  if (ver < 3)
1792  return;
1793  a & x.multisig_sigs;
1794  }
1795  }
1796 }
1797 
1798 namespace tools
1799 {
1800 
1801  namespace detail
1802  {
1803  //----------------------------------------------------------------------------------------------------
1804  inline void digit_split_strategy(const std::vector<cryptonote::tx_destination_entry>& dsts,
1805  const cryptonote::tx_destination_entry& change_dst, uint64_t dust_threshold,
1806  std::vector<cryptonote::tx_destination_entry>& splitted_dsts, std::vector<cryptonote::tx_destination_entry> &dust_dsts)
1807  {
1808  splitted_dsts.clear();
1809  dust_dsts.clear();
1810 
1811  for(auto& de: dsts)
1812  {
1814  [&](uint64_t chunk) { splitted_dsts.push_back(cryptonote::tx_destination_entry(chunk, de.addr, de.is_subaddress)); },
1815  [&](uint64_t a_dust) { splitted_dsts.push_back(cryptonote::tx_destination_entry(a_dust, de.addr, de.is_subaddress)); } );
1816  }
1817 
1819  [&](uint64_t chunk) {
1820  if (chunk <= dust_threshold)
1821  dust_dsts.push_back(cryptonote::tx_destination_entry(chunk, change_dst.addr, false));
1822  else
1823  splitted_dsts.push_back(cryptonote::tx_destination_entry(chunk, change_dst.addr, false));
1824  },
1825  [&](uint64_t a_dust) { dust_dsts.push_back(cryptonote::tx_destination_entry(a_dust, change_dst.addr, false)); } );
1826  }
1827  //----------------------------------------------------------------------------------------------------
1828  inline void null_split_strategy(const std::vector<cryptonote::tx_destination_entry>& dsts,
1829  const cryptonote::tx_destination_entry& change_dst, uint64_t dust_threshold,
1830  std::vector<cryptonote::tx_destination_entry>& splitted_dsts, std::vector<cryptonote::tx_destination_entry> &dust_dsts)
1831  {
1832  splitted_dsts = dsts;
1833 
1834  dust_dsts.clear();
1835  uint64_t change = change_dst.amount;
1836 
1837  if (0 != change)
1838  {
1839  splitted_dsts.push_back(cryptonote::tx_destination_entry(change, change_dst.addr, false));
1840  }
1841  }
1842  //----------------------------------------------------------------------------------------------------
1844  {
1845  std::string indexes;
1846  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) + " "; });
1847  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);
1848  }
1849  //----------------------------------------------------------------------------------------------------
1850  }
1851  //----------------------------------------------------------------------------------------------------
1852 }
uint64_t m_upper_transaction_weight_limit
Definition: wallet2.h:1296
bool reconnect_device()
Definition: wallet2.cpp:1053
bool watch_only() const
Definition: wallet2.h:717
uint32_t subaddr_account
Definition: wallet2.h:350
uint64_t unlock_time
Definition: wallet2.h:346
static bool parse_long_payment_id(const std::string &payment_id_str, crypto::hash &payment_id)
Definition: wallet2.cpp:4482
void rescan_spent()
Definition: wallet2.cpp:5025
Definition: binary_utils.h:36
Definition: wallet2.h:428
std::vector< crypto::public_key > get_subaddress_spend_public_keys(uint32_t account, uint32_t begin, uint32_t end) const
Definition: wallet2.h:168
epee::net_utils::http::http_simple_client m_http_client
Definition: wallet2.h:1276
std::vector< crypto::key_image > key_images
Definition: wallet2.h:425
bool error
Definition: wallet2.h:229
uint64_t m_segregation_height
Definition: wallet2.h:1342
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:6667
void set_unspent(size_t idx)
Definition: wallet2.cpp:1215
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:9916
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:5016
cryptonote::transaction tx
Definition: wallet2.h:385
crypto::chacha_iv iv
Definition: wallet2.h:441
bool m_always_confirm_transfers
Definition: wallet2.h:1318
void setup_new_blockchain()
Definition: wallet2.cpp:3565
AskPasswordType ask_password() const
Definition: wallet2.h:928
bool sign_multisig_tx(multisig_tx_set &exported_txs, std::vector< crypto::hash > &txids)
Definition: wallet2.cpp:5965
uint64_t unlocked_balance(uint32_t subaddr_index_major) const
Definition: wallet2.cpp:4888
crypto::public_key ignore
Definition: wallet2.h:374
void callback(i_wallet2_callback *callback)
Definition: wallet2.h:658
rct::multisig_kLRki get_multisig_kLRki(size_t n, const rct::key &k) const
Definition: wallet2.cpp:11016
void set_tx_notify(const std::shared_ptr< tools::Notify > &notify)
Definition: wallet2.h:1188
Definition: wallet2.h:422
const boost::optional< epee::net_utils::http::login > & get_daemon_login() const
Definition: wallet2.h:1004
const uint32_t T[512]
Definition: groestl_tables.h:33
hw::device::device_type m_key_device_type
Definition: wallet2.h:1306
size_t get_num_subaddresses(uint32_t index_major) const
Definition: wallet2.h:697
std::string cache_data
Definition: wallet2.h:453
std::unordered_map< crypto::hash, std::vector< crypto::secret_key > > m_additional_tx_keys
Definition: wallet2.h:1283
bool m_confirm_export_overwrite
Definition: wallet2.h:1338
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:11123
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)
Definition: wallet2.cpp:2053
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:5284
Definition: rctTypes.h:111
const crypto::hash & operator[](size_t idx) const
Definition: wallet2.h:129
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:4965
crypto::public_key get_tx_pub_key_from_received_outs(const tools::wallet2::transfer_details &td) const
Definition: wallet2.cpp:10368
Definition: cryptonote_config.h:210
cryptonote::blobdata export_multisig()
Definition: wallet2.cpp:11073
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:1152
bool get_seed(epee::wipeable_string &electrum_words, const epee::wipeable_string &passphrase=epee::wipeable_string()) const
Definition: wallet2.cpp:964
std::atomic< bool > m_run
Definition: wallet2.h:1300
payment_container export_payments() const
Definition: wallet2.cpp:10786
uint64_t m_block_height
Definition: wallet2.h:285
bool m_is_subaddress
Definition: wallet2.h:467
bool key_on_device() const
Definition: wallet2.h:722
void auto_low_priority(bool value)
Definition: wallet2.h:943
std::map< uint32_t, uint64_t > unlocked_balance_per_subaddress(uint32_t subaddr_index_major) const
Definition: wallet2.cpp:4927
std::string export_outputs_to_str() const
Definition: wallet2.cpp:10859
uint64_t m_unlock_time
Definition: wallet2.h:286
void commit_tx(pending_tx &ptx_vector)
Definition: wallet2.cpp:5342
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:935
virtual boost::optional< epee::wipeable_string > on_get_password(const char *reason)
Definition: wallet2.h:94
cryptonote::subaddress_index m_subaddr_index
Definition: wallet2.h:289
bool is_old_file_format
Definition: wallet2.h:1310
Definition: unordered_containers_boost_serialization.h:37
bool ignore_fractional_outputs() const
Definition: wallet2.h:950
void trim(size_t height)
Definition: wallet2.h:134
const std::string & get_seed_language() const
Gets the seed language.
Definition: wallet2.cpp:1077
cryptonote::network_type m_nettype
Definition: wallet2.h:1307
uint64_t m_change
Definition: wallet2.h:324
size_t import_outputs(const std::vector< tools::wallet2::transfer_details > &outputs)
Definition: wallet2.cpp:10876
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:8871
void confirm_non_default_ring_size(bool always)
Definition: wallet2.h:953
std::pair< size_t, size_t > get_subaddress_lookahead() const
Definition: wallet2.h:703
bool is_output_blackballed(const std::pair< uint64_t, uint64_t > &output) const
Definition: wallet2.cpp:6512
Definition: wallet2.h:152
Definition: node_rpc_proxy.h:39
bool dust_added_to_fee
Definition: wallet2.h:387
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)
Definition: wallet2.cpp:1384
void expand_subaddresses(const cryptonote::subaddress_index &index)
Definition: wallet2.cpp:1136
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:4467
cryptonote::subaddress_index m_subaddr_index
Definition: wallet2.h:250
const std::string get_ring_database() const
Definition: wallet2.h:1171
std::vector< size_t > select_available_unmixable_outputs()
Definition: wallet2.cpp:9219
void confirm_missing_payment_id(bool always)
Definition: wallet2.h:927
Definition: wallet2.h:280
Definition: cryptonote_basic.h:427
void default_mixin(uint32_t m)
Definition: wallet2.h:921
uint64_t get_approximate_blockchain_height() const
Calculates the approximate blockchain height from current date/time.
Definition: wallet2.cpp:10207
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:5543
bool confirm_export_overwrite() const
Definition: wallet2.h:940
void parse_block_round(const cryptonote::blobdata &blob, cryptonote::block &bl, crypto::hash &bl_id, bool &error) const
Definition: wallet2.cpp:2004
Definition: cryptonote_protocol_defs.h:109
uint64_t amount
Definition: wallet2.h:227
static const unsigned char iv[64]
Definition: sha512-hash.c:13
Definition: wallet2.h:119
std::vector< cryptonote::tx_destination_entry > dests
Definition: wallet2.h:393
std::vector< crypto::secret_key > additional_tx_keys
Definition: wallet2.h:392
std::vector< rct::key > m_multisig_k
Definition: wallet2.h:252
std::vector< LR > m_LR
Definition: wallet2.h:212
size_t import_multisig(std::vector< cryptonote::blobdata > info)
Definition: wallet2.cpp:11144
int get_fee_algorithm() const
Definition: wallet2.cpp:6184
void auto_refresh(bool r)
Definition: wallet2.h:925
crypto::public_key shared_secret
Definition: wallet2.h:474
crypto::public_key get_multisig_signing_public_key(size_t idx) const
Definition: wallet2.cpp:10994
uint32_t m_confirm_backlog_threshold
Definition: wallet2.h:1337
uint64_t balance(uint32_t subaddr_index_major) const
Definition: wallet2.cpp:4878
POD_CLASS key_derivation
Definition: crypto.h:85
void get_hard_fork_info(uint8_t version, uint64_t &earliest_height) const
Definition: wallet2.cpp:9082
Definition: cryptonote_basic.h:366
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:3600
void merge_destinations(bool merge)
Definition: wallet2.h:934
bool save_tx(const std::vector< pending_tx > &ptx_vector, const std::string &filename) const
Definition: wallet2.cpp:5427
std::string path() const
Definition: wallet2.cpp:4761
bool is_transfer_unlocked(const transfer_details &td) const
Definition: wallet2.cpp:5087
std::vector< size_t > selected_transfers
Definition: wallet2.h:389
boost::optional< crypto::chacha_key > m_ringdb_key
Definition: wallet2.h:1367
std::unordered_map< crypto::public_key, cryptonote::subaddress_index > m_subaddresses
Definition: wallet2.h:1290
bool is_unattended() const
Definition: wallet2.h:1107
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:11386
uint64_t m_kdf_rounds
Definition: wallet2.h:1308
crypto::hash hash
Definition: wallet2.h:484
bool segregate_pre_fork_outputs() const
Definition: wallet2.h:944
std::deque< crypto::hash > m_blockchain
Definition: wallet2.h:148
std::string sign(const std::string &data) const
Definition: wallet2.cpp:10301
static constexpr const std::chrono::seconds rpc_timeout
Definition: wallet2.h:157
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:187
wallet2(cryptonote::network_type nettype=cryptonote::MAINNET, uint64_t kdf_rounds=1, bool unattended=false)
Definition: wallet2.cpp:810
std::vector< crypto::public_key > m_multisig_signers
Definition: wallet2.h:1314
void decrypt_keys(const crypto::chacha_key &key)
Definition: wallet2.cpp:3545
uint64_t height
Definition: blockchain.cpp:89
void process_unconfirmed(const crypto::hash &txid, const cryptonote::transaction &tx, uint64_t height)
Definition: wallet2.cpp:1871
void stop()
Definition: wallet2.h:655
bool use_bulletproofs
Definition: wallet2.h:348
std::string exchange_multisig_keys(const epee::wipeable_string &password, const std::vector< std::string > &info)
Definition: wallet2.cpp:4067
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:91
Definition: wallet2.h:200
void generate_genesis(cryptonote::block &b) const
Definition: wallet2.cpp:11689
uint64_t dust
Definition: wallet2.h:386
const cryptonote::account_base & get_account() const
Definition: wallet2.h:638
bool is_synced() const
Definition: wallet2.cpp:11557
std::string key_images
Definition: wallet2.h:390
std::vector< cryptonote::transaction > txes
Definition: wallet2.h:486
uint64_t m_timestamp
Definition: wallet2.h:287
std::vector< uint64_t > get_unspent_amounts_vector() const
Definition: wallet2.cpp:9136
boost::optional< cryptonote::subaddress_receive_info > received
Definition: wallet2.h:230
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:5874
uint64_t m_light_wallet_blockchain_height
Definition: wallet2.h:1353
std::string get_daemon_address() const
Definition: wallet2.cpp:10174
uint64_t m_last_block_reward
Definition: wallet2.h:1369
rct::key m_mask
Definition: wallet2.h:245
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:4253
uint64_t unlocked_balance_all() const
Definition: wallet2.cpp:4952
std::vector< pending_tx > ptx
Definition: wallet2.h:424
crypto::key_derivation derivation
Definition: wallet2.h:494
void refill(const crypto::hash &hash)
Definition: wallet2.h:135
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:6563
uint64_t index_in_tx
Definition: wallet2.h:473
crypto::key_image ki
Definition: wallet2.h:225
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:901
cryptonote::tx_destination_entry change_dts
Definition: wallet2.h:342
void print_source_entry(const cryptonote::tx_source_entry &src)
Definition: wallet2.h:1843
wallet_keys_unlocker(wallet2 &w, const boost::optional< tools::password_container > &password)
Definition: wallet2.cpp:779
crypto namespace.
Definition: crypto.cpp:59
epee::mlocked< tools::scrubbed< ec_scalar > > secret_key
Definition: crypto.h:69
size_t m_subaddress_lookahead_minor
Definition: wallet2.h:1347
void store_tx_info(bool store)
Definition: wallet2.h:919
Definition: blockchain_ancestry.cpp:70
crypto::hash m_txid
Definition: wallet2.h:239
std::string get_keys_file() const
Definition: wallet2.cpp:10169
Definition: wallet2.h:198
Definition: wallet2.h:470
uint64_t m_min_output_value
Definition: wallet2.h:1334
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:1263
uint64_t balance_all() const
Definition: wallet2.cpp:4944
cryptonote::account_public_address m_address
Definition: wallet2.h:464
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:6547
bool explicit_refresh_from_block_height() const
Definition: wallet2.h:649
Definition: wallet2.h:105
uint64_t m_timestamp
Definition: wallet2.h:328
void rescan_blockchain(bool refresh=true)
Definition: wallet2.cpp:5077
Definition: cryptonote_basic.h:77
std::vector< cryptonote::tx_destination_entry > m_dests
Definition: wallet2.h:326
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:5690
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:3903
#define FEE_PER_KB
Definition: cryptonote_config.h:69
bool confirm_non_default_ring_size() const
Definition: wallet2.h:952
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:672
uint64_t m_amount_out
Definition: wallet2.h:308
std::string account_data
Definition: wallet2.h:442
void change_password(const std::string &filename, const epee::wipeable_string &original_password, const epee::wipeable_string &new_password)
Definition: wallet2.cpp:3170
std::unordered_multimap< crypto::hash, payment_details > payment_container
Definition: wallet2.h:369
crypto::hash m_tx_hash
Definition: wallet2.h:282
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:1828
const std::string & device_name() const
Definition: wallet2.h:954
std::string get_spend_proof(const crypto::hash &txid, const std::string &message)
Definition: wallet2.cpp:9332
uint64_t get_light_wallet_scanned_block_height() const
Definition: wallet2.h:674
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:4201
uint64_t m_fee
Definition: wallet2.h:284
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:5005
rct::key m_L
Definition: wallet2.h:202
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:5268
void key_reuse_mitigation2(bool value)
Definition: wallet2.h:947
bool check_connection(uint32_t *version=NULL, uint32_t timeout=200000)
Definition: wallet2.cpp:4528
uint32_t m_default_mixin
Definition: wallet2.h:1321
crypto::hash m_genesis
Definition: wallet2.h:147
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)
Definition: wallet2.cpp:1299
cryptonote::network_type nettype() const
Definition: wallet2.h:716
boost::optional< cryptonote::subaddress_index > get_subaddress_index(const cryptonote::account_public_address &address) const
Definition: wallet2.cpp:1096
tools::wallet2::RefreshType refresh_type
Definition: simplewallet.cpp:285
boost::optional< tools::password_container > password_prompter(const char *prompt, bool verify)
Definition: simplewallet.cpp:184
uint64_t amount
Definition: cryptonote_tx_utils.h:51
std::vector< std::pair< uint64_t, uint64_t > > estimate_backlog(const std::vector< std::pair< double, double >> &fee_levels)
Definition: wallet2.cpp:11566
rct::rctSig sigs
Definition: wallet2.h:373
size_t import_outputs_from_str(const std::string &outputs_st)
Definition: wallet2.cpp:10910
std::string m_daemon_address
Definition: wallet2.h:1273
static const crypto::hash null_hash
Definition: hash.h:93
cryptonote::account_public_address addr_for_dust
Definition: wallet2.h:109
bool m_merge_destinations
Definition: wallet2.h:1335
crypto::public_key pkey
Definition: wallet2.h:493
uint64_t money_transfered
Definition: wallet2.h:228
std::unordered_set< crypto::public_key > m_signers
Definition: wallet2.h:431
bool clear()
Definition: wallet2.cpp:2947
std::unordered_map< crypto::hash, confirmed_transfer_details > m_confirmed_txs
Definition: wallet2.h:1279
void get_short_chain_history(std::list< crypto::hash > &ids, uint64_t granularity=1) const
Definition: wallet2.cpp:1971
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:4991
void trim_hashchain()
Definition: wallet2.cpp:4719
uint64_t get_dynamic_base_fee_estimate() const
Definition: wallet2.cpp:6140
uint64_t m_amount_in
Definition: wallet2.h:322
std::unordered_map< crypto::public_key, std::map< uint64_t, crypto::key_image > > m_key_image_cache
Definition: wallet2.h:1362
void set_trusted_daemon(bool trusted)
Definition: wallet2.h:661
void set_attribute(const std::string &key, const std::string &value)
Definition: wallet2.cpp:10238
std::string get_tx_note(const crypto::hash &txid) const
Definition: wallet2.cpp:10230
bool add_to_fee
Definition: wallet2.h:108
void confirm_backlog(bool always)
Definition: wallet2.h:937
size_t real_output
Definition: cryptonote_tx_utils.h:47
static std::string device_name_option(const boost::program_options::variables_map &vm)
Definition: wallet2.cpp:877
bool m_segregate_pre_fork_outputs
Definition: wallet2.h:1340
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:5941
std::unordered_set< crypto::public_key > signing_keys
Definition: wallet2.h:376
static bool verify_extra_multisig_info(const std::string &data, std::unordered_set< crypto::public_key > &pkeys, crypto::public_key &signer)
Definition: wallet2.cpp:4356
Definition: rctTypes.h:104
std::unique_ptr< ringdb > m_ringdb
Definition: wallet2.h:1366
std::unordered_map< crypto::hash, crypto::secret_key > m_tx_keys
Definition: wallet2.h:1281
bool key_reuse_mitigation2() const
Definition: wallet2.h:946
bool print_ring_members() const
Definition: wallet2.h:916
void set_seed_language(const std::string &language)
Sets the seed language.
Definition: wallet2.cpp:1085
uint64_t get_base_fee() const
Definition: wallet2.cpp:6151
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:1223
bool m_light_wallet_connected
Definition: wallet2.h:1355
RefreshType
Definition: wallet2.h:159
uint32_t m_multisig_threshold
Definition: wallet2.h:1313
float get_output_relatedness(const transfer_details &td0, const transfer_details &td1) const
Definition: wallet2.cpp:5183
virtual void on_pool_tx_removed(const crypto::hash &txid)
Definition: wallet2.h:101
Definition: wallet2.h:85
bool always_confirm_transfers() const
Definition: wallet2.h:914
#define END_SERIALIZE()
self-explanatory
Definition: serialization.h:214
uint32_t m_multisig_rounds_passed
Definition: wallet2.h:1316
bool use_fork_rules(uint8_t version, int64_t early_blocks=0) const
Definition: wallet2.cpp:9088
uint32_t get_confirm_backlog_threshold() const
Definition: wallet2.h:939
std::vector< cryptonote::tx_destination_entry > m_dests
Definition: wallet2.h:311
std::vector< cryptonote::tx_source_entry > sources
Definition: wallet2.h:341
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:7408
std::vector< std::pair< crypto::key_image, crypto::signature > > export_key_images() const
Definition: wallet2.cpp:10447
std::shared_ptr< tools::Notify > m_tx_notify
Definition: wallet2.h:1377
void generate_chacha_key_from_password(const epee::wipeable_string &pass, crypto::chacha_key &key) const
Definition: wallet2.cpp:4571
const std::vector< std::vector< rct::key > > * m_multisig_rescan_k
Definition: wallet2.h:1298
size_t m_subaddress_lookahead_major
Definition: wallet2.h:1347
std::vector< crypto::key_image > m_partial_key_images
Definition: wallet2.h:213
rct::key get_multisig_k(size_t idx, const std::unordered_set< rct::key > &used_L) const
Definition: wallet2.cpp:11001
tx_scan_info_t()
Definition: wallet2.h:232
bool unblackball_output(const std::pair< uint64_t, uint64_t > &output)
Definition: wallet2.cpp:6504
bool is_in_bounds(size_t idx) const
Definition: wallet2.h:128
Definition: cryptonote_basic.h:156
BOOST_CLASS_VERSION(nodetool::node_server< cryptonote::t_cryptonote_protocol_handler< cryptonote::core > >, 1)
std::vector< tx_out > vout
Definition: cryptonote_basic.h:165
~wallet2()
Definition: wallet2.cpp:863
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)
Definition: wallet2.h:90
bool has_multisig_partial_key_images() const
Definition: wallet2.cpp:4417
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:1891
Definition: core_rpc_server_commands_defs.h:542
bool is_deprecated() const
Tells if the wallet file is deprecated.
Definition: wallet2.cpp:1202
std::vector< tx_construction_data > txes
Definition: wallet2.h:418
crypto::chacha_key m_cache_key
Definition: wallet2.h:1372
std::vector< is_out_data > primary
Definition: wallet2.h:501
uint64_t get_max_ring_size() const
Definition: wallet2.cpp:6209
bool light_wallet_login(bool &new_address)
Definition: wallet2.cpp:7778
rct::multisig_kLRki get_multisig_composite_kLRki(size_t n, const crypto::public_key &ignore, std::unordered_set< rct::key > &used_L, std::unordered_set< rct::key > &new_used_L) const
Definition: wallet2.cpp:11026
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:8179
std::map< uint32_t, uint64_t > balance_per_subaddress(uint32_t subaddr_index_major) const
Definition: wallet2.cpp:4898
uint64_t get_segregation_fork_height() const
Definition: wallet2.cpp:11637
std::vector< tools::wallet2::address_book_row > m_address_book
Definition: wallet2.h:1294
std::vector< size_t > select_available_outputs_from_histogram(uint64_t count, bool atleast, bool unlocked, bool allow_rct)
Definition: wallet2.cpp:9153
virtual void on_skip_transaction(uint64_t height, const crypto::hash &txid, const cryptonote::transaction &tx)
Definition: wallet2.h:93
std::unordered_set< rct::key > used_L
Definition: wallet2.h:375
NodeRPCProxy m_node_rpc_proxy
Definition: wallet2.h:1345
std::unordered_map< crypto::public_key, size_t > m_pub_keys
Definition: wallet2.h:1288
size_t m_pk_index
Definition: wallet2.h:249
const crypto::hash & genesis() const
Definition: wallet2.h:126
i_wallet2_callback * m_callback
Definition: wallet2.h:1305
uint64_t amount() const
Definition: wallet2.h:256
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:2515
void detach_blockchain(uint64_t height)
Definition: wallet2.cpp:2876
bool m_confirm_backlog
Definition: wallet2.h:1336
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:8262
virtual void on_lw_new_block(uint64_t height)
Definition: wallet2.h:96
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:5210
uint64_t m_light_wallet_per_kb_fee
Definition: wallet2.h:1354
bool m_double_spend_seen
Definition: wallet2.h:301
cryptonote::account_public_address get_subaddress(const cryptonote::subaddress_index &index) const
Definition: wallet2.cpp:1090
bool m_key_image_known
Definition: wallet2.h:248
Definition: wallet2.h:339
std::string get_address_as_str() const
Definition: wallet2.h:693
bool m_incoming
Definition: wallet2.h:295
void set_refresh_type(RefreshType refresh_type)
Definition: wallet2.h:713
Definition: wallet2.h:160
std::vector< transfer_details > transfer_container
Definition: wallet2.h:368
uint64_t m_amount_out
Definition: wallet2.h:323
declaration and default definition for the functions used the API
Definition: expect.cpp:33
void segregate_pre_fork_outputs(bool value)
Definition: wallet2.h:945
bool finalize_multisig(const epee::wipeable_string &password, const std::vector< std::string > &info)
Finalizes creation of a multisig wallet.
Definition: wallet2.cpp:4286
static void add(ge_p3 &p3, const ge_cached &other)
Definition: multiexp.cc:124
std::unordered_map< std::string, std::string > m_attributes
Definition: wallet2.h:1293
bool m_unattended
Definition: wallet2.h:1375
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:4771
bool unlock_keys_file()
Definition: wallet2.cpp:6531
crypto::hash m_payment_id
Definition: wallet2.h:312
bool m_auto_low_priority
Definition: wallet2.h:1339
std::vector< std::vector< std::string > > m_subaddress_labels
Definition: wallet2.h:1291
bool is_tx_spendtime_unlocked(uint64_t unlock_time, uint64_t block_height) const
Definition: wallet2.cpp:5103
std::unordered_set< crypto::hash > m_scanned_pool_txs[2]
Definition: wallet2.h:1346
bool m_coinbase
Definition: wallet2.h:288
size_t m_internal_output_index
Definition: wallet2.h:240
uint32_t get_min_output_count() const
Definition: wallet2.h:931
uint32_t m_min_output_count
Definition: wallet2.h:1333
device_type
Definition: device.hpp:100
std::vector< size_t > select_available_outputs(const std::function< bool(const transfer_details &td)> &f) const
Definition: wallet2.cpp:9118
payment_details m_pd
Definition: wallet2.h:300
uint64_t m_timestamp
Definition: wallet2.h:314
bool auto_refresh() const
Definition: wallet2.h:924
std::set< uint32_t > subaddr_indices
Definition: wallet2.h:351
Various Tools.
Definition: apply_permutation.h:39
boost::optional< epee::net_utils::http::login > m_daemon_login
Definition: wallet2.h:1272
bool locked
Definition: wallet2.h:81
confirmed_transfer_details(const unconfirmed_transfer_details &utd, uint64_t height)
Definition: wallet2.h:335
wallet2 & w
Definition: wallet2.h:80
uint64_t m_global_output_index
Definition: wallet2.h:241
wallet2::transfer_container transfers
Definition: wallet2.h:419
void set_tx_note(const crypto::hash &txid, const std::string &note)
Definition: wallet2.cpp:10225
Definition: wallet2.h:222
Definition: cryptonote_tx_utils.h:42
void set_light_wallet(bool light_wallet)
Definition: wallet2.h:673
crypto::chacha_key key
Definition: wallet2.h:82
Definition: account.h:75
bool is_trusted_daemon() const
Definition: wallet2.h:660
uint64_t m_unlock_time
Definition: wallet2.h:329
void confirm_export_overwrite(bool always)
Definition: wallet2.h:941
uint64_t get_refresh_from_block_height() const
Definition: wallet2.h:646
uint64_t get_daemon_blockchain_height(std::string &err) const
Definition: wallet2.cpp:10179
uint64_t get_min_output_value() const
Definition: wallet2.h:933
Definition: wallet2.h:163
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:8796
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:3492
std::pair< std::map< std::string, std::string >, std::vector< std::string > > m_account_tags
Definition: wallet2.h:1295
Definition: rctTypes.h:78
uint64_t m_light_wallet_scanned_block_height
Definition: wallet2.h:1352
#define ts
Definition: skein.c:522
uint32_t m_subaddr_account
Definition: wallet2.h:330
uint64_t get_upper_transaction_weight_limit() const
Definition: wallet2.cpp:9107
int b
Definition: base.py:1
std::vector< cryptonote::tx_destination_entry > splitted_dsts
Definition: wallet2.h:343
std::string get_subaddress_as_str(const cryptonote::subaddress_index &index) const
Definition: wallet2.cpp:1110
std::vector< multisig_sig > multisig_sigs
Definition: wallet2.h:394
Definition: subaddress_index.h:38
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:5664
#define BEGIN_SERIALIZE_OBJECT()
begins the environment of the DSL \detailed for described the serialization of an object
Definition: serialization.h:190
void ignore_fractional_outputs(bool value)
Definition: wallet2.h:951
Definition: wallet2.h:292
void remove_obsolete_pool_txs(const std::vector< crypto::hash > &tx_hashes)
Definition: wallet2.cpp:2260
Definition: rctTypes.h:436
cryptonote::COMMAND_RPC_GET_BLOCKS_FAST::block_output_indices o_indices
Definition: wallet2.h:487
Definition: password.h:40
bool empty() const
Definition: wallet2.h:133
std::vector< is_out_data > additional
Definition: wallet2.h:502
bool store_tx_info() const
Definition: wallet2.h:918
cryptonote::transaction_prefix m_tx
Definition: wallet2.h:238
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:7724
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:2580
uint64_t amount
Definition: cryptonote_tx_utils.h:77
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:111
void clear()
Definition: wallet2.h:132
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:5711
bool m_mempool
Definition: wallet2.h:294
Definition: device.hpp:83
std::string m_wallet_file
Definition: wallet2.h:1274
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:2195
std::string seed_language
Definition: wallet2.h:1309
std::string decrypt_with_view_secret_key(const std::string &ciphertext, bool authenticated=true) const
Definition: wallet2.cpp:11327
std::string get_wallet_file() const
Definition: wallet2.cpp:10164
uint64_t m_block_height
Definition: wallet2.h:237
static void init_options(boost::program_options::options_description &desc_params)
Definition: wallet2.cpp:882
Definition: wallet2.h:298
uint32_t m_subaddr_account
Definition: wallet2.h:315
std::vector< tools::wallet2::transfer_details > export_outputs() const
Definition: wallet2.cpp:10844
uint64_t get_light_wallet_blockchain_height() const
Definition: wallet2.h:675
std::vector< uint8_t > extra
Definition: wallet2.h:345
crypto::hash & operator[](size_t idx)
Definition: wallet2.h:130
void cache_tx_data(const cryptonote::transaction &tx, const crypto::hash &txid, tx_cache_data &tx_cache_data) const
Definition: wallet2.cpp:1345
std::tuple< uint64_t, crypto::public_key, rct::key > get_outs_entry
Definition: wallet2.h:480
void store()
Definition: wallet2.cpp:4766
crypto::hash get_payment_id(const pending_tx &ptx) const
Definition: wallet2.cpp:5311
bool light_wallet_import_wallet_request(cryptonote::COMMAND_RPC_IMPORT_WALLET_REQUEST::response &response)
Definition: wallet2.cpp:7807
std::unique_ptr< tools::file_locker > m_keys_file_locker
Definition: wallet2.h:1370
void set_subaddress_lookahead(size_t major, size_t minor)
Definition: wallet2.cpp:1191
bool set_ring_database(const std::string &filename)
Definition: wallet2.cpp:6309
void serialize(t_archive &a, const unsigned int ver)
Definition: wallet2.h:138
tx_construction_data construction_data
Definition: wallet2.h:396
void discard_unmixable_outputs()
Definition: wallet2.cpp:9261
Definition: wallet2.h:73
bool set_blackballed_outputs(const std::vector< std::pair< uint64_t, uint64_t >> &outputs, bool add=false)
Definition: wallet2.cpp:6489
POD_CLASS public_key
Definition: crypto.h:63
uint64_t get_num_rct_outputs()
Definition: wallet2.cpp:9192
void light_wallet_get_unspent_outs()
Definition: wallet2.cpp:7822
bool deinit()
Definition: wallet2.cpp:2940
size_t size() const
Definition: wallet2.h:124
static bool wallet_valid_path_format(const std::string &file_path)
Check if wallet file path is valid format.
Definition: wallet2.cpp:4477
cryptonote::account_base m_account
Definition: wallet2.h:1271
cryptonote::block block
Definition: wallet2.h:485
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:2011
bool is_keys_file_locked() const
Definition: wallet2.cpp:6542
bool m_store_tx_info
Definition: wallet2.h:1320
enum tools::wallet2::unconfirmed_transfer_details::@16 m_state
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:7664
Definition: core_rpc_server_commands_defs.h:327
static bool parse_short_payment_id(const std::string &payment_id_str, crypto::hash8 &payment_id)
Definition: wallet2.cpp:4495
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:5259
bool generate_chacha_key_from_secret_keys(crypto::chacha_key &key) const
Definition: wallet2.cpp:4565
void set_subaddress_label(const cryptonote::subaddress_index &index, const std::string &label)
Definition: wallet2.cpp:1184
void set_account_tag_description(const std::string &tag, const std::string &description)
Set the label of the given tag.
Definition: wallet2.cpp:10294
void set_refresh_from_block_height(uint64_t height)
Definition: wallet2.h:645
std::vector< crypto::public_key > m_multisig_derivations
Definition: wallet2.h:1317
std::string get_multisig_info() const
Definition: wallet2.cpp:4299
uint8_t version
Definition: blockchain.cpp:88
uint64_t m_light_wallet_balance
Definition: wallet2.h:1356
Definition: wallet2.h:416
payment_container m_payments
Definition: wallet2.h:1286
void set_min_output_value(uint64_t value)
Definition: wallet2.h:932
std::string m_keys_file
Definition: wallet2.h:1275
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:9800
bool m_watch_only
Definition: wallet2.h:1311
rct::multisig_out msout
Definition: wallet2.h:377
std::string m_description
Definition: wallet2.h:466
account_public_address addr
Definition: cryptonote_tx_utils.h:78
cryptonote::transaction_prefix m_tx
Definition: wallet2.h:306
std::string blobdata
Definition: blobdatatype.h:35
void add_subaddress_account(const std::string &label)
Definition: wallet2.cpp:1121
cryptonote::checkpoints m_checkpoints
Definition: wallet2.h:1282
crypto::public_key get_subaddress_spend_public_key(const cryptonote::subaddress_index &index) const
Definition: wallet2.cpp:1104
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:924
const transfer_details & get_transfer_details(size_t idx) const
Definition: wallet2.cpp:9213
CXA_THROW_INFO_T * info
Definition: stack_trace.cpp:90
size_t offset() const
Definition: wallet2.h:125
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:907
virtual void on_new_block(uint64_t height, const cryptonote::block &block)
Definition: wallet2.h:89
#define blocks
Definition: sha512-hash.c:11
void create_keys_file(const std::string &wallet_, bool watch_only, const epee::wipeable_string &password, bool create_address_file)
Definition: wallet2.cpp:3574
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:4440
hashchain()
Definition: wallet2.h:122
std::set< uint32_t > m_subaddr_indices
Definition: wallet2.h:316
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)
Definition: wallet2.cpp:1933
crypto::public_key get_multisig_signer_public_key() const
Definition: wallet2.cpp:10978
bool confirm_backlog() const
Definition: wallet2.h:936
bool is_deterministic() const
Checks if deterministic wallet.
Definition: wallet2.cpp:956
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:1158
cryptonote::account_public_address get_address() const
Definition: wallet2.h:688
network_type
Definition: cryptonote_config.h:208
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:10035
void segregation_height(uint64_t height)
Definition: wallet2.h:949
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:1804
POD_CLASS signature
Definition: crypto.h:95
Definition: wallet2.h:450
Definition: cryptonote_basic.h:400
Definition: wallet2.h:169
cryptonote::account_public_address m_account_public_address
Definition: wallet2.h:1289
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:10281
size_t get_num_subaddress_accounts() const
Definition: wallet2.h:696
key identity()
Definition: rctOps.h:73
POD_CLASS hash8
Definition: hash.h:52
void encrypt_keys(const crypto::chacha_key &key)
Definition: wallet2.cpp:3539
uint64_t m_block_height
Definition: wallet2.h:325
crypto::public_key key
Definition: cryptonote_basic.h:81
crypto::signature shared_secret_sig
Definition: wallet2.h:476
bool m_explicit_refresh_from_block_height
Definition: wallet2.h:1329
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:11332
bool prepare_file_names(const std::string &file_path)
Definition: wallet2.cpp:4522
bool m_rct
Definition: wallet2.h:247
uint64_t get_fee_multiplier(uint32_t priority, int fee_algorithm=-1) const
Definition: wallet2.cpp:6098
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:8204
bool parse_unsigned_tx_from_str(const std::string &unsigned_tx_st, unsigned_tx_set &exported_txs) const
Definition: wallet2.cpp:5484
void load(const std::string &wallet, const epee::wipeable_string &password)
Definition: wallet2.cpp:4576
void check_genesis(const crypto::hash &genesis_hash) const
Definition: wallet2.cpp:4755
uint64_t estimate_blockchain_height()
Definition: wallet2.cpp:3776
POD_CLASS key_image
Definition: crypto.h:89
bool get_rings(const crypto::hash &txid, std::vector< std::pair< crypto::key_image, std::vector< uint64_t >>> &outs)
Definition: wallet2.cpp:6374
bool get_ring(const crypto::key_image &key_image, std::vector< uint64_t > &outs)
Definition: wallet2.cpp:6397
const std::vector< std::vector< tools::wallet2::multisig_info > > * m_multisig_rescan_info
Definition: wallet2.h:1297
bool confirm_missing_payment_id() const
Definition: wallet2.h:926
uint64_t get_blockchain_height_by_date(uint16_t year, uint8_t month, uint8_t day)
Definition: wallet2.cpp:11470
static const char * tr(const char *str)
Definition: wallet2.cpp:777
T decrypt(const std::string &ciphertext, const crypto::secret_key &skey, bool authenticated=true) const
Definition: wallet2.cpp:11300
void import_blockchain(const std::tuple< size_t, crypto::hash, std::vector< crypto::hash >> &bc)
Definition: wallet2.cpp:10824
bool merge_destinations() const
Definition: wallet2.h:935
void set_description(const std::string &description)
Definition: wallet2.cpp:10251
uint64_t m_change
Definition: wallet2.h:309
uint64_t segregation_height() const
Definition: wallet2.h:948
std::vector< size_t > select_available_mixable_outputs()
Definition: wallet2.cpp:9225
i_wallet2_callback * callback() const
Definition: wallet2.h:657
bool m_first_refresh_done
Definition: wallet2.h:1325
txout_target_v target
Definition: cryptonote_basic.h:146
std::vector< cryptonote::tx_destination_entry > dests
Definition: wallet2.h:349
rct::key mask
Definition: wallet2.h:226
uint64_t m_light_wallet_unlocked_balance
Definition: wallet2.h:1357
std::unordered_map< crypto::hash, std::string > m_tx_notes
Definition: wallet2.h:1292
crypto::hash m_payment_id
Definition: wallet2.h:465
size_t real_output_in_tx_index
Definition: cryptonote_tx_utils.h:50
string a
Definition: MakeCryptoOps.py:15
std::string dump_tx_to_str(const std::vector< pending_tx > &ptx_vector) const
Definition: wallet2.cpp:5436
static bool has_testnet_option(const boost::program_options::variables_map &vm)
Definition: wallet2.cpp:867
bool check_spend_proof(const crypto::hash &txid, const std::string &message, const std::string &sig_str)
Definition: wallet2.cpp:9450
crypto::hash get_transaction_hash(const transaction &t)
Definition: cryptonote_format_utils.cpp:829
void always_confirm_transfers(bool always)
Definition: wallet2.h:915
void crop(size_t height)
Definition: wallet2.h:131
AskPasswordType m_ask_password
Definition: wallet2.h:1332
rct::key m_R
Definition: wallet2.h:203
confirmed_transfer_details()
Definition: wallet2.h:334
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:4269
void set_spent(size_t idx, uint64_t height)
Definition: wallet2.cpp:1207
std::vector< std::pair< crypto::key_image, std::vector< uint64_t > > > m_rings
Definition: wallet2.h:317
bool verify(const std::string &data, const cryptonote::account_public_address &address, const std::string &signature) const
Definition: wallet2.cpp:10311
static bool has_stagenet_option(const boost::program_options::variables_map &vm)
Definition: wallet2.cpp:872
bool get_tx_key(const crypto::hash &txid, crypto::secret_key &tx_key, std::vector< crypto::secret_key > &additional_tx_keys) const
Definition: wallet2.cpp:9271
uint64_t m_refresh_from_block_height
Definition: wallet2.h:1326
hashchain m_blockchain
Definition: wallet2.h:1277
bool has_unknown_key_images() const
Definition: wallet2.cpp:4427
Definition: wallet2.h:491
Definition: wallet2.h:167
crypto::key_image m_key_image
Definition: wallet2.h:244
std::vector< output_entry > outputs
Definition: cryptonote_tx_utils.h:46
bool remove_rings(const cryptonote::transaction_prefix &tx)
Definition: wallet2.cpp:6358
Definition: rctTypes.h:236
std::vector< address_book_row > get_address_book() const
GUI Address book get/store.
Definition: wallet2.h:989
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:1164
RefreshType get_refresh_type() const
Definition: wallet2.h:714
Definition: cryptonote_tx_utils.h:74
crypto::signature key_image_sig
Definition: wallet2.h:477
std::vector< cryptonote::tx_extra_field > tx_extra_fields
Definition: wallet2.h:500
uint64_t dust_threshold
Definition: wallet2.h:107
size_t m_offset
Definition: wallet2.h:146
std::string save_multisig_tx(multisig_tx_set txs)
Definition: wallet2.cpp:5800
bool m_light_wallet
Definition: wallet2.h:1351
crypto::hash txid
Definition: wallet2.h:472
std::set< uint32_t > m_subaddr_indices
Definition: wallet2.h:331
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:9565
std::unordered_multimap< crypto::hash, pool_payment_details > m_unconfirmed_payments
Definition: wallet2.h:1280
size_t get_num_transfer_details() const
Definition: wallet2.h:994
Definition: wallet2.h:498
AskPasswordType
Definition: wallet2.h:166
Definition: wallet2.h:383
std::unordered_map< crypto::hash, unconfirmed_transfer_details > m_unconfirmed_txs
Definition: wallet2.h:1278
bool m_print_ring_members
Definition: wallet2.h:1319
bool delete_address_book_row(std::size_t row_id)
Definition: wallet2.cpp:2595
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:10334
cryptonote::account_base & get_account()
Definition: wallet2.h:637
POD_CLASS hash
Definition: hash.h:49
uint64_t m_amount
Definition: wallet2.h:283
bool m_multisig
Definition: wallet2.h:1312
cryptonote::tx_destination_entry change_dts
Definition: wallet2.h:388
void device_name(const std::string &device_name)
Definition: wallet2.h:955
uint64_t get_blockchain_current_height() const
Definition: wallet2.h:783
std::string get_integrated_address_as_str(const crypto::hash8 &payment_id) const
Definition: wallet2.cpp:1116
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:92
bool get_rct_distribution(uint64_t &start_height, std::vector< uint64_t > &distribution)
Definition: wallet2.cpp:2808
bool load_unsigned_tx(const std::string &unsigned_filename, unsigned_tx_set &exported_txs) const
Definition: wallet2.cpp:5465
bool m_confirm_non_default_ring_size
Definition: wallet2.h:1331
crypto::secret_key tx_key
Definition: wallet2.h:391
const char *const ATTRIBUTE_DESCRIPTION
Definition: wallet2.h:1142
bool add_rings(const crypto::chacha_key &key, const cryptonote::transaction_prefix &tx)
Definition: wallet2.cpp:6344
A container for blockchain checkpoints.
Definition: checkpoints.h:51
~wallet_keys_unlocker()
Definition: wallet2.cpp:803
bool load_keys(const std::string &keys_file_name, const epee::wipeable_string &password)
Load wallet information from wallet file.
Definition: wallet2.cpp:3184
void set_confirm_backlog_threshold(uint32_t threshold)
Definition: wallet2.h:938
Definition: wallet2.h:439
void print_ring_members(bool value)
Definition: wallet2.h:917
bool find_and_save_rings(bool force=true)
Definition: wallet2.cpp:6412
uint32_t m_default_priority
Definition: wallet2.h:1322
crypto::key_image key_image
Definition: wallet2.h:475
virtual void on_lw_unconfirmed_money_received(uint64_t height, const crypto::hash &txid, uint64_t amount)
Definition: wallet2.h:98
boost::optional< epee::wipeable_string > m_encrypt_keys_after_refresh
Definition: wallet2.h:1373
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:7757
std::vector< pending_tx > create_unmixable_sweep_transactions()
Definition: wallet2.cpp:9231
std::pair< uint64_t, rct::ctkey > output_entry
Definition: cryptonote_tx_utils.h:44
std::string print_money(uint64_t amount, unsigned int decimal_point)
Definition: cryptonote_format_utils.cpp:808
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:9284
crypto::chacha_iv iv
Definition: wallet2.h:452
bool get_multisig_seed(epee::wipeable_string &seed, const epee::wipeable_string &passphrase=std::string(), bool raw=true) const
Definition: wallet2.cpp:990
std::vector< boost::optional< cryptonote::subaddress_receive_info > > received
Definition: wallet2.h:495
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:8850
crypto::key_image get_multisig_composite_key_image(size_t n) const
Definition: wallet2.cpp:11056
Definition: cryptonote_basic.h:143
void refresh(bool trusted_daemon)
Definition: wallet2.cpp:2183
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:1406
virtual void on_lw_money_received(uint64_t height, const crypto::hash &txid, uint64_t amount)
Definition: wallet2.h:97
bool set_ring(const crypto::key_image &key_image, const std::vector< uint64_t > &outs, bool relative)
Definition: wallet2.cpp:6403
transfer_container m_transfers
Definition: wallet2.h:1285
std::vector< pending_tx > m_ptx
Definition: wallet2.h:430
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:10261
bool light_wallet_get_address_info(cryptonote::COMMAND_RPC_GET_ADDRESS_INFO::response &response)
Definition: wallet2.cpp:7974
bool blackball_output(const std::pair< uint64_t, uint64_t > &output)
Definition: wallet2.cpp:6481
bool is_rct() const
Definition: wallet2.h:255
#define FIELD(f)
tags the field with the variable name and then serializes it
Definition: serialization.h:243
uint32_t get_default_priority() const
Definition: wallet2.h:922
bool m_key_reuse_mitigation2
Definition: wallet2.h:1341
uint64_t m_amount_in
Definition: wallet2.h:307
void import_payments_out(const std::list< std::pair< crypto::hash, wallet2::confirmed_transfer_details >> &confirmed_payments)
Definition: wallet2.cpp:10803
void push_back(const crypto::hash &hash)
Definition: wallet2.h:127
cryptonote::keypair in_ephemeral
Definition: wallet2.h:224
uint64_t adjust_mixin(uint64_t mixin) const
Definition: wallet2.cpp:6216
RefreshType m_refresh_type
Definition: wallet2.h:1323
bool init(std::string daemon_address="http://localhost:8080", boost::optional< epee::net_utils::http::login > daemon_login=boost::none, uint64_t upper_transaction_weight_limit=0, bool ssl=false, bool trusted_daemon=false)
Definition: wallet2.cpp:942
std::unordered_map< crypto::key_image, size_t > m_key_images
Definition: wallet2.h:1287
Definition: wallet2.h:482
bool m_confirm_missing_payment_id
Definition: wallet2.h:1330
Definition: wallet2.h:162
uint64_t get_fee_quantization_mask() const
Definition: wallet2.cpp:6167
std::string get_description() const
Definition: wallet2.cpp:10256
Definition: core_rpc_server_commands_defs.h:104
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:4456
std::string get_attribute(const std::string &key) const
Definition: wallet2.cpp:10243
uint64_t get_last_block_reward() const
Definition: wallet2.h:789
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:6084
void explicit_refresh_from_block_height(bool expl)
Definition: wallet2.h:648
crypto::chacha_key get_ringdb_key()
Definition: wallet2.cpp:6332
crypto::public_key m_signer
Definition: wallet2.h:211
uint32_t adjust_priority(uint32_t priority)
Definition: wallet2.cpp:6233
bool m_key_image_partial
Definition: wallet2.h:251
hw::device::device_type get_device_type() const
Definition: wallet2.h:723
virtual void on_lw_money_spent(uint64_t height, const crypto::hash &txid, uint64_t amount)
Definition: wallet2.h:99
bool lock_keys_file()
Definition: wallet2.cpp:6520
void ask_password(AskPasswordType ask)
Definition: wallet2.h:929
crypto::hash m_payment_id
Definition: wallet2.h:327
uint32_t default_mixin() const
Definition: wallet2.h:920
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:9580
const crypto::public_key & get_public_key() const
Definition: wallet2.h:257
std::tuple< size_t, crypto::hash, std::vector< crypto::hash > > export_blockchain() const
Definition: wallet2.cpp:10812
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)
std::string encrypt(const char *plaintext, size_t len, const crypto::secret_key &skey, bool authenticated=true) const
Definition: wallet2.cpp:11258
bool m_is_initialized
Definition: wallet2.h:1344
time_t m_sent_time
Definition: wallet2.h:310
Definition: cryptonote_basic.h:182
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:9668
void set_default_priority(uint32_t p)
Definition: wallet2.h:923
bool sign_multisig_tx_to_file(multisig_tx_set &exported_txs, const std::string &filename, std::vector< crypto::hash > &txids)
Definition: wallet2.cpp:6076
std::string encrypt_with_view_secret_key(const std::string &plaintext, bool authenticated=true) const
Definition: wallet2.cpp:11294
Definition: wallet2.h:371
#define true
Definition: stdbool.h:36
void set_min_output_count(uint32_t count)
Definition: wallet2.h:930
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:3651
virtual ~i_wallet2_callback()
Definition: wallet2.h:102
std::string m_device_name
Definition: wallet2.h:1348
boost::mutex m_daemon_rpc_mutex
Definition: wallet2.h:1302
void update_pool_state(bool refreshed=false)
Definition: wallet2.cpp:2288
static bool parse_payment_id(const std::string &payment_id_str, crypto::hash &payment_id)
Definition: wallet2.cpp:4508
uint64_t import_key_images(const std::vector< std::pair< crypto::key_image, crypto::signature >> &signed_key_images, uint64_t &spent, uint64_t &unspent, bool check_spent=true)
Definition: wallet2.cpp:10550
bool use_rct
Definition: wallet2.h:347
uint64_t m_amount
Definition: wallet2.h:246
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:2975
static bool verify_multisig_info(const std::string &data, crypto::secret_key &skey, crypto::public_key &pkey)
Definition: wallet2.cpp:4318
void add_subaddress(uint32_t index_major, const std::string &label)
Definition: wallet2.cpp:1128
bool m_spent
Definition: wallet2.h:242
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:2035
bool m_trusted_daemon
Definition: wallet2.h:1304
bool auto_low_priority() const
Definition: wallet2.h:942
bool m_ring_history_saved
Definition: wallet2.h:1365
uint64_t m_spent_height
Definition: wallet2.h:243
void setup_keys(const epee::wipeable_string &password)
Definition: wallet2.cpp:3150
uint64_t fee
Definition: wallet2.h:386
multisig_tx_set make_multisig_tx_set(const std::vector< pending_tx > &ptx_vector) const
Definition: wallet2.cpp:5846
Definition: wallet2.h:462
uint64_t get_daemon_blockchain_target_height(std::string &err)
Definition: wallet2.cpp:10194
std::vector< size_t > selected_transfers
Definition: wallet2.h:344
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:10346
bool m_auto_refresh
Definition: wallet2.h:1324
std::unordered_map< crypto::hash, address_tx > m_light_wallet_address_txs
Definition: wallet2.h:1360
void import_payments(const payment_container &payments)
Definition: wallet2.cpp:10795
Definition: wallet2.h:235
std::string get_subaddress_label(const cryptonote::subaddress_index &index) const
Definition: wallet2.cpp:1174
std::string m_ring_database
Definition: wallet2.h:1364
bool m_ignore_fractional_outputs
Definition: wallet2.h:1343
void light_wallet_get_address_txs()
Definition: wallet2.cpp:7990
void serialize(t_archive &a, const unsigned int ver)
Definition: wallet2.h:792
bool multisig(bool *ready=NULL, uint32_t *threshold=NULL, uint32_t *total=NULL) const
Definition: wallet2.cpp:4404
bool error
Definition: wallet2.h:488
std::vector< multisig_info > m_multisig_info
Definition: wallet2.h:253
uint64_t get_min_ring_size() const
Definition: wallet2.cpp:6196
void get_transfers(wallet2::transfer_container &incoming_transfers) const
Definition: wallet2.cpp:4960
uint8_t threshold
Definition: blockchain.cpp:90
std::vector< std::pair< crypto::key_image, std::vector< uint64_t > > > m_rings
Definition: wallet2.h:332