Monero
wallet2.h
Go to the documentation of this file.
1 // Copyright (c) 2014-2022, The Monero Project
2 //
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification, are
6 // permitted provided that the following conditions are met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice, this list of
9 // conditions and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 // of conditions and the following disclaimer in the documentation and/or other
13 // materials provided with the distribution.
14 //
15 // 3. Neither the name of the copyright holder nor the names of its contributors may be
16 // used to endorse or promote products derived from this software without specific
17 // prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27 // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 //
29 // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
30 
31 #pragma once
32 
33 #include <memory>
34 
35 #include <boost/program_options/options_description.hpp>
36 #include <boost/program_options/variables_map.hpp>
37 #if BOOST_VERSION >= 107400
38 #include <boost/serialization/library_version_type.hpp>
39 #endif
40 #include <boost/serialization/list.hpp>
41 #include <boost/serialization/vector.hpp>
42 #include <boost/serialization/deque.hpp>
43 #include <boost/thread/lock_guard.hpp>
44 #include <atomic>
45 #include <random>
46 
47 #include "include_base_utils.h"
51 #include "net/http.h"
57 #include "common/util.h"
58 #include "crypto/chacha.h"
59 #include "crypto/hash.h"
60 #include "ringct/rctTypes.h"
61 #include "ringct/rctOps.h"
63 #include "serialization/crypto.h"
64 #include "serialization/string.h"
65 #include "serialization/pair.h"
66 #include "serialization/tuple.h"
68 
69 #include "wallet_errors.h"
70 #include "common/password.h"
71 #include "node_rpc_proxy.h"
72 #include "message_store.h"
73 #include "wallet_light_rpc.h"
74 #include "wallet_rpc_helpers.h"
75 
76 #undef MONERO_DEFAULT_LOG_CATEGORY
77 #define MONERO_DEFAULT_LOG_CATEGORY "wallet.wallet2"
78 
79 #define THROW_ON_RPC_RESPONSE_ERROR(r, error, res, method, ...) \
80  do { \
81  handle_payment_changes(res, std::integral_constant<bool, HasCredits<decltype(res)>::Has>()); \
82  throw_on_rpc_response_error(r, error, res.status, method); \
83  THROW_WALLET_EXCEPTION_IF(res.status != CORE_RPC_STATUS_OK, ## __VA_ARGS__); \
84  } while(0)
85 
86 #define THROW_ON_RPC_RESPONSE_ERROR_GENERIC(r, err, res, method) \
87  THROW_ON_RPC_RESPONSE_ERROR(r, err, res, method, tools::error::wallet_generic_rpc_error, method, res.status)
88 
89 class Serialization_portability_wallet_Test;
91 
92 namespace tools
93 {
94  class ringdb;
95  class wallet2;
96  class Notify;
97 
99  {
100  public:
101  uint64_t pick();
102  gamma_picker(const std::vector<uint64_t> &rct_offsets);
103  gamma_picker(const std::vector<uint64_t> &rct_offsets, double shape, double scale);
105 
106  private:
108  {
110  static constexpr result_type min() { return 0; }
111  static constexpr result_type max() { return std::numeric_limits<result_type>::max(); }
112  result_type operator()() { return crypto::rand<result_type>(); }
113  } engine;
114 
115 private:
116  std::gamma_distribution<double> gamma;
117  const std::vector<uint64_t> &rct_offsets;
118  const uint64_t *begin, *end;
121  };
122 
124  {
125  public:
126  wallet_keys_unlocker(wallet2 &w, const boost::optional<tools::password_container> &password);
127  wallet_keys_unlocker(wallet2 &w, bool locked, const epee::wipeable_string &password);
129  private:
131  bool locked;
132  crypto::chacha_key key;
133  static boost::mutex lockers_lock;
134  static unsigned int lockers;
135  };
136 
138  {
139  public:
140  // Full wallet callbacks
141  virtual void on_new_block(uint64_t height, const cryptonote::block& block) {}
142  virtual void on_reorg(uint64_t height, uint64_t blocks_detached, size_t transfers_detached) {}
143  virtual void on_money_received(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t amount, uint64_t burnt, const cryptonote::subaddress_index& subaddr_index, bool is_change, uint64_t unlock_time) {}
144  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) {}
145  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) {}
146  virtual void on_skip_transaction(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx) {}
147  virtual boost::optional<epee::wipeable_string> on_get_password(const char *reason) { return boost::none; }
148  // Light wallet callbacks
149  virtual void on_lw_new_block(uint64_t height) {}
150  virtual void on_lw_money_received(uint64_t height, const crypto::hash &txid, uint64_t amount) {}
151  virtual void on_lw_unconfirmed_money_received(uint64_t height, const crypto::hash &txid, uint64_t amount) {}
152  virtual void on_lw_money_spent(uint64_t height, const crypto::hash &txid, uint64_t amount) {}
153  // Device callbacks
155  virtual void on_device_button_pressed() {}
156  virtual boost::optional<epee::wipeable_string> on_device_pin_request() { return boost::none; }
157  virtual boost::optional<epee::wipeable_string> on_device_passphrase_request(bool & on_device) { on_device = true; return boost::none; }
159  // Common callbacks
160  virtual void on_pool_tx_removed(const crypto::hash &txid) {}
161  virtual ~i_wallet2_callback() {}
162  };
163 
165  {
166  public:
168  void on_button_request(uint64_t code=0) override;
169  void on_button_pressed() override;
170  boost::optional<epee::wipeable_string> on_pin_request() override;
171  boost::optional<epee::wipeable_string> on_passphrase_request(bool & on_device) override;
172  void on_progress(const hw::device_progress& event) override;
173  private:
175  };
176 
178  {
182 
183  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())
184  : dust_threshold(a_dust_threshold)
185  , add_to_fee(an_add_to_fee)
186  , addr_for_dust(an_addr_for_dust)
187  {
188  }
189  };
190 
191  class hashchain
192  {
193  public:
195 
196  size_t size() const { return m_blockchain.size() + m_offset; }
197  size_t offset() const { return m_offset; }
198  const crypto::hash &genesis() const { return m_genesis; }
199  void push_back(const crypto::hash &hash) { if (m_offset == 0 && m_blockchain.empty()) m_genesis = hash; m_blockchain.push_back(hash); }
200  bool is_in_bounds(size_t idx) const { return idx >= m_offset && idx < size(); }
201  const crypto::hash &operator[](size_t idx) const { return m_blockchain[idx - m_offset]; }
202  crypto::hash &operator[](size_t idx) { return m_blockchain[idx - m_offset]; }
203  void crop(size_t height) { m_blockchain.resize(height - m_offset); }
204  void clear() { m_offset = 0; m_blockchain.clear(); }
205  bool empty() const { return m_blockchain.empty() && m_offset == 0; }
206  void trim(size_t height) { while (height > m_offset && m_blockchain.size() > 1) { m_blockchain.pop_front(); ++m_offset; } m_blockchain.shrink_to_fit(); }
207  void refill(const crypto::hash &hash) { m_blockchain.push_back(hash); --m_offset; }
208 
209  template <class t_archive>
210  inline void serialize(t_archive &a, const unsigned int ver)
211  {
212  a & m_offset;
213  a & m_genesis;
214  a & m_blockchain;
215  }
216 
218  VERSION_FIELD(0)
222  END_SERIALIZE()
223 
224  private:
225  size_t m_offset;
228  };
229 
230  class wallet_keys_unlocker;
231  class wallet2
232  {
233  friend class ::Serialization_portability_wallet_Test;
234  friend class ::wallet_accessor_test;
235  friend class wallet_keys_unlocker;
237  public:
238  static constexpr const std::chrono::seconds rpc_timeout = std::chrono::minutes(3) + std::chrono::seconds(30);
239 
240  enum RefreshType {
244  RefreshDefault = RefreshOptimizeCoinbase,
245  };
246 
248  AskPasswordNever = 0,
249  AskPasswordOnAction = 1,
250  AskPasswordToDecrypt = 2,
251  };
252 
254  BackgroundMiningMaybe = 0,
255  BackgroundMiningYes = 1,
256  BackgroundMiningNo = 2,
257  };
258 
260  BackgroundSyncOff = 0,
261  BackgroundSyncReusePassword = 1,
262  BackgroundSyncCustomPassword = 2,
263  };
264 
265  static BackgroundSyncType background_sync_type_from_str(const std::string &background_sync_type_str)
266  {
267  if (background_sync_type_str == "off") return BackgroundSyncOff;
268  if (background_sync_type_str == "reuse-wallet-password") return BackgroundSyncReusePassword;
269  if (background_sync_type_str == "custom-background-password") return BackgroundSyncCustomPassword;
270  throw std::logic_error("Unknown background sync type");
271  };
272 
274  Binary = 0,
276  };
277 
278  static const char* tr(const char* str);
279 
280  static bool has_testnet_option(const boost::program_options::variables_map& vm);
281  static bool has_stagenet_option(const boost::program_options::variables_map& vm);
282  static std::string device_name_option(const boost::program_options::variables_map& vm);
283  static std::string device_derivation_path_option(const boost::program_options::variables_map &vm);
284  static void init_options(boost::program_options::options_description& desc_params);
285 
287  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);
288 
290  static std::pair<std::unique_ptr<wallet2>, password_container>
291  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);
292 
294  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);
295 
297  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);
298 
299  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)
300  {
302  return verify_password(keys_file_name, password, no_spend_key, hwdev, kdf_rounds, spend_key);
303  };
304  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, crypto::secret_key &spend_key_out);
305  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);
306 
307  wallet2(cryptonote::network_type nettype = cryptonote::MAINNET, uint64_t kdf_rounds = 1, bool unattended = false, std::unique_ptr<epee::net_utils::http::http_client_factory> http_client_factory = std::unique_ptr<epee::net_utils::http::http_client_factory>(new net::http::client_factory()));
308  ~wallet2();
309 
311  {
312  struct LR
313  {
316 
318  FIELD(m_L)
319  FIELD(m_R)
320  END_SERIALIZE()
321  };
322 
323  crypto::public_key m_signer;
324  std::vector<LR> m_LR;
325  std::vector<crypto::key_image> m_partial_key_images; // one per key the participant has
326 
328  FIELD(m_signer)
329  FIELD(m_LR)
330  FIELD(m_partial_key_images)
331  END_SERIALIZE()
332  };
333 
335  {
341  bool error;
342  boost::optional<cryptonote::subaddress_receive_info> received;
343 
344  tx_scan_info_t(): amount(0), money_transfered(0), error(true) {}
345  };
346 
348  {
354  bool m_spent;
355  bool m_frozen;
357  crypto::key_image m_key_image; //TODO: key_image stored twice :(
360  bool m_rct;
362  bool m_key_image_request; // view wallets: we want to request it; cold wallets: it was requested
366  std::vector<rct::key> m_multisig_k;
367  std::vector<multisig_info> m_multisig_info; // one per other participant
368  std::vector<std::pair<uint64_t, crypto::hash>> m_uses;
369 
370  bool is_rct() const { return m_rct; }
371  uint64_t amount() const { return m_amount; }
373  crypto::public_key output_public_key;
374  THROW_WALLET_EXCEPTION_IF(m_tx.vout.size() <= m_internal_output_index,
375  error::wallet_internal_error, "Too few outputs, outputs may be corrupted");
376  THROW_WALLET_EXCEPTION_IF(!get_output_public_key(m_tx.vout[m_internal_output_index], output_public_key),
377  error::wallet_internal_error, "Unable to get output public key from output");
378  return output_public_key;
379  };
380 
382  FIELD(m_block_height)
383  FIELD(m_tx)
384  FIELD(m_txid)
385  FIELD(m_internal_output_index)
386  FIELD(m_global_output_index)
387  FIELD(m_spent)
388  FIELD(m_frozen)
389  FIELD(m_spent_height)
390  FIELD(m_key_image)
391  FIELD(m_mask)
392  FIELD(m_amount)
393  FIELD(m_rct)
394  FIELD(m_key_image_known)
395  FIELD(m_key_image_request)
396  FIELD(m_pk_index)
397  FIELD(m_subaddr_index)
398  FIELD(m_key_image_partial)
399  FIELD(m_multisig_k)
400  FIELD(m_multisig_info)
401  FIELD(m_uses)
402  END_SERIALIZE()
403  };
404 
406  {
411  union
412  {
413  struct
414  {
419  uint8_t m_key_image_request: 1; // view wallets: we want to request it; cold wallets: it was requested
421  };
423  } m_flags;
425  std::vector<crypto::public_key> m_additional_tx_keys;
428 
430  VERSION_FIELD(1)
431  if (version < 1)
432  return false;
433  FIELD(m_pubkey)
434  VARINT_FIELD(m_internal_output_index)
435  VARINT_FIELD(m_global_output_index)
436  FIELD(m_tx_pubkey)
437  FIELD(m_flags.flags)
438  VARINT_FIELD(m_amount)
439  FIELD(m_additional_tx_keys)
440  VARINT_FIELD(m_subaddr_index_major)
441  VARINT_FIELD(m_subaddr_index_minor)
442  END_SERIALIZE()
443  };
444 
445  typedef std::vector<uint64_t> amounts_container;
447  {
457 
459  VERSION_FIELD(0)
460  FIELD(m_tx_hash)
461  VARINT_FIELD(m_amount)
462  FIELD(m_amounts)
463  VARINT_FIELD(m_fee)
464  VARINT_FIELD(m_block_height)
465  VARINT_FIELD(m_unlock_time)
466  VARINT_FIELD(m_timestamp)
467  FIELD(m_coinbase)
468  FIELD(m_subaddr_index)
469  END_SERIALIZE()
470  };
471 
473  {
474  bool m_mempool;
476  };
477 
479  {
482 
484  VERSION_FIELD(0)
485  FIELD(m_pd)
486  FIELD(m_double_spend_seen)
487  END_SERIALIZE()
488  };
489 
491  {
496  time_t m_sent_time;
497  std::vector<cryptonote::tx_destination_entry> m_dests;
499  enum { pending, pending_in_pool, failed } m_state;
501  uint32_t m_subaddr_account; // subaddress account of your wallet to be used in this transfer
502  std::set<uint32_t> m_subaddr_indices; // set of address indices used as inputs in this transfer
503  std::vector<std::pair<crypto::key_image, std::vector<uint64_t>>> m_rings; // relative
504 
506  VERSION_FIELD(1)
507  FIELD(m_tx)
508  VARINT_FIELD(m_amount_in)
509  VARINT_FIELD(m_amount_out)
510  VARINT_FIELD(m_change)
511  VARINT_FIELD(m_sent_time)
512  FIELD(m_dests)
513  FIELD(m_payment_id)
514  if (version >= 1)
515  VARINT_FIELD(m_state)
516  VARINT_FIELD(m_timestamp)
517  VARINT_FIELD(m_subaddr_account)
518  FIELD(m_subaddr_indices)
519  FIELD(m_rings)
520  END_SERIALIZE()
521  };
522 
524  {
530  std::vector<cryptonote::tx_destination_entry> m_dests;
534  uint32_t m_subaddr_account; // subaddress account of your wallet to be used in this transfer
535  std::set<uint32_t> m_subaddr_indices; // set of address indices used as inputs in this transfer
536  std::vector<std::pair<crypto::key_image, std::vector<uint64_t>>> m_rings; // relative
537 
538  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) {}
540  m_tx(utd.m_tx), 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) {}
541 
543  VERSION_FIELD(1)
544  if (version >= 1)
545  FIELD(m_tx)
546  VARINT_FIELD(m_amount_in)
547  VARINT_FIELD(m_amount_out)
548  VARINT_FIELD(m_change)
549  VARINT_FIELD(m_block_height)
550  FIELD(m_dests)
551  FIELD(m_payment_id)
552  VARINT_FIELD(m_timestamp)
553  VARINT_FIELD(m_unlock_time)
554  VARINT_FIELD(m_subaddr_account)
555  FIELD(m_subaddr_indices)
556  FIELD(m_rings)
557  END_SERIALIZE()
558  };
559 
561  {
562  std::vector<cryptonote::tx_source_entry> sources;
564  std::vector<cryptonote::tx_destination_entry> splitted_dsts; // split, includes change
565  std::vector<size_t> selected_transfers;
566  std::vector<uint8_t> extra;
568  bool use_rct;
571  std::vector<cryptonote::tx_destination_entry> dests; // original setup, does not include change
572  uint32_t subaddr_account; // subaddress account of your wallet to be used in this transfer
573  std::set<uint32_t> subaddr_indices; // set of address indices used as inputs in this transfer
574 
576  {
577  _use_rct = 1 << 0, // 00000001
578  _use_view_tags = 1 << 1 // 00000010
579  // next flag = 1 << 2 // 00000100
580  // ...
581  // final flag = 1 << 7 // 10000000
582  };
584 
586  FIELD(sources)
587  FIELD(change_dts)
588  FIELD(splitted_dsts)
589  FIELD(selected_transfers)
590  FIELD(extra)
591  FIELD(unlock_time)
592 
593  // converted `use_rct` field into construction_flags when view tags
594  // were introduced to maintain backwards compatibility
595  if (!typename Archive<W>::is_saving())
596  {
597  FIELD_N("use_rct", construction_flags)
598  use_rct = (construction_flags & _use_rct) > 0;
599  use_view_tags = (construction_flags & _use_view_tags) > 0;
600  }
601  else
602  {
603  construction_flags = 0;
604  if (use_rct)
605  construction_flags ^= _use_rct;
606  if (use_view_tags)
607  construction_flags ^= _use_view_tags;
608 
609  FIELD_N("use_rct", construction_flags)
610  }
611 
612  FIELD(rct_config)
613  FIELD(dests)
614  FIELD(subaddr_account)
615  FIELD(subaddr_indices)
616  END_SERIALIZE()
617  };
618 
619  typedef std::vector<transfer_details> transfer_container;
621  typedef std::set<uint32_t> unique_index_container;
622 
624  {
626  std::unordered_set<crypto::public_key> ignore;
627  std::unordered_set<rct::key> used_L;
628  std::unordered_set<crypto::public_key> signing_keys;
630 
635 
637  VERSION_FIELD(1)
638  if (version < 1)
639  return false;
640  FIELD(sigs)
641  FIELD(ignore)
642  FIELD(used_L)
643  FIELD(signing_keys)
644  FIELD(msout)
645  FIELD(total_alpha_G)
646  FIELD(total_alpha_H)
647  FIELD(c_0)
648  FIELD(s)
649  END_SERIALIZE()
650  };
651 
652  // The convention for destinations is:
653  // dests does not include change
654  // splitted_dsts (in construction_data) does
655  struct pending_tx
656  {
658  uint64_t dust, fee;
661  std::vector<size_t> selected_transfers;
664  std::vector<crypto::secret_key> additional_tx_keys;
665  std::vector<cryptonote::tx_destination_entry> dests;
666  std::vector<multisig_sig> multisig_sigs;
668 
670 
672  VERSION_FIELD(1)
673  FIELD(tx)
674  FIELD(dust)
675  FIELD(fee)
676  FIELD(dust_added_to_fee)
677  FIELD(change_dts)
678  FIELD(selected_transfers)
679  FIELD(key_images)
680  FIELD(tx_key)
681  FIELD(additional_tx_keys)
682  FIELD(dests)
683  FIELD(construction_data)
684  FIELD(multisig_sigs)
685  if (version < 1)
686  {
687  multisig_tx_key_entropy = crypto::null_skey;
688  return true;
689  }
690  FIELD(multisig_tx_key_entropy)
691  END_SERIALIZE()
692  };
693 
694  // The term "Unsigned tx" is not really a tx since it's not signed yet.
695  // It doesnt have tx hash, key and the integrated address is not separated into addr + payment id.
697  {
698  std::vector<tx_construction_data> txes;
699  std::tuple<uint64_t, uint64_t, wallet2::transfer_container> transfers;
700  std::tuple<uint64_t, uint64_t, std::vector<wallet2::exported_transfer_details>> new_transfers;
701 
703  VERSION_FIELD(2)
704  FIELD(txes)
705  if (version == 0)
706  {
707  std::pair<size_t, wallet2::transfer_container> v0_transfers;
708  FIELD(v0_transfers);
709  std::get<0>(transfers) = std::get<0>(v0_transfers);
710  std::get<1>(transfers) = std::get<0>(v0_transfers) + std::get<1>(v0_transfers).size();
711  std::get<2>(transfers) = std::get<1>(v0_transfers);
712  return true;
713  }
714  if (version == 1)
715  {
716  std::pair<size_t, std::vector<wallet2::exported_transfer_details>> v1_transfers;
717  FIELD(v1_transfers);
718  std::get<0>(new_transfers) = std::get<0>(v1_transfers);
719  std::get<1>(new_transfers) = std::get<0>(v1_transfers) + std::get<1>(v1_transfers).size();
720  std::get<2>(new_transfers) = std::get<1>(v1_transfers);
721  return true;
722  }
723 
724  FIELD(new_transfers)
725  END_SERIALIZE()
726  };
727 
729  {
730  std::vector<pending_tx> ptx;
731  std::vector<crypto::key_image> key_images;
733 
735  VERSION_FIELD(0)
736  FIELD(ptx)
737  FIELD(key_images)
738  FIELD(tx_key_images)
739  END_SERIALIZE()
740  };
741 
743  {
744  std::vector<pending_tx> m_ptx;
745  std::unordered_set<crypto::public_key> m_signers;
746 
748  FIELD(m_ptx)
749  FIELD(m_signers)
750  END_SERIALIZE()
751  };
752 
754  {
755  crypto::chacha_iv iv;
757 
759  FIELD(iv)
760  FIELD(account_data)
761  END_SERIALIZE()
762  };
763 
765  {
766  crypto::chacha_iv iv;
768 
770  FIELD(iv)
771  FIELD(cache_data)
772  END_SERIALIZE()
773  };
774 
775  // GUI Address book
777  {
783 
785  VERSION_FIELD(0)
786  FIELD(m_address)
787  FIELD(m_payment_id)
788  FIELD(m_description)
789  FIELD(m_is_subaddress)
790  FIELD(m_has_payment_id)
791  END_SERIALIZE()
792  };
793 
795  {
802 
804  VERSION_FIELD(0)
805  FIELD(txid)
806  VARINT_FIELD(index_in_tx)
807  FIELD(shared_secret)
809  FIELD(shared_secret_sig)
810  FIELD(key_image_sig)
811  END_SERIALIZE()
812  };
813 
815  {
818  std::vector<uint64_t> output_indices;
822 
824  VERSION_FIELD(0)
825  VARINT_FIELD(index_in_background_sync_data)
826 
827  // prune tx; don't need to keep signature data
828  if (!tx.serialize_base(ar))
829  return false;
830 
831  FIELD(output_indices)
832  VARINT_FIELD(height)
833  VARINT_FIELD(block_timestamp)
834  FIELD(double_spend_seen)
835  END_SERIALIZE()
836  };
837 
839  {
840  bool first_refresh_done = false;
841  uint64_t start_height = 0;
843 
844  // Relevant wallet settings
849 
851  VERSION_FIELD(0)
852  FIELD(first_refresh_done)
853  FIELD(start_height)
854  FIELD(txs)
855  FIELD(wallet_refresh_from_block_height)
856  VARINT_FIELD(subaddress_lookahead_major)
857  VARINT_FIELD(subaddress_lookahead_minor)
858  VARINT_FIELD(wallet_refresh_type)
859  END_SERIALIZE()
860  };
861 
863 
865  {
868  std::vector<cryptonote::transaction> txes;
870  bool error;
871  };
872 
873  struct is_out_data
874  {
877  std::vector<boost::optional<cryptonote::subaddress_receive_info>> received;
878  };
879 
881  {
882  std::vector<cryptonote::tx_extra_field> tx_extra_fields;
883  std::vector<is_out_data> primary;
884  std::vector<is_out_data> additional;
885 
886  bool empty() const { return tx_extra_fields.empty() && primary.empty() && additional.empty(); }
887  };
888 
890  {
893  std::unordered_set<crypto::hash> detached_tx_hashes;
894  std::unordered_map<crypto::hash, std::vector<cryptonote::tx_destination_entry>> detached_confirmed_txs_dests;
895  };
896 
898  {
902  };
903 
905  {
906  std::vector<process_tx_entry_t> tx_entries;
909 
910  tx_entry_data(): lowest_height((uint64_t)-1), highest_height(0) {}
911  };
912 
921  void generate(const std::string& wallet_, const epee::wipeable_string& password,
922  const epee::wipeable_string& multisig_data, bool create_address_file = false);
923 
935  const crypto::secret_key& recovery_param = crypto::secret_key(), bool recover = false,
936  bool two_random = false, bool create_address_file = false);
946  void generate(const std::string& wallet, const epee::wipeable_string& password,
947  const cryptonote::account_public_address &account_public_address,
948  const crypto::secret_key& spendkey, const crypto::secret_key& viewkey, bool create_address_file = false);
957  void generate(const std::string& wallet, const epee::wipeable_string& password,
958  const cryptonote::account_public_address &account_public_address,
959  const crypto::secret_key& viewkey = crypto::secret_key(), bool create_address_file = false);
967  void restore(const std::string& wallet_, const epee::wipeable_string& password, const std::string &device_name, bool create_address_file = false);
968 
974  std::string make_multisig(const epee::wipeable_string &password,
975  const std::vector<std::string> &kex_messages,
976  const std::uint32_t threshold);
982  std::string exchange_multisig_keys(const epee::wipeable_string &password,
983  const std::vector<std::string> &kex_messages,
984  const bool force_update_use_with_caution = false);
989  std::string get_multisig_first_kex_msg() const;
994  cryptonote::blobdata export_multisig();
999  size_t import_multisig(std::vector<cryptonote::blobdata> info);
1005  void rewrite(const std::string& wallet_name, const epee::wipeable_string& password);
1006  void write_watch_only_wallet(const std::string& wallet_name, const epee::wipeable_string& password, std::string &new_keys_filename);
1007  void load(const std::string& wallet, const epee::wipeable_string& password, const std::string& keys_buf = "", const std::string& cache_buf = "");
1008  void store();
1024  void store_to(const std::string &path, const epee::wipeable_string &password, bool force_rewrite_keys = false);
1032  boost::optional<wallet2::keys_file_data> get_keys_file_data(const epee::wipeable_string& password, bool watch_only);
1037  boost::optional<wallet2::cache_file_data> get_cache_file_data();
1038 
1039  std::string path() const;
1040 
1045  bool has_proxy_option() const;
1046 
1051  bool verify_password(const epee::wipeable_string& password, crypto::secret_key &spend_key_out);
1053  const cryptonote::account_base& get_account()const{return m_account;}
1054 
1055  void encrypt_keys(const crypto::chacha_key &key);
1056  void encrypt_keys(const epee::wipeable_string &password);
1057  void decrypt_keys(const crypto::chacha_key &key);
1058  void decrypt_keys(const epee::wipeable_string &password);
1059 
1060  void set_refresh_from_block_height(uint64_t height) {m_refresh_from_block_height = height;}
1061  uint64_t get_refresh_from_block_height() const {return m_refresh_from_block_height;}
1062 
1063  void explicit_refresh_from_block_height(bool expl) {m_explicit_refresh_from_block_height = expl;}
1064  bool explicit_refresh_from_block_height() const {return m_explicit_refresh_from_block_height;}
1065 
1066  void max_reorg_depth(uint64_t depth) {m_max_reorg_depth = depth;}
1067  uint64_t max_reorg_depth() const {return m_max_reorg_depth;}
1068 
1069  bool deinit();
1070  bool init(std::string daemon_address = "http://localhost:8080",
1071  boost::optional<epee::net_utils::http::login> daemon_login = boost::none,
1072  const std::string &proxy = "",
1073  uint64_t upper_transaction_weight_limit = 0,
1074  bool trusted_daemon = true,
1076  bool set_daemon(std::string daemon_address = "http://localhost:8080",
1077  boost::optional<epee::net_utils::http::login> daemon_login = boost::none, bool trusted_daemon = true,
1079  const std::string &proxy = "");
1080  bool set_proxy(const std::string &address);
1081 
1082  void stop() { m_run.store(false, std::memory_order_relaxed); m_message_store.stop(); }
1083 
1084  i_wallet2_callback* callback() const { return m_callback; }
1085  void callback(i_wallet2_callback* callback) { m_callback = callback; }
1086 
1087  bool is_trusted_daemon() const { return m_trusted_daemon; }
1088  void set_trusted_daemon(bool trusted) { m_trusted_daemon = trusted; }
1089 
1093  bool is_deterministic() const;
1094  bool get_seed(epee::wipeable_string& electrum_words, const epee::wipeable_string &passphrase = epee::wipeable_string()) const;
1095 
1099  bool light_wallet() const { return m_light_wallet; }
1100  void set_light_wallet(bool light_wallet) { m_light_wallet = light_wallet; }
1101  uint64_t get_light_wallet_scanned_block_height() const { return m_light_wallet_scanned_block_height; }
1102  uint64_t get_light_wallet_blockchain_height() const { return m_light_wallet_blockchain_height; }
1103 
1107  const std::string &get_seed_language() const;
1111  void set_seed_language(const std::string &language);
1112 
1113  // Subaddress scheme
1114  cryptonote::account_public_address get_subaddress(const cryptonote::subaddress_index& index) const;
1115  cryptonote::account_public_address get_address() const { return get_subaddress({0,0}); }
1116  boost::optional<cryptonote::subaddress_index> get_subaddress_index(const cryptonote::account_public_address& address) const;
1117  crypto::public_key get_subaddress_spend_public_key(const cryptonote::subaddress_index& index) const;
1118  std::vector<crypto::public_key> get_subaddress_spend_public_keys(uint32_t account, uint32_t begin, uint32_t end) const;
1119  std::string get_subaddress_as_str(const cryptonote::subaddress_index& index) const;
1120  std::string get_address_as_str() const { return get_subaddress_as_str({0, 0}); }
1121  std::string get_integrated_address_as_str(const crypto::hash8& payment_id) const;
1122  void add_subaddress_account(const std::string& label);
1123  size_t get_num_subaddress_accounts() const { return m_subaddress_labels.size(); }
1124  size_t get_num_subaddresses(uint32_t index_major) const { return index_major < m_subaddress_labels.size() ? m_subaddress_labels[index_major].size() : 0; }
1125  void add_subaddress(uint32_t index_major, const std::string& label); // throws when index is out of bound
1133  void expand_subaddresses(const cryptonote::subaddress_index& index);
1134  void create_one_off_subaddress(const cryptonote::subaddress_index& index);
1135  std::string get_subaddress_label(const cryptonote::subaddress_index& index) const;
1136  void set_subaddress_label(const cryptonote::subaddress_index &index, const std::string &label);
1137  void set_subaddress_lookahead(size_t major, size_t minor);
1138  std::pair<size_t, size_t> get_subaddress_lookahead() const { return {m_subaddress_lookahead_major, m_subaddress_lookahead_minor}; }
1142  bool is_deprecated() const;
1143  void refresh(bool trusted_daemon);
1144  void refresh(bool trusted_daemon, uint64_t start_height, uint64_t & blocks_fetched);
1145  void refresh(bool trusted_daemon, uint64_t start_height, uint64_t & blocks_fetched, bool& received_money, bool check_pool = true, bool try_incremental = true, uint64_t max_blocks = std::numeric_limits<uint64_t>::max());
1146  bool refresh(bool trusted_daemon, uint64_t & blocks_fetched, bool& received_money, bool& ok);
1147 
1148  void set_refresh_type(RefreshType refresh_type) { m_refresh_type = refresh_type; }
1149  RefreshType get_refresh_type() const { return m_refresh_type; }
1150 
1151  cryptonote::network_type nettype() const { return m_nettype; }
1152  bool watch_only() const { return m_watch_only; }
1153  bool multisig(bool *ready = NULL, uint32_t *threshold = NULL, uint32_t *total = NULL) const;
1154  bool is_background_wallet() const { return m_is_background_wallet; }
1155  bool has_multisig_partial_key_images() const;
1156  bool has_unknown_key_images() const;
1157  bool get_multisig_seed(epee::wipeable_string& seed, const epee::wipeable_string &passphrase = std::string()) const;
1158  bool key_on_device() const { return get_device_type() != hw::device::device_type::SOFTWARE; }
1159  hw::device::device_type get_device_type() const { return m_key_device_type; }
1160  bool reconnect_device();
1161 
1162  // locked & unlocked balance of given or current subaddress account
1163  uint64_t balance(uint32_t subaddr_index_major, bool strict) const;
1164  uint64_t unlocked_balance(uint32_t subaddr_index_major, bool strict, uint64_t *blocks_to_unlock = NULL, uint64_t *time_to_unlock = NULL);
1165  // locked & unlocked balance per subaddress of given or current subaddress account
1166  std::map<uint32_t, uint64_t> balance_per_subaddress(uint32_t subaddr_index_major, bool strict) const;
1167  std::map<uint32_t, std::pair<uint64_t, std::pair<uint64_t, uint64_t>>> unlocked_balance_per_subaddress(uint32_t subaddr_index_major, bool strict);
1168  // all locked & unlocked balances of all subaddress accounts
1169  uint64_t balance_all(bool strict) const;
1170  uint64_t unlocked_balance_all(bool strict, uint64_t *blocks_to_unlock = NULL, uint64_t *time_to_unlock = NULL);
1171  template<typename T>
1172  void transfer_selected(const std::vector<cryptonote::tx_destination_entry>& dsts, const std::vector<size_t>& selected_transfers, size_t fake_outputs_count,
1173  std::vector<std::vector<tools::wallet2::get_outs_entry>> &outs, std::unordered_set<crypto::public_key> &valid_public_keys_cache,
1174  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, const bool use_view_tags);
1175  void transfer_selected_rct(std::vector<cryptonote::tx_destination_entry> dsts, const std::vector<size_t>& selected_transfers, size_t fake_outputs_count,
1176  std::vector<std::vector<tools::wallet2::get_outs_entry>> &outs, std::unordered_set<crypto::public_key> &valid_public_keys_cache,
1177  uint64_t fee, const std::vector<uint8_t>& extra, cryptonote::transaction& tx, pending_tx &ptx, const rct::RCTConfig &rct_config, const bool use_view_tags);
1178 
1179  void commit_tx(pending_tx& ptx_vector);
1180  void commit_tx(std::vector<pending_tx>& ptx_vector);
1181  bool save_tx(const std::vector<pending_tx>& ptx_vector, const std::string &filename) const;
1182  std::string dump_tx_to_str(const std::vector<pending_tx> &ptx_vector) const;
1183  std::string save_multisig_tx(multisig_tx_set txs);
1184  bool save_multisig_tx(const multisig_tx_set &txs, const std::string &filename);
1185  std::string save_multisig_tx(const std::vector<pending_tx>& ptx_vector);
1186  bool save_multisig_tx(const std::vector<pending_tx>& ptx_vector, const std::string &filename);
1187  multisig_tx_set make_multisig_tx_set(const std::vector<pending_tx>& ptx_vector) const;
1188  // load unsigned tx from file and sign it. Takes confirmation callback as argument. Used by the cli wallet
1189  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);
1190  // sign unsigned tx. Takes unsigned_tx_set as argument. Used by GUI
1191  bool sign_tx(unsigned_tx_set &exported_txs, const std::string &signed_filename, std::vector<wallet2::pending_tx> &ptx, bool export_raw = false);
1192  bool sign_tx(unsigned_tx_set &exported_txs, std::vector<wallet2::pending_tx> &ptx, signed_tx_set &signed_txs);
1193  std::string sign_tx_dump_to_str(unsigned_tx_set &exported_txs, std::vector<wallet2::pending_tx> &ptx, signed_tx_set &signed_txes);
1194  // load unsigned_tx_set from file.
1195  bool load_unsigned_tx(const std::string &unsigned_filename, unsigned_tx_set &exported_txs) const;
1196  bool parse_unsigned_tx_from_str(const std::string &unsigned_tx_st, unsigned_tx_set &exported_txs) const;
1197  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);
1198  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);
1199  std::vector<wallet2::pending_tx> create_transactions_2(std::vector<cryptonote::tx_destination_entry> dsts, const size_t fake_outs_count, uint32_t priority, const std::vector<uint8_t>& extra, uint32_t subaddr_account, std::set<uint32_t> subaddr_indices, const unique_index_container& subtract_fee_from_outputs = {}); // pass subaddr_indices by value on purpose
1200  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, uint32_t priority, const std::vector<uint8_t>& extra, uint32_t subaddr_account, std::set<uint32_t> subaddr_indices);
1201  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, uint32_t priority, const std::vector<uint8_t>& extra);
1202  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, uint32_t priority, const std::vector<uint8_t>& extra);
1203  bool sanity_check(const std::vector<wallet2::pending_tx> &ptx_vector, const std::vector<cryptonote::tx_destination_entry>& dsts, const unique_index_container& subtract_fee_from_outputs = {}) const;
1204  void cold_tx_aux_import(const std::vector<pending_tx>& ptx, const std::vector<std::string>& tx_device_aux);
1205  void cold_sign_tx(const std::vector<pending_tx>& ptx_vector, signed_tx_set &exported_txs, std::vector<cryptonote::address_parse_info> &dsts_info, std::vector<std::string> & tx_device_aux);
1206  uint64_t cold_key_image_sync(uint64_t &spent, uint64_t &unspent);
1207  void device_show_address(uint32_t account_index, uint32_t address_index, const boost::optional<crypto::hash8> &payment_id);
1208  bool parse_multisig_tx_from_str(std::string multisig_tx_st, multisig_tx_set &exported_txs) const;
1209  bool load_multisig_tx(cryptonote::blobdata blob, multisig_tx_set &exported_txs, std::function<bool(const multisig_tx_set&)> accept_func = NULL);
1210  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);
1211  bool sign_multisig_tx_from_file(const std::string &filename, std::vector<crypto::hash> &txids, std::function<bool(const multisig_tx_set&)> accept_func);
1212  bool sign_multisig_tx(multisig_tx_set &exported_txs, std::vector<crypto::hash> &txids);
1213  bool sign_multisig_tx_to_file(multisig_tx_set &exported_txs, const std::string &filename, std::vector<crypto::hash> &txids);
1214  std::vector<pending_tx> create_unmixable_sweep_transactions();
1215  void discard_unmixable_outputs();
1216  bool check_connection(uint32_t *version = NULL, bool *ssl = NULL, uint32_t timeout = 200000, bool *wallet_is_outdated = NULL, bool *daemon_is_outdated = NULL);
1217  bool check_version(uint32_t *version, bool *wallet_is_outdated, bool *daemon_is_outdated);
1218  bool check_hard_fork_version(cryptonote::network_type nettype, const std::vector<std::pair<uint8_t, uint64_t>> &daemon_hard_forks, const uint64_t height, const uint64_t target_height, bool *wallet_is_outdated, bool *daemon_is_outdated);
1219  void get_transfers(wallet2::transfer_container& incoming_transfers) const;
1220  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;
1221  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;
1222  void get_payments_out(std::list<std::pair<crypto::hash,wallet2::confirmed_transfer_details>>& confirmed_payments,
1223  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;
1224  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;
1225  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;
1226 
1227  uint64_t get_blockchain_current_height() const { return m_light_wallet_blockchain_height ? m_light_wallet_blockchain_height : m_blockchain.size(); }
1228  void rescan_spent();
1229  void rescan_blockchain(bool hard, bool refresh = true, bool keep_key_images = false);
1230  bool is_transfer_unlocked(const transfer_details& td);
1231  bool is_transfer_unlocked(uint64_t unlock_time, uint64_t block_height);
1232 
1233  uint64_t get_last_block_reward() const { return m_last_block_reward; }
1234  uint64_t get_device_last_key_image_sync() const { return m_device_last_key_image_sync; }
1235 
1236  std::vector<cryptonote::public_node> get_public_nodes(bool white_only = true);
1237 
1238  template <class t_archive>
1239  inline void serialize(t_archive &a, const unsigned int ver)
1240  {
1241  uint64_t dummy_refresh_height = 0; // moved to keys file
1242  if(ver < 5)
1243  return;
1244  if (ver < 19)
1245  {
1246  std::vector<crypto::hash> blockchain;
1247  a & blockchain;
1248  m_blockchain.clear();
1249  for (const auto &b: blockchain)
1250  {
1251  m_blockchain.push_back(b);
1252  }
1253  }
1254  else
1255  {
1256  a & m_blockchain;
1257  }
1258  a & m_transfers;
1259  a & m_account_public_address;
1260  a & m_key_images.parent();
1261  if(ver < 6)
1262  return;
1263  a & m_unconfirmed_txs.parent();
1264  if(ver < 7)
1265  return;
1266  a & m_payments.parent();
1267  if(ver < 8)
1268  return;
1269  a & m_tx_keys.parent();
1270  if(ver < 9)
1271  return;
1272  a & m_confirmed_txs.parent();
1273  if(ver < 11)
1274  return;
1275  a & dummy_refresh_height;
1276  if(ver < 12)
1277  return;
1278  a & m_tx_notes.parent();
1279  if(ver < 13)
1280  return;
1281  if (ver < 17)
1282  {
1283  // we're loading an old version, where m_unconfirmed_payments was a std::map
1284  std::unordered_map<crypto::hash, payment_details> m;
1285  a & m;
1286  m_unconfirmed_payments.clear();
1287  for (std::unordered_map<crypto::hash, payment_details>::const_iterator i = m.begin(); i != m.end(); ++i)
1288  m_unconfirmed_payments.insert(std::make_pair(i->first, pool_payment_details{i->second, false}));
1289  }
1290  if(ver < 14)
1291  return;
1292  if(ver < 15)
1293  {
1294  // we're loading an older wallet without a pubkey map, rebuild it
1295  m_pub_keys.clear();
1296  for (size_t i = 0; i < m_transfers.size(); ++i)
1297  {
1298  const transfer_details &td = m_transfers[i];
1299  m_pub_keys.emplace(td.get_public_key(), i);
1300  }
1301  return;
1302  }
1303  a & m_pub_keys.parent();
1304  if(ver < 16)
1305  return;
1306  a & m_address_book;
1307  if(ver < 17)
1308  return;
1309  if (ver < 22)
1310  {
1311  // we're loading an old version, where m_unconfirmed_payments payload was payment_details
1312  std::unordered_multimap<crypto::hash, payment_details> m;
1313  a & m;
1314  m_unconfirmed_payments.clear();
1315  for (const auto &i: m)
1316  m_unconfirmed_payments.insert(std::make_pair(i.first, pool_payment_details{i.second, false}));
1317  }
1318  if(ver < 18)
1319  return;
1320  a & m_scanned_pool_txs[0];
1321  a & m_scanned_pool_txs[1];
1322  if (ver < 20)
1323  return;
1324  a & m_subaddresses.parent();
1325  std::unordered_map<cryptonote::subaddress_index, crypto::public_key> dummy_subaddresses_inv;
1326  a & dummy_subaddresses_inv;
1327  a & m_subaddress_labels;
1328  a & m_additional_tx_keys.parent();
1329  if(ver < 21)
1330  return;
1331  a & m_attributes.parent();
1332  if(ver < 22)
1333  return;
1334  a & m_unconfirmed_payments.parent();
1335  if(ver < 23)
1336  return;
1337  a & (std::pair<std::map<std::string, std::string>, std::vector<std::string>>&)m_account_tags;
1338  if(ver < 24)
1339  return;
1340  a & m_ring_history_saved;
1341  if(ver < 25)
1342  return;
1343  a & m_last_block_reward;
1344  if(ver < 26)
1345  return;
1346  a & m_tx_device.parent();
1347  if(ver < 27)
1348  return;
1349  a & m_device_last_key_image_sync;
1350  if(ver < 28)
1351  return;
1352  a & m_cold_key_images.parent();
1353  if(ver < 29)
1354  return;
1355  a & m_rpc_client_secret_key;
1356  if(ver < 30)
1357  {
1358  m_has_ever_refreshed_from_node = false;
1359  return;
1360  }
1361  a & m_has_ever_refreshed_from_node;
1362  if(ver < 31)
1363  {
1364  m_background_sync_data = background_sync_data_t{};
1365  return;
1366  }
1367  a & m_background_sync_data;
1368  }
1369 
1371  MAGIC_FIELD("monero wallet cache")
1372  VERSION_FIELD(2)
1374  FIELD(m_transfers)
1375  FIELD(m_account_public_address)
1376  FIELD(m_key_images)
1377  FIELD(m_unconfirmed_txs)
1378  FIELD(m_payments)
1379  FIELD(m_tx_keys)
1380  FIELD(m_confirmed_txs)
1381  FIELD(m_tx_notes)
1382  FIELD(m_unconfirmed_payments)
1383  FIELD(m_pub_keys)
1384  FIELD(m_address_book)
1385  FIELD(m_scanned_pool_txs[0])
1386  FIELD(m_scanned_pool_txs[1])
1387  FIELD(m_subaddresses)
1388  FIELD(m_subaddress_labels)
1389  FIELD(m_additional_tx_keys)
1390  FIELD(m_attributes)
1391  FIELD(m_account_tags)
1392  FIELD(m_ring_history_saved)
1393  FIELD(m_last_block_reward)
1394  FIELD(m_tx_device)
1395  FIELD(m_device_last_key_image_sync)
1396  FIELD(m_cold_key_images)
1397  FIELD(m_rpc_client_secret_key)
1398  if (version < 1)
1399  {
1400  m_has_ever_refreshed_from_node = false;
1401  return true;
1402  }
1403  FIELD(m_has_ever_refreshed_from_node)
1404  if (version < 2)
1405  {
1406  m_background_sync_data = background_sync_data_t{};
1407  return true;
1408  }
1409  FIELD(m_background_sync_data)
1410  END_SERIALIZE()
1411 
1412 
1418  static void wallet_exists(const std::string& file_path, bool& keys_file_exists, bool& wallet_file_exists);
1424  static bool wallet_valid_path_format(const std::string& file_path);
1425  static std::string make_background_wallet_file_name(const std::string &wallet_file);
1426  static std::string make_background_keys_file_name(const std::string &wallet_file);
1427  static bool parse_long_payment_id(const std::string& payment_id_str, crypto::hash& payment_id);
1428  static bool parse_short_payment_id(const std::string& payment_id_str, crypto::hash8& payment_id);
1429  static bool parse_payment_id(const std::string& payment_id_str, crypto::hash& payment_id);
1430 
1431  bool always_confirm_transfers() const { return m_always_confirm_transfers; }
1432  void always_confirm_transfers(bool always) { m_always_confirm_transfers = always; }
1433  bool print_ring_members() const { return m_print_ring_members; }
1434  void print_ring_members(bool value) { m_print_ring_members = value; }
1435  bool store_tx_info() const { return m_store_tx_info; }
1436  void store_tx_info(bool store) { m_store_tx_info = store; }
1437  uint32_t default_mixin() const { return m_default_mixin; }
1438  void default_mixin(uint32_t m) { m_default_mixin = m; }
1439  uint32_t get_default_priority() const { return m_default_priority; }
1440  void set_default_priority(uint32_t p) { m_default_priority = p; }
1441  bool auto_refresh() const { return m_auto_refresh; }
1442  void auto_refresh(bool r) { m_auto_refresh = r; }
1443  AskPasswordType ask_password() const { return m_ask_password; }
1444  void ask_password(AskPasswordType ask) { m_ask_password = ask; }
1445  void set_min_output_count(uint32_t count) { m_min_output_count = count; }
1446  uint32_t get_min_output_count() const { return m_min_output_count; }
1447  void set_min_output_value(uint64_t value) { m_min_output_value = value; }
1448  uint64_t get_min_output_value() const { return m_min_output_value; }
1449  void merge_destinations(bool merge) { m_merge_destinations = merge; }
1450  bool merge_destinations() const { return m_merge_destinations; }
1451  bool confirm_backlog() const { return m_confirm_backlog; }
1452  void confirm_backlog(bool always) { m_confirm_backlog = always; }
1453  void set_confirm_backlog_threshold(uint32_t threshold) { m_confirm_backlog_threshold = threshold; };
1454  uint32_t get_confirm_backlog_threshold() const { return m_confirm_backlog_threshold; };
1455  bool confirm_export_overwrite() const { return m_confirm_export_overwrite; }
1456  void confirm_export_overwrite(bool always) { m_confirm_export_overwrite = always; }
1457  bool auto_low_priority() const { return m_auto_low_priority; }
1458  void auto_low_priority(bool value) { m_auto_low_priority = value; }
1459  bool segregate_pre_fork_outputs() const { return m_segregate_pre_fork_outputs; }
1460  void segregate_pre_fork_outputs(bool value) { m_segregate_pre_fork_outputs = value; }
1461  bool key_reuse_mitigation2() const { return m_key_reuse_mitigation2; }
1462  void key_reuse_mitigation2(bool value) { m_key_reuse_mitigation2 = value; }
1463  uint64_t segregation_height() const { return m_segregation_height; }
1464  void segregation_height(uint64_t height) { m_segregation_height = height; }
1465  bool ignore_fractional_outputs() const { return m_ignore_fractional_outputs; }
1466  void ignore_fractional_outputs(bool value) { m_ignore_fractional_outputs = value; }
1467  bool confirm_non_default_ring_size() const { return m_confirm_non_default_ring_size; }
1468  void confirm_non_default_ring_size(bool always) { m_confirm_non_default_ring_size = always; }
1469  uint64_t ignore_outputs_above() const { return m_ignore_outputs_above; }
1470  void ignore_outputs_above(uint64_t value) { m_ignore_outputs_above = value; }
1471  uint64_t ignore_outputs_below() const { return m_ignore_outputs_below; }
1472  void ignore_outputs_below(uint64_t value) { m_ignore_outputs_below = value; }
1473  bool track_uses() const { return m_track_uses; }
1474  void track_uses(bool value) { m_track_uses = value; }
1475  BackgroundSyncType background_sync_type() const { return m_background_sync_type; }
1476  void setup_background_sync(BackgroundSyncType background_sync_type, const epee::wipeable_string &wallet_password, const boost::optional<epee::wipeable_string> &background_cache_password);
1477  bool is_background_syncing() const { return m_background_syncing; }
1478  bool show_wallet_name_when_locked() const { return m_show_wallet_name_when_locked; }
1479  void show_wallet_name_when_locked(bool value) { m_show_wallet_name_when_locked = value; }
1480  BackgroundMiningSetupType setup_background_mining() const { return m_setup_background_mining; }
1481  void setup_background_mining(BackgroundMiningSetupType value) { m_setup_background_mining = value; }
1482  uint32_t inactivity_lock_timeout() const { return m_inactivity_lock_timeout; }
1483  void inactivity_lock_timeout(uint32_t seconds) { m_inactivity_lock_timeout = seconds; }
1484  const std::string & device_name() const { return m_device_name; }
1485  void device_name(const std::string & device_name) { m_device_name = device_name; }
1486  const std::string & device_derivation_path() const { return m_device_derivation_path; }
1487  void device_derivation_path(const std::string &device_derivation_path) { m_device_derivation_path = device_derivation_path; }
1488  const ExportFormat & export_format() const { return m_export_format; }
1489  inline void set_export_format(const ExportFormat& export_format) { m_export_format = export_format; }
1490  bool load_deprecated_formats() const { return m_load_deprecated_formats; }
1491  void load_deprecated_formats(bool load) { m_load_deprecated_formats = load; }
1492  bool persistent_rpc_client_id() const { return m_persistent_rpc_client_id; }
1493  void persistent_rpc_client_id(bool persistent) { m_persistent_rpc_client_id = persistent; }
1494  void auto_mine_for_rpc_payment_threshold(float threshold) { m_auto_mine_for_rpc_payment_threshold = threshold; }
1495  float auto_mine_for_rpc_payment_threshold() const { return m_auto_mine_for_rpc_payment_threshold; }
1496  crypto::secret_key get_rpc_client_secret_key() const { return m_rpc_client_secret_key; }
1497  void set_rpc_client_secret_key(const crypto::secret_key &key) { m_rpc_client_secret_key = key; m_node_rpc_proxy.set_client_secret_key(key); }
1498  uint64_t credits_target() const { return m_credits_target; }
1499  void credits_target(uint64_t threshold) { m_credits_target = threshold; }
1500  bool is_multisig_enabled() const { return m_enable_multisig; }
1501  void enable_multisig(bool enable) { m_enable_multisig = enable; }
1502  bool is_mismatched_daemon_version_allowed() const { return m_allow_mismatched_daemon_version; }
1503  void allow_mismatched_daemon_version(bool allow_mismatch) { m_allow_mismatched_daemon_version = allow_mismatch; }
1504 
1505  bool get_tx_key_cached(const crypto::hash &txid, crypto::secret_key &tx_key, std::vector<crypto::secret_key> &additional_tx_keys) const;
1506  void set_tx_key(const crypto::hash &txid, const crypto::secret_key &tx_key, const std::vector<crypto::secret_key> &additional_tx_keys, const boost::optional<cryptonote::account_public_address> &single_destination_subaddress = boost::none);
1507  bool get_tx_key(const crypto::hash &txid, crypto::secret_key &tx_key, std::vector<crypto::secret_key> &additional_tx_keys);
1508  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);
1509  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);
1510  void check_tx_key_helper(const cryptonote::transaction &tx, const crypto::key_derivation &derivation, const std::vector<crypto::key_derivation> &additional_derivations, const cryptonote::account_public_address &address, uint64_t &received) const;
1511  bool is_out_to_acc(const cryptonote::account_public_address &address, const crypto::public_key& out_key, const crypto::key_derivation &derivation, const std::vector<crypto::key_derivation> &additional_derivations, const size_t output_index, const boost::optional<crypto::view_tag> &view_tag_opt, crypto::key_derivation &found_derivation) const;
1512  std::string get_tx_proof(const crypto::hash &txid, const cryptonote::account_public_address &address, bool is_subaddress, const std::string &message);
1513  std::string get_tx_proof(const cryptonote::transaction &tx, const crypto::secret_key &tx_key, const std::vector<crypto::secret_key> &additional_tx_keys, const cryptonote::account_public_address &address, bool is_subaddress, const std::string &message) const;
1514  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);
1515  bool check_tx_proof(const cryptonote::transaction &tx, const cryptonote::account_public_address &address, bool is_subaddress, const std::string &message, const std::string &sig_str, uint64_t &received) const;
1516 
1517  std::string get_spend_proof(const crypto::hash &txid, const std::string &message);
1518  bool check_spend_proof(const crypto::hash &txid, const std::string &message, const std::string &sig_str);
1519 
1520  void scan_tx(const std::unordered_set<crypto::hash> &txids);
1521 
1529  std::string get_reserve_proof(const boost::optional<std::pair<uint32_t, uint64_t>> &account_minreserve, const std::string &message);
1539  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);
1540 
1544  std::vector<address_book_row> get_address_book() const { return m_address_book; }
1545  bool add_address_book_row(const cryptonote::account_public_address &address, const crypto::hash8 *payment_id, const std::string &description, bool is_subaddress);
1546  bool set_address_book_row(size_t row_id, const cryptonote::account_public_address &address, const crypto::hash8 *payment_id, const std::string &description, bool is_subaddress);
1547  bool delete_address_book_row(std::size_t row_id);
1548 
1549  uint64_t get_num_rct_outputs();
1550  size_t get_num_transfer_details() const { return m_transfers.size(); }
1551  const transfer_details &get_transfer_details(size_t idx) const;
1552 
1553  uint8_t get_current_hard_fork();
1554  void get_hard_fork_info(uint8_t version, uint64_t &earliest_height);
1555  bool use_fork_rules(uint8_t version, int64_t early_blocks = 0);
1556  int get_fee_algorithm();
1557 
1558  std::string get_wallet_file() const;
1559  std::string get_keys_file() const;
1560  std::string get_daemon_address() const;
1561  const boost::optional<epee::net_utils::http::login>& get_daemon_login() const { return m_daemon_login; }
1562  uint64_t get_daemon_blockchain_height(std::string& err);
1563  uint64_t get_daemon_blockchain_target_height(std::string& err);
1564  uint64_t get_daemon_adjusted_time();
1565 
1569  uint64_t get_approximate_blockchain_height() const;
1570  uint64_t estimate_blockchain_height();
1571  std::vector<size_t> select_available_outputs_from_histogram(uint64_t count, bool atleast, bool unlocked, bool allow_rct);
1572  std::vector<size_t> select_available_outputs(const std::function<bool(const transfer_details &td)> &f);
1573  std::vector<size_t> select_available_unmixable_outputs();
1574  std::vector<size_t> select_available_mixable_outputs();
1575 
1576  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;
1577  size_t pop_best_value(std::vector<size_t> &unused_dust_indices, const std::vector<size_t>& selected_transfers, bool smallest = false) const;
1578 
1579  void set_tx_note(const crypto::hash &txid, const std::string &note);
1580  std::string get_tx_note(const crypto::hash &txid) const;
1581 
1582  void set_tx_device_aux(const crypto::hash &txid, const std::string &aux);
1583  std::string get_tx_device_aux(const crypto::hash &txid) const;
1584 
1585  void set_description(const std::string &description);
1586  std::string get_description() const;
1587 
1592  const std::pair<serializable_map<std::string, std::string>, std::vector<std::string>>& get_account_tags();
1598  void set_account_tag(const std::set<uint32_t> &account_indices, const std::string& tag);
1604  void set_account_tag_description(const std::string& tag, const std::string& description);
1605 
1606  enum message_signature_type_t { sign_with_spend_key, sign_with_view_key };
1607  std::string sign(const std::string &data, message_signature_type_t signature_type, cryptonote::subaddress_index index = {0, 0}) const;
1608  struct message_signature_result_t { bool valid; unsigned version; bool old; message_signature_type_t type; };
1610 
1617  std::string sign_multisig_participant(const std::string& data) const;
1625  bool verify_with_public_key(const std::string &data, const crypto::public_key &public_key, const std::string &signature) const;
1626 
1627  // Import/Export wallet data
1628  std::tuple<uint64_t, uint64_t, std::vector<tools::wallet2::exported_transfer_details>> export_outputs(bool all = false, uint32_t start = 0, uint32_t count = 0xffffffff) const;
1629  std::string export_outputs_to_str(bool all = false, uint32_t start = 0, uint32_t count = 0xffffffff) const;
1630  size_t import_outputs(const std::tuple<uint64_t, uint64_t, std::vector<tools::wallet2::exported_transfer_details>> &outputs);
1631  size_t import_outputs(const std::tuple<uint64_t, uint64_t, std::vector<tools::wallet2::transfer_details>> &outputs);
1632  size_t import_outputs_from_str(const std::string &outputs_st);
1633  payment_container export_payments() const;
1634  void import_payments(const payment_container &payments);
1635  void import_payments_out(const std::list<std::pair<crypto::hash,wallet2::confirmed_transfer_details>> &confirmed_payments);
1636  std::tuple<size_t, crypto::hash, std::vector<crypto::hash>> export_blockchain() const;
1637  void import_blockchain(const std::tuple<size_t, crypto::hash, std::vector<crypto::hash>> &bc);
1638  bool export_key_images(const std::string &filename, bool all = false) const;
1639  std::pair<uint64_t, std::vector<std::pair<crypto::key_image, crypto::signature>>> export_key_images(bool all = false) const;
1640  uint64_t import_key_images(const std::vector<std::pair<crypto::key_image, crypto::signature>> &signed_key_images, size_t offset, uint64_t &spent, uint64_t &unspent, bool check_spent = true);
1641  uint64_t import_key_images(const std::string &filename, uint64_t &spent, uint64_t &unspent);
1642  bool import_key_images(std::vector<crypto::key_image> key_images, size_t offset=0, boost::optional<std::unordered_set<size_t>> selected_transfers=boost::none);
1643  bool import_key_images(signed_tx_set & signed_tx, size_t offset=0, bool only_selected_transfers=false);
1645 
1646  void update_pool_state(std::vector<std::tuple<cryptonote::transaction, crypto::hash, bool>> &process_txs, bool refreshed = false, bool try_incremental = false);
1647  void process_pool_state(const std::vector<std::tuple<cryptonote::transaction, crypto::hash, bool>> &txs);
1648  void remove_obsolete_pool_txs(const std::vector<crypto::hash> &tx_hashes, bool remove_if_found);
1649 
1650  std::string encrypt(const char *plaintext, size_t len, const crypto::secret_key &skey, bool authenticated = true) const;
1651  std::string encrypt(const epee::span<char> &span, const crypto::secret_key &skey, bool authenticated = true) const;
1652  std::string encrypt(const std::string &plaintext, const crypto::secret_key &skey, bool authenticated = true) const;
1653  std::string encrypt(const epee::wipeable_string &plaintext, const crypto::secret_key &skey, bool authenticated = true) const;
1654  std::string encrypt_with_view_secret_key(const std::string &plaintext, bool authenticated = true) const;
1655  template<typename T=std::string> T decrypt(const std::string &ciphertext, const crypto::secret_key &skey, bool authenticated = true) const;
1656  std::string decrypt_with_view_secret_key(const std::string &ciphertext, bool authenticated = true) const;
1657 
1658  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;
1659  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);
1660 
1661  uint64_t get_blockchain_height_by_date(uint16_t year, uint8_t month, uint8_t day); // 1<=month<=12, 1<=day<=31
1662 
1663  bool is_synced();
1664 
1665  std::vector<std::pair<uint64_t, uint64_t>> estimate_backlog(const std::vector<std::pair<double, double>> &fee_levels);
1666  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);
1667 
1668  static uint64_t estimate_fee(bool use_per_byte_fee, bool use_rct, int n_inputs, int mixin, int n_outputs, size_t extra_size, bool bulletproof, bool clsag, bool bulletproof_plus, bool use_view_tags, uint64_t base_fee, uint64_t fee_quantization_mask);
1669  uint64_t get_fee_multiplier(uint32_t priority, int fee_algorithm = -1);
1670  uint64_t get_base_fee(uint32_t priority);
1671  uint64_t get_base_fee();
1672  uint64_t get_fee_quantization_mask();
1673  uint64_t get_min_ring_size();
1674  uint64_t get_max_ring_size();
1675  uint64_t adjust_mixin(uint64_t mixin);
1676 
1677  uint32_t adjust_priority(uint32_t priority);
1678 
1679  bool is_unattended() const { return m_unattended; }
1680 
1681  std::pair<size_t, uint64_t> estimate_tx_size_and_weight(bool use_rct, int n_inputs, int ring_size, int n_outputs, size_t extra_size);
1682 
1683  bool get_rpc_payment_info(bool mining, bool &payment_required, uint64_t &credits, uint64_t &diff, uint64_t &credits_per_hash_found, cryptonote::blobdata &hashing_blob, uint64_t &height, uint64_t &seed_height, crypto::hash &seed_hash, crypto::hash &next_seed_hash, uint32_t &cookie);
1684  bool daemon_requires_payment();
1685  bool make_rpc_payment(uint32_t nonce, uint32_t cookie, uint64_t &credits, uint64_t &balance);
1686  bool search_for_rpc_payment(uint64_t credits_target, uint32_t n_threads, const std::function<bool(uint64_t, uint64_t)> &startfunc, const std::function<bool(unsigned)> &contfunc, const std::function<bool(uint64_t)> &foundfunc = NULL, const std::function<void(const std::string&)> &errorfunc = NULL);
1687  template<typename T> void handle_payment_changes(const T &res, std::true_type) {
1688  if (res.status == CORE_RPC_STATUS_OK || res.status == CORE_RPC_STATUS_PAYMENT_REQUIRED)
1689  m_rpc_payment_state.credits = res.credits;
1690  if (res.top_hash != m_rpc_payment_state.top_hash)
1691  {
1692  m_rpc_payment_state.top_hash = res.top_hash;
1693  m_rpc_payment_state.stale = true;
1694  }
1695  }
1696  template<typename T> void handle_payment_changes(const T &res, std::false_type) {}
1697 
1698  // Light wallet specific functions
1699  // fetch unspent outs from lw node and store in m_transfers
1700  void light_wallet_get_unspent_outs();
1701  // fetch txs and store in m_payments
1702  void light_wallet_get_address_txs();
1703  // get_address_info
1704  bool light_wallet_get_address_info(tools::COMMAND_RPC_GET_ADDRESS_INFO::response &response);
1705  // Login. new_address is true if address hasn't been used on lw node before.
1706  bool light_wallet_login(bool &new_address);
1707  // Send an import request to lw node. returns info about import fee, address and payment_id
1708  bool light_wallet_import_wallet_request(tools::COMMAND_RPC_IMPORT_WALLET_REQUEST::response &response);
1709  // get random outputs from light wallet server
1710  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);
1711  // Parse rct string
1712  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;
1713  // check if key image is ours
1714  bool light_wallet_key_image_is_ours(const crypto::key_image& key_image, const crypto::public_key& tx_public_key, uint64_t out_index);
1715 
1716  /*
1717  * "attributes" are a mechanism to store an arbitrary number of string values
1718  * on the level of the wallet as a whole, identified by keys. Their introduction,
1719  * technically the unordered map m_attributes stored as part of a wallet file,
1720  * led to a new wallet file version, but now new singular pieces of info may be added
1721  * without the need for a new version.
1722  *
1723  * The first and so far only value stored as such an attribute is the description.
1724  * It's stored under the standard key ATTRIBUTE_DESCRIPTION (see method set_description).
1725  *
1726  * The mechanism is open to all clients and allows them to use it for storing basically any
1727  * single string values in a wallet. To avoid the problem that different clients possibly
1728  * overwrite or misunderstand each other's attributes, a two-part key scheme is
1729  * proposed: <client name>.<value name>
1730  */
1731  const char* const ATTRIBUTE_DESCRIPTION = "wallet2.description";
1732  void set_attribute(const std::string &key, const std::string &value);
1733  bool get_attribute(const std::string &key, std::string &value) const;
1734 
1735  crypto::public_key get_multisig_signer_public_key() const;
1736  crypto::public_key get_multisig_signing_public_key(size_t idx) const;
1737  crypto::public_key get_multisig_signing_public_key(const crypto::secret_key &skey) const;
1738 
1739  template<class t_request, class t_response>
1740  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 = "POST")
1741  {
1742  if (m_offline) return false;
1743  boost::lock_guard<boost::recursive_mutex> lock(m_daemon_rpc_mutex);
1744  return epee::net_utils::invoke_http_json(uri, req, res, *m_http_client, timeout, http_method);
1745  }
1746  template<class t_request, class t_response>
1747  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 = "POST")
1748  {
1749  if (m_offline) return false;
1750  boost::lock_guard<boost::recursive_mutex> lock(m_daemon_rpc_mutex);
1751  return epee::net_utils::invoke_http_bin(uri, req, res, *m_http_client, timeout, http_method);
1752  }
1753  template<class t_request, class t_response>
1754  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 = "POST", const std::string& req_id = "0")
1755  {
1756  if (m_offline) return false;
1757  boost::lock_guard<boost::recursive_mutex> lock(m_daemon_rpc_mutex);
1758  return epee::net_utils::invoke_http_json_rpc(uri, method_name, req, res, *m_http_client, timeout, http_method, req_id);
1759  }
1760 
1761  bool set_ring_database(const std::string &filename);
1762  const std::string get_ring_database() const { return m_ring_database; }
1763  bool get_ring(const crypto::key_image &key_image, std::vector<uint64_t> &outs);
1764  bool get_rings(const crypto::hash &txid, std::vector<std::pair<crypto::key_image, std::vector<uint64_t>>> &outs);
1765  bool get_rings(const crypto::chacha_key &key, const std::vector<crypto::key_image> &key_images, std::vector<std::vector<uint64_t>> &outs);
1766  bool set_ring(const crypto::key_image &key_image, const std::vector<uint64_t> &outs, bool relative);
1767  bool set_rings(const std::vector<std::pair<crypto::key_image, std::vector<uint64_t>>> &rings, bool relative);
1768  bool unset_ring(const std::vector<crypto::key_image> &key_images);
1769  bool unset_ring(const crypto::hash &txid);
1770  [[deprecated]] bool find_and_save_rings(bool force = true);
1771 
1772  bool blackball_output(const std::pair<uint64_t, uint64_t> &output);
1773  bool set_blackballed_outputs(const std::vector<std::pair<uint64_t, uint64_t>> &outputs, bool add = false);
1774  bool unblackball_output(const std::pair<uint64_t, uint64_t> &output);
1775  bool is_output_blackballed(const std::pair<uint64_t, uint64_t> &output) const;
1776 
1777  void freeze(size_t idx);
1778  void thaw(size_t idx);
1779  bool frozen(size_t idx) const;
1780  void freeze(const crypto::key_image &ki);
1781  void thaw(const crypto::key_image &ki);
1782  bool frozen(const crypto::key_image &ki) const;
1783  bool frozen(const transfer_details &td) const;
1784  bool frozen(const multisig_tx_set& txs) const; // does partially signed txset contain frozen enotes?
1785 
1786  bool save_to_file(const std::string& path_to_file, const std::string& binary, bool is_printable = false) const;
1787  static bool load_from_file(const std::string& path_to_file, std::string& target_str, size_t max_size = 1000000000);
1788 
1789  uint64_t get_bytes_sent() const;
1790  uint64_t get_bytes_received() const;
1791 
1792  void start_background_sync();
1793  void stop_background_sync(const epee::wipeable_string &wallet_password, const crypto::secret_key &spend_secret_key = crypto::null_skey);
1794 
1795  // MMS -------------------------------------------------------------------------------------------------
1796  mms::message_store& get_message_store() { return m_message_store; };
1797  const mms::message_store& get_message_store() const { return m_message_store; };
1798  mms::multisig_wallet_state get_multisig_wallet_state() const;
1799 
1800  bool lock_keys_file();
1801  bool unlock_keys_file();
1802  bool is_keys_file_locked() const;
1803 
1804  void change_password(const std::string &filename, const epee::wipeable_string &original_password, const epee::wipeable_string &new_password);
1805 
1806  void set_tx_notify(const std::shared_ptr<tools::Notify> &notify) { m_tx_notify = notify; }
1807 
1808  bool is_tx_spendtime_unlocked(uint64_t unlock_time, uint64_t block_height);
1809  void hash_m_transfer(const transfer_details & transfer, crypto::hash &hash) const;
1810  uint64_t hash_m_transfers(boost::optional<uint64_t> transfer_height, crypto::hash &hash) const;
1811  void finish_rescan_bc_keep_key_images(uint64_t transfer_height, const crypto::hash &hash);
1812  void enable_dns(bool enable) { m_use_dns = enable; }
1813  void set_offline(bool offline = true);
1814  bool is_offline() const { return m_offline; }
1815 
1816  uint64_t credits() const { return m_rpc_payment_state.credits; }
1817  void credit_report(uint64_t &expected_spent, uint64_t &discrepancy) const { expected_spent = m_rpc_payment_state.expected_spent; discrepancy = m_rpc_payment_state.discrepancy; }
1818 
1819  static std::string get_default_daemon_address() { CRITICAL_REGION_LOCAL(default_daemon_address_lock); return default_daemon_address; }
1820 
1821  private:
1829  bool store_keys(const std::string& keys_file_name, const epee::wipeable_string& password, bool watch_only = false);
1830  bool store_keys(const std::string& keys_file_name, const crypto::chacha_key& key, bool watch_only = false, bool background_keys_file = false);
1831  boost::optional<wallet2::keys_file_data> get_keys_file_data(const crypto::chacha_key& key, bool watch_only = false, bool background_keys_file = false);
1832  bool store_keys_file_data(const std::string& keys_file_name, wallet2::keys_file_data &keys_file_data, bool background_keys_file = false);
1838  bool load_keys(const std::string& keys_file_name, const epee::wipeable_string& password);
1844  bool load_keys_buf(const std::string& keys_buf, const epee::wipeable_string& password);
1845  bool load_keys_buf(const std::string& keys_buf, const epee::wipeable_string& password, boost::optional<crypto::chacha_key>& keys_to_encrypt);
1846  void load_wallet_cache(const bool use_fs, const std::string& cache_buf = "");
1847  void process_new_transaction(const crypto::hash &txid, const cryptonote::transaction& tx, const std::vector<uint64_t> &o_indices, uint64_t height, uint8_t block_version, uint64_t ts, bool miner_tx, bool pool, bool double_spend_seen, const tx_cache_data &tx_cache_data, std::map<std::pair<uint64_t, uint64_t>, size_t> *output_tracker_cache = NULL, bool ignore_callbacks = false);
1848  bool should_skip_block(const cryptonote::block &b, uint64_t height) const;
1849  void process_new_blockchain_entry(const cryptonote::block& b, const cryptonote::block_complete_entry& bche, const parsed_block &parsed_block, const crypto::hash& bl_id, uint64_t height, const std::vector<tx_cache_data> &tx_cache_data, size_t tx_cache_data_offset, std::map<std::pair<uint64_t, uint64_t>, size_t> *output_tracker_cache = NULL);
1850  detached_blockchain_data detach_blockchain(uint64_t height, std::map<std::pair<uint64_t, uint64_t>, size_t> *output_tracker_cache = NULL);
1851  void handle_reorg(uint64_t height, std::map<std::pair<uint64_t, uint64_t>, size_t> *output_tracker_cache = NULL);
1852  void get_short_chain_history(std::list<crypto::hash>& ids, uint64_t granularity = 1) const;
1853  bool clear();
1854  void clear_soft(bool keep_key_images=false);
1855  /*
1856  * clear_user_data clears data created by the user, which is mostly data
1857  * that a view key cannot identify on chain. This function was initially
1858  * added to ensure that a "background" wallet (a wallet that syncs with just
1859  * a view key hot in memory) does not have any sensitive data loaded that it
1860  * does not need in order to sync. Future devs should take care to ensure
1861  * that this function deletes data that is not useful for background syncing
1862  */
1863  void clear_user_data();
1864  void pull_blocks(bool first, bool try_incremental, 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, uint64_t &current_height);
1865  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);
1866  void fast_refresh(uint64_t stop_height, uint64_t &blocks_start_height, std::list<crypto::hash> &short_chain_history, bool force = false);
1867  void pull_and_parse_next_blocks(bool first, bool try_incremental, 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 &last, bool &error, std::exception_ptr &exception);
1868  void process_parsed_blocks(uint64_t start_height, const std::vector<cryptonote::block_complete_entry> &blocks, const std::vector<parsed_block> &parsed_blocks, uint64_t& blocks_added, std::map<std::pair<uint64_t, uint64_t>, size_t> *output_tracker_cache = NULL);
1869  bool accept_pool_tx_for_processing(const crypto::hash &txid);
1870  void process_unconfirmed_transfer(bool incremental, const crypto::hash &txid, wallet2::unconfirmed_transfer_details &tx_details, bool seen_in_pool, std::chrono::system_clock::time_point now, bool refreshed);
1871  void process_pool_info_extent(const cryptonote::COMMAND_RPC_GET_BLOCKS_FAST::response &res, std::vector<std::tuple<cryptonote::transaction, crypto::hash, bool>> &process_txs, bool refreshed);
1872  void update_pool_state_by_pool_query(std::vector<std::tuple<cryptonote::transaction, crypto::hash, bool>> &process_txs, bool refreshed = false);
1873  void update_pool_state_from_pool_data(bool incremental, const std::vector<crypto::hash> &removed_pool_txids, const std::vector<std::tuple<cryptonote::transaction, crypto::hash, bool>> &added_pool_txs, std::vector<std::tuple<cryptonote::transaction, crypto::hash, bool>> &process_txs, bool refreshed);
1874  uint64_t select_transfers(uint64_t needed_money, std::vector<size_t> unused_transfers_indices, std::vector<size_t>& selected_transfers) const;
1875  bool prepare_file_names(const std::string& file_path);
1876  void process_unconfirmed(const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t height);
1877  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);
1878  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);
1879  void generate_genesis(cryptonote::block& b) const;
1880  void check_genesis(const crypto::hash& genesis_hash) const; //throws
1881  bool generate_chacha_key_from_secret_keys(crypto::chacha_key &key) const;
1882  void generate_chacha_key_from_password(const epee::wipeable_string &pass, crypto::chacha_key &key) const;
1883  crypto::hash get_payment_id(const pending_tx &ptx) const;
1884  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;
1885  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;
1886  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;
1887  void parse_block_round(const cryptonote::blobdata &blob, cryptonote::block &bl, crypto::hash &bl_id, bool &error) const;
1888  uint64_t get_upper_transaction_weight_limit();
1889  std::vector<uint64_t> get_unspent_amounts_vector(bool strict);
1890  uint64_t get_dynamic_base_fee_estimate();
1891  float get_output_relatedness(const transfer_details &td0, const transfer_details &td1) const;
1892  std::vector<size_t> pick_preferred_rct_inputs(uint64_t needed_money, uint32_t subaddr_account, const std::set<uint32_t> &subaddr_indices);
1893  void set_spent(size_t idx, uint64_t height);
1894  void set_unspent(size_t idx);
1895  bool is_spent(const transfer_details &td, bool strict = true) const;
1896  bool is_spent(size_t idx, bool strict = true) const;
1897  void get_outs(std::vector<std::vector<get_outs_entry>> &outs, const std::vector<size_t> &selected_transfers, size_t fake_outputs_count, bool rct, std::unordered_set<crypto::public_key> &valid_public_keys_cache);
1898  void get_outs(std::vector<std::vector<get_outs_entry>> &outs, const std::vector<size_t> &selected_transfers, size_t fake_outputs_count, std::vector<uint64_t> &rct_offsets, std::unordered_set<crypto::public_key> &valid_public_keys_cache);
1899  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, std::unordered_set<crypto::public_key> &valid_public_keys_cache) const;
1900  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;
1901  std::vector<size_t> get_only_rct(const std::vector<size_t> &unused_dust_indices, const std::vector<size_t> &unused_transfers_indices) const;
1902  void scan_output(const cryptonote::transaction &tx, bool miner_tx, const crypto::public_key &tx_pub_key, size_t i, tx_scan_info_t &tx_scan_info, int &num_vouts_received, std::unordered_map<cryptonote::subaddress_index, uint64_t> &tx_money_got_in_outs, std::vector<size_t> &outs, bool pool);
1903  void trim_hashchain();
1904  crypto::key_image get_multisig_composite_key_image(size_t n) const;
1905  rct::multisig_kLRki get_multisig_composite_kLRki(size_t n, const std::unordered_set<crypto::public_key> &ignore_set, std::unordered_set<rct::key> &used_L, std::unordered_set<rct::key> &new_used_L) const;
1906  rct::multisig_kLRki get_multisig_kLRki(size_t n, const rct::key &k) const;
1907  void get_multisig_k(size_t idx, const std::unordered_set<rct::key> &used_L, rct::key &nonce);
1908  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);
1909  bool add_rings(const crypto::chacha_key &key, const cryptonote::transaction_prefix &tx);
1910  bool add_rings(const cryptonote::transaction_prefix &tx);
1911  bool remove_rings(const cryptonote::transaction_prefix &tx);
1912  bool get_ring(const crypto::chacha_key &key, const crypto::key_image &key_image, std::vector<uint64_t> &outs);
1913  crypto::chacha_key get_ringdb_key();
1914  void setup_keys(const epee::wipeable_string &password);
1915  const crypto::chacha_key get_cache_key();
1916  void verify_password_with_cached_key(const epee::wipeable_string &password);
1917  void verify_password_with_cached_key(const crypto::chacha_key &key);
1918  size_t get_transfer_details(const crypto::key_image &ki) const;
1919  tx_entry_data get_tx_entries(const std::unordered_set<crypto::hash> &txids);
1920  void sort_scan_tx_entries(std::vector<process_tx_entry_t> &unsorted_tx_entries);
1921  void process_scan_txs(const tx_entry_data &txs_to_scan, const tx_entry_data &txs_to_reprocess, const std::unordered_set<crypto::hash> &tx_hashes_to_reprocess, detached_blockchain_data &dbd);
1922  void write_background_sync_wallet(const epee::wipeable_string &wallet_password, const epee::wipeable_string &background_cache_password);
1923  void process_background_cache_on_open();
1924  void process_background_cache(const background_sync_data_t &background_sync_data, const hashchain &background_chain, uint64_t last_block_reward);
1925  void reset_background_sync_data(background_sync_data_t &background_sync_data);
1926  void store_background_cache(const crypto::chacha_key &custom_background_key, const bool do_reset_background_sync_data = true);
1927  void store_background_keys(const crypto::chacha_key &custom_background_key);
1928 
1929  bool lock_background_keys_file(const std::string &background_keys_file);
1930  bool unlock_background_keys_file();
1931  bool is_background_keys_file_locked() const;
1932 
1933  void register_devices();
1934  hw::device& lookup_device(const std::string & device_descriptor);
1935 
1936  bool get_rct_distribution(uint64_t &start_height, std::vector<uint64_t> &distribution);
1937 
1938  uint64_t get_segregation_fork_height() const;
1939 
1940  void cache_tx_data(const cryptonote::transaction& tx, const crypto::hash &txid, tx_cache_data &tx_cache_data) const;
1941  std::shared_ptr<std::map<std::pair<uint64_t, uint64_t>, size_t>> create_output_tracker_cache() const;
1942 
1943  void init_type(hw::device::device_type device_type);
1944  void setup_new_blockchain();
1945  void create_keys_file(const std::string &wallet_, bool watch_only, const epee::wipeable_string &password, bool create_address_file);
1946 
1947  wallet_device_callback * get_device_callback();
1948  void on_device_button_request(uint64_t code);
1949  void on_device_button_pressed();
1950  boost::optional<epee::wipeable_string> on_device_pin_request();
1951  boost::optional<epee::wipeable_string> on_device_passphrase_request(bool & on_device);
1952  void on_device_progress(const hw::device_progress& event);
1953 
1954  std::string get_rpc_status(const std::string &s) const;
1955  void throw_on_rpc_response_error(bool r, const epee::json_rpc::error &error, const std::string &status, const char *method) const;
1956 
1957  std::string get_client_signature() const;
1958  void check_rpc_cost(const char *call, uint64_t post_call_credits, uint64_t pre_credits, double expected_cost);
1959 
1960  bool should_expand(const cryptonote::subaddress_index &index) const;
1961  bool spends_one_of_ours(const cryptonote::transaction &tx) const;
1962 
1964  boost::optional<epee::net_utils::http::login> m_daemon_login;
1970  const std::unique_ptr<epee::net_utils::http::abstract_http_client> m_http_client;
1978 
1985  std::vector<std::vector<std::string>> m_subaddress_labels;
1988  std::vector<tools::wallet2::address_book_row> m_address_book;
1989  std::pair<serializable_map<std::string, std::string>, std::vector<std::string>> m_account_tags;
1990  uint64_t m_upper_transaction_weight_limit; //TODO: auto-calc this value or request from daemon, now use some fixed value
1991  std::vector<std::vector<tools::wallet2::multisig_info>> m_multisig_rescan_info;
1992  std::vector<std::vector<rct::key>> m_multisig_rescan_k;
1994 
1995  std::atomic<bool> m_run;
1996 
1997  boost::recursive_mutex m_daemon_rpc_mutex;
1998 
2007  bool m_multisig;
2009  std::vector<crypto::public_key> m_multisig_signers;
2010  //in case of general M/N multisig wallet we should perform N - M + 1 key exchange rounds and remember how many rounds are passed.
2012  std::vector<crypto::public_key> m_multisig_derivations;
2022  // If m_refresh_from_block_height is explicitly set to zero we need this to differentiate it from the case that
2023  // m_refresh_from_block_height was defaulted to zero.*/
2026  std::vector<std::tuple<cryptonote::transaction, crypto::hash, bool>> m_process_pool_txs;
2028  // m_skip_to_height is useful when we don't want to modify the wallet's restore height.
2029  // m_refresh_from_block_height is also a wallet's restore height which should remain constant unless explicitly modified by the user.
2056  std::unordered_set<crypto::hash> m_scanned_pool_txs[2];
2057  size_t m_subaddress_lookahead_major, m_subaddress_lookahead_minor;
2069 
2070  // Aux transaction data from device
2072 
2073  // Light wallet
2074  bool m_light_wallet; /* sends view key to daemon for scanning */
2077  uint64_t m_light_wallet_per_kb_fee = FEE_PER_KB;
2081  // Light wallet info needed to populate m_payment requires 2 separate api calls (get_address_txs and get_unspent_outs)
2082  // We save the info from the first call in m_light_wallet_address_txs for easier lookup.
2083  std::unordered_map<crypto::hash, address_tx> m_light_wallet_address_txs;
2084  // store calculated key image for faster lookup
2086 
2089  std::unique_ptr<ringdb> m_ringdb;
2090  boost::optional<crypto::chacha_key> m_ringdb_key;
2091 
2093  std::unique_ptr<tools::file_locker> m_keys_file_locker;
2094  std::unique_ptr<tools::file_locker> m_background_keys_file_locker;
2095 
2100 
2101  crypto::chacha_key m_cache_key;
2102  boost::optional<crypto::chacha_key> m_custom_background_key = boost::none;
2103  std::shared_ptr<wallet_keys_unlocker> m_encrypt_keys_after_refresh;
2104 
2107 
2108  std::shared_ptr<tools::Notify> m_tx_notify;
2109  std::unique_ptr<wallet_device_callback> m_device_callback;
2110 
2113 
2115 
2116  static boost::mutex default_daemon_address_lock;
2118 
2122  };
2123 }
2125 BOOST_CLASS_VERSION(tools::wallet2::transfer_details, 12)
2126 BOOST_CLASS_VERSION(tools::wallet2::multisig_info, 1)
2127 BOOST_CLASS_VERSION(tools::wallet2::multisig_info::LR, 0)
2128 BOOST_CLASS_VERSION(tools::wallet2::multisig_tx_set, 1)
2129 BOOST_CLASS_VERSION(tools::wallet2::payment_details, 5)
2130 BOOST_CLASS_VERSION(tools::wallet2::pool_payment_details, 1)
2131 BOOST_CLASS_VERSION(tools::wallet2::unconfirmed_transfer_details, 8)
2132 BOOST_CLASS_VERSION(tools::wallet2::confirmed_transfer_details, 6)
2133 BOOST_CLASS_VERSION(tools::wallet2::address_book_row, 18)
2134 BOOST_CLASS_VERSION(tools::wallet2::reserve_proof_entry, 0)
2136 BOOST_CLASS_VERSION(tools::wallet2::signed_tx_set, 1)
2138 BOOST_CLASS_VERSION(tools::wallet2::pending_tx, 3)
2139 BOOST_CLASS_VERSION(tools::wallet2::multisig_sig, 1)
2140 BOOST_CLASS_VERSION(tools::wallet2::background_synced_tx_t, 0)
2141 BOOST_CLASS_VERSION(tools::wallet2::background_sync_data_t, 0)
2142 
2143 namespace boost
2144 {
2145  namespace serialization
2146  {
2147  template<class Archive, class F, class S, class T>
2148  inline void serialize(
2149  Archive & ar,
2150  std::tuple<F, S, T> & t,
2151  const unsigned int /* file_version */
2152  ){
2153  ar & boost::serialization::make_nvp("f", std::get<0>(t));
2154  ar & boost::serialization::make_nvp("s", std::get<1>(t));
2155  ar & boost::serialization::make_nvp("t", std::get<2>(t));
2156  }
2157 
2158  template <class Archive>
2159  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)
2160  {
2161  }
2162  template <class Archive>
2163  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)
2164  {
2165  if (ver < 1)
2166  {
2167  x.m_mask = rct::identity();
2168  x.m_amount = x.m_tx.vout[x.m_internal_output_index].amount;
2169  }
2170  if (ver < 2)
2171  {
2172  x.m_spent_height = 0;
2173  }
2174  if (ver < 4)
2175  {
2176  x.m_rct = x.m_tx.vout[x.m_internal_output_index].amount == 0;
2177  }
2178  if (ver < 6)
2179  {
2180  x.m_key_image_known = true;
2181  }
2182  if (ver < 7)
2183  {
2184  x.m_pk_index = 0;
2185  }
2186  if (ver < 8)
2187  {
2188  x.m_subaddr_index = {};
2189  }
2190  if (ver < 9)
2191  {
2192  x.m_key_image_partial = false;
2193  x.m_multisig_k.clear();
2194  x.m_multisig_info.clear();
2195  }
2196  if (ver < 10)
2197  {
2198  x.m_key_image_request = false;
2199  }
2200  if (ver < 12)
2201  {
2202  x.m_frozen = false;
2203  }
2204  }
2205 
2206  template <class Archive>
2207  inline void serialize(Archive &a, tools::wallet2::transfer_details &x, const boost::serialization::version_type ver)
2208  {
2209  a & x.m_block_height;
2212  if (ver < 3)
2213  {
2215  a & tx;
2218  }
2219  else
2220  {
2221  a & x.m_tx;
2222  }
2223  a & x.m_spent;
2224  a & x.m_key_image;
2225  if (ver < 1)
2226  {
2227  // ensure mask and amount are set
2228  initialize_transfer_details(a, x, ver);
2229  return;
2230  }
2231  a & x.m_mask;
2232  a & x.m_amount;
2233  if (ver < 2)
2234  {
2235  initialize_transfer_details(a, x, ver);
2236  return;
2237  }
2238  a & x.m_spent_height;
2239  if (ver < 3)
2240  {
2241  initialize_transfer_details(a, x, ver);
2242  return;
2243  }
2244  a & x.m_txid;
2245  if (ver < 4)
2246  {
2247  initialize_transfer_details(a, x, ver);
2248  return;
2249  }
2250  a & x.m_rct;
2251  if (ver < 5)
2252  {
2253  initialize_transfer_details(a, x, ver);
2254  return;
2255  }
2256  if (ver < 6)
2257  {
2258  // v5 did not properly initialize
2259  uint8_t u;
2260  a & u;
2261  x.m_key_image_known = true;
2262  return;
2263  }
2264  a & x.m_key_image_known;
2265  if (ver < 7)
2266  {
2267  initialize_transfer_details(a, x, ver);
2268  return;
2269  }
2270  a & x.m_pk_index;
2271  if (ver < 8)
2272  {
2273  initialize_transfer_details(a, x, ver);
2274  return;
2275  }
2276  a & x.m_subaddr_index;
2277  if (ver < 9)
2278  {
2279  initialize_transfer_details(a, x, ver);
2280  return;
2281  }
2282  a & x.m_multisig_info;
2283  a & x.m_multisig_k;
2284  a & x.m_key_image_partial;
2285  if (ver < 10)
2286  {
2287  initialize_transfer_details(a, x, ver);
2288  return;
2289  }
2290  a & x.m_key_image_request;
2291  if (ver < 11)
2292  {
2293  initialize_transfer_details(a, x, ver);
2294  return;
2295  }
2296  a & x.m_uses;
2297  if (ver < 12)
2298  {
2299  initialize_transfer_details(a, x, ver);
2300  return;
2301  }
2302  a & x.m_frozen;
2303  }
2304 
2305  template <class Archive>
2306  inline void serialize(Archive &a, tools::wallet2::multisig_info::LR &x, const boost::serialization::version_type ver)
2307  {
2308  a & x.m_L;
2309  a & x.m_R;
2310  }
2311 
2312  template <class Archive>
2313  inline void serialize(Archive &a, tools::wallet2::multisig_info &x, const boost::serialization::version_type ver)
2314  {
2315  a & x.m_signer;
2316  a & x.m_LR;
2317  a & x.m_partial_key_images;
2318  }
2319 
2320  template <class Archive>
2321  inline void serialize(Archive &a, tools::wallet2::multisig_tx_set &x, const boost::serialization::version_type ver)
2322  {
2323  a & x.m_ptx;
2324  a & x.m_signers;
2325  }
2326 
2327  template <class Archive>
2328  inline void serialize(Archive &a, tools::wallet2::unconfirmed_transfer_details &x, const boost::serialization::version_type ver)
2329  {
2330  a & x.m_change;
2331  a & x.m_sent_time;
2332  if (ver < 5)
2333  {
2335  a & tx;
2337  }
2338  else
2339  {
2340  a & x.m_tx;
2341  }
2342  if (ver < 1)
2343  return;
2344  a & x.m_dests;
2345  a & x.m_payment_id;
2346  if (ver < 2)
2347  return;
2348  a & x.m_state;
2349  if (ver < 3)
2350  return;
2351  a & x.m_timestamp;
2352  if (ver < 4)
2353  return;
2354  a & x.m_amount_in;
2355  a & x.m_amount_out;
2356  if (ver < 6)
2357  {
2358  // v<6 may not have change accumulated in m_amount_out, which is a pain,
2359  // as it's readily understood to be sum of outputs.
2360  // We convert it to include change from v6
2361  if (!typename Archive::is_saving() && x.m_change != (uint64_t)-1)
2362  x.m_amount_out += x.m_change;
2363  }
2364  if (ver < 7)
2365  {
2366  x.m_subaddr_account = 0;
2367  return;
2368  }
2369  a & x.m_subaddr_account;
2370  a & x.m_subaddr_indices;
2371  if (ver < 8)
2372  return;
2373  a & x.m_rings;
2374  }
2375 
2376  template <class Archive>
2377  inline void serialize(Archive &a, tools::wallet2::confirmed_transfer_details &x, const boost::serialization::version_type ver)
2378  {
2379  a & x.m_amount_in;
2380  a & x.m_amount_out;
2381  a & x.m_change;
2382  a & x.m_block_height;
2383  if (ver < 1)
2384  return;
2385  a & x.m_dests;
2386  a & x.m_payment_id;
2387  if (ver < 2)
2388  return;
2389  a & x.m_timestamp;
2390  if (ver < 3)
2391  {
2392  // v<3 may not have change accumulated in m_amount_out, which is a pain,
2393  // as it's readily understood to be sum of outputs. Whether it got added
2394  // or not depends on whether it came from a unconfirmed_transfer_details
2395  // (not included) or not (included). We can't reliably tell here, so we
2396  // check whether either yields a "negative" fee, or use the other if so.
2397  // We convert it to include change from v3
2398  if (!typename Archive::is_saving() && x.m_change != (uint64_t)-1)
2399  {
2400  if (x.m_amount_in > (x.m_amount_out + x.m_change))
2401  x.m_amount_out += x.m_change;
2402  }
2403  }
2404  if (ver < 4)
2405  {
2406  if (!typename Archive::is_saving())
2407  x.m_unlock_time = 0;
2408  return;
2409  }
2410  a & x.m_unlock_time;
2411  if (ver < 5)
2412  {
2413  x.m_subaddr_account = 0;
2414  return;
2415  }
2416  a & x.m_subaddr_account;
2417  a & x.m_subaddr_indices;
2418  if (ver < 6)
2419  return;
2420  a & x.m_rings;
2421  }
2422 
2423  template <class Archive>
2424  inline void serialize(Archive& a, tools::wallet2::payment_details& x, const boost::serialization::version_type ver)
2425  {
2426  a & x.m_tx_hash;
2427  a & x.m_amount;
2428  a & x.m_block_height;
2429  a & x.m_unlock_time;
2430  if (ver < 1)
2431  return;
2432  a & x.m_timestamp;
2433  if (ver < 2)
2434  {
2435  x.m_coinbase = false;
2436  x.m_subaddr_index = {};
2437  return;
2438  }
2439  a & x.m_subaddr_index;
2440  if (ver < 3)
2441  {
2442  x.m_coinbase = false;
2443  x.m_fee = 0;
2444  return;
2445  }
2446  a & x.m_fee;
2447  if (ver < 4)
2448  {
2449  x.m_coinbase = false;
2450  return;
2451  }
2452  a & x.m_coinbase;
2453  if (ver < 5)
2454  return;
2455  a & x.m_amounts;
2456  }
2457 
2458  template <class Archive>
2459  inline void serialize(Archive& a, tools::wallet2::pool_payment_details& x, const boost::serialization::version_type ver)
2460  {
2461  a & x.m_pd;
2462  a & x.m_double_spend_seen;
2463  }
2464 
2465  template <class Archive>
2466  inline void serialize(Archive& a, tools::wallet2::address_book_row& x, const boost::serialization::version_type ver)
2467  {
2468  a & x.m_address;
2469  if (ver < 18)
2470  {
2471  crypto::hash payment_id;
2472  a & payment_id;
2473  x.m_has_payment_id = !(payment_id == crypto::null_hash);
2474  if (x.m_has_payment_id)
2475  {
2476  bool is_long = false;
2477  for (int i = 8; i < 32; ++i)
2478  is_long |= payment_id.data[i];
2479  if (is_long)
2480  {
2481  MWARNING("Long payment ID ignored on address book load");
2483  x.m_has_payment_id = false;
2484  }
2485  else
2486  memcpy(x.m_payment_id.data, payment_id.data, 8);
2487  }
2488  }
2489  a & x.m_description;
2490  if (ver < 17)
2491  {
2492  x.m_is_subaddress = false;
2493  return;
2494  }
2495  a & x.m_is_subaddress;
2496  if (ver < 18)
2497  return;
2498  a & x.m_has_payment_id;
2499  if (x.m_has_payment_id)
2500  a & x.m_payment_id;
2501  }
2502 
2503  template <class Archive>
2504  inline void serialize(Archive& a, tools::wallet2::reserve_proof_entry& x, const boost::serialization::version_type ver)
2505  {
2506  a & x.txid;
2507  a & x.index_in_tx;
2508  a & x.shared_secret;
2509  a & x.key_image;
2510  a & x.shared_secret_sig;
2511  a & x.key_image_sig;
2512  }
2513 
2514  template <class Archive>
2515  inline void serialize(Archive &a, tools::wallet2::unsigned_tx_set &x, const boost::serialization::version_type ver)
2516  {
2517  a & x.txes;
2518  if (ver == 0)
2519  {
2520  // load old version
2521  std::pair<size_t, tools::wallet2::transfer_container> old_transfers;
2522  a & old_transfers;
2523  std::get<0>(x.transfers) = std::get<0>(old_transfers);
2524  std::get<1>(x.transfers) = std::get<0>(old_transfers) + std::get<1>(old_transfers).size();
2525  std::get<2>(x.transfers) = std::get<1>(old_transfers);
2526  return;
2527  }
2528  throw std::runtime_error("Boost serialization not supported for newest unsigned_tx_set");
2529  }
2530 
2531  template <class Archive>
2532  inline void serialize(Archive &a, tools::wallet2::signed_tx_set &x, const boost::serialization::version_type ver)
2533  {
2534  a & x.ptx;
2535  a & x.key_images;
2536  if (ver < 1)
2537  return;
2538  a & x.tx_key_images.parent();
2539  }
2540 
2541  template <class Archive>
2542  inline void serialize(Archive &a, tools::wallet2::tx_construction_data &x, const boost::serialization::version_type ver)
2543  {
2544  a & x.sources;
2545  a & x.change_dts;
2546  a & x.splitted_dsts;
2547  if (ver < 2)
2548  {
2549  // load list to vector
2550  std::list<size_t> selected_transfers;
2551  a & selected_transfers;
2552  x.selected_transfers.clear();
2553  x.selected_transfers.reserve(selected_transfers.size());
2554  for (size_t t: selected_transfers)
2555  x.selected_transfers.push_back(t);
2556  }
2557  a & x.extra;
2558  a & x.unlock_time;
2559  a & x.use_rct;
2560  a & x.dests;
2561  if (ver < 1)
2562  {
2563  x.subaddr_account = 0;
2564  return;
2565  }
2566  a & x.subaddr_account;
2567  a & x.subaddr_indices;
2568  if (ver < 2)
2569  {
2570  if (!typename Archive::is_saving())
2572  return;
2573  }
2574  a & x.selected_transfers;
2575  if (ver < 3)
2576  {
2577  if (!typename Archive::is_saving())
2579  return;
2580  }
2581  if (ver < 4)
2582  {
2583  bool use_bulletproofs = x.rct_config.range_proof_type != rct::RangeProofBorromean;
2584  a & use_bulletproofs;
2585  if (!typename Archive::is_saving())
2587  return;
2588  }
2589  a & x.rct_config;
2590  }
2591 
2592  template <class Archive>
2593  inline void serialize(Archive &a, tools::wallet2::multisig_sig &x, const boost::serialization::version_type ver)
2594  {
2595  a & x.sigs;
2596  a & x.ignore;
2597  a & x.used_L;
2598  a & x.signing_keys;
2599  a & x.msout;
2600  if (ver < 1)
2601  return;
2602  a & x.total_alpha_G;
2603  a & x.total_alpha_H;
2604  a & x.c_0;
2605  a & x.s;
2606  }
2607 
2608  template <class Archive>
2609  inline void serialize(Archive &a, tools::wallet2::pending_tx &x, const boost::serialization::version_type ver)
2610  {
2611  a & x.tx;
2612  a & x.dust;
2613  a & x.fee;
2614  a & x.dust_added_to_fee;
2615  a & x.change_dts;
2616  if (ver < 2)
2617  {
2618  // load list to vector
2619  std::list<size_t> selected_transfers;
2620  a & selected_transfers;
2621  x.selected_transfers.clear();
2622  x.selected_transfers.reserve(selected_transfers.size());
2623  for (size_t t: selected_transfers)
2624  x.selected_transfers.push_back(t);
2625  }
2626  a & x.key_images;
2627  a & x.tx_key;
2628  a & x.dests;
2629  a & x.construction_data;
2630  if (ver < 1)
2631  return;
2632  a & x.additional_tx_keys;
2633  if (ver < 2)
2634  return;
2635  a & x.selected_transfers;
2636  if (ver < 3)
2637  return;
2638  a & x.multisig_sigs;
2639  }
2640 
2641  template <class Archive>
2642  inline void serialize(Archive& a, tools::wallet2::background_synced_tx_t &x, const boost::serialization::version_type ver)
2643  {
2645  a & x.tx;
2646  a & x.output_indices;
2647  a & x.height;
2648  a & x.block_timestamp;
2649  a & x.double_spend_seen;
2650  }
2651 
2652  template <class Archive>
2653  inline void serialize(Archive& a, tools::wallet2::background_sync_data_t &x, const boost::serialization::version_type ver)
2654  {
2655  a & x.first_refresh_done;
2656  a & x.start_height;
2657  a & x.txs.parent();
2661  a & x.wallet_refresh_type;
2662  }
2663  }
2664 }
2665 
2666 namespace tools
2667 {
2668 
2669  namespace detail
2670  {
2671  //----------------------------------------------------------------------------------------------------
2672  inline void digit_split_strategy(const std::vector<cryptonote::tx_destination_entry>& dsts,
2673  const cryptonote::tx_destination_entry& change_dst, uint64_t dust_threshold,
2674  std::vector<cryptonote::tx_destination_entry>& splitted_dsts, std::vector<cryptonote::tx_destination_entry> &dust_dsts)
2675  {
2676  splitted_dsts.clear();
2677  dust_dsts.clear();
2678 
2679  for(auto& de: dsts)
2680  {
2682  [&](uint64_t chunk) { splitted_dsts.push_back(cryptonote::tx_destination_entry(chunk, de.addr, de.is_subaddress)); },
2683  [&](uint64_t a_dust) { splitted_dsts.push_back(cryptonote::tx_destination_entry(a_dust, de.addr, de.is_subaddress)); } );
2684  }
2685 
2687  [&](uint64_t chunk) {
2688  if (chunk <= dust_threshold)
2689  dust_dsts.push_back(cryptonote::tx_destination_entry(chunk, change_dst.addr, false));
2690  else
2691  splitted_dsts.push_back(cryptonote::tx_destination_entry(chunk, change_dst.addr, false));
2692  },
2693  [&](uint64_t a_dust) { dust_dsts.push_back(cryptonote::tx_destination_entry(a_dust, change_dst.addr, false)); } );
2694  }
2695  //----------------------------------------------------------------------------------------------------
2696  inline void null_split_strategy(const std::vector<cryptonote::tx_destination_entry>& dsts,
2697  const cryptonote::tx_destination_entry& change_dst, uint64_t dust_threshold,
2698  std::vector<cryptonote::tx_destination_entry>& splitted_dsts, std::vector<cryptonote::tx_destination_entry> &dust_dsts)
2699  {
2700  splitted_dsts = dsts;
2701 
2702  dust_dsts.clear();
2703  uint64_t change = change_dst.amount;
2704 
2705  if (0 != change)
2706  {
2707  splitted_dsts.push_back(cryptonote::tx_destination_entry(change, change_dst.addr, false));
2708  }
2709  }
2710  //----------------------------------------------------------------------------------------------------
2712  {
2713  std::string indexes;
2714  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) + " "; });
2715  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);
2716  }
2717  //----------------------------------------------------------------------------------------------------
2718  }
2719  //----------------------------------------------------------------------------------------------------
2720 }
uint64_t m_upper_transaction_weight_limit
Definition: wallet2.h:1990
const char * res
Definition: hmac_keccak.cpp:42
bool watch_only() const
Definition: wallet2.h:1152
uint32_t subaddr_account
Definition: wallet2.h:572
def sign(data)
Definition: cointool.py:602
boost::recursive_mutex m_daemon_rpc_mutex
Definition: wallet2.h:1997
uint64_t unlock_time
Definition: wallet2.h:567
virtual void on_money_received(uint64_t height, const crypto::hash &txid, const cryptonote::transaction &tx, uint64_t amount, uint64_t burnt, const cryptonote::subaddress_index &subaddr_index, bool is_change, uint64_t unlock_time)
Definition: wallet2.h:143
Definition: binary_utils.h:36
Definition: wallet2.h:742
#define tr(x)
Definition: common_defines.h:4
uint8_t m_rct
Definition: wallet2.h:417
std::vector< crypto::key_image > key_images
Definition: wallet2.h:731
bool error
Definition: wallet2.h:341
uint64_t m_segregation_height
Definition: wallet2.h:2042
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)
Definition: wallet2.h:299
rpc_payment_state_t m_rpc_payment_state
Definition: wallet2.h:2065
cryptonote::transaction tx
Definition: wallet2.h:657
description
Definition: setupmingw32.py:29
crypto::chacha_iv iv
Definition: wallet2.h:755
rct::RCTConfig rct_config
Definition: wallet2.h:569
uint64_t get_num_rct_outs() const
Definition: wallet2.h:104
serializable_unordered_map< crypto::hash, unconfirmed_transfer_details > m_unconfirmed_txs
Definition: wallet2.h:1972
bool m_always_confirm_transfers
Definition: wallet2.h:2013
AskPasswordType ask_password() const
Definition: wallet2.h:1443
void setup_background_mining(BackgroundMiningSetupType value)
Definition: wallet2.h:1481
crypto::hash tx_hash
Definition: wallet2.h:901
void callback(i_wallet2_callback *callback)
Definition: wallet2.h:1085
static int init(int argc, char **argv, struct runtime_vars *v)
Definition: miniupnpd.c:1149
void set_tx_notify(const std::shared_ptr< tools::Notify > &notify)
Definition: wallet2.h:1806
Definition: wallet2.h:728
bool m_processing_background_cache
Definition: wallet2.h:2120
const boost::optional< epee::net_utils::http::login > & get_daemon_login() const
Definition: wallet2.h:1561
const uint32_t T[512]
Definition: groestl_tables.h:36
bool persistent_rpc_client_id() const
Definition: wallet2.h:1492
hw::device::device_type m_key_device_type
Definition: wallet2.h:2001
size_t get_num_subaddresses(uint32_t index_major) const
Definition: wallet2.h:1124
Definition: net_ssl.h:76
Definition: mining.py:1
std::string cache_data
Definition: wallet2.h:767
void handle_payment_changes(const T &res, std::false_type)
Definition: wallet2.h:1696
bool m_confirm_export_overwrite
Definition: wallet2.h:2038
uint64_t ignore_outputs_below() const
Definition: wallet2.h:1471
size_t subaddress_lookahead_minor
Definition: wallet2.h:847
uint32_t m_inactivity_lock_timeout
Definition: wallet2.h:2050
Definition: rctTypes.h:122
const crypto::hash & operator[](size_t idx) const
Definition: wallet2.h:201
RefreshType wallet_refresh_type
Definition: wallet2.h:848
Definition: cryptonote_config.h:303
cryptonote::COMMAND_RPC_GET_TRANSACTIONS::entry tx_entry
Definition: wallet2.h:899
std::atomic< bool > m_run
Definition: wallet2.h:1995
static const std::chrono::seconds rpc_timeout
Definition: node_rpc_proxy.cpp:54
wallet2 * wallet
Definition: wallet2.h:174
uint64_t m_block_height
Definition: wallet2.h:452
const char * tag
Definition: testobsdrdr.c:19
bool m_is_subaddress
Definition: wallet2.h:781
bool key_on_device() const
Definition: wallet2.h:1158
void auto_low_priority(bool value)
Definition: wallet2.h:1458
void init_options(boost::program_options::options_description &hidden_options, boost::program_options::options_description &normal_options)
Definition: posix_daemonizer.inl:56
bool m_frozen
Definition: wallet2.h:355
uint8_t construction_flags
Definition: wallet2.h:583
struct tools::gamma_picker::gamma_engine engine
uint64_t m_unlock_time
Definition: wallet2.h:453
binary_archive< false > ar
Definition: cold-outputs.cpp:54
int * count
Definition: gmock_stress_test.cc:176
virtual boost::optional< epee::wipeable_string > on_get_password(const char *reason)
Definition: wallet2.h:147
cryptonote::subaddress_index m_subaddr_index
Definition: wallet2.h:456
bool is_old_file_format
Definition: wallet2.h:2005
Definition: portable_binary_archive.hpp:29
bool ignore_fractional_outputs() const
Definition: wallet2.h:1465
void inactivity_lock_timeout(uint32_t seconds)
Definition: wallet2.h:1483
#define CORE_RPC_STATUS_PAYMENT_REQUIRED
Definition: core_rpc_server_commands_defs.h:81
void trim(size_t height)
Definition: wallet2.h:206
cryptonote::network_type m_nettype
Definition: wallet2.h:2002
uint64_t m_change
Definition: wallet2.h:528
Definition: wallet_rpc_helpers.h:49
void confirm_non_default_ring_size(bool always)
Definition: wallet2.h:1468
std::pair< size_t, size_t > get_subaddress_lookahead() const
Definition: wallet2.h:1138
bool m_show_wallet_name_when_locked
Definition: wallet2.h:2049
background_sync_data_t m_background_sync_data
Definition: wallet2.h:2121
Definition: wallet2.h:231
Definition: node_rpc_proxy.h:42
bool is_mismatched_daemon_version_allowed() const
Definition: wallet2.h:1502
bool m_key_image_request
Definition: wallet2.h:362
bool m_has_payment_id
Definition: wallet2.h:782
bool dust_added_to_fee
Definition: wallet2.h:659
std::unordered_set< crypto::hash > detached_tx_hashes
Definition: wallet2.h:893
int i
Definition: pymoduletest.py:23
uint64_t max_reorg_depth() const
Definition: wallet2.h:1067
cryptonote::subaddress_index m_subaddr_index
Definition: wallet2.h:364
const std::string get_ring_database() const
Definition: wallet2.h:1762
Definition: jsonrpc_structs.h:31
static constexpr crypto::hash8 null_hash8
Definition: hash.h:103
Definition: wallet2.h:446
Definition: cryptonote_basic.h:538
void default_mixin(uint32_t m)
Definition: wallet2.h:1438
bool confirm_export_overwrite() const
Definition: wallet2.h:1455
Definition: cryptonote_protocol_defs.h:132
uint64_t amount
Definition: wallet2.h:339
bool m_offline
Definition: wallet2.h:2062
uint64_t pick()
Definition: wallet2.cpp:1051
u
Definition: pymoduletest.py:20
static const unsigned char iv[64]
Definition: sha512-hash.c:13
Definition: wallet2.h:191
std::vector< cryptonote::tx_destination_entry > dests
Definition: wallet2.h:665
std::vector< crypto::secret_key > additional_tx_keys
Definition: wallet2.h:664
std::vector< rct::key > m_multisig_k
Definition: wallet2.h:366
std::vector< LR > m_LR
Definition: wallet2.h:324
void auto_refresh(bool r)
Definition: wallet2.h:1442
crypto::public_key shared_secret
Definition: wallet2.h:798
::std::string string
Definition: gtest-port.h:1097
http_method
Definition: http_base.h:48
uint32_t m_confirm_backlog_threshold
Definition: wallet2.h:2037
void device_derivation_path(const std::string &device_derivation_path)
Definition: wallet2.h:1487
bool m_enable_multisig
Definition: wallet2.h:2067
uint64_t m_internal_output_index
Definition: wallet2.h:408
BackgroundMiningSetupType m_setup_background_mining
Definition: wallet2.h:2051
static std::string default_daemon_address
Definition: wallet2.h:2117
POD_CLASS key_derivation
Definition: crypto.h:88
static constexpr result_type max()
Definition: wallet2.h:111
std::vector< std::pair< uint64_t, crypto::hash > > m_uses
Definition: wallet2.h:368
Definition: cryptonote_basic.h:474
void merge_destinations(bool merge)
Definition: wallet2.h:1449
serializable_unordered_map< crypto::hash, background_synced_tx_t > txs
Definition: wallet2.h:842
virtual void on_reorg(uint64_t height, uint64_t blocks_detached, size_t transfers_detached)
Definition: wallet2.h:142
Definition: message_store.h:267
std::vector< size_t > selected_transfers
Definition: wallet2.h:661
boost::optional< crypto::chacha_key > m_ringdb_key
Definition: wallet2.h:2090
bool is_unattended() const
Definition: wallet2.h:1679
bool invoke_http_json_rpc(const boost::string_ref uri, std::string method_name, const t_request &out_struct, t_response &result_struct, epee::json_rpc::error &error_struct, t_transport &transport, std::chrono::milliseconds timeout=std::chrono::seconds(15), const boost::string_ref http_method="POST", const std::string &req_id="0")
Definition: http_abstract_invoke.h:110
bool invoke_http_json(const boost::string_ref uri, const t_request &out_struct, t_response &result_struct, t_transport &transport, std::chrono::milliseconds timeout=std::chrono::seconds(15), const boost::string_ref method="POST")
Definition: http_abstract_invoke.h:42
uint64_t m_kdf_rounds
Definition: wallet2.h:2003
crypto::hash hash
Definition: wallet2.h:866
const char * method_name
Definition: daemon_handler.cpp:55
const uint64_t * begin
Definition: wallet2.h:118
bool segregate_pre_fork_outputs() const
Definition: wallet2.h:1459
Definition: blockchain.py:1
t
Definition: console.py:33
std::deque< crypto::hash > m_blockchain
Definition: wallet2.h:227
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:217
std::vector< crypto::public_key > m_multisig_signers
Definition: wallet2.h:2009
bool verify_password(const epee::wipeable_string &password)
verifies given password is correct for default wallet keys file
Definition: wallet2.h:1050
void stop()
Definition: wallet2.h:1082
hashchain detached_blockchain
Definition: wallet2.h:891
handler_function * call
Definition: daemon_handler.cpp:56
std::unordered_map< crypto::hash, std::vector< cryptonote::tx_destination_entry > > detached_confirmed_txs_dests
Definition: wallet2.h:894
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:144
virtual boost::optional< epee::wipeable_string > on_device_pin_request()
Definition: wallet2.h:156
Definition: wallet2.h:312
uint64_t dust
Definition: wallet2.h:658
float m_auto_mine_for_rpc_payment_threshold
Definition: wallet2.h:2053
const cryptonote::account_base & get_account() const
Definition: wallet2.h:1053
crypto::secret_key multisig_tx_key_entropy
Definition: wallet2.h:667
std::string key_images
Definition: wallet2.h:662
std::vector< cryptonote::transaction > txes
Definition: wallet2.h:868
uint64_t m_timestamp
Definition: wallet2.h:454
boost::optional< cryptonote::subaddress_receive_info > received
Definition: wallet2.h:342
uint64_t m_light_wallet_blockchain_height
Definition: wallet2.h:2076
uint64_t m_last_block_reward
Definition: wallet2.h:2092
void track_uses(bool value)
Definition: wallet2.h:1474
const mms::message_store & get_message_store() const
Definition: wallet2.h:1797
serializable_unordered_map< std::string, std::string > m_attributes
Definition: wallet2.h:1987
crypto::public_key m_pubkey
Definition: wallet2.h:407
uint32_t m_subaddr_index_major
Definition: wallet2.h:426
rct::key m_mask
Definition: wallet2.h:358
void generate(randomx::Program &p, uint32_t nonce)
Definition: perf-simulation.cpp:62
static boost::mutex lockers_lock
Definition: wallet2.h:133
std::vector< pending_tx > ptx
Definition: wallet2.h:730
std::string data
Definition: base58.cpp:37
crypto::key_derivation derivation
Definition: wallet2.h:876
void refill(const crypto::hash &hash)
Definition: wallet2.h:207
uint64_t index_in_tx
Definition: wallet2.h:797
crypto::key_image ki
Definition: wallet2.h:337
const char * key
Definition: hmac_keccak.cpp:40
cryptonote::tx_destination_entry change_dts
Definition: wallet2.h:563
int type
Definition: superscalar.cpp:50
void print_source_entry(const cryptonote::tx_source_entry &src)
Definition: wallet2.h:2711
wallet_keys_unlocker(wallet2 &w, const boost::optional< tools::password_container > &password)
Definition: wallet2.cpp:1102
mms::message_store m_message_store
Definition: wallet2.h:2096
cryptonote::transaction_prefix m_tx
Definition: wallet2.h:525
crypto namespace.
Definition: crypto.cpp:60
size_t m_subaddress_lookahead_minor
Definition: wallet2.h:2057
const crypto::public_key get_public_key() const
Definition: wallet2.h:372
void store_tx_info(bool store)
Definition: wallet2.h:1436
const char * s
Definition: minissdp.c:596
Definition: minixmlvalid.c:15
Definition: enums.h:67
Definition: bulletproofs.cc:63
crypto::hash m_txid
Definition: wallet2.h:351
std::vector< std::vector< tools::wallet2::multisig_info > > m_multisig_rescan_info
Definition: wallet2.h:1991
Definition: wallet2.h:310
unsigned short uint16_t
Definition: stdint.h:125
bool get_output_public_key(const cryptonote::tx_out &out, crypto::public_key &output_public_key)
Definition: cryptonote_format_utils.cpp:923
Definition: wallet2.h:794
uint64_t m_min_output_value
Definition: wallet2.h:2034
cryptonote::account_public_address m_address
Definition: wallet2.h:778
bool explicit_refresh_from_block_height() const
Definition: wallet2.h:1064
Definition: wallet2.h:177
uint64_t m_timestamp
Definition: wallet2.h:532
Non-owning sequence of data. Does not deep copy.
Definition: span.h:54
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="POST")
Definition: wallet2.h:1740
serializable_unordered_map< crypto::hash, std::string > m_tx_device
Definition: wallet2.h:2071
size_t original_chain_size
Definition: wallet2.h:892
std::tuple< uint64_t, uint64_t, std::vector< tools::wallet2::transfer_details > > outputs
Definition: cold-outputs.cpp:53
std::vector< cryptonote::tx_destination_entry > m_dests
Definition: wallet2.h:530
#define FEE_PER_KB
Definition: cryptonote_config.h:70
bool confirm_non_default_ring_size() const
Definition: wallet2.h:1467
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:1099
uint64_t m_amount_out
Definition: wallet2.h:494
uint64_t credits() const
Definition: wallet2.h:1816
std::string account_data
Definition: wallet2.h:756
mms::message_store & get_message_store()
Definition: wallet2.h:1796
bool m_has_ever_refreshed_from_node
Definition: wallet2.h:2114
crypto::hash m_tx_hash
Definition: wallet2.h:448
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:2696
const std::string & device_name() const
Definition: wallet2.h:1484
Definition: blocks.cpp:12
uint64_t get_light_wallet_scanned_block_height() const
Definition: wallet2.h:1101
uint64_t m_fee
Definition: wallet2.h:451
rct::key m_L
Definition: wallet2.h:314
boost::optional< epee::wipeable_string > on_passphrase_request(bool &on_device) override
Definition: wallet2.cpp:1173
void key_reuse_mitigation2(bool value)
Definition: wallet2.h:1462
unsigned char uint8_t
Definition: stdint.h:124
uint64_t real_output_in_tx_index
Definition: cryptonote_tx_utils.h:50
void on_progress(const hw::device_progress &event) override
Definition: wallet2.cpp:1182
uint32_t m_default_mixin
Definition: wallet2.h:2016
crypto::hash m_genesis
Definition: wallet2.h:226
cryptonote::network_type nettype() const
Definition: wallet2.h:1151
void max_reorg_depth(uint64_t depth)
Definition: wallet2.h:1066
crypto::secret_key m_original_view_secret_key
Definition: wallet2.h:2099
uint64_t m_pool_info_query_time
Definition: wallet2.h:2025
uint64_t amount
Definition: cryptonote_tx_utils.h:51
rct::rctSig sigs
Definition: wallet2.h:625
const ExportFormat & export_format() const
Definition: wallet2.h:1488
std::string m_daemon_address
Definition: wallet2.h:1965
cryptonote::account_public_address addr_for_dust
Definition: wallet2.h:181
bool m_merge_destinations
Definition: wallet2.h:2035
crypto::public_key pkey
Definition: wallet2.h:875
uint64_t money_transfered
Definition: wallet2.h:340
static std::string get_payment_id(const std::vector< uint8_t > &tx_extra)
Definition: trezor_tests.cpp:473
std::unordered_set< crypto::public_key > m_signers
Definition: wallet2.h:745
struct hash_func hashes[]
uint8_t m_key_image_request
Definition: wallet2.h:419
serializable_unordered_map< crypto::public_key, size_t > m_pub_keys
Definition: wallet2.h:1982
uint64_t m_amount_in
Definition: wallet2.h:526
void set_trusted_daemon(bool trusted)
Definition: wallet2.h:1088
rct::keyM total_alpha_G
Definition: wallet2.h:631
bool add_to_fee
Definition: wallet2.h:180
void confirm_backlog(bool always)
Definition: wallet2.h:1452
bool m_segregate_pre_fork_outputs
Definition: wallet2.h:2040
std::unordered_set< crypto::public_key > signing_keys
Definition: wallet2.h:628
uint8_t m_key_image_known
Definition: wallet2.h:418
Definition: rctTypes.h:113
std::unique_ptr< ringdb > m_ringdb
Definition: wallet2.h:2089
bool key_reuse_mitigation2() const
Definition: wallet2.h:1461
bool print_ring_members() const
Definition: wallet2.h:1433
uint8_t m_key_image_partial
Definition: wallet2.h:420
BackgroundMiningSetupType
Definition: wallet2.h:253
virtual void on_device_button_pressed()
Definition: wallet2.h:155
bool m_devices_registered
Definition: wallet2.h:2106
ExportFormat
Definition: wallet2.h:273
bool m_light_wallet_connected
Definition: wallet2.h:2078
RefreshType
Definition: wallet2.h:240
BackgroundSyncType m_background_sync_type
Definition: wallet2.h:2048
uint32_t m_multisig_threshold
Definition: wallet2.h:2008
bool m_is_background_wallet
Definition: wallet2.h:2047
#define CORE_RPC_STATUS_OK
Definition: core_rpc_server_commands_defs.h:78
virtual void on_pool_tx_removed(const crypto::hash &txid)
Definition: wallet2.h:160
Definition: wallet2.h:137
size_t subaddress_lookahead_major
Definition: wallet2.h:846
#define END_SERIALIZE()
self-explanatory
Definition: serialization.h:150
bool m_persistent_rpc_client_id
Definition: wallet2.h:2052
bool m_use_dns
Definition: wallet2.h:2061
bool_constant< true > true_type
Definition: gtest-port.h:2210
const std::string & device_derivation_path() const
Definition: wallet2.h:1486
uint32_t m_multisig_rounds_passed
Definition: wallet2.h:2011
std::unique_ptr< wallet_device_callback > m_device_callback
Definition: wallet2.h:2109
uint64_t result_type
Definition: wallet2.h:109
uint32_t get_confirm_backlog_threshold() const
Definition: wallet2.h:1454
std::vector< cryptonote::tx_destination_entry > m_dests
Definition: wallet2.h:497
std::vector< cryptonote::tx_source_entry > sources
Definition: wallet2.h:562
std::vector< key > keyV
Definition: rctTypes.h:89
Definition: message_store.h:241
static int flags
Definition: mdb_load.c:31
void ignore_outputs_above(uint64_t value)
Definition: wallet2.h:1470
void on_button_pressed() override
Definition: wallet2.cpp:1160
std::shared_ptr< tools::Notify > m_tx_notify
Definition: wallet2.h:2108
double average_output_time
Definition: wallet2.h:120
ExportFormat m_export_format
Definition: wallet2.h:2111
uint64_t m_ignore_outputs_below
Definition: wallet2.h:2045
std::vector< crypto::key_image > m_partial_key_images
Definition: wallet2.h:325
tx_scan_info_t()
Definition: wallet2.h:344
bool is_in_bounds(size_t idx) const
Definition: wallet2.h:200
Definition: cryptonote_basic.h:170
void show_wallet_name_when_locked(bool value)
Definition: wallet2.h:1479
std::vector< tx_out > vout
Definition: cryptonote_basic.h:179
static void check_rpc_cost(rpc_payment_state_t &rpc_payment_state, const char *call, uint64_t post_call_credits, uint64_t pre_call_credits, double expected_cost)
Definition: wallet_rpc_helpers.h:60
wallet_device_callback(wallet2 *wallet)
Definition: wallet2.h:167
std::vector< tx_construction_data > txes
Definition: wallet2.h:698
crypto::chacha_key m_cache_key
Definition: wallet2.h:2101
std::vector< is_out_data > primary
Definition: wallet2.h:883
const crypto::secret_key null_skey
Definition: crypto.cpp:75
uint64_t m_pk_index
Definition: wallet2.h:363
uint64_t m_max_reorg_depth
Definition: wallet2.h:2032
std::vector< tools::wallet2::address_book_row > m_address_book
Definition: wallet2.h:1988
virtual void on_skip_transaction(uint64_t height, const crypto::hash &txid, const cryptonote::transaction &tx)
Definition: wallet2.h:146
std::unordered_set< rct::key > used_L
Definition: wallet2.h:627
NodeRPCProxy m_node_rpc_proxy
Definition: wallet2.h:2055
const crypto::hash & genesis() const
Definition: wallet2.h:198
i_wallet2_callback * m_callback
Definition: wallet2.h:2000
uint64_t amount() const
Definition: wallet2.h:371
first
Definition: compare.py:8
bool m_confirm_backlog
Definition: wallet2.h:2036
virtual void on_lw_new_block(uint64_t height)
Definition: wallet2.h:149
void auto_mine_for_rpc_payment_threshold(float threshold)
Definition: wallet2.h:1494
result_type operator()()
Definition: wallet2.h:112
Definition: core_rpc_server_commands_defs.h:392
bool m_double_spend_seen
Definition: wallet2.h:481
bool m_key_image_known
Definition: wallet2.h:361
Definition: wallet2.h:560
std::string get_address_as_str() const
Definition: wallet2.h:1120
std::vector< uint64_t > amounts_container
Definition: wallet2.h:445
const portMappingElt code
Definition: portlistingparse.c:22
bool m_incoming
Definition: wallet2.h:475
virtual boost::optional< epee::wipeable_string > on_device_passphrase_request(bool &on_device)
Definition: wallet2.h:157
void set_refresh_type(RefreshType refresh_type)
Definition: wallet2.h:1148
Definition: wallet2.h:241
std::vector< transfer_details > transfer_container
Definition: wallet2.h:619
uint64_t m_amount_out
Definition: wallet2.h:527
serializable_unordered_map< crypto::public_key, cryptonote::subaddress_index > m_subaddresses
Definition: wallet2.h:1984
declaration and default definition for the functions used the API
Definition: expect.cpp:33
void segregate_pre_fork_outputs(bool value)
Definition: wallet2.h:1460
construction_flags_
Definition: wallet2.h:575
static void add(ge_p3 &p3, const ge_cached &other)
Definition: multiexp.cc:144
Definition: wallet2.h:275
bool m_unattended
Definition: wallet2.h:2105
Definition: chaingen.h:294
bool is_background_wallet() const
Definition: wallet2.h:1154
#define VERSION_FIELD(v)
Definition: serialization.h:220
void enable_multisig(bool enable)
Definition: wallet2.h:1501
void allow_mismatched_daemon_version(bool allow_mismatch)
Definition: wallet2.h:1503
crypto::hash m_payment_id
Definition: wallet2.h:498
bool m_load_deprecated_formats
Definition: wallet2.h:2112
bool m_auto_low_priority
Definition: wallet2.h:2039
std::vector< std::vector< std::string > > m_subaddress_labels
Definition: wallet2.h:1985
unsigned int uint32_t
Definition: stdint.h:126
bool m_coinbase
Definition: wallet2.h:455
uint32_t get_min_output_count() const
Definition: wallet2.h:1446
uint32_t m_min_output_count
Definition: wallet2.h:2033
device_type
Definition: device.hpp:103
payment_details m_pd
Definition: wallet2.h:480
uint64_t m_device_last_key_image_sync
Definition: wallet2.h:2060
uint64_t m_timestamp
Definition: wallet2.h:500
bool auto_refresh() const
Definition: wallet2.h:1441
Definition: argon2_core.h:74
Definition: wallet_errors.h:170
std::set< uint32_t > subaddr_indices
Definition: wallet2.h:573
Various Tools.
Definition: apply_permutation.h:39
boost::optional< epee::net_utils::http::login > m_daemon_login
Definition: wallet2.h:1964
bool locked
Definition: wallet2.h:131
uint64_t get_device_last_key_image_sync() const
Definition: wallet2.h:1234
bool track_uses() const
Definition: wallet2.h:1473
confirmed_transfer_details(const unconfirmed_transfer_details &utd, uint64_t height)
Definition: wallet2.h:539
wallet2 & w
Definition: wallet2.h:130
uint64_t m_global_output_index
Definition: wallet2.h:353
bool parse_uri(const std::string uri, http::uri_content &content)
Definition: net_parse_helpers.cpp:102
BackgroundSyncType
Definition: wallet2.h:259
static boost::mutex default_daemon_address_lock
Definition: wallet2.h:2116
std::vector< tools::wallet2::pending_tx > ptx
Definition: cold-transaction.cpp:56
Definition: wallet2.h:334
Definition: cryptonote_tx_utils.h:42
Definition: serialization.cpp:892
void set_light_wallet(bool light_wallet)
Definition: wallet2.h:1100
crypto::chacha_key key
Definition: wallet2.h:132
Definition: account.h:73
bool is_trusted_daemon() const
Definition: wallet2.h:1087
def verify()
Definition: gitian-build.py:101
crypto::secret_key m_rpc_client_secret_key
Definition: wallet2.h:2064
uint64_t m_unlock_time
Definition: wallet2.h:533
void confirm_export_overwrite(bool always)
Definition: wallet2.h:1456
tools::wallet2::unsigned_tx_set exported_txs
Definition: cold-transaction.cpp:53
uint64_t get_refresh_from_block_height() const
Definition: wallet2.h:1061
uint64_t get_min_output_value() const
Definition: wallet2.h:1448
uint64_t m_ignore_outputs_above
Definition: wallet2.h:2044
bool m_background_syncing
Definition: wallet2.h:2119
uint8_t m_spent
Definition: wallet2.h:415
Definition: rctTypes.h:79
uint64_t m_light_wallet_scanned_block_height
Definition: wallet2.h:2075
size_t n_outputs
Definition: cold-outputs.cpp:56
#define ts
Definition: skein.c:522
uint32_t m_subaddr_account
Definition: wallet2.h:534
const uint64_t * end
Definition: wallet2.h:118
unsigned __int64 uint64_t
Definition: stdint.h:136
serializable_unordered_multimap< crypto::hash, payment_details > payment_container
Definition: wallet2.h:620
std::vector< cryptonote::tx_destination_entry > splitted_dsts
Definition: wallet2.h:564
std::vector< multisig_sig > multisig_sigs
Definition: wallet2.h:666
Definition: subaddress_index.h:38
#define BEGIN_SERIALIZE_OBJECT()
begins the environment of the DSL for described the serialization of an object
Definition: serialization.h:131
static std::string get_default_daemon_address()
Definition: wallet2.h:1819
#define CRITICAL_REGION_LOCAL(x)
Definition: syncobj.h:153
void ignore_fractional_outputs(bool value)
Definition: wallet2.h:1466
Definition: wallet2.h:472
Definition: rctTypes.h:613
cryptonote::COMMAND_RPC_GET_BLOCKS_FAST::block_output_indices o_indices
Definition: wallet2.h:869
Definition: password.h:40
rct::keyM total_alpha_H
Definition: wallet2.h:632
void load(Archive &a, std::unordered_map< h_key, hval > &x, const boost::serialization::version_type ver)
Definition: unordered_containers_boost_serialization.h:54
bool empty() const
Definition: wallet2.h:205
std::vector< is_out_data > additional
Definition: wallet2.h:884
rct::keyV c_0
Definition: wallet2.h:633
bool store_tx_info() const
Definition: wallet2.h:1435
void handle_payment_changes(const T &res, std::true_type)
Definition: wallet2.h:1687
cryptonote::transaction_prefix m_tx
Definition: wallet2.h:350
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:183
void clear()
Definition: wallet2.h:204
bool is_background_syncing() const
Definition: wallet2.h:1477
static constexpr crypto::hash null_hash
Definition: hash.h:102
uint64_t credits_target() const
Definition: wallet2.h:1498
crypto::public_key m_tx_pubkey
Definition: wallet2.h:410
std::vector< cryptonote::tx_extra_field > tx_extra_fields
Definition: tx-extra.cpp:38
bool m_mempool
Definition: wallet2.h:474
Definition: rctTypes.h:307
Definition: device.hpp:87
#define false
Definition: stdbool.h:37
uint64_t start_height
Definition: wallet2.h:841
std::string m_wallet_file
Definition: wallet2.h:1967
std::string seed_language
Definition: wallet2.h:2004
Definition: device.hpp:71
uint64_t m_block_height
Definition: wallet2.h:349
uint64_t height
Definition: wallet2.h:819
static std::string encrypt(const std::string &plaintext, const crypto::key_image &key_image, const crypto::chacha_key &key, uint8_t field)
Definition: ringdb.cpp:121
Definition: transfer.py:1
Definition: wallet2.h:478
const char * Binary(const char *input, short n)
Definition: gmock-generated-actions_test.cc:95
std::string m_device_derivation_path
Definition: wallet2.h:2059
uint32_t m_subaddr_account
Definition: wallet2.h:501
serializable_unordered_map< crypto::public_key, serializable_map< uint64_t, crypto::key_image > > m_key_image_cache
Definition: wallet2.h:2085
uint64_t get_light_wallet_blockchain_height() const
Definition: wallet2.h:1102
std::vector< uint8_t > extra
Definition: wallet2.h:566
crypto::hash & operator[](size_t idx)
Definition: wallet2.h:202
std::tuple< uint64_t, crypto::public_key, rct::key > get_outs_entry
Definition: wallet2.h:862
std::unique_ptr< tools::file_locker > m_keys_file_locker
Definition: wallet2.h:2093
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="POST")
Definition: wallet2.h:1747
static MDB_envinfo info
Definition: mdb_load.c:37
Definition: wallet.py:1
boost::optional< epee::wipeable_string > on_pin_request() override
Definition: wallet2.cpp:1166
void serialize(t_archive &a, const unsigned int ver)
Definition: wallet2.h:210
tx_construction_data construction_data
Definition: wallet2.h:669
Definition: misc_language.h:103
Definition: wallet2.h:123
POD_CLASS public_key
Definition: crypto.h:61
tools::wallet2::tx_construction_data tx_construction_data
Definition: protocol.hpp:154
uint64_t lowest_height
Definition: wallet2.h:907
cryptonote::transaction tx
Definition: wallet2.h:900
version
Supported socks variants.
Definition: socks.h:57
std::unique_ptr< tools::file_locker > m_background_keys_file_locker
Definition: wallet2.h:2094
uint8_t m_frozen
Definition: wallet2.h:416
size_t size() const
Definition: wallet2.h:196
std::vector< uint64_t > output_indices
Definition: wallet2.h:818
cryptonote::account_base m_account
Definition: wallet2.h:1963
static crypto::public_key get_tx_pub_key_from_received_outs(const tools::wallet2::transfer_details &td)
Definition: trezor_tests.cpp:413
cryptonote::block block
Definition: wallet2.h:867
crypto::secret_key spendkey
Definition: cold-outputs.cpp:44
uint64_t m_skip_to_height
Definition: wallet2.h:2027
static BackgroundSyncType background_sync_type_from_str(const std::string &background_sync_type_str)
Definition: wallet2.h:265
Definition: rctTypes.h:307
bool m_store_tx_info
Definition: wallet2.h:2015
uint64_t index_in_background_sync_data
Definition: wallet2.h:816
uint64_t m_amount
Definition: wallet2.h:424
void ignore_outputs_below(uint64_t value)
Definition: wallet2.h:1472
diff
Definition: gen_wide_data.py:42
void set_refresh_from_block_height(uint64_t height)
Definition: wallet2.h:1060
void credits_target(uint64_t threshold)
Definition: wallet2.h:1499
std::vector< crypto::public_key > m_multisig_derivations
Definition: wallet2.h:2012
virtual void on_device_button_request(uint64_t code)
Definition: wallet2.h:154
uint64_t m_light_wallet_balance
Definition: wallet2.h:2079
uint32_t m_rpc_version
Definition: wallet2.h:2063
Definition: wallet2.h:696
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition: pointer.h:1124
payment_container m_payments
Definition: wallet2.h:1980
r
Definition: testupnpigd.py:61
void set_min_output_value(uint64_t value)
Definition: wallet2.h:1447
std::string m_keys_file
Definition: wallet2.h:1968
void load_deprecated_formats(bool load)
Definition: wallet2.h:1491
bool m_watch_only
Definition: wallet2.h:2006
rct::multisig_out msout
Definition: wallet2.h:629
std::string m_description
Definition: wallet2.h:780
account_public_address addr
Definition: cryptonote_tx_utils.h:78
cryptonote::transaction_prefix m_tx
Definition: wallet2.h:492
std::string blobdata
Definition: blobdatatype.h:39
cryptonote::checkpoints m_checkpoints
Definition: wallet2.h:1976
const char *const str
Definition: portlistingparse.c:23
void persistent_rpc_client_id(bool persistent)
Definition: wallet2.h:1493
size_t offset() const
Definition: wallet2.h:197
Definition: wallet2.h:904
virtual void on_new_block(uint64_t height, const cryptonote::block &block)
Definition: wallet2.h:141
std::unordered_map< K, V > & parent()
Definition: containers.h:52
const std::unique_ptr< epee::net_utils::http::abstract_http_client > m_http_client
Definition: wallet2.h:1970
uint64_t highest_height
Definition: wallet2.h:908
hashchain()
Definition: wallet2.h:194
std::set< uint32_t > m_subaddr_indices
Definition: wallet2.h:502
std::vector< keyV > keyM
Definition: rctTypes.h:90
bool confirm_backlog() const
Definition: wallet2.h:1451
Definition: http.h:45
#define MAGIC_FIELD(m)
Definition: serialization.h:209
cryptonote::account_public_address get_address() const
Definition: wallet2.h:1115
network_type
Definition: cryptonote_config.h:301
randomx_vm * vm
Definition: tests.cpp:20
void segregation_height(uint64_t height)
Definition: wallet2.h:1464
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:2672
uint32_t address
Definition: getifaddr.c:269
POD_CLASS signature
Definition: crypto.h:98
uint64_t ignore_outputs_above() const
Definition: wallet2.h:1469
Definition: wallet2.h:764
void set_export_format(const ExportFormat &export_format)
Definition: wallet2.h:1489
Definition: cryptonote_basic.h:511
uint64_t m_credits_target
Definition: wallet2.h:2066
cryptonote::account_public_address m_account_public_address
Definition: wallet2.h:1983
size_t get_num_subaddress_accounts() const
Definition: wallet2.h:1123
key identity()
Definition: rctOps.h:73
POD_CLASS hash8
Definition: hash.h:52
output
Definition: gmock_output_test.py:175
uint64_t m_block_height
Definition: wallet2.h:529
randomx_cache * cache
Definition: tests.cpp:19
crypto::signature shared_secret_sig
Definition: wallet2.h:800
gamma_picker(const std::vector< uint64_t > &rct_offsets)
Definition: wallet2.cpp:1049
string daemon_address
Definition: transfers.cpp:41
bool m_explicit_refresh_from_block_height
Definition: wallet2.h:2024
bool m_rct
Definition: wallet2.h:360
void on_button_request(uint64_t code=0) override
Definition: wallet2.cpp:1154
uint64_t real_output
Definition: cryptonote_tx_utils.h:47
static void ready(int code, upnpc_t *p, upnpc_device_t *d, void *data)
Definition: upnpc-libevent.c:40
POD_CLASS key_image
Definition: crypto.h:92
void credit_report(uint64_t &expected_spent, uint64_t &discrepancy) const
Definition: wallet2.h:1817
bool merge_destinations() const
Definition: wallet2.h:1450
#define VARINT_FIELD(f)
tags and serializes the varint f
Definition: serialization.h:189
cryptonote::account_public_address m_original_address
Definition: wallet2.h:2098
#define THROW_WALLET_EXCEPTION_IF(cond, err_type,...)
Definition: wallet_errors.h:1036
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
uint64_t m_change
Definition: wallet2.h:495
unsigned version
Definition: wallet2.h:1608
uint64_t segregation_height() const
Definition: wallet2.h:1463
void * memcpy(void *a, const void *b, size_t c)
Definition: glibc_compat.cpp:16
i_wallet2_callback * callback() const
Definition: wallet2.h:1084
bool m_first_refresh_done
Definition: wallet2.h:2020
std::vector< cryptonote::tx_destination_entry > dests
Definition: wallet2.h:571
rct::key mask
Definition: wallet2.h:338
uint64_t m_light_wallet_unlocked_balance
Definition: wallet2.h:2080
uint64_t num_rct_outputs
Definition: wallet2.h:119
bool m_original_keys_available
Definition: wallet2.h:2097
crypto::hash get_transaction_hash(const transaction &t)
Definition: cryptonote_format_utils.cpp:1273
void always_confirm_transfers(bool always)
Definition: wallet2.h:1432
serializable_unordered_map< crypto::hash, std::string > m_tx_notes
Definition: wallet2.h:1986
void crop(size_t height)
Definition: wallet2.h:203
AskPasswordType m_ask_password
Definition: wallet2.h:2031
rct::key m_R
Definition: wallet2.h:315
crypto::hash8 m_payment_id
Definition: wallet2.h:779
confirmed_transfer_details()
Definition: wallet2.h:538
signed __int64 int64_t
Definition: stdint.h:135
std::unordered_set< crypto::public_key > ignore
Definition: wallet2.h:626
Definition: mlocker.h:68
conn start()
std::vector< std::pair< crypto::key_image, std::vector< uint64_t > > > m_rings
Definition: wallet2.h:503
tx_entry_data()
Definition: wallet2.h:910
std::pair< serializable_map< std::string, std::string >, std::vector< std::string > > m_account_tags
Definition: wallet2.h:1989
void set_rpc_client_secret_key(const crypto::secret_key &key)
Definition: wallet2.h:1497
std::tuple< uint64_t, uint64_t, wallet2::transfer_container > transfers
Definition: wallet2.h:699
uint64_t m_refresh_from_block_height
Definition: wallet2.h:2021
hashchain m_blockchain
Definition: wallet2.h:1971
std::shared_ptr< messages::monero::MoneroGetTxKeyRequest > get_tx_key(const hw::device_cold::tx_key_data_t &tx_data)
Definition: protocol.cpp:1053
cryptonote::transaction tx
Definition: transaction.cpp:40
RangeProofType range_proof_type
Definition: rctTypes.h:309
Definition: wallet2.h:873
crypto::key_image m_key_image
Definition: wallet2.h:357
float auto_mine_for_rpc_payment_threshold() const
Definition: wallet2.h:1495
std::vector< output_entry > outputs
Definition: cryptonote_tx_utils.h:46
std::vector< std::tuple< cryptonote::transaction, crypto::hash, bool > > m_process_pool_txs
Definition: wallet2.h:2026
bool m_allow_mismatched_daemon_version
Definition: wallet2.h:2068
Definition: rctTypes.h:308
uint32_t inactivity_lock_timeout() const
Definition: wallet2.h:1482
serializable_unordered_map< crypto::hash, confirmed_transfer_details > m_confirmed_txs
Definition: wallet2.h:1973
Definition: wallet2.h:897
std::vector< address_book_row > get_address_book() const
GUI Address book get/store.
Definition: wallet2.h:1544
std::shared_ptr< wallet_keys_unlocker > m_encrypt_keys_after_refresh
Definition: wallet2.h:2103
RefreshType get_refresh_type() const
Definition: wallet2.h:1149
bool_constant< false > false_type
Definition: gtest-port.h:2209
const uint8_t seed[32]
Definition: code-generator.cpp:37
Definition: cryptonote_tx_utils.h:74
Definition: wipeable_string.h:40
rct::keyV s
Definition: wallet2.h:634
crypto::signature key_image_sig
Definition: wallet2.h:801
Definition: multisig.cpp:45
p
Definition: pymoduletest.py:75
std::vector< cryptonote::tx_extra_field > tx_extra_fields
Definition: wallet2.h:882
uint64_t dust_threshold
Definition: wallet2.h:179
BOOST_CLASS_VERSION(nodetool::peerlist_types, nodetool::CURRENT_PEERLIST_STORAGE_ARCHIVE_VER)
size_t m_offset
Definition: wallet2.h:225
bool m_light_wallet
Definition: wallet2.h:2074
crypto::hash txid
Definition: wallet2.h:796
static std::string decrypt(const std::string &ciphertext, const crypto::key_image &key_image, const crypto::chacha_key &key, uint8_t field)
Definition: ringdb.cpp:136
bool use_view_tags
Definition: wallet2.h:570
std::set< uint32_t > m_subaddr_indices
Definition: wallet2.h:535
size_t get_num_transfer_details() const
Definition: wallet2.h:1550
Definition: wallet2.h:107
static boost::multiprecision::uint128_t fees
Definition: blockchain_stats.cpp:58
serializable_unordered_map< crypto::public_key, crypto::key_image > tx_key_images
Definition: wallet2.h:732
uint64_t block_timestamp
Definition: wallet2.h:820
void enable_dns(bool enable)
Definition: wallet2.h:1812
Definition: wallet2.h:880
AskPasswordType
Definition: wallet2.h:247
Definition: wallet2.h:655
bool m_print_ring_members
Definition: wallet2.h:2014
std::gamma_distribution< double > gamma
Definition: wallet2.h:116
wallet set_subaddress_lookahead(1, 1)
cryptonote::account_base & get_account()
Definition: wallet2.h:1052
POD_CLASS hash
Definition: hash.h:49
Definition: uri.py:1
uint64_t m_amount
Definition: wallet2.h:449
bool m_multisig
Definition: wallet2.h:2007
cryptonote::tx_destination_entry change_dts
Definition: wallet2.h:660
bool is_offline() const
Definition: wallet2.h:1814
void device_name(const std::string &device_name)
Definition: wallet2.h:1485
uint64_t get_blockchain_current_height() const
Definition: wallet2.h:1227
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:145
std::vector< process_tx_entry_t > tx_entries
Definition: wallet2.h:906
uint64_t m_global_output_index
Definition: wallet2.h:409
const std::vector< uint64_t > & rct_offsets
Definition: wallet2.h:117
bool m_confirm_non_default_ring_size
Definition: wallet2.h:2030
crypto::secret_key tx_key
Definition: wallet2.h:663
A container for blockchain checkpoints.
Definition: checkpoints.h:52
~wallet_keys_unlocker()
Definition: wallet2.cpp:1132
static int priority(Level level)
Definition: easylogging++.cc:2128
void set_confirm_backlog_threshold(uint32_t threshold)
Definition: wallet2.h:1453
Definition: wallet2.h:753
std::string to_string(t_connection_type type)
Definition: connection_basic.cpp:70
void print_ring_members(bool value)
Definition: wallet2.h:1434
uint32_t m_default_priority
Definition: wallet2.h:2017
crypto::key_image key_image
Definition: wallet2.h:799
virtual void on_lw_unconfirmed_money_received(uint64_t height, const crypto::hash &txid, uint64_t amount)
Definition: wallet2.h:151
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:1180
serializable_unordered_map< crypto::hash, crypto::secret_key > m_tx_keys
Definition: wallet2.h:1975
crypto::chacha_iv iv
Definition: wallet2.h:766
bool is_multisig_enabled() const
Definition: wallet2.h:1500
std::vector< boost::optional< cryptonote::subaddress_receive_info > > received
Definition: wallet2.h:877
Definition: cryptonote_basic.h:157
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:2163
virtual void on_lw_money_received(uint64_t height, const crypto::hash &txid, uint64_t amount)
Definition: wallet2.h:150
Definition: wallet2.h:98
bool is_out_to_acc(const account_keys &acc, const crypto::public_key &output_public_key, const crypto::public_key &tx_pub_key, const std::vector< crypto::public_key > &additional_tx_pub_keys, size_t output_index, const boost::optional< crypto::view_tag > &view_tag_opt)
Definition: cryptonote_format_utils.cpp:1031
transfer_container m_transfers
Definition: wallet2.h:1979
std::vector< pending_tx > m_ptx
Definition: wallet2.h:744
bool m_track_uses
Definition: wallet2.h:2046
std::string m_proxy
Definition: wallet2.h:1966
bool is_rct() const
Definition: wallet2.h:370
#define FIELD(f)
tags the field with the variable name and then serializes it
Definition: serialization.h:169
uint32_t get_default_priority() const
Definition: wallet2.h:1439
std::set< uint32_t > unique_index_container
Definition: wallet2.h:621
bool m_key_reuse_mitigation2
Definition: wallet2.h:2041
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="POST", const std::string &req_id="0")
Definition: wallet2.h:1754
uint64_t m_amount_in
Definition: wallet2.h:493
void push_back(const crypto::hash &hash)
Definition: wallet2.h:199
cryptonote::keypair in_ephemeral
Definition: wallet2.h:336
serializable_unordered_multimap< crypto::hash, pool_payment_details > m_unconfirmed_payments
Definition: wallet2.h:1974
RefreshType m_refresh_type
Definition: wallet2.h:2018
cryptonote::transaction tx
Definition: wallet2.h:817
Definition: wallet2.h:864
Definition: wallet2.h:243
bool load_deprecated_formats() const
Definition: wallet2.h:1490
#define FIELD_N(t, f)
serializes a field f tagged t
Definition: serialization.h:158
uint8_t flags
Definition: wallet2.h:422
std::vector< std::vector< rct::key > > m_multisig_rescan_k
Definition: wallet2.h:1992
Definition: core_rpc_server_commands_defs.h:204
uint64_t get_last_block_reward() const
Definition: wallet2.h:1233
void explicit_refresh_from_block_height(bool expl)
Definition: wallet2.h:1063
crypto::public_key m_signer
Definition: wallet2.h:323
std::vector< crypto::public_key > m_additional_tx_keys
Definition: wallet2.h:425
Definition: wallet_tools.h:51
static __thread int depth
Definition: threadpool.cpp:34
BackgroundSyncType background_sync_type() const
Definition: wallet2.h:1475
bool m_key_image_partial
Definition: wallet2.h:365
std::string m_mms_file
Definition: wallet2.h:1969
error
Tracks LMDB error codes.
Definition: error.h:44
tuple message
Definition: gtest_output_test.py:331
#define const
Definition: ipfrdr.c:80
hw::device::device_type get_device_type() const
Definition: wallet2.h:1159
virtual void on_lw_money_spent(uint64_t height, const crypto::hash &txid, uint64_t amount)
Definition: wallet2.h:152
serializable_unordered_map< crypto::key_image, size_t > m_key_images
Definition: wallet2.h:1981
void ask_password(AskPasswordType ask)
Definition: wallet2.h:1444
bool check_tx_proof(const hash &prefix_hash, const public_key &R, const public_key &A, const boost::optional< public_key > &B, const public_key &D, const signature &sig, const int version)
Definition: crypto.h:269
crypto::hash m_payment_id
Definition: wallet2.h:531
uint32_t default_mixin() const
Definition: wallet2.h:1437
bool double_spend_seen
Definition: wallet2.h:821
bool m_is_initialized
Definition: wallet2.h:2054
time_t m_sent_time
Definition: wallet2.h:496
Definition: cryptonote_basic.h:204
void set_default_priority(uint32_t p)
Definition: wallet2.h:1440
Definition: wallet2.h:623
uint64_t m_internal_output_index
Definition: wallet2.h:352
#define true
Definition: stdbool.h:36
virtual void on_device_progress(const hw::device_progress &event)
Definition: wallet2.h:158
void set_min_output_count(uint32_t count)
Definition: wallet2.h:1445
std::tuple< uint64_t, uint64_t, std::vector< wallet2::exported_transfer_details > > new_transfers
Definition: wallet2.h:700
bool first_refresh_done
Definition: wallet2.h:840
serializable_unordered_map< crypto::hash, std::vector< crypto::secret_key > > m_additional_tx_keys
Definition: wallet2.h:1977
virtual ~i_wallet2_callback()
Definition: wallet2.h:161
bool invoke_http_bin(const boost::string_ref uri, const t_request &out_struct, t_response &result_struct, t_transport &transport, std::chrono::milliseconds timeout=std::chrono::seconds(15), const boost::string_ref method="POST")
Definition: http_abstract_invoke.h:76
std::string m_device_name
Definition: wallet2.h:2058
bool use_rct
Definition: wallet2.h:568
uint64_t m_amount
Definition: wallet2.h:359
static constexpr result_type min()
Definition: wallet2.h:110
Definition: device.hpp:77
bool m_spent
Definition: wallet2.h:354
Definition: wallet2.h:164
message_signature_type_t
Definition: wallet2.h:1606
bool m_trusted_daemon
Definition: wallet2.h:1999
bool auto_low_priority() const
Definition: wallet2.h:1457
bool m_ring_history_saved
Definition: wallet2.h:2088
uint64_t m_spent_height
Definition: wallet2.h:356
cryptonote::block b
Definition: block.cpp:40
uint64_t fee
Definition: wallet2.h:658
uint32_t m_subaddr_index_minor
Definition: wallet2.h:427
Definition: wallet2.h:776
crypto::secret_key get_rpc_client_secret_key() const
Definition: wallet2.h:1496
std::vector< size_t > selected_transfers
Definition: wallet2.h:565
amounts_container m_amounts
Definition: wallet2.h:450
BackgroundMiningSetupType setup_background_mining() const
Definition: wallet2.h:1480
bool m_auto_refresh
Definition: wallet2.h:2019
std::unordered_map< crypto::hash, address_tx > m_light_wallet_address_txs
Definition: wallet2.h:2083
uint64_t wallet_refresh_from_block_height
Definition: wallet2.h:845
if(!cryptonote::get_account_address_from_str_or_url(info, cryptonote::TESTNET, "9uVsvEryzpN8WH2t1WWhFFCG5tS8cBNdmJYNRuckLENFimfauV5pZKeS1P2CbxGkSDTUPHXWwiYE5ZGSXDAGbaZgDxobqDN"))
Definition: signature.cpp:53
Definition: wallet2.h:347
std::string m_ring_database
Definition: wallet2.h:2087
bool m_ignore_fractional_outputs
Definition: wallet2.h:2043
bool show_wallet_name_when_locked() const
Definition: wallet2.h:1478
void serialize(t_archive &a, const unsigned int ver)
Definition: wallet2.h:1239
bool error
Definition: wallet2.h:870
bool empty() const
Definition: wallet2.h:886
std::vector< multisig_info > m_multisig_info
Definition: wallet2.h:367
serializable_unordered_map< crypto::public_key, crypto::key_image > m_cold_key_images
Definition: wallet2.h:1993
enum tools::wallet2::unconfirmed_transfer_details::@99 m_state
static unsigned int lockers
Definition: wallet2.h:134
std::vector< std::pair< crypto::key_image, std::vector< uint64_t > > > m_rings
Definition: wallet2.h:536