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  Binary = 0,
262  };
263 
264  static const char* tr(const char* str);
265 
266  static bool has_testnet_option(const boost::program_options::variables_map& vm);
267  static bool has_stagenet_option(const boost::program_options::variables_map& vm);
268  static std::string device_name_option(const boost::program_options::variables_map& vm);
269  static std::string device_derivation_path_option(const boost::program_options::variables_map &vm);
270  static void init_options(boost::program_options::options_description& desc_params);
271 
273  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);
274 
276  static std::pair<std::unique_ptr<wallet2>, password_container>
277  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);
278 
280  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);
281 
283  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);
284 
285  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);
286  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);
287 
288  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()));
289  ~wallet2();
290 
292  {
293  struct LR
294  {
297 
299  FIELD(m_L)
300  FIELD(m_R)
301  END_SERIALIZE()
302  };
303 
304  crypto::public_key m_signer;
305  std::vector<LR> m_LR;
306  std::vector<crypto::key_image> m_partial_key_images; // one per key the participant has
307 
309  FIELD(m_signer)
310  FIELD(m_LR)
311  FIELD(m_partial_key_images)
312  END_SERIALIZE()
313  };
314 
316  {
322  bool error;
323  boost::optional<cryptonote::subaddress_receive_info> received;
324 
325  tx_scan_info_t(): amount(0), money_transfered(0), error(true) {}
326  };
327 
329  {
335  bool m_spent;
336  bool m_frozen;
338  crypto::key_image m_key_image; //TODO: key_image stored twice :(
341  bool m_rct;
343  bool m_key_image_request; // view wallets: we want to request it; cold wallets: it was requested
347  std::vector<rct::key> m_multisig_k;
348  std::vector<multisig_info> m_multisig_info; // one per other participant
349  std::vector<std::pair<uint64_t, crypto::hash>> m_uses;
350 
351  bool is_rct() const { return m_rct; }
352  uint64_t amount() const { return m_amount; }
354  crypto::public_key output_public_key;
355  THROW_WALLET_EXCEPTION_IF(m_tx.vout.size() <= m_internal_output_index,
356  error::wallet_internal_error, "Too few outputs, outputs may be corrupted");
357  THROW_WALLET_EXCEPTION_IF(!get_output_public_key(m_tx.vout[m_internal_output_index], output_public_key),
358  error::wallet_internal_error, "Unable to get output public key from output");
359  return output_public_key;
360  };
361 
363  FIELD(m_block_height)
364  FIELD(m_tx)
365  FIELD(m_txid)
366  FIELD(m_internal_output_index)
367  FIELD(m_global_output_index)
368  FIELD(m_spent)
369  FIELD(m_frozen)
370  FIELD(m_spent_height)
371  FIELD(m_key_image)
372  FIELD(m_mask)
373  FIELD(m_amount)
374  FIELD(m_rct)
375  FIELD(m_key_image_known)
376  FIELD(m_key_image_request)
377  FIELD(m_pk_index)
378  FIELD(m_subaddr_index)
379  FIELD(m_key_image_partial)
380  FIELD(m_multisig_k)
381  FIELD(m_multisig_info)
382  FIELD(m_uses)
383  END_SERIALIZE()
384  };
385 
387  {
392  union
393  {
394  struct
395  {
400  uint8_t m_key_image_request: 1; // view wallets: we want to request it; cold wallets: it was requested
402  };
404  } m_flags;
406  std::vector<crypto::public_key> m_additional_tx_keys;
409 
411  VERSION_FIELD(1)
412  if (version < 1)
413  return false;
414  FIELD(m_pubkey)
415  VARINT_FIELD(m_internal_output_index)
416  VARINT_FIELD(m_global_output_index)
417  FIELD(m_tx_pubkey)
418  FIELD(m_flags.flags)
419  VARINT_FIELD(m_amount)
420  FIELD(m_additional_tx_keys)
421  VARINT_FIELD(m_subaddr_index_major)
422  VARINT_FIELD(m_subaddr_index_minor)
423  END_SERIALIZE()
424  };
425 
426  typedef std::vector<uint64_t> amounts_container;
428  {
438 
440  VERSION_FIELD(0)
441  FIELD(m_tx_hash)
442  VARINT_FIELD(m_amount)
443  FIELD(m_amounts)
444  VARINT_FIELD(m_fee)
445  VARINT_FIELD(m_block_height)
446  VARINT_FIELD(m_unlock_time)
447  VARINT_FIELD(m_timestamp)
448  FIELD(m_coinbase)
449  FIELD(m_subaddr_index)
450  END_SERIALIZE()
451  };
452 
454  {
455  bool m_mempool;
457  };
458 
460  {
463 
465  VERSION_FIELD(0)
466  FIELD(m_pd)
467  FIELD(m_double_spend_seen)
468  END_SERIALIZE()
469  };
470 
472  {
477  time_t m_sent_time;
478  std::vector<cryptonote::tx_destination_entry> m_dests;
480  enum { pending, pending_in_pool, failed } m_state;
482  uint32_t m_subaddr_account; // subaddress account of your wallet to be used in this transfer
483  std::set<uint32_t> m_subaddr_indices; // set of address indices used as inputs in this transfer
484  std::vector<std::pair<crypto::key_image, std::vector<uint64_t>>> m_rings; // relative
485 
487  VERSION_FIELD(1)
488  FIELD(m_tx)
489  VARINT_FIELD(m_amount_in)
490  VARINT_FIELD(m_amount_out)
491  VARINT_FIELD(m_change)
492  VARINT_FIELD(m_sent_time)
493  FIELD(m_dests)
494  FIELD(m_payment_id)
495  if (version >= 1)
496  VARINT_FIELD(m_state)
497  VARINT_FIELD(m_timestamp)
498  VARINT_FIELD(m_subaddr_account)
499  FIELD(m_subaddr_indices)
500  FIELD(m_rings)
501  END_SERIALIZE()
502  };
503 
505  {
511  std::vector<cryptonote::tx_destination_entry> m_dests;
515  uint32_t m_subaddr_account; // subaddress account of your wallet to be used in this transfer
516  std::set<uint32_t> m_subaddr_indices; // set of address indices used as inputs in this transfer
517  std::vector<std::pair<crypto::key_image, std::vector<uint64_t>>> m_rings; // relative
518 
519  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) {}
521  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) {}
522 
524  VERSION_FIELD(1)
525  if (version >= 1)
526  FIELD(m_tx)
527  VARINT_FIELD(m_amount_in)
528  VARINT_FIELD(m_amount_out)
529  VARINT_FIELD(m_change)
530  VARINT_FIELD(m_block_height)
531  FIELD(m_dests)
532  FIELD(m_payment_id)
533  VARINT_FIELD(m_timestamp)
534  VARINT_FIELD(m_unlock_time)
535  VARINT_FIELD(m_subaddr_account)
536  FIELD(m_subaddr_indices)
537  FIELD(m_rings)
538  END_SERIALIZE()
539  };
540 
542  {
543  std::vector<cryptonote::tx_source_entry> sources;
545  std::vector<cryptonote::tx_destination_entry> splitted_dsts; // split, includes change
546  std::vector<size_t> selected_transfers;
547  std::vector<uint8_t> extra;
549  bool use_rct;
552  std::vector<cryptonote::tx_destination_entry> dests; // original setup, does not include change
553  uint32_t subaddr_account; // subaddress account of your wallet to be used in this transfer
554  std::set<uint32_t> subaddr_indices; // set of address indices used as inputs in this transfer
555 
557  {
558  _use_rct = 1 << 0, // 00000001
559  _use_view_tags = 1 << 1 // 00000010
560  // next flag = 1 << 2 // 00000100
561  // ...
562  // final flag = 1 << 7 // 10000000
563  };
565 
567  FIELD(sources)
568  FIELD(change_dts)
569  FIELD(splitted_dsts)
570  FIELD(selected_transfers)
571  FIELD(extra)
572  FIELD(unlock_time)
573 
574  // converted `use_rct` field into construction_flags when view tags
575  // were introduced to maintain backwards compatibility
576  if (!typename Archive<W>::is_saving())
577  {
578  FIELD_N("use_rct", construction_flags)
579  use_rct = (construction_flags & _use_rct) > 0;
580  use_view_tags = (construction_flags & _use_view_tags) > 0;
581  }
582  else
583  {
584  construction_flags = 0;
585  if (use_rct)
586  construction_flags ^= _use_rct;
587  if (use_view_tags)
588  construction_flags ^= _use_view_tags;
589 
590  FIELD_N("use_rct", construction_flags)
591  }
592 
593  FIELD(rct_config)
594  FIELD(dests)
595  FIELD(subaddr_account)
596  FIELD(subaddr_indices)
597  END_SERIALIZE()
598  };
599 
600  typedef std::vector<transfer_details> transfer_container;
602  typedef std::set<uint32_t> unique_index_container;
603 
605  {
607  std::unordered_set<crypto::public_key> ignore;
608  std::unordered_set<rct::key> used_L;
609  std::unordered_set<crypto::public_key> signing_keys;
611 
616 
618  VERSION_FIELD(1)
619  if (version < 1)
620  return false;
621  FIELD(sigs)
622  FIELD(ignore)
623  FIELD(used_L)
624  FIELD(signing_keys)
625  FIELD(msout)
626  FIELD(total_alpha_G)
627  FIELD(total_alpha_H)
628  FIELD(c_0)
629  FIELD(s)
630  END_SERIALIZE()
631  };
632 
633  // The convention for destinations is:
634  // dests does not include change
635  // splitted_dsts (in construction_data) does
636  struct pending_tx
637  {
639  uint64_t dust, fee;
642  std::vector<size_t> selected_transfers;
645  std::vector<crypto::secret_key> additional_tx_keys;
646  std::vector<cryptonote::tx_destination_entry> dests;
647  std::vector<multisig_sig> multisig_sigs;
649 
651 
653  VERSION_FIELD(1)
654  FIELD(tx)
655  FIELD(dust)
656  FIELD(fee)
657  FIELD(dust_added_to_fee)
658  FIELD(change_dts)
659  FIELD(selected_transfers)
660  FIELD(key_images)
661  FIELD(tx_key)
662  FIELD(additional_tx_keys)
663  FIELD(dests)
664  FIELD(construction_data)
665  FIELD(multisig_sigs)
666  if (version < 1)
667  {
668  multisig_tx_key_entropy = crypto::null_skey;
669  return true;
670  }
671  FIELD(multisig_tx_key_entropy)
672  END_SERIALIZE()
673  };
674 
675  // The term "Unsigned tx" is not really a tx since it's not signed yet.
676  // It doesnt have tx hash, key and the integrated address is not separated into addr + payment id.
678  {
679  std::vector<tx_construction_data> txes;
680  std::tuple<uint64_t, uint64_t, wallet2::transfer_container> transfers;
681  std::tuple<uint64_t, uint64_t, std::vector<wallet2::exported_transfer_details>> new_transfers;
682 
684  VERSION_FIELD(2)
685  FIELD(txes)
686  if (version == 0)
687  {
688  std::pair<size_t, wallet2::transfer_container> v0_transfers;
689  FIELD(v0_transfers);
690  std::get<0>(transfers) = std::get<0>(v0_transfers);
691  std::get<1>(transfers) = std::get<0>(v0_transfers) + std::get<1>(v0_transfers).size();
692  std::get<2>(transfers) = std::get<1>(v0_transfers);
693  return true;
694  }
695  if (version == 1)
696  {
697  std::pair<size_t, std::vector<wallet2::exported_transfer_details>> v1_transfers;
698  FIELD(v1_transfers);
699  std::get<0>(new_transfers) = std::get<0>(v1_transfers);
700  std::get<1>(new_transfers) = std::get<0>(v1_transfers) + std::get<1>(v1_transfers).size();
701  std::get<2>(new_transfers) = std::get<1>(v1_transfers);
702  return true;
703  }
704 
705  FIELD(new_transfers)
706  END_SERIALIZE()
707  };
708 
710  {
711  std::vector<pending_tx> ptx;
712  std::vector<crypto::key_image> key_images;
714 
716  VERSION_FIELD(0)
717  FIELD(ptx)
718  FIELD(key_images)
719  FIELD(tx_key_images)
720  END_SERIALIZE()
721  };
722 
724  {
725  std::vector<pending_tx> m_ptx;
726  std::unordered_set<crypto::public_key> m_signers;
727 
729  FIELD(m_ptx)
730  FIELD(m_signers)
731  END_SERIALIZE()
732  };
733 
735  {
736  crypto::chacha_iv iv;
738 
740  FIELD(iv)
741  FIELD(account_data)
742  END_SERIALIZE()
743  };
744 
746  {
747  crypto::chacha_iv iv;
749 
751  FIELD(iv)
752  FIELD(cache_data)
753  END_SERIALIZE()
754  };
755 
756  // GUI Address book
758  {
764 
766  VERSION_FIELD(0)
767  FIELD(m_address)
768  FIELD(m_payment_id)
769  FIELD(m_description)
770  FIELD(m_is_subaddress)
771  FIELD(m_has_payment_id)
772  END_SERIALIZE()
773  };
774 
776  {
783 
785  VERSION_FIELD(0)
786  FIELD(txid)
787  VARINT_FIELD(index_in_tx)
788  FIELD(shared_secret)
790  FIELD(shared_secret_sig)
791  FIELD(key_image_sig)
792  END_SERIALIZE()
793  };
794 
796 
798  {
801  std::vector<cryptonote::transaction> txes;
803  bool error;
804  };
805 
806  struct is_out_data
807  {
810  std::vector<boost::optional<cryptonote::subaddress_receive_info>> received;
811  };
812 
814  {
815  std::vector<cryptonote::tx_extra_field> tx_extra_fields;
816  std::vector<is_out_data> primary;
817  std::vector<is_out_data> additional;
818 
819  bool empty() const { return tx_extra_fields.empty() && primary.empty() && additional.empty(); }
820  };
821 
823  {
826  std::unordered_set<crypto::hash> detached_tx_hashes;
827  std::unordered_map<crypto::hash, std::vector<cryptonote::tx_destination_entry>> detached_confirmed_txs_dests;
828  };
829 
831  {
835  };
836 
838  {
839  std::vector<process_tx_entry_t> tx_entries;
842 
843  tx_entry_data(): lowest_height((uint64_t)-1), highest_height(0) {}
844  };
845 
854  void generate(const std::string& wallet_, const epee::wipeable_string& password,
855  const epee::wipeable_string& multisig_data, bool create_address_file = false);
856 
868  const crypto::secret_key& recovery_param = crypto::secret_key(), bool recover = false,
869  bool two_random = false, bool create_address_file = false);
879  void generate(const std::string& wallet, const epee::wipeable_string& password,
880  const cryptonote::account_public_address &account_public_address,
881  const crypto::secret_key& spendkey, const crypto::secret_key& viewkey, bool create_address_file = false);
890  void generate(const std::string& wallet, const epee::wipeable_string& password,
891  const cryptonote::account_public_address &account_public_address,
892  const crypto::secret_key& viewkey = crypto::secret_key(), bool create_address_file = false);
900  void restore(const std::string& wallet_, const epee::wipeable_string& password, const std::string &device_name, bool create_address_file = false);
901 
907  std::string make_multisig(const epee::wipeable_string &password,
908  const std::vector<std::string> &kex_messages,
909  const std::uint32_t threshold);
915  std::string exchange_multisig_keys(const epee::wipeable_string &password,
916  const std::vector<std::string> &kex_messages,
917  const bool force_update_use_with_caution = false);
922  std::string get_multisig_first_kex_msg() const;
927  cryptonote::blobdata export_multisig();
932  size_t import_multisig(std::vector<cryptonote::blobdata> info);
938  void rewrite(const std::string& wallet_name, const epee::wipeable_string& password);
939  void write_watch_only_wallet(const std::string& wallet_name, const epee::wipeable_string& password, std::string &new_keys_filename);
940  void load(const std::string& wallet, const epee::wipeable_string& password, const std::string& keys_buf = "", const std::string& cache_buf = "");
941  void store();
957  void store_to(const std::string &path, const epee::wipeable_string &password, bool force_rewrite_keys = false);
965  boost::optional<wallet2::keys_file_data> get_keys_file_data(const epee::wipeable_string& password, bool watch_only);
970  boost::optional<wallet2::cache_file_data> get_cache_file_data();
971 
972  std::string path() const;
973 
977  bool verify_password(const epee::wipeable_string& password);
978  cryptonote::account_base& get_account(){return m_account;}
979  const cryptonote::account_base& get_account()const{return m_account;}
980 
981  void encrypt_keys(const crypto::chacha_key &key);
982  void encrypt_keys(const epee::wipeable_string &password);
983  void decrypt_keys(const crypto::chacha_key &key);
984  void decrypt_keys(const epee::wipeable_string &password);
985 
986  void set_refresh_from_block_height(uint64_t height) {m_refresh_from_block_height = height;}
987  uint64_t get_refresh_from_block_height() const {return m_refresh_from_block_height;}
988 
989  void explicit_refresh_from_block_height(bool expl) {m_explicit_refresh_from_block_height = expl;}
990  bool explicit_refresh_from_block_height() const {return m_explicit_refresh_from_block_height;}
991 
992  void max_reorg_depth(uint64_t depth) {m_max_reorg_depth = depth;}
993  uint64_t max_reorg_depth() const {return m_max_reorg_depth;}
994 
995  bool deinit();
996  bool init(std::string daemon_address = "http://localhost:8080",
997  boost::optional<epee::net_utils::http::login> daemon_login = boost::none,
998  const std::string &proxy = "",
999  uint64_t upper_transaction_weight_limit = 0,
1000  bool trusted_daemon = true,
1002  bool set_daemon(std::string daemon_address = "http://localhost:8080",
1003  boost::optional<epee::net_utils::http::login> daemon_login = boost::none, bool trusted_daemon = true,
1005  bool set_proxy(const std::string &address);
1006 
1007  void stop() { m_run.store(false, std::memory_order_relaxed); m_message_store.stop(); }
1008 
1009  i_wallet2_callback* callback() const { return m_callback; }
1010  void callback(i_wallet2_callback* callback) { m_callback = callback; }
1011 
1012  bool is_trusted_daemon() const { return m_trusted_daemon; }
1013  void set_trusted_daemon(bool trusted) { m_trusted_daemon = trusted; }
1014 
1018  bool is_deterministic() const;
1019  bool get_seed(epee::wipeable_string& electrum_words, const epee::wipeable_string &passphrase = epee::wipeable_string()) const;
1020 
1024  bool light_wallet() const { return m_light_wallet; }
1025  void set_light_wallet(bool light_wallet) { m_light_wallet = light_wallet; }
1026  uint64_t get_light_wallet_scanned_block_height() const { return m_light_wallet_scanned_block_height; }
1027  uint64_t get_light_wallet_blockchain_height() const { return m_light_wallet_blockchain_height; }
1028 
1032  const std::string &get_seed_language() const;
1036  void set_seed_language(const std::string &language);
1037 
1038  // Subaddress scheme
1039  cryptonote::account_public_address get_subaddress(const cryptonote::subaddress_index& index) const;
1040  cryptonote::account_public_address get_address() const { return get_subaddress({0,0}); }
1041  boost::optional<cryptonote::subaddress_index> get_subaddress_index(const cryptonote::account_public_address& address) const;
1042  crypto::public_key get_subaddress_spend_public_key(const cryptonote::subaddress_index& index) const;
1043  std::vector<crypto::public_key> get_subaddress_spend_public_keys(uint32_t account, uint32_t begin, uint32_t end) const;
1044  std::string get_subaddress_as_str(const cryptonote::subaddress_index& index) const;
1045  std::string get_address_as_str() const { return get_subaddress_as_str({0, 0}); }
1046  std::string get_integrated_address_as_str(const crypto::hash8& payment_id) const;
1047  void add_subaddress_account(const std::string& label);
1048  size_t get_num_subaddress_accounts() const { return m_subaddress_labels.size(); }
1049  size_t get_num_subaddresses(uint32_t index_major) const { return index_major < m_subaddress_labels.size() ? m_subaddress_labels[index_major].size() : 0; }
1050  void add_subaddress(uint32_t index_major, const std::string& label); // throws when index is out of bound
1051  void expand_subaddresses(const cryptonote::subaddress_index& index);
1052  void create_one_off_subaddress(const cryptonote::subaddress_index& index);
1053  std::string get_subaddress_label(const cryptonote::subaddress_index& index) const;
1054  void set_subaddress_label(const cryptonote::subaddress_index &index, const std::string &label);
1055  void set_subaddress_lookahead(size_t major, size_t minor);
1056  std::pair<size_t, size_t> get_subaddress_lookahead() const { return {m_subaddress_lookahead_major, m_subaddress_lookahead_minor}; }
1060  bool is_deprecated() const;
1061  void refresh(bool trusted_daemon);
1062  void refresh(bool trusted_daemon, uint64_t start_height, uint64_t & blocks_fetched);
1063  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());
1064  bool refresh(bool trusted_daemon, uint64_t & blocks_fetched, bool& received_money, bool& ok);
1065 
1066  void set_refresh_type(RefreshType refresh_type) { m_refresh_type = refresh_type; }
1067  RefreshType get_refresh_type() const { return m_refresh_type; }
1068 
1069  cryptonote::network_type nettype() const { return m_nettype; }
1070  bool watch_only() const { return m_watch_only; }
1071  bool multisig(bool *ready = NULL, uint32_t *threshold = NULL, uint32_t *total = NULL) const;
1072  bool has_multisig_partial_key_images() const;
1073  bool has_unknown_key_images() const;
1074  bool get_multisig_seed(epee::wipeable_string& seed, const epee::wipeable_string &passphrase = std::string()) const;
1075  bool key_on_device() const { return get_device_type() != hw::device::device_type::SOFTWARE; }
1076  hw::device::device_type get_device_type() const { return m_key_device_type; }
1077  bool reconnect_device();
1078 
1079  // locked & unlocked balance of given or current subaddress account
1080  uint64_t balance(uint32_t subaddr_index_major, bool strict) const;
1081  uint64_t unlocked_balance(uint32_t subaddr_index_major, bool strict, uint64_t *blocks_to_unlock = NULL, uint64_t *time_to_unlock = NULL);
1082  // locked & unlocked balance per subaddress of given or current subaddress account
1083  std::map<uint32_t, uint64_t> balance_per_subaddress(uint32_t subaddr_index_major, bool strict) const;
1084  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);
1085  // all locked & unlocked balances of all subaddress accounts
1086  uint64_t balance_all(bool strict) const;
1087  uint64_t unlocked_balance_all(bool strict, uint64_t *blocks_to_unlock = NULL, uint64_t *time_to_unlock = NULL);
1088  template<typename T>
1089  void transfer_selected(const std::vector<cryptonote::tx_destination_entry>& dsts, const std::vector<size_t>& selected_transfers, size_t fake_outputs_count,
1090  std::vector<std::vector<tools::wallet2::get_outs_entry>> &outs, std::unordered_set<crypto::public_key> &valid_public_keys_cache,
1091  uint64_t unlock_time, uint64_t fee, const std::vector<uint8_t>& extra, T destination_split_strategy, const tx_dust_policy& dust_policy, cryptonote::transaction& tx, pending_tx &ptx, const bool use_view_tags);
1092  void transfer_selected_rct(std::vector<cryptonote::tx_destination_entry> dsts, const std::vector<size_t>& selected_transfers, size_t fake_outputs_count,
1093  std::vector<std::vector<tools::wallet2::get_outs_entry>> &outs, std::unordered_set<crypto::public_key> &valid_public_keys_cache,
1094  uint64_t unlock_time, 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);
1095 
1096  void commit_tx(pending_tx& ptx_vector);
1097  void commit_tx(std::vector<pending_tx>& ptx_vector);
1098  bool save_tx(const std::vector<pending_tx>& ptx_vector, const std::string &filename) const;
1099  std::string dump_tx_to_str(const std::vector<pending_tx> &ptx_vector) const;
1100  std::string save_multisig_tx(multisig_tx_set txs);
1101  bool save_multisig_tx(const multisig_tx_set &txs, const std::string &filename);
1102  std::string save_multisig_tx(const std::vector<pending_tx>& ptx_vector);
1103  bool save_multisig_tx(const std::vector<pending_tx>& ptx_vector, const std::string &filename);
1104  multisig_tx_set make_multisig_tx_set(const std::vector<pending_tx>& ptx_vector) const;
1105  // load unsigned tx from file and sign it. Takes confirmation callback as argument. Used by the cli wallet
1106  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);
1107  // sign unsigned tx. Takes unsigned_tx_set as argument. Used by GUI
1108  bool sign_tx(unsigned_tx_set &exported_txs, const std::string &signed_filename, std::vector<wallet2::pending_tx> &ptx, bool export_raw = false);
1109  bool sign_tx(unsigned_tx_set &exported_txs, std::vector<wallet2::pending_tx> &ptx, signed_tx_set &signed_txs);
1110  std::string sign_tx_dump_to_str(unsigned_tx_set &exported_txs, std::vector<wallet2::pending_tx> &ptx, signed_tx_set &signed_txes);
1111  // load unsigned_tx_set from file.
1112  bool load_unsigned_tx(const std::string &unsigned_filename, unsigned_tx_set &exported_txs) const;
1113  bool parse_unsigned_tx_from_str(const std::string &unsigned_tx_st, unsigned_tx_set &exported_txs) const;
1114  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);
1115  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);
1116  std::vector<wallet2::pending_tx> create_transactions_2(std::vector<cryptonote::tx_destination_entry> dsts, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector<uint8_t>& extra, uint32_t subaddr_account, std::set<uint32_t> subaddr_indices, const unique_index_container& subtract_fee_from_outputs = {}); // pass subaddr_indices by value on purpose
1117  std::vector<wallet2::pending_tx> create_transactions_all(uint64_t below, const cryptonote::account_public_address &address, bool is_subaddress, const size_t outputs, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector<uint8_t>& extra, uint32_t subaddr_account, std::set<uint32_t> subaddr_indices);
1118  std::vector<wallet2::pending_tx> create_transactions_single(const crypto::key_image &ki, const cryptonote::account_public_address &address, bool is_subaddress, const size_t outputs, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector<uint8_t>& extra);
1119  std::vector<wallet2::pending_tx> create_transactions_from(const cryptonote::account_public_address &address, bool is_subaddress, const size_t outputs, std::vector<size_t> unused_transfers_indices, std::vector<size_t> unused_dust_indices, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector<uint8_t>& extra);
1120  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;
1121  void cold_tx_aux_import(const std::vector<pending_tx>& ptx, const std::vector<std::string>& tx_device_aux);
1122  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);
1123  uint64_t cold_key_image_sync(uint64_t &spent, uint64_t &unspent);
1124  void device_show_address(uint32_t account_index, uint32_t address_index, const boost::optional<crypto::hash8> &payment_id);
1125  bool parse_multisig_tx_from_str(std::string multisig_tx_st, multisig_tx_set &exported_txs) const;
1126  bool load_multisig_tx(cryptonote::blobdata blob, multisig_tx_set &exported_txs, std::function<bool(const multisig_tx_set&)> accept_func = NULL);
1127  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);
1128  bool sign_multisig_tx_from_file(const std::string &filename, std::vector<crypto::hash> &txids, std::function<bool(const multisig_tx_set&)> accept_func);
1129  bool sign_multisig_tx(multisig_tx_set &exported_txs, std::vector<crypto::hash> &txids);
1130  bool sign_multisig_tx_to_file(multisig_tx_set &exported_txs, const std::string &filename, std::vector<crypto::hash> &txids);
1131  std::vector<pending_tx> create_unmixable_sweep_transactions();
1132  void discard_unmixable_outputs();
1133  bool check_connection(uint32_t *version = NULL, bool *ssl = NULL, uint32_t timeout = 200000, bool *wallet_is_outdated = NULL, bool *daemon_is_outdated = NULL);
1134  bool check_version(uint32_t *version, bool *wallet_is_outdated, bool *daemon_is_outdated);
1135  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);
1136  void get_transfers(wallet2::transfer_container& incoming_transfers) const;
1137  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;
1138  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;
1139  void get_payments_out(std::list<std::pair<crypto::hash,wallet2::confirmed_transfer_details>>& confirmed_payments,
1140  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;
1141  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;
1142  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;
1143 
1144  uint64_t get_blockchain_current_height() const { return m_light_wallet_blockchain_height ? m_light_wallet_blockchain_height : m_blockchain.size(); }
1145  void rescan_spent();
1146  void rescan_blockchain(bool hard, bool refresh = true, bool keep_key_images = false);
1147  bool is_transfer_unlocked(const transfer_details& td);
1148  bool is_transfer_unlocked(uint64_t unlock_time, uint64_t block_height);
1149 
1150  uint64_t get_last_block_reward() const { return m_last_block_reward; }
1151  uint64_t get_device_last_key_image_sync() const { return m_device_last_key_image_sync; }
1152 
1153  std::vector<cryptonote::public_node> get_public_nodes(bool white_only = true);
1154 
1155  template <class t_archive>
1156  inline void serialize(t_archive &a, const unsigned int ver)
1157  {
1158  uint64_t dummy_refresh_height = 0; // moved to keys file
1159  if(ver < 5)
1160  return;
1161  if (ver < 19)
1162  {
1163  std::vector<crypto::hash> blockchain;
1164  a & blockchain;
1165  m_blockchain.clear();
1166  for (const auto &b: blockchain)
1167  {
1168  m_blockchain.push_back(b);
1169  }
1170  }
1171  else
1172  {
1173  a & m_blockchain;
1174  }
1175  a & m_transfers;
1176  a & m_account_public_address;
1177  a & m_key_images.parent();
1178  if(ver < 6)
1179  return;
1180  a & m_unconfirmed_txs.parent();
1181  if(ver < 7)
1182  return;
1183  a & m_payments.parent();
1184  if(ver < 8)
1185  return;
1186  a & m_tx_keys.parent();
1187  if(ver < 9)
1188  return;
1189  a & m_confirmed_txs.parent();
1190  if(ver < 11)
1191  return;
1192  a & dummy_refresh_height;
1193  if(ver < 12)
1194  return;
1195  a & m_tx_notes.parent();
1196  if(ver < 13)
1197  return;
1198  if (ver < 17)
1199  {
1200  // we're loading an old version, where m_unconfirmed_payments was a std::map
1201  std::unordered_map<crypto::hash, payment_details> m;
1202  a & m;
1203  m_unconfirmed_payments.clear();
1204  for (std::unordered_map<crypto::hash, payment_details>::const_iterator i = m.begin(); i != m.end(); ++i)
1205  m_unconfirmed_payments.insert(std::make_pair(i->first, pool_payment_details{i->second, false}));
1206  }
1207  if(ver < 14)
1208  return;
1209  if(ver < 15)
1210  {
1211  // we're loading an older wallet without a pubkey map, rebuild it
1212  m_pub_keys.clear();
1213  for (size_t i = 0; i < m_transfers.size(); ++i)
1214  {
1215  const transfer_details &td = m_transfers[i];
1216  m_pub_keys.emplace(td.get_public_key(), i);
1217  }
1218  return;
1219  }
1220  a & m_pub_keys.parent();
1221  if(ver < 16)
1222  return;
1223  a & m_address_book;
1224  if(ver < 17)
1225  return;
1226  if (ver < 22)
1227  {
1228  // we're loading an old version, where m_unconfirmed_payments payload was payment_details
1229  std::unordered_multimap<crypto::hash, payment_details> m;
1230  a & m;
1231  m_unconfirmed_payments.clear();
1232  for (const auto &i: m)
1233  m_unconfirmed_payments.insert(std::make_pair(i.first, pool_payment_details{i.second, false}));
1234  }
1235  if(ver < 18)
1236  return;
1237  a & m_scanned_pool_txs[0];
1238  a & m_scanned_pool_txs[1];
1239  if (ver < 20)
1240  return;
1241  a & m_subaddresses.parent();
1242  std::unordered_map<cryptonote::subaddress_index, crypto::public_key> dummy_subaddresses_inv;
1243  a & dummy_subaddresses_inv;
1244  a & m_subaddress_labels;
1245  a & m_additional_tx_keys.parent();
1246  if(ver < 21)
1247  return;
1248  a & m_attributes.parent();
1249  if(ver < 22)
1250  return;
1251  a & m_unconfirmed_payments.parent();
1252  if(ver < 23)
1253  return;
1254  a & (std::pair<std::map<std::string, std::string>, std::vector<std::string>>&)m_account_tags;
1255  if(ver < 24)
1256  return;
1257  a & m_ring_history_saved;
1258  if(ver < 25)
1259  return;
1260  a & m_last_block_reward;
1261  if(ver < 26)
1262  return;
1263  a & m_tx_device.parent();
1264  if(ver < 27)
1265  return;
1266  a & m_device_last_key_image_sync;
1267  if(ver < 28)
1268  return;
1269  a & m_cold_key_images.parent();
1270  if(ver < 29)
1271  return;
1272  a & m_rpc_client_secret_key;
1273  if(ver < 30)
1274  {
1275  m_has_ever_refreshed_from_node = false;
1276  return;
1277  }
1278  a & m_has_ever_refreshed_from_node;
1279  }
1280 
1282  MAGIC_FIELD("monero wallet cache")
1283  VERSION_FIELD(1)
1285  FIELD(m_transfers)
1286  FIELD(m_account_public_address)
1287  FIELD(m_key_images)
1288  FIELD(m_unconfirmed_txs)
1289  FIELD(m_payments)
1290  FIELD(m_tx_keys)
1291  FIELD(m_confirmed_txs)
1292  FIELD(m_tx_notes)
1293  FIELD(m_unconfirmed_payments)
1294  FIELD(m_pub_keys)
1295  FIELD(m_address_book)
1296  FIELD(m_scanned_pool_txs[0])
1297  FIELD(m_scanned_pool_txs[1])
1298  FIELD(m_subaddresses)
1299  FIELD(m_subaddress_labels)
1300  FIELD(m_additional_tx_keys)
1301  FIELD(m_attributes)
1302  FIELD(m_account_tags)
1303  FIELD(m_ring_history_saved)
1304  FIELD(m_last_block_reward)
1305  FIELD(m_tx_device)
1306  FIELD(m_device_last_key_image_sync)
1307  FIELD(m_cold_key_images)
1308  FIELD(m_rpc_client_secret_key)
1309  if (version < 1)
1310  {
1311  m_has_ever_refreshed_from_node = false;
1312  return true;
1313  }
1314  FIELD(m_has_ever_refreshed_from_node)
1315  END_SERIALIZE()
1316 
1317 
1323  static void wallet_exists(const std::string& file_path, bool& keys_file_exists, bool& wallet_file_exists);
1329  static bool wallet_valid_path_format(const std::string& file_path);
1330  static bool parse_long_payment_id(const std::string& payment_id_str, crypto::hash& payment_id);
1331  static bool parse_short_payment_id(const std::string& payment_id_str, crypto::hash8& payment_id);
1332  static bool parse_payment_id(const std::string& payment_id_str, crypto::hash& payment_id);
1333 
1334  bool always_confirm_transfers() const { return m_always_confirm_transfers; }
1335  void always_confirm_transfers(bool always) { m_always_confirm_transfers = always; }
1336  bool print_ring_members() const { return m_print_ring_members; }
1337  void print_ring_members(bool value) { m_print_ring_members = value; }
1338  bool store_tx_info() const { return m_store_tx_info; }
1339  void store_tx_info(bool store) { m_store_tx_info = store; }
1340  uint32_t default_mixin() const { return m_default_mixin; }
1341  void default_mixin(uint32_t m) { m_default_mixin = m; }
1342  uint32_t get_default_priority() const { return m_default_priority; }
1343  void set_default_priority(uint32_t p) { m_default_priority = p; }
1344  bool auto_refresh() const { return m_auto_refresh; }
1345  void auto_refresh(bool r) { m_auto_refresh = r; }
1346  AskPasswordType ask_password() const { return m_ask_password; }
1347  void ask_password(AskPasswordType ask) { m_ask_password = ask; }
1348  void set_min_output_count(uint32_t count) { m_min_output_count = count; }
1349  uint32_t get_min_output_count() const { return m_min_output_count; }
1350  void set_min_output_value(uint64_t value) { m_min_output_value = value; }
1351  uint64_t get_min_output_value() const { return m_min_output_value; }
1352  void merge_destinations(bool merge) { m_merge_destinations = merge; }
1353  bool merge_destinations() const { return m_merge_destinations; }
1354  bool confirm_backlog() const { return m_confirm_backlog; }
1355  void confirm_backlog(bool always) { m_confirm_backlog = always; }
1356  void set_confirm_backlog_threshold(uint32_t threshold) { m_confirm_backlog_threshold = threshold; };
1357  uint32_t get_confirm_backlog_threshold() const { return m_confirm_backlog_threshold; };
1358  bool confirm_export_overwrite() const { return m_confirm_export_overwrite; }
1359  void confirm_export_overwrite(bool always) { m_confirm_export_overwrite = always; }
1360  bool auto_low_priority() const { return m_auto_low_priority; }
1361  void auto_low_priority(bool value) { m_auto_low_priority = value; }
1362  bool segregate_pre_fork_outputs() const { return m_segregate_pre_fork_outputs; }
1363  void segregate_pre_fork_outputs(bool value) { m_segregate_pre_fork_outputs = value; }
1364  bool key_reuse_mitigation2() const { return m_key_reuse_mitigation2; }
1365  void key_reuse_mitigation2(bool value) { m_key_reuse_mitigation2 = value; }
1366  uint64_t segregation_height() const { return m_segregation_height; }
1367  void segregation_height(uint64_t height) { m_segregation_height = height; }
1368  bool ignore_fractional_outputs() const { return m_ignore_fractional_outputs; }
1369  void ignore_fractional_outputs(bool value) { m_ignore_fractional_outputs = value; }
1370  bool confirm_non_default_ring_size() const { return m_confirm_non_default_ring_size; }
1371  void confirm_non_default_ring_size(bool always) { m_confirm_non_default_ring_size = always; }
1372  uint64_t ignore_outputs_above() const { return m_ignore_outputs_above; }
1373  void ignore_outputs_above(uint64_t value) { m_ignore_outputs_above = value; }
1374  uint64_t ignore_outputs_below() const { return m_ignore_outputs_below; }
1375  void ignore_outputs_below(uint64_t value) { m_ignore_outputs_below = value; }
1376  bool track_uses() const { return m_track_uses; }
1377  void track_uses(bool value) { m_track_uses = value; }
1378  bool show_wallet_name_when_locked() const { return m_show_wallet_name_when_locked; }
1379  void show_wallet_name_when_locked(bool value) { m_show_wallet_name_when_locked = value; }
1380  BackgroundMiningSetupType setup_background_mining() const { return m_setup_background_mining; }
1381  void setup_background_mining(BackgroundMiningSetupType value) { m_setup_background_mining = value; }
1382  uint32_t inactivity_lock_timeout() const { return m_inactivity_lock_timeout; }
1383  void inactivity_lock_timeout(uint32_t seconds) { m_inactivity_lock_timeout = seconds; }
1384  const std::string & device_name() const { return m_device_name; }
1385  void device_name(const std::string & device_name) { m_device_name = device_name; }
1386  const std::string & device_derivation_path() const { return m_device_derivation_path; }
1387  void device_derivation_path(const std::string &device_derivation_path) { m_device_derivation_path = device_derivation_path; }
1388  const ExportFormat & export_format() const { return m_export_format; }
1389  inline void set_export_format(const ExportFormat& export_format) { m_export_format = export_format; }
1390  bool load_deprecated_formats() const { return m_load_deprecated_formats; }
1391  void load_deprecated_formats(bool load) { m_load_deprecated_formats = load; }
1392  bool persistent_rpc_client_id() const { return m_persistent_rpc_client_id; }
1393  void persistent_rpc_client_id(bool persistent) { m_persistent_rpc_client_id = persistent; }
1394  void auto_mine_for_rpc_payment_threshold(float threshold) { m_auto_mine_for_rpc_payment_threshold = threshold; }
1395  float auto_mine_for_rpc_payment_threshold() const { return m_auto_mine_for_rpc_payment_threshold; }
1396  crypto::secret_key get_rpc_client_secret_key() const { return m_rpc_client_secret_key; }
1397  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); }
1398  uint64_t credits_target() const { return m_credits_target; }
1399  void credits_target(uint64_t threshold) { m_credits_target = threshold; }
1400  bool is_multisig_enabled() const { return m_enable_multisig; }
1401  void enable_multisig(bool enable) { m_enable_multisig = enable; }
1402  bool is_mismatched_daemon_version_allowed() const { return m_allow_mismatched_daemon_version; }
1403  void allow_mismatched_daemon_version(bool allow_mismatch) { m_allow_mismatched_daemon_version = allow_mismatch; }
1404 
1405  bool get_tx_key_cached(const crypto::hash &txid, crypto::secret_key &tx_key, std::vector<crypto::secret_key> &additional_tx_keys) const;
1406  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);
1407  bool get_tx_key(const crypto::hash &txid, crypto::secret_key &tx_key, std::vector<crypto::secret_key> &additional_tx_keys);
1408  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);
1409  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);
1410  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;
1411  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;
1412  std::string get_tx_proof(const crypto::hash &txid, const cryptonote::account_public_address &address, bool is_subaddress, const std::string &message);
1413  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;
1414  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);
1415  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;
1416 
1417  std::string get_spend_proof(const crypto::hash &txid, const std::string &message);
1418  bool check_spend_proof(const crypto::hash &txid, const std::string &message, const std::string &sig_str);
1419 
1420  void scan_tx(const std::unordered_set<crypto::hash> &txids);
1421 
1429  std::string get_reserve_proof(const boost::optional<std::pair<uint32_t, uint64_t>> &account_minreserve, const std::string &message);
1439  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);
1440 
1444  std::vector<address_book_row> get_address_book() const { return m_address_book; }
1445  bool add_address_book_row(const cryptonote::account_public_address &address, const crypto::hash8 *payment_id, const std::string &description, bool is_subaddress);
1446  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);
1447  bool delete_address_book_row(std::size_t row_id);
1448 
1449  uint64_t get_num_rct_outputs();
1450  size_t get_num_transfer_details() const { return m_transfers.size(); }
1451  const transfer_details &get_transfer_details(size_t idx) const;
1452 
1453  uint8_t get_current_hard_fork();
1454  void get_hard_fork_info(uint8_t version, uint64_t &earliest_height);
1455  bool use_fork_rules(uint8_t version, int64_t early_blocks = 0);
1456  int get_fee_algorithm();
1457 
1458  std::string get_wallet_file() const;
1459  std::string get_keys_file() const;
1460  std::string get_daemon_address() const;
1461  const boost::optional<epee::net_utils::http::login>& get_daemon_login() const { return m_daemon_login; }
1462  uint64_t get_daemon_blockchain_height(std::string& err);
1463  uint64_t get_daemon_blockchain_target_height(std::string& err);
1464  uint64_t get_daemon_adjusted_time();
1465 
1469  uint64_t get_approximate_blockchain_height() const;
1470  uint64_t estimate_blockchain_height();
1471  std::vector<size_t> select_available_outputs_from_histogram(uint64_t count, bool atleast, bool unlocked, bool allow_rct);
1472  std::vector<size_t> select_available_outputs(const std::function<bool(const transfer_details &td)> &f);
1473  std::vector<size_t> select_available_unmixable_outputs();
1474  std::vector<size_t> select_available_mixable_outputs();
1475 
1476  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;
1477  size_t pop_best_value(std::vector<size_t> &unused_dust_indices, const std::vector<size_t>& selected_transfers, bool smallest = false) const;
1478 
1479  void set_tx_note(const crypto::hash &txid, const std::string &note);
1480  std::string get_tx_note(const crypto::hash &txid) const;
1481 
1482  void set_tx_device_aux(const crypto::hash &txid, const std::string &aux);
1483  std::string get_tx_device_aux(const crypto::hash &txid) const;
1484 
1485  void set_description(const std::string &description);
1486  std::string get_description() const;
1487 
1492  const std::pair<serializable_map<std::string, std::string>, std::vector<std::string>>& get_account_tags();
1498  void set_account_tag(const std::set<uint32_t> &account_indices, const std::string& tag);
1504  void set_account_tag_description(const std::string& tag, const std::string& description);
1505 
1506  enum message_signature_type_t { sign_with_spend_key, sign_with_view_key };
1507  std::string sign(const std::string &data, message_signature_type_t signature_type, cryptonote::subaddress_index index = {0, 0}) const;
1508  struct message_signature_result_t { bool valid; unsigned version; bool old; message_signature_type_t type; };
1510 
1517  std::string sign_multisig_participant(const std::string& data) const;
1525  bool verify_with_public_key(const std::string &data, const crypto::public_key &public_key, const std::string &signature) const;
1526 
1527  // Import/Export wallet data
1528  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;
1529  std::string export_outputs_to_str(bool all = false, uint32_t start = 0, uint32_t count = 0xffffffff) const;
1530  size_t import_outputs(const std::tuple<uint64_t, uint64_t, std::vector<tools::wallet2::exported_transfer_details>> &outputs);
1531  size_t import_outputs(const std::tuple<uint64_t, uint64_t, std::vector<tools::wallet2::transfer_details>> &outputs);
1532  size_t import_outputs_from_str(const std::string &outputs_st);
1533  payment_container export_payments() const;
1534  void import_payments(const payment_container &payments);
1535  void import_payments_out(const std::list<std::pair<crypto::hash,wallet2::confirmed_transfer_details>> &confirmed_payments);
1536  std::tuple<size_t, crypto::hash, std::vector<crypto::hash>> export_blockchain() const;
1537  void import_blockchain(const std::tuple<size_t, crypto::hash, std::vector<crypto::hash>> &bc);
1538  bool export_key_images(const std::string &filename, bool all = false) const;
1539  std::pair<uint64_t, std::vector<std::pair<crypto::key_image, crypto::signature>>> export_key_images(bool all = false) const;
1540  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);
1541  uint64_t import_key_images(const std::string &filename, uint64_t &spent, uint64_t &unspent);
1542  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);
1543  bool import_key_images(signed_tx_set & signed_tx, size_t offset=0, bool only_selected_transfers=false);
1545 
1546  void update_pool_state(std::vector<std::tuple<cryptonote::transaction, crypto::hash, bool>> &process_txs, bool refreshed = false, bool try_incremental = false);
1547  void process_pool_state(const std::vector<std::tuple<cryptonote::transaction, crypto::hash, bool>> &txs);
1548  void remove_obsolete_pool_txs(const std::vector<crypto::hash> &tx_hashes, bool remove_if_found);
1549 
1550  std::string encrypt(const char *plaintext, size_t len, const crypto::secret_key &skey, bool authenticated = true) const;
1551  std::string encrypt(const epee::span<char> &span, const crypto::secret_key &skey, bool authenticated = true) const;
1552  std::string encrypt(const std::string &plaintext, const crypto::secret_key &skey, bool authenticated = true) const;
1553  std::string encrypt(const epee::wipeable_string &plaintext, const crypto::secret_key &skey, bool authenticated = true) const;
1554  std::string encrypt_with_view_secret_key(const std::string &plaintext, bool authenticated = true) const;
1555  template<typename T=std::string> T decrypt(const std::string &ciphertext, const crypto::secret_key &skey, bool authenticated = true) const;
1556  std::string decrypt_with_view_secret_key(const std::string &ciphertext, bool authenticated = true) const;
1557 
1558  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;
1559  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);
1560 
1561  uint64_t get_blockchain_height_by_date(uint16_t year, uint8_t month, uint8_t day); // 1<=month<=12, 1<=day<=31
1562 
1563  bool is_synced();
1564 
1565  std::vector<std::pair<uint64_t, uint64_t>> estimate_backlog(const std::vector<std::pair<double, double>> &fee_levels);
1566  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);
1567 
1568  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) const;
1569  uint64_t get_fee_multiplier(uint32_t priority, int fee_algorithm = -1);
1570  uint64_t get_base_fee(uint32_t priority);
1571  uint64_t get_base_fee();
1572  uint64_t get_fee_quantization_mask();
1573  uint64_t get_min_ring_size();
1574  uint64_t get_max_ring_size();
1575  uint64_t adjust_mixin(uint64_t mixin);
1576 
1577  uint32_t adjust_priority(uint32_t priority);
1578 
1579  bool is_unattended() const { return m_unattended; }
1580 
1581  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);
1582 
1583  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);
1584  bool daemon_requires_payment();
1585  bool make_rpc_payment(uint32_t nonce, uint32_t cookie, uint64_t &credits, uint64_t &balance);
1586  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);
1587  template<typename T> void handle_payment_changes(const T &res, std::true_type) {
1588  if (res.status == CORE_RPC_STATUS_OK || res.status == CORE_RPC_STATUS_PAYMENT_REQUIRED)
1589  m_rpc_payment_state.credits = res.credits;
1590  if (res.top_hash != m_rpc_payment_state.top_hash)
1591  {
1592  m_rpc_payment_state.top_hash = res.top_hash;
1593  m_rpc_payment_state.stale = true;
1594  }
1595  }
1596  template<typename T> void handle_payment_changes(const T &res, std::false_type) {}
1597 
1598  // Light wallet specific functions
1599  // fetch unspent outs from lw node and store in m_transfers
1600  void light_wallet_get_unspent_outs();
1601  // fetch txs and store in m_payments
1602  void light_wallet_get_address_txs();
1603  // get_address_info
1604  bool light_wallet_get_address_info(tools::COMMAND_RPC_GET_ADDRESS_INFO::response &response);
1605  // Login. new_address is true if address hasn't been used on lw node before.
1606  bool light_wallet_login(bool &new_address);
1607  // Send an import request to lw node. returns info about import fee, address and payment_id
1608  bool light_wallet_import_wallet_request(tools::COMMAND_RPC_IMPORT_WALLET_REQUEST::response &response);
1609  // get random outputs from light wallet server
1610  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);
1611  // Parse rct string
1612  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;
1613  // check if key image is ours
1614  bool light_wallet_key_image_is_ours(const crypto::key_image& key_image, const crypto::public_key& tx_public_key, uint64_t out_index);
1615 
1616  /*
1617  * "attributes" are a mechanism to store an arbitrary number of string values
1618  * on the level of the wallet as a whole, identified by keys. Their introduction,
1619  * technically the unordered map m_attributes stored as part of a wallet file,
1620  * led to a new wallet file version, but now new singular pieces of info may be added
1621  * without the need for a new version.
1622  *
1623  * The first and so far only value stored as such an attribute is the description.
1624  * It's stored under the standard key ATTRIBUTE_DESCRIPTION (see method set_description).
1625  *
1626  * The mechanism is open to all clients and allows them to use it for storing basically any
1627  * single string values in a wallet. To avoid the problem that different clients possibly
1628  * overwrite or misunderstand each other's attributes, a two-part key scheme is
1629  * proposed: <client name>.<value name>
1630  */
1631  const char* const ATTRIBUTE_DESCRIPTION = "wallet2.description";
1632  void set_attribute(const std::string &key, const std::string &value);
1633  bool get_attribute(const std::string &key, std::string &value) const;
1634 
1635  crypto::public_key get_multisig_signer_public_key() const;
1636  crypto::public_key get_multisig_signing_public_key(size_t idx) const;
1637  crypto::public_key get_multisig_signing_public_key(const crypto::secret_key &skey) const;
1638 
1639  template<class t_request, class t_response>
1640  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")
1641  {
1642  if (m_offline) return false;
1643  boost::lock_guard<boost::recursive_mutex> lock(m_daemon_rpc_mutex);
1644  return epee::net_utils::invoke_http_json(uri, req, res, *m_http_client, timeout, http_method);
1645  }
1646  template<class t_request, class t_response>
1647  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")
1648  {
1649  if (m_offline) return false;
1650  boost::lock_guard<boost::recursive_mutex> lock(m_daemon_rpc_mutex);
1651  return epee::net_utils::invoke_http_bin(uri, req, res, *m_http_client, timeout, http_method);
1652  }
1653  template<class t_request, class t_response>
1654  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")
1655  {
1656  if (m_offline) return false;
1657  boost::lock_guard<boost::recursive_mutex> lock(m_daemon_rpc_mutex);
1658  return epee::net_utils::invoke_http_json_rpc(uri, method_name, req, res, *m_http_client, timeout, http_method, req_id);
1659  }
1660 
1661  bool set_ring_database(const std::string &filename);
1662  const std::string get_ring_database() const { return m_ring_database; }
1663  bool get_ring(const crypto::key_image &key_image, std::vector<uint64_t> &outs);
1664  bool get_rings(const crypto::hash &txid, std::vector<std::pair<crypto::key_image, std::vector<uint64_t>>> &outs);
1665  bool get_rings(const crypto::chacha_key &key, const std::vector<crypto::key_image> &key_images, std::vector<std::vector<uint64_t>> &outs);
1666  bool set_ring(const crypto::key_image &key_image, const std::vector<uint64_t> &outs, bool relative);
1667  bool set_rings(const std::vector<std::pair<crypto::key_image, std::vector<uint64_t>>> &rings, bool relative);
1668  bool unset_ring(const std::vector<crypto::key_image> &key_images);
1669  bool unset_ring(const crypto::hash &txid);
1670  bool find_and_save_rings(bool force = true);
1671 
1672  bool blackball_output(const std::pair<uint64_t, uint64_t> &output);
1673  bool set_blackballed_outputs(const std::vector<std::pair<uint64_t, uint64_t>> &outputs, bool add = false);
1674  bool unblackball_output(const std::pair<uint64_t, uint64_t> &output);
1675  bool is_output_blackballed(const std::pair<uint64_t, uint64_t> &output) const;
1676 
1677  void freeze(size_t idx);
1678  void thaw(size_t idx);
1679  bool frozen(size_t idx) const;
1680  void freeze(const crypto::key_image &ki);
1681  void thaw(const crypto::key_image &ki);
1682  bool frozen(const crypto::key_image &ki) const;
1683  bool frozen(const transfer_details &td) const;
1684  bool frozen(const multisig_tx_set& txs) const; // does partially signed txset contain frozen enotes?
1685 
1686  bool save_to_file(const std::string& path_to_file, const std::string& binary, bool is_printable = false) const;
1687  static bool load_from_file(const std::string& path_to_file, std::string& target_str, size_t max_size = 1000000000);
1688 
1689  uint64_t get_bytes_sent() const;
1690  uint64_t get_bytes_received() const;
1691 
1692  // MMS -------------------------------------------------------------------------------------------------
1693  mms::message_store& get_message_store() { return m_message_store; };
1694  const mms::message_store& get_message_store() const { return m_message_store; };
1695  mms::multisig_wallet_state get_multisig_wallet_state() const;
1696 
1697  bool lock_keys_file();
1698  bool unlock_keys_file();
1699  bool is_keys_file_locked() const;
1700 
1701  void change_password(const std::string &filename, const epee::wipeable_string &original_password, const epee::wipeable_string &new_password);
1702 
1703  void set_tx_notify(const std::shared_ptr<tools::Notify> &notify) { m_tx_notify = notify; }
1704 
1705  bool is_tx_spendtime_unlocked(uint64_t unlock_time, uint64_t block_height);
1706  void hash_m_transfer(const transfer_details & transfer, crypto::hash &hash) const;
1707  uint64_t hash_m_transfers(boost::optional<uint64_t> transfer_height, crypto::hash &hash) const;
1708  void finish_rescan_bc_keep_key_images(uint64_t transfer_height, const crypto::hash &hash);
1709  void enable_dns(bool enable) { m_use_dns = enable; }
1710  void set_offline(bool offline = true);
1711  bool is_offline() const { return m_offline; }
1712 
1713  uint64_t credits() const { return m_rpc_payment_state.credits; }
1714  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; }
1715 
1716  static std::string get_default_daemon_address() { CRITICAL_REGION_LOCAL(default_daemon_address_lock); return default_daemon_address; }
1717 
1718  private:
1726  bool store_keys(const std::string& keys_file_name, const epee::wipeable_string& password, bool watch_only = false);
1732  bool load_keys(const std::string& keys_file_name, const epee::wipeable_string& password);
1738  bool load_keys_buf(const std::string& keys_buf, const epee::wipeable_string& password);
1739  bool load_keys_buf(const std::string& keys_buf, const epee::wipeable_string& password, boost::optional<crypto::chacha_key>& keys_to_encrypt);
1740  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);
1741  bool should_skip_block(const cryptonote::block &b, uint64_t height) const;
1742  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);
1743  detached_blockchain_data detach_blockchain(uint64_t height, std::map<std::pair<uint64_t, uint64_t>, size_t> *output_tracker_cache = NULL);
1744  void handle_reorg(uint64_t height, std::map<std::pair<uint64_t, uint64_t>, size_t> *output_tracker_cache = NULL);
1745  void get_short_chain_history(std::list<crypto::hash>& ids, uint64_t granularity = 1) const;
1746  bool clear();
1747  void clear_soft(bool keep_key_images=false);
1748  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);
1749  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);
1750  void fast_refresh(uint64_t stop_height, uint64_t &blocks_start_height, std::list<crypto::hash> &short_chain_history, bool force = false);
1751  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);
1752  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);
1753  bool accept_pool_tx_for_processing(const crypto::hash &txid);
1754  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);
1755  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);
1756  void update_pool_state_by_pool_query(std::vector<std::tuple<cryptonote::transaction, crypto::hash, bool>> &process_txs, bool refreshed = false);
1757  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);
1758  uint64_t select_transfers(uint64_t needed_money, std::vector<size_t> unused_transfers_indices, std::vector<size_t>& selected_transfers) const;
1759  bool prepare_file_names(const std::string& file_path);
1760  void process_unconfirmed(const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t height);
1761  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);
1762  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);
1763  void generate_genesis(cryptonote::block& b) const;
1764  void check_genesis(const crypto::hash& genesis_hash) const; //throws
1765  bool generate_chacha_key_from_secret_keys(crypto::chacha_key &key) const;
1766  void generate_chacha_key_from_password(const epee::wipeable_string &pass, crypto::chacha_key &key) const;
1767  crypto::hash get_payment_id(const pending_tx &ptx) const;
1768  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;
1769  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;
1770  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;
1771  void parse_block_round(const cryptonote::blobdata &blob, cryptonote::block &bl, crypto::hash &bl_id, bool &error) const;
1772  uint64_t get_upper_transaction_weight_limit();
1773  std::vector<uint64_t> get_unspent_amounts_vector(bool strict);
1774  uint64_t get_dynamic_base_fee_estimate();
1775  float get_output_relatedness(const transfer_details &td0, const transfer_details &td1) const;
1776  std::vector<size_t> pick_preferred_rct_inputs(uint64_t needed_money, uint32_t subaddr_account, const std::set<uint32_t> &subaddr_indices);
1777  void set_spent(size_t idx, uint64_t height);
1778  void set_unspent(size_t idx);
1779  bool is_spent(const transfer_details &td, bool strict = true) const;
1780  bool is_spent(size_t idx, bool strict = true) const;
1781  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);
1782  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);
1783  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;
1784  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;
1785  std::vector<size_t> get_only_rct(const std::vector<size_t> &unused_dust_indices, const std::vector<size_t> &unused_transfers_indices) const;
1786  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);
1787  void trim_hashchain();
1788  crypto::key_image get_multisig_composite_key_image(size_t n) const;
1789  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;
1790  rct::multisig_kLRki get_multisig_kLRki(size_t n, const rct::key &k) const;
1791  void get_multisig_k(size_t idx, const std::unordered_set<rct::key> &used_L, rct::key &nonce);
1792  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);
1793  bool add_rings(const crypto::chacha_key &key, const cryptonote::transaction_prefix &tx);
1794  bool add_rings(const cryptonote::transaction_prefix &tx);
1795  bool remove_rings(const cryptonote::transaction_prefix &tx);
1796  bool get_ring(const crypto::chacha_key &key, const crypto::key_image &key_image, std::vector<uint64_t> &outs);
1797  crypto::chacha_key get_ringdb_key();
1798  void setup_keys(const epee::wipeable_string &password);
1799  size_t get_transfer_details(const crypto::key_image &ki) const;
1800  tx_entry_data get_tx_entries(const std::unordered_set<crypto::hash> &txids);
1801  void sort_scan_tx_entries(std::vector<process_tx_entry_t> &unsorted_tx_entries);
1802  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);
1803 
1804  void register_devices();
1805  hw::device& lookup_device(const std::string & device_descriptor);
1806 
1807  bool get_rct_distribution(uint64_t &start_height, std::vector<uint64_t> &distribution);
1808 
1809  uint64_t get_segregation_fork_height() const;
1810 
1811  void cache_tx_data(const cryptonote::transaction& tx, const crypto::hash &txid, tx_cache_data &tx_cache_data) const;
1812  std::shared_ptr<std::map<std::pair<uint64_t, uint64_t>, size_t>> create_output_tracker_cache() const;
1813 
1814  void init_type(hw::device::device_type device_type);
1815  void setup_new_blockchain();
1816  void create_keys_file(const std::string &wallet_, bool watch_only, const epee::wipeable_string &password, bool create_address_file);
1817 
1818  wallet_device_callback * get_device_callback();
1819  void on_device_button_request(uint64_t code);
1820  void on_device_button_pressed();
1821  boost::optional<epee::wipeable_string> on_device_pin_request();
1822  boost::optional<epee::wipeable_string> on_device_passphrase_request(bool & on_device);
1823  void on_device_progress(const hw::device_progress& event);
1824 
1825  std::string get_rpc_status(const std::string &s) const;
1826  void throw_on_rpc_response_error(bool r, const epee::json_rpc::error &error, const std::string &status, const char *method) const;
1827 
1828  std::string get_client_signature() const;
1829  void check_rpc_cost(const char *call, uint64_t post_call_credits, uint64_t pre_credits, double expected_cost);
1830 
1831  bool should_expand(const cryptonote::subaddress_index &index) const;
1832  bool spends_one_of_ours(const cryptonote::transaction &tx) const;
1833 
1835  boost::optional<epee::net_utils::http::login> m_daemon_login;
1840  const std::unique_ptr<epee::net_utils::http::abstract_http_client> m_http_client;
1848 
1855  std::vector<std::vector<std::string>> m_subaddress_labels;
1858  std::vector<tools::wallet2::address_book_row> m_address_book;
1859  std::pair<serializable_map<std::string, std::string>, std::vector<std::string>> m_account_tags;
1860  uint64_t m_upper_transaction_weight_limit; //TODO: auto-calc this value or request from daemon, now use some fixed value
1861  const std::vector<std::vector<tools::wallet2::multisig_info>> *m_multisig_rescan_info;
1862  const std::vector<std::vector<rct::key>> *m_multisig_rescan_k;
1864 
1865  std::atomic<bool> m_run;
1866 
1867  boost::recursive_mutex m_daemon_rpc_mutex;
1868 
1877  bool m_multisig;
1879  std::vector<crypto::public_key> m_multisig_signers;
1880  //in case of general M/N multisig wallet we should perform N - M + 1 key exchange rounds and remember how many rounds are passed.
1882  std::vector<crypto::public_key> m_multisig_derivations;
1892  // If m_refresh_from_block_height is explicitly set to zero we need this to differentiate it from the case that
1893  // m_refresh_from_block_height was defaulted to zero.*/
1896  std::vector<std::tuple<cryptonote::transaction, crypto::hash, bool>> m_process_pool_txs;
1898  // m_skip_to_height is useful when we don't want to modify the wallet's restore height.
1899  // m_refresh_from_block_height is also a wallet's restore height which should remain constant unless explicitly modified by the user.
1924  std::unordered_set<crypto::hash> m_scanned_pool_txs[2];
1925  size_t m_subaddress_lookahead_major, m_subaddress_lookahead_minor;
1937 
1938  // Aux transaction data from device
1940 
1941  // Light wallet
1942  bool m_light_wallet; /* sends view key to daemon for scanning */
1945  uint64_t m_light_wallet_per_kb_fee = FEE_PER_KB;
1949  // Light wallet info needed to populate m_payment requires 2 separate api calls (get_address_txs and get_unspent_outs)
1950  // We save the info from the first call in m_light_wallet_address_txs for easier lookup.
1951  std::unordered_map<crypto::hash, address_tx> m_light_wallet_address_txs;
1952  // store calculated key image for faster lookup
1954 
1957  std::unique_ptr<ringdb> m_ringdb;
1958  boost::optional<crypto::chacha_key> m_ringdb_key;
1959 
1961  std::unique_ptr<tools::file_locker> m_keys_file_locker;
1962 
1967 
1968  crypto::chacha_key m_cache_key;
1969  std::shared_ptr<wallet_keys_unlocker> m_encrypt_keys_after_refresh;
1970 
1973 
1974  std::shared_ptr<tools::Notify> m_tx_notify;
1975  std::unique_ptr<wallet_device_callback> m_device_callback;
1976 
1979 
1981 
1982  static boost::mutex default_daemon_address_lock;
1984  };
1985 }
1987 BOOST_CLASS_VERSION(tools::wallet2::transfer_details, 12)
1988 BOOST_CLASS_VERSION(tools::wallet2::multisig_info, 1)
1989 BOOST_CLASS_VERSION(tools::wallet2::multisig_info::LR, 0)
1990 BOOST_CLASS_VERSION(tools::wallet2::multisig_tx_set, 1)
1991 BOOST_CLASS_VERSION(tools::wallet2::payment_details, 5)
1992 BOOST_CLASS_VERSION(tools::wallet2::pool_payment_details, 1)
1993 BOOST_CLASS_VERSION(tools::wallet2::unconfirmed_transfer_details, 8)
1994 BOOST_CLASS_VERSION(tools::wallet2::confirmed_transfer_details, 6)
1995 BOOST_CLASS_VERSION(tools::wallet2::address_book_row, 18)
1996 BOOST_CLASS_VERSION(tools::wallet2::reserve_proof_entry, 0)
1998 BOOST_CLASS_VERSION(tools::wallet2::signed_tx_set, 1)
2000 BOOST_CLASS_VERSION(tools::wallet2::pending_tx, 3)
2001 BOOST_CLASS_VERSION(tools::wallet2::multisig_sig, 1)
2002 
2003 namespace boost
2004 {
2005  namespace serialization
2006  {
2007  template<class Archive, class F, class S, class T>
2008  inline void serialize(
2009  Archive & ar,
2010  std::tuple<F, S, T> & t,
2011  const unsigned int /* file_version */
2012  ){
2013  ar & boost::serialization::make_nvp("f", std::get<0>(t));
2014  ar & boost::serialization::make_nvp("s", std::get<1>(t));
2015  ar & boost::serialization::make_nvp("t", std::get<2>(t));
2016  }
2017 
2018  template <class Archive>
2019  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)
2020  {
2021  }
2022  template <class Archive>
2023  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)
2024  {
2025  if (ver < 1)
2026  {
2027  x.m_mask = rct::identity();
2028  x.m_amount = x.m_tx.vout[x.m_internal_output_index].amount;
2029  }
2030  if (ver < 2)
2031  {
2032  x.m_spent_height = 0;
2033  }
2034  if (ver < 4)
2035  {
2036  x.m_rct = x.m_tx.vout[x.m_internal_output_index].amount == 0;
2037  }
2038  if (ver < 6)
2039  {
2040  x.m_key_image_known = true;
2041  }
2042  if (ver < 7)
2043  {
2044  x.m_pk_index = 0;
2045  }
2046  if (ver < 8)
2047  {
2048  x.m_subaddr_index = {};
2049  }
2050  if (ver < 9)
2051  {
2052  x.m_key_image_partial = false;
2053  x.m_multisig_k.clear();
2054  x.m_multisig_info.clear();
2055  }
2056  if (ver < 10)
2057  {
2058  x.m_key_image_request = false;
2059  }
2060  if (ver < 12)
2061  {
2062  x.m_frozen = false;
2063  }
2064  }
2065 
2066  template <class Archive>
2067  inline void serialize(Archive &a, tools::wallet2::transfer_details &x, const boost::serialization::version_type ver)
2068  {
2069  a & x.m_block_height;
2072  if (ver < 3)
2073  {
2075  a & tx;
2078  }
2079  else
2080  {
2081  a & x.m_tx;
2082  }
2083  a & x.m_spent;
2084  a & x.m_key_image;
2085  if (ver < 1)
2086  {
2087  // ensure mask and amount are set
2088  initialize_transfer_details(a, x, ver);
2089  return;
2090  }
2091  a & x.m_mask;
2092  a & x.m_amount;
2093  if (ver < 2)
2094  {
2095  initialize_transfer_details(a, x, ver);
2096  return;
2097  }
2098  a & x.m_spent_height;
2099  if (ver < 3)
2100  {
2101  initialize_transfer_details(a, x, ver);
2102  return;
2103  }
2104  a & x.m_txid;
2105  if (ver < 4)
2106  {
2107  initialize_transfer_details(a, x, ver);
2108  return;
2109  }
2110  a & x.m_rct;
2111  if (ver < 5)
2112  {
2113  initialize_transfer_details(a, x, ver);
2114  return;
2115  }
2116  if (ver < 6)
2117  {
2118  // v5 did not properly initialize
2119  uint8_t u;
2120  a & u;
2121  x.m_key_image_known = true;
2122  return;
2123  }
2124  a & x.m_key_image_known;
2125  if (ver < 7)
2126  {
2127  initialize_transfer_details(a, x, ver);
2128  return;
2129  }
2130  a & x.m_pk_index;
2131  if (ver < 8)
2132  {
2133  initialize_transfer_details(a, x, ver);
2134  return;
2135  }
2136  a & x.m_subaddr_index;
2137  if (ver < 9)
2138  {
2139  initialize_transfer_details(a, x, ver);
2140  return;
2141  }
2142  a & x.m_multisig_info;
2143  a & x.m_multisig_k;
2144  a & x.m_key_image_partial;
2145  if (ver < 10)
2146  {
2147  initialize_transfer_details(a, x, ver);
2148  return;
2149  }
2150  a & x.m_key_image_request;
2151  if (ver < 11)
2152  {
2153  initialize_transfer_details(a, x, ver);
2154  return;
2155  }
2156  a & x.m_uses;
2157  if (ver < 12)
2158  {
2159  initialize_transfer_details(a, x, ver);
2160  return;
2161  }
2162  a & x.m_frozen;
2163  }
2164 
2165  template <class Archive>
2166  inline void serialize(Archive &a, tools::wallet2::multisig_info::LR &x, const boost::serialization::version_type ver)
2167  {
2168  a & x.m_L;
2169  a & x.m_R;
2170  }
2171 
2172  template <class Archive>
2173  inline void serialize(Archive &a, tools::wallet2::multisig_info &x, const boost::serialization::version_type ver)
2174  {
2175  a & x.m_signer;
2176  a & x.m_LR;
2177  a & x.m_partial_key_images;
2178  }
2179 
2180  template <class Archive>
2181  inline void serialize(Archive &a, tools::wallet2::multisig_tx_set &x, const boost::serialization::version_type ver)
2182  {
2183  a & x.m_ptx;
2184  a & x.m_signers;
2185  }
2186 
2187  template <class Archive>
2188  inline void serialize(Archive &a, tools::wallet2::unconfirmed_transfer_details &x, const boost::serialization::version_type ver)
2189  {
2190  a & x.m_change;
2191  a & x.m_sent_time;
2192  if (ver < 5)
2193  {
2195  a & tx;
2197  }
2198  else
2199  {
2200  a & x.m_tx;
2201  }
2202  if (ver < 1)
2203  return;
2204  a & x.m_dests;
2205  a & x.m_payment_id;
2206  if (ver < 2)
2207  return;
2208  a & x.m_state;
2209  if (ver < 3)
2210  return;
2211  a & x.m_timestamp;
2212  if (ver < 4)
2213  return;
2214  a & x.m_amount_in;
2215  a & x.m_amount_out;
2216  if (ver < 6)
2217  {
2218  // v<6 may not have change accumulated in m_amount_out, which is a pain,
2219  // as it's readily understood to be sum of outputs.
2220  // We convert it to include change from v6
2221  if (!typename Archive::is_saving() && x.m_change != (uint64_t)-1)
2222  x.m_amount_out += x.m_change;
2223  }
2224  if (ver < 7)
2225  {
2226  x.m_subaddr_account = 0;
2227  return;
2228  }
2229  a & x.m_subaddr_account;
2230  a & x.m_subaddr_indices;
2231  if (ver < 8)
2232  return;
2233  a & x.m_rings;
2234  }
2235 
2236  template <class Archive>
2237  inline void serialize(Archive &a, tools::wallet2::confirmed_transfer_details &x, const boost::serialization::version_type ver)
2238  {
2239  a & x.m_amount_in;
2240  a & x.m_amount_out;
2241  a & x.m_change;
2242  a & x.m_block_height;
2243  if (ver < 1)
2244  return;
2245  a & x.m_dests;
2246  a & x.m_payment_id;
2247  if (ver < 2)
2248  return;
2249  a & x.m_timestamp;
2250  if (ver < 3)
2251  {
2252  // v<3 may not have change accumulated in m_amount_out, which is a pain,
2253  // as it's readily understood to be sum of outputs. Whether it got added
2254  // or not depends on whether it came from a unconfirmed_transfer_details
2255  // (not included) or not (included). We can't reliably tell here, so we
2256  // check whether either yields a "negative" fee, or use the other if so.
2257  // We convert it to include change from v3
2258  if (!typename Archive::is_saving() && x.m_change != (uint64_t)-1)
2259  {
2260  if (x.m_amount_in > (x.m_amount_out + x.m_change))
2261  x.m_amount_out += x.m_change;
2262  }
2263  }
2264  if (ver < 4)
2265  {
2266  if (!typename Archive::is_saving())
2267  x.m_unlock_time = 0;
2268  return;
2269  }
2270  a & x.m_unlock_time;
2271  if (ver < 5)
2272  {
2273  x.m_subaddr_account = 0;
2274  return;
2275  }
2276  a & x.m_subaddr_account;
2277  a & x.m_subaddr_indices;
2278  if (ver < 6)
2279  return;
2280  a & x.m_rings;
2281  }
2282 
2283  template <class Archive>
2284  inline void serialize(Archive& a, tools::wallet2::payment_details& x, const boost::serialization::version_type ver)
2285  {
2286  a & x.m_tx_hash;
2287  a & x.m_amount;
2288  a & x.m_block_height;
2289  a & x.m_unlock_time;
2290  if (ver < 1)
2291  return;
2292  a & x.m_timestamp;
2293  if (ver < 2)
2294  {
2295  x.m_coinbase = false;
2296  x.m_subaddr_index = {};
2297  return;
2298  }
2299  a & x.m_subaddr_index;
2300  if (ver < 3)
2301  {
2302  x.m_coinbase = false;
2303  x.m_fee = 0;
2304  return;
2305  }
2306  a & x.m_fee;
2307  if (ver < 4)
2308  {
2309  x.m_coinbase = false;
2310  return;
2311  }
2312  a & x.m_coinbase;
2313  if (ver < 5)
2314  return;
2315  a & x.m_amounts;
2316  }
2317 
2318  template <class Archive>
2319  inline void serialize(Archive& a, tools::wallet2::pool_payment_details& x, const boost::serialization::version_type ver)
2320  {
2321  a & x.m_pd;
2322  a & x.m_double_spend_seen;
2323  }
2324 
2325  template <class Archive>
2326  inline void serialize(Archive& a, tools::wallet2::address_book_row& x, const boost::serialization::version_type ver)
2327  {
2328  a & x.m_address;
2329  if (ver < 18)
2330  {
2331  crypto::hash payment_id;
2332  a & payment_id;
2333  x.m_has_payment_id = !(payment_id == crypto::null_hash);
2334  if (x.m_has_payment_id)
2335  {
2336  bool is_long = false;
2337  for (int i = 8; i < 32; ++i)
2338  is_long |= payment_id.data[i];
2339  if (is_long)
2340  {
2341  MWARNING("Long payment ID ignored on address book load");
2343  x.m_has_payment_id = false;
2344  }
2345  else
2346  memcpy(x.m_payment_id.data, payment_id.data, 8);
2347  }
2348  }
2349  a & x.m_description;
2350  if (ver < 17)
2351  {
2352  x.m_is_subaddress = false;
2353  return;
2354  }
2355  a & x.m_is_subaddress;
2356  if (ver < 18)
2357  return;
2358  a & x.m_has_payment_id;
2359  if (x.m_has_payment_id)
2360  a & x.m_payment_id;
2361  }
2362 
2363  template <class Archive>
2364  inline void serialize(Archive& a, tools::wallet2::reserve_proof_entry& x, const boost::serialization::version_type ver)
2365  {
2366  a & x.txid;
2367  a & x.index_in_tx;
2368  a & x.shared_secret;
2369  a & x.key_image;
2370  a & x.shared_secret_sig;
2371  a & x.key_image_sig;
2372  }
2373 
2374  template <class Archive>
2375  inline void serialize(Archive &a, tools::wallet2::unsigned_tx_set &x, const boost::serialization::version_type ver)
2376  {
2377  a & x.txes;
2378  if (ver == 0)
2379  {
2380  // load old version
2381  std::pair<size_t, tools::wallet2::transfer_container> old_transfers;
2382  a & old_transfers;
2383  std::get<0>(x.transfers) = std::get<0>(old_transfers);
2384  std::get<1>(x.transfers) = std::get<0>(old_transfers) + std::get<1>(old_transfers).size();
2385  std::get<2>(x.transfers) = std::get<1>(old_transfers);
2386  return;
2387  }
2388  throw std::runtime_error("Boost serialization not supported for newest unsigned_tx_set");
2389  }
2390 
2391  template <class Archive>
2392  inline void serialize(Archive &a, tools::wallet2::signed_tx_set &x, const boost::serialization::version_type ver)
2393  {
2394  a & x.ptx;
2395  a & x.key_images;
2396  if (ver < 1)
2397  return;
2398  a & x.tx_key_images.parent();
2399  }
2400 
2401  template <class Archive>
2402  inline void serialize(Archive &a, tools::wallet2::tx_construction_data &x, const boost::serialization::version_type ver)
2403  {
2404  a & x.sources;
2405  a & x.change_dts;
2406  a & x.splitted_dsts;
2407  if (ver < 2)
2408  {
2409  // load list to vector
2410  std::list<size_t> selected_transfers;
2411  a & selected_transfers;
2412  x.selected_transfers.clear();
2413  x.selected_transfers.reserve(selected_transfers.size());
2414  for (size_t t: selected_transfers)
2415  x.selected_transfers.push_back(t);
2416  }
2417  a & x.extra;
2418  a & x.unlock_time;
2419  a & x.use_rct;
2420  a & x.dests;
2421  if (ver < 1)
2422  {
2423  x.subaddr_account = 0;
2424  return;
2425  }
2426  a & x.subaddr_account;
2427  a & x.subaddr_indices;
2428  if (ver < 2)
2429  {
2430  if (!typename Archive::is_saving())
2432  return;
2433  }
2434  a & x.selected_transfers;
2435  if (ver < 3)
2436  {
2437  if (!typename Archive::is_saving())
2439  return;
2440  }
2441  if (ver < 4)
2442  {
2443  bool use_bulletproofs = x.rct_config.range_proof_type != rct::RangeProofBorromean;
2444  a & use_bulletproofs;
2445  if (!typename Archive::is_saving())
2446  x.rct_config = { use_bulletproofs ? rct::RangeProofBulletproof : rct::RangeProofBorromean, 0 };
2447  return;
2448  }
2449  a & x.rct_config;
2450  }
2451 
2452  template <class Archive>
2453  inline void serialize(Archive &a, tools::wallet2::multisig_sig &x, const boost::serialization::version_type ver)
2454  {
2455  a & x.sigs;
2456  a & x.ignore;
2457  a & x.used_L;
2458  a & x.signing_keys;
2459  a & x.msout;
2460  if (ver < 1)
2461  return;
2462  a & x.total_alpha_G;
2463  a & x.total_alpha_H;
2464  a & x.c_0;
2465  a & x.s;
2466  }
2467 
2468  template <class Archive>
2469  inline void serialize(Archive &a, tools::wallet2::pending_tx &x, const boost::serialization::version_type ver)
2470  {
2471  a & x.tx;
2472  a & x.dust;
2473  a & x.fee;
2474  a & x.dust_added_to_fee;
2475  a & x.change_dts;
2476  if (ver < 2)
2477  {
2478  // load list to vector
2479  std::list<size_t> selected_transfers;
2480  a & selected_transfers;
2481  x.selected_transfers.clear();
2482  x.selected_transfers.reserve(selected_transfers.size());
2483  for (size_t t: selected_transfers)
2484  x.selected_transfers.push_back(t);
2485  }
2486  a & x.key_images;
2487  a & x.tx_key;
2488  a & x.dests;
2489  a & x.construction_data;
2490  if (ver < 1)
2491  return;
2492  a & x.additional_tx_keys;
2493  if (ver < 2)
2494  return;
2495  a & x.selected_transfers;
2496  if (ver < 3)
2497  return;
2498  a & x.multisig_sigs;
2499  }
2500  }
2501 }
2502 
2503 namespace tools
2504 {
2505 
2506  namespace detail
2507  {
2508  //----------------------------------------------------------------------------------------------------
2509  inline void digit_split_strategy(const std::vector<cryptonote::tx_destination_entry>& dsts,
2510  const cryptonote::tx_destination_entry& change_dst, uint64_t dust_threshold,
2511  std::vector<cryptonote::tx_destination_entry>& splitted_dsts, std::vector<cryptonote::tx_destination_entry> &dust_dsts)
2512  {
2513  splitted_dsts.clear();
2514  dust_dsts.clear();
2515 
2516  for(auto& de: dsts)
2517  {
2519  [&](uint64_t chunk) { splitted_dsts.push_back(cryptonote::tx_destination_entry(chunk, de.addr, de.is_subaddress)); },
2520  [&](uint64_t a_dust) { splitted_dsts.push_back(cryptonote::tx_destination_entry(a_dust, de.addr, de.is_subaddress)); } );
2521  }
2522 
2524  [&](uint64_t chunk) {
2525  if (chunk <= dust_threshold)
2526  dust_dsts.push_back(cryptonote::tx_destination_entry(chunk, change_dst.addr, false));
2527  else
2528  splitted_dsts.push_back(cryptonote::tx_destination_entry(chunk, change_dst.addr, false));
2529  },
2530  [&](uint64_t a_dust) { dust_dsts.push_back(cryptonote::tx_destination_entry(a_dust, change_dst.addr, false)); } );
2531  }
2532  //----------------------------------------------------------------------------------------------------
2533  inline void null_split_strategy(const std::vector<cryptonote::tx_destination_entry>& dsts,
2534  const cryptonote::tx_destination_entry& change_dst, uint64_t dust_threshold,
2535  std::vector<cryptonote::tx_destination_entry>& splitted_dsts, std::vector<cryptonote::tx_destination_entry> &dust_dsts)
2536  {
2537  splitted_dsts = dsts;
2538 
2539  dust_dsts.clear();
2540  uint64_t change = change_dst.amount;
2541 
2542  if (0 != change)
2543  {
2544  splitted_dsts.push_back(cryptonote::tx_destination_entry(change, change_dst.addr, false));
2545  }
2546  }
2547  //----------------------------------------------------------------------------------------------------
2549  {
2550  std::string indexes;
2551  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) + " "; });
2552  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);
2553  }
2554  //----------------------------------------------------------------------------------------------------
2555  }
2556  //----------------------------------------------------------------------------------------------------
2557 }
uint64_t m_upper_transaction_weight_limit
Definition: wallet2.h:1860
const char * res
Definition: hmac_keccak.cpp:42
bool watch_only() const
Definition: wallet2.h:1070
uint32_t subaddr_account
Definition: wallet2.h:553
def sign(data)
Definition: cointool.py:602
boost::recursive_mutex m_daemon_rpc_mutex
Definition: wallet2.h:1867
uint64_t unlock_time
Definition: wallet2.h:548
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:723
#define tr(x)
Definition: common_defines.h:4
uint8_t m_rct
Definition: wallet2.h:398
std::vector< crypto::key_image > key_images
Definition: wallet2.h:712
bool error
Definition: wallet2.h:322
uint64_t m_segregation_height
Definition: wallet2.h:1912
rpc_payment_state_t m_rpc_payment_state
Definition: wallet2.h:1933
cryptonote::transaction tx
Definition: wallet2.h:638
description
Definition: setupmingw32.py:29
crypto::chacha_iv iv
Definition: wallet2.h:736
rct::RCTConfig rct_config
Definition: wallet2.h:550
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:1842
bool m_always_confirm_transfers
Definition: wallet2.h:1883
AskPasswordType ask_password() const
Definition: wallet2.h:1346
void setup_background_mining(BackgroundMiningSetupType value)
Definition: wallet2.h:1381
crypto::hash tx_hash
Definition: wallet2.h:834
void callback(i_wallet2_callback *callback)
Definition: wallet2.h:1010
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:1703
Definition: wallet2.h:709
const boost::optional< epee::net_utils::http::login > & get_daemon_login() const
Definition: wallet2.h:1461
const uint32_t T[512]
Definition: groestl_tables.h:36
bool persistent_rpc_client_id() const
Definition: wallet2.h:1392
hw::device::device_type m_key_device_type
Definition: wallet2.h:1871
size_t get_num_subaddresses(uint32_t index_major) const
Definition: wallet2.h:1049
Definition: net_ssl.h:75
Definition: mining.py:1
std::string cache_data
Definition: wallet2.h:748
void handle_payment_changes(const T &res, std::false_type)
Definition: wallet2.h:1596
bool m_confirm_export_overwrite
Definition: wallet2.h:1908
uint64_t ignore_outputs_below() const
Definition: wallet2.h:1374
uint32_t m_inactivity_lock_timeout
Definition: wallet2.h:1918
Definition: rctTypes.h:122
const crypto::hash & operator[](size_t idx) const
Definition: wallet2.h:201
Definition: cryptonote_config.h:297
cryptonote::COMMAND_RPC_GET_TRANSACTIONS::entry tx_entry
Definition: wallet2.h:832
std::atomic< bool > m_run
Definition: wallet2.h:1865
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:433
const char * tag
Definition: testobsdrdr.c:19
bool m_is_subaddress
Definition: wallet2.h:762
bool key_on_device() const
Definition: wallet2.h:1075
void auto_low_priority(bool value)
Definition: wallet2.h:1361
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:336
uint8_t construction_flags
Definition: wallet2.h:564
struct tools::gamma_picker::gamma_engine engine
uint64_t m_unlock_time
Definition: wallet2.h:434
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:437
bool is_old_file_format
Definition: wallet2.h:1875
Definition: portable_binary_archive.hpp:29
bool ignore_fractional_outputs() const
Definition: wallet2.h:1368
void inactivity_lock_timeout(uint32_t seconds)
Definition: wallet2.h:1383
#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:1872
uint64_t m_change
Definition: wallet2.h:509
Definition: wallet_rpc_helpers.h:49
void confirm_non_default_ring_size(bool always)
Definition: wallet2.h:1371
std::pair< size_t, size_t > get_subaddress_lookahead() const
Definition: wallet2.h:1056
bool m_show_wallet_name_when_locked
Definition: wallet2.h:1917
Definition: wallet2.h:231
Definition: node_rpc_proxy.h:42
bool is_mismatched_daemon_version_allowed() const
Definition: wallet2.h:1402
bool m_key_image_request
Definition: wallet2.h:343
bool m_has_payment_id
Definition: wallet2.h:763
bool dust_added_to_fee
Definition: wallet2.h:640
std::unordered_set< crypto::hash > detached_tx_hashes
Definition: wallet2.h:826
int i
Definition: pymoduletest.py:23
uint64_t max_reorg_depth() const
Definition: wallet2.h:993
cryptonote::subaddress_index m_subaddr_index
Definition: wallet2.h:345
const std::string get_ring_database() const
Definition: wallet2.h:1662
Definition: jsonrpc_structs.h:31
static constexpr crypto::hash8 null_hash8
Definition: hash.h:93
Definition: wallet2.h:427
Definition: cryptonote_basic.h:538
void default_mixin(uint32_t m)
Definition: wallet2.h:1341
bool confirm_export_overwrite() const
Definition: wallet2.h:1358
Definition: cryptonote_protocol_defs.h:132
uint64_t amount
Definition: wallet2.h:320
bool m_offline
Definition: wallet2.h:1930
uint64_t pick()
Definition: wallet2.cpp:1049
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:646
std::vector< crypto::secret_key > additional_tx_keys
Definition: wallet2.h:645
std::vector< rct::key > m_multisig_k
Definition: wallet2.h:347
std::vector< LR > m_LR
Definition: wallet2.h:305
void auto_refresh(bool r)
Definition: wallet2.h:1345
crypto::public_key shared_secret
Definition: wallet2.h:779
::std::string string
Definition: gtest-port.h:1097
http_method
Definition: http_base.h:48
uint32_t m_confirm_backlog_threshold
Definition: wallet2.h:1907
void device_derivation_path(const std::string &device_derivation_path)
Definition: wallet2.h:1387
bool m_enable_multisig
Definition: wallet2.h:1935
uint64_t m_internal_output_index
Definition: wallet2.h:389
BackgroundMiningSetupType m_setup_background_mining
Definition: wallet2.h:1919
static std::string default_daemon_address
Definition: wallet2.h:1983
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:349
Definition: cryptonote_basic.h:474
void merge_destinations(bool merge)
Definition: wallet2.h:1352
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:642
boost::optional< crypto::chacha_key > m_ringdb_key
Definition: wallet2.h:1958
bool is_unattended() const
Definition: wallet2.h:1579
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:1873
crypto::hash hash
Definition: wallet2.h:799
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:1362
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:216
std::vector< crypto::public_key > m_multisig_signers
Definition: wallet2.h:1879
void stop()
Definition: wallet2.h:1007
hashchain detached_blockchain
Definition: wallet2.h:824
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:827
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:293
uint64_t dust
Definition: wallet2.h:639
float m_auto_mine_for_rpc_payment_threshold
Definition: wallet2.h:1921
const cryptonote::account_base & get_account() const
Definition: wallet2.h:979
crypto::secret_key multisig_tx_key_entropy
Definition: wallet2.h:648
std::string key_images
Definition: wallet2.h:643
std::vector< cryptonote::transaction > txes
Definition: wallet2.h:801
uint64_t m_timestamp
Definition: wallet2.h:435
boost::optional< cryptonote::subaddress_receive_info > received
Definition: wallet2.h:323
uint64_t m_light_wallet_blockchain_height
Definition: wallet2.h:1944
uint64_t m_last_block_reward
Definition: wallet2.h:1960
void track_uses(bool value)
Definition: wallet2.h:1377
const mms::message_store & get_message_store() const
Definition: wallet2.h:1694
serializable_unordered_map< std::string, std::string > m_attributes
Definition: wallet2.h:1857
crypto::public_key m_pubkey
Definition: wallet2.h:388
uint32_t m_subaddr_index_major
Definition: wallet2.h:407
rct::key m_mask
Definition: wallet2.h:339
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:711
std::string data
Definition: base58.cpp:37
crypto::key_derivation derivation
Definition: wallet2.h:809
void refill(const crypto::hash &hash)
Definition: wallet2.h:207
uint64_t index_in_tx
Definition: wallet2.h:778
crypto::key_image ki
Definition: wallet2.h:318
const char * key
Definition: hmac_keccak.cpp:40
cryptonote::tx_destination_entry change_dts
Definition: wallet2.h:544
int type
Definition: superscalar.cpp:50
void print_source_entry(const cryptonote::tx_source_entry &src)
Definition: wallet2.h:2548
wallet_keys_unlocker(wallet2 &w, const boost::optional< tools::password_container > &password)
Definition: wallet2.cpp:1100
mms::message_store m_message_store
Definition: wallet2.h:1963
cryptonote::transaction_prefix m_tx
Definition: wallet2.h:506
crypto namespace.
Definition: crypto.cpp:60
size_t m_subaddress_lookahead_minor
Definition: wallet2.h:1925
const crypto::public_key get_public_key() const
Definition: wallet2.h:353
void store_tx_info(bool store)
Definition: wallet2.h:1339
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:332
Definition: wallet2.h:291
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:909
Definition: wallet2.h:775
uint64_t m_min_output_value
Definition: wallet2.h:1904
cryptonote::account_public_address m_address
Definition: wallet2.h:759
bool explicit_refresh_from_block_height() const
Definition: wallet2.h:990
Definition: wallet2.h:177
uint64_t m_timestamp
Definition: wallet2.h:513
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:1640
serializable_unordered_map< crypto::hash, std::string > m_tx_device
Definition: wallet2.h:1939
size_t original_chain_size
Definition: wallet2.h:825
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:511
#define FEE_PER_KB
Definition: cryptonote_config.h:70
bool confirm_non_default_ring_size() const
Definition: wallet2.h:1370
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:1024
uint64_t m_amount_out
Definition: wallet2.h:475
uint64_t credits() const
Definition: wallet2.h:1713
std::string account_data
Definition: wallet2.h:737
mms::message_store & get_message_store()
Definition: wallet2.h:1693
bool m_has_ever_refreshed_from_node
Definition: wallet2.h:1980
crypto::hash m_tx_hash
Definition: wallet2.h:429
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:2533
const std::string & device_name() const
Definition: wallet2.h:1384
Definition: blocks.cpp:12
uint64_t get_light_wallet_scanned_block_height() const
Definition: wallet2.h:1026
uint64_t m_fee
Definition: wallet2.h:432
rct::key m_L
Definition: wallet2.h:295
boost::optional< epee::wipeable_string > on_passphrase_request(bool &on_device) override
Definition: wallet2.cpp:1171
void key_reuse_mitigation2(bool value)
Definition: wallet2.h:1365
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:1180
uint32_t m_default_mixin
Definition: wallet2.h:1886
crypto::hash m_genesis
Definition: wallet2.h:226
cryptonote::network_type nettype() const
Definition: wallet2.h:1069
void max_reorg_depth(uint64_t depth)
Definition: wallet2.h:992
crypto::secret_key m_original_view_secret_key
Definition: wallet2.h:1966
uint64_t m_pool_info_query_time
Definition: wallet2.h:1895
uint64_t amount
Definition: cryptonote_tx_utils.h:51
rct::rctSig sigs
Definition: wallet2.h:606
const ExportFormat & export_format() const
Definition: wallet2.h:1388
std::string m_daemon_address
Definition: wallet2.h:1836
cryptonote::account_public_address addr_for_dust
Definition: wallet2.h:181
bool m_merge_destinations
Definition: wallet2.h:1905
crypto::public_key pkey
Definition: wallet2.h:808
uint64_t money_transfered
Definition: wallet2.h:321
static std::string get_payment_id(const std::vector< uint8_t > &tx_extra)
Definition: trezor_tests.cpp:472
std::unordered_set< crypto::public_key > m_signers
Definition: wallet2.h:726
struct hash_func hashes[]
uint8_t m_key_image_request
Definition: wallet2.h:400
serializable_unordered_map< crypto::public_key, size_t > m_pub_keys
Definition: wallet2.h:1852
uint64_t m_amount_in
Definition: wallet2.h:507
void set_trusted_daemon(bool trusted)
Definition: wallet2.h:1013
rct::keyM total_alpha_G
Definition: wallet2.h:612
bool add_to_fee
Definition: wallet2.h:180
void confirm_backlog(bool always)
Definition: wallet2.h:1355
bool m_segregate_pre_fork_outputs
Definition: wallet2.h:1910
std::unordered_set< crypto::public_key > signing_keys
Definition: wallet2.h:609
uint8_t m_key_image_known
Definition: wallet2.h:399
Definition: rctTypes.h:113
std::unique_ptr< ringdb > m_ringdb
Definition: wallet2.h:1957
bool key_reuse_mitigation2() const
Definition: wallet2.h:1364
bool print_ring_members() const
Definition: wallet2.h:1336
uint8_t m_key_image_partial
Definition: wallet2.h:401
BackgroundMiningSetupType
Definition: wallet2.h:253
virtual void on_device_button_pressed()
Definition: wallet2.h:155
bool m_devices_registered
Definition: wallet2.h:1972
ExportFormat
Definition: wallet2.h:259
bool m_light_wallet_connected
Definition: wallet2.h:1946
RefreshType
Definition: wallet2.h:240
uint32_t m_multisig_threshold
Definition: wallet2.h:1878
#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
#define END_SERIALIZE()
self-explanatory
Definition: serialization.h:150
bool m_persistent_rpc_client_id
Definition: wallet2.h:1920
bool m_use_dns
Definition: wallet2.h:1929
bool_constant< true > true_type
Definition: gtest-port.h:2210
const std::string & device_derivation_path() const
Definition: wallet2.h:1386
uint32_t m_multisig_rounds_passed
Definition: wallet2.h:1881
std::unique_ptr< wallet_device_callback > m_device_callback
Definition: wallet2.h:1975
uint64_t result_type
Definition: wallet2.h:109
uint32_t get_confirm_backlog_threshold() const
Definition: wallet2.h:1357
std::vector< cryptonote::tx_destination_entry > m_dests
Definition: wallet2.h:478
std::vector< cryptonote::tx_source_entry > sources
Definition: wallet2.h:543
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:1373
void on_button_pressed() override
Definition: wallet2.cpp:1158
std::shared_ptr< tools::Notify > m_tx_notify
Definition: wallet2.h:1974
double average_output_time
Definition: wallet2.h:120
ExportFormat m_export_format
Definition: wallet2.h:1977
uint64_t m_ignore_outputs_below
Definition: wallet2.h:1915
const std::vector< std::vector< rct::key > > * m_multisig_rescan_k
Definition: wallet2.h:1862
std::vector< crypto::key_image > m_partial_key_images
Definition: wallet2.h:306
tx_scan_info_t()
Definition: wallet2.h:325
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:1379
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:679
crypto::chacha_key m_cache_key
Definition: wallet2.h:1968
std::vector< is_out_data > primary
Definition: wallet2.h:816
const crypto::secret_key null_skey
Definition: crypto.cpp:75
uint64_t m_pk_index
Definition: wallet2.h:344
uint64_t m_max_reorg_depth
Definition: wallet2.h:1902
std::vector< tools::wallet2::address_book_row > m_address_book
Definition: wallet2.h:1858
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:608
NodeRPCProxy m_node_rpc_proxy
Definition: wallet2.h:1923
const crypto::hash & genesis() const
Definition: wallet2.h:198
i_wallet2_callback * m_callback
Definition: wallet2.h:1870
uint64_t amount() const
Definition: wallet2.h:352
first
Definition: compare.py:8
bool m_confirm_backlog
Definition: wallet2.h:1906
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:1394
result_type operator()()
Definition: wallet2.h:112
Definition: core_rpc_server_commands_defs.h:389
bool m_double_spend_seen
Definition: wallet2.h:462
bool m_key_image_known
Definition: wallet2.h:342
Definition: wallet2.h:541
std::string get_address_as_str() const
Definition: wallet2.h:1045
std::vector< uint64_t > amounts_container
Definition: wallet2.h:426
const portMappingElt code
Definition: portlistingparse.c:22
bool m_incoming
Definition: wallet2.h:456
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:1066
Definition: wallet2.h:241
std::vector< transfer_details > transfer_container
Definition: wallet2.h:600
uint64_t m_amount_out
Definition: wallet2.h:508
serializable_unordered_map< crypto::public_key, cryptonote::subaddress_index > m_subaddresses
Definition: wallet2.h:1854
declaration and default definition for the functions used the API
Definition: expect.cpp:33
void segregate_pre_fork_outputs(bool value)
Definition: wallet2.h:1363
construction_flags_
Definition: wallet2.h:556
static void add(ge_p3 &p3, const ge_cached &other)
Definition: multiexp.cc:144
Definition: wallet2.h:261
bool m_unattended
Definition: wallet2.h:1971
Definition: chaingen.h:294
#define VERSION_FIELD(v)
Definition: serialization.h:220
void enable_multisig(bool enable)
Definition: wallet2.h:1401
void allow_mismatched_daemon_version(bool allow_mismatch)
Definition: wallet2.h:1403
crypto::hash m_payment_id
Definition: wallet2.h:479
bool m_load_deprecated_formats
Definition: wallet2.h:1978
bool m_auto_low_priority
Definition: wallet2.h:1909
std::vector< std::vector< std::string > > m_subaddress_labels
Definition: wallet2.h:1855
unsigned int uint32_t
Definition: stdint.h:126
bool m_coinbase
Definition: wallet2.h:436
uint32_t get_min_output_count() const
Definition: wallet2.h:1349
uint32_t m_min_output_count
Definition: wallet2.h:1903
device_type
Definition: device.hpp:103
payment_details m_pd
Definition: wallet2.h:461
uint64_t m_device_last_key_image_sync
Definition: wallet2.h:1928
uint64_t m_timestamp
Definition: wallet2.h:481
bool auto_refresh() const
Definition: wallet2.h:1344
Definition: argon2_core.h:74
Definition: wallet_errors.h:165
std::set< uint32_t > subaddr_indices
Definition: wallet2.h:554
Various Tools.
Definition: apply_permutation.h:39
boost::optional< epee::net_utils::http::login > m_daemon_login
Definition: wallet2.h:1835
bool locked
Definition: wallet2.h:131
uint64_t get_device_last_key_image_sync() const
Definition: wallet2.h:1151
bool track_uses() const
Definition: wallet2.h:1376
confirmed_transfer_details(const unconfirmed_transfer_details &utd, uint64_t height)
Definition: wallet2.h:520
wallet2 & w
Definition: wallet2.h:130
uint64_t m_global_output_index
Definition: wallet2.h:334
bool parse_uri(const std::string uri, http::uri_content &content)
Definition: net_parse_helpers.cpp:96
static boost::mutex default_daemon_address_lock
Definition: wallet2.h:1982
std::vector< tools::wallet2::pending_tx > ptx
Definition: cold-transaction.cpp:56
Definition: wallet2.h:315
Definition: cryptonote_tx_utils.h:42
Definition: serialization.cpp:892
void set_light_wallet(bool light_wallet)
Definition: wallet2.h:1025
crypto::chacha_key key
Definition: wallet2.h:132
Definition: account.h:73
bool is_trusted_daemon() const
Definition: wallet2.h:1012
def verify()
Definition: gitian-build.py:101
crypto::secret_key m_rpc_client_secret_key
Definition: wallet2.h:1932
uint64_t m_unlock_time
Definition: wallet2.h:514
void confirm_export_overwrite(bool always)
Definition: wallet2.h:1359
tools::wallet2::unsigned_tx_set exported_txs
Definition: cold-transaction.cpp:53
uint64_t get_refresh_from_block_height() const
Definition: wallet2.h:987
uint64_t get_min_output_value() const
Definition: wallet2.h:1351
uint64_t m_ignore_outputs_above
Definition: wallet2.h:1914
uint8_t m_spent
Definition: wallet2.h:396
Definition: rctTypes.h:79
uint64_t m_light_wallet_scanned_block_height
Definition: wallet2.h:1943
size_t n_outputs
Definition: cold-outputs.cpp:56
#define ts
Definition: skein.c:522
uint32_t m_subaddr_account
Definition: wallet2.h:515
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:601
std::vector< cryptonote::tx_destination_entry > splitted_dsts
Definition: wallet2.h:545
std::vector< multisig_sig > multisig_sigs
Definition: wallet2.h:647
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:1716
#define CRITICAL_REGION_LOCAL(x)
Definition: syncobj.h:153
void ignore_fractional_outputs(bool value)
Definition: wallet2.h:1369
Definition: wallet2.h:453
Definition: rctTypes.h:613
cryptonote::COMMAND_RPC_GET_BLOCKS_FAST::block_output_indices o_indices
Definition: wallet2.h:802
Definition: password.h:40
rct::keyM total_alpha_H
Definition: wallet2.h:613
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:817
rct::keyV c_0
Definition: wallet2.h:614
bool store_tx_info() const
Definition: wallet2.h:1338
void handle_payment_changes(const T &res, std::true_type)
Definition: wallet2.h:1587
cryptonote::transaction_prefix m_tx
Definition: wallet2.h:331
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
static constexpr crypto::hash null_hash
Definition: hash.h:92
uint64_t credits_target() const
Definition: wallet2.h:1398
crypto::public_key m_tx_pubkey
Definition: wallet2.h:391
std::vector< cryptonote::tx_extra_field > tx_extra_fields
Definition: tx-extra.cpp:38
bool m_mempool
Definition: wallet2.h:455
Definition: rctTypes.h:307
Definition: device.hpp:87
#define false
Definition: stdbool.h:37
std::string m_wallet_file
Definition: wallet2.h:1837
std::string seed_language
Definition: wallet2.h:1874
Definition: device.hpp:71
uint64_t m_block_height
Definition: wallet2.h:330
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:459
const char * Binary(const char *input, short n)
Definition: gmock-generated-actions_test.cc:95
std::string m_device_derivation_path
Definition: wallet2.h:1927
uint32_t m_subaddr_account
Definition: wallet2.h:482
serializable_unordered_map< crypto::public_key, serializable_map< uint64_t, crypto::key_image > > m_key_image_cache
Definition: wallet2.h:1953
uint64_t get_light_wallet_blockchain_height() const
Definition: wallet2.h:1027
std::vector< uint8_t > extra
Definition: wallet2.h:547
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:795
std::unique_ptr< tools::file_locker > m_keys_file_locker
Definition: wallet2.h:1961
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:1647
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:1164
void serialize(t_archive &a, const unsigned int ver)
Definition: wallet2.h:210
tx_construction_data construction_data
Definition: wallet2.h:650
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:840
cryptonote::transaction tx
Definition: wallet2.h:833
version
Supported socks variants.
Definition: socks.h:57
uint8_t m_frozen
Definition: wallet2.h:397
size_t size() const
Definition: wallet2.h:196
cryptonote::account_base m_account
Definition: wallet2.h:1834
static crypto::public_key get_tx_pub_key_from_received_outs(const tools::wallet2::transfer_details &td)
Definition: trezor_tests.cpp:412
cryptonote::block block
Definition: wallet2.h:800
crypto::secret_key spendkey
Definition: cold-outputs.cpp:44
uint64_t m_skip_to_height
Definition: wallet2.h:1897
bool m_store_tx_info
Definition: wallet2.h:1885
uint64_t m_amount
Definition: wallet2.h:405
void ignore_outputs_below(uint64_t value)
Definition: wallet2.h:1375
diff
Definition: gen_wide_data.py:42
void set_refresh_from_block_height(uint64_t height)
Definition: wallet2.h:986
void credits_target(uint64_t threshold)
Definition: wallet2.h:1399
std::vector< crypto::public_key > m_multisig_derivations
Definition: wallet2.h:1882
virtual void on_device_button_request(uint64_t code)
Definition: wallet2.h:154
uint64_t m_light_wallet_balance
Definition: wallet2.h:1947
uint32_t m_rpc_version
Definition: wallet2.h:1931
Definition: wallet2.h:677
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition: pointer.h:1124
payment_container m_payments
Definition: wallet2.h:1850
r
Definition: testupnpigd.py:61
void set_min_output_value(uint64_t value)
Definition: wallet2.h:1350
std::string m_keys_file
Definition: wallet2.h:1838
void load_deprecated_formats(bool load)
Definition: wallet2.h:1391
enum tools::wallet2::unconfirmed_transfer_details::@98 m_state
bool m_watch_only
Definition: wallet2.h:1876
rct::multisig_out msout
Definition: wallet2.h:610
std::string m_description
Definition: wallet2.h:761
account_public_address addr
Definition: cryptonote_tx_utils.h:78
cryptonote::transaction_prefix m_tx
Definition: wallet2.h:473
std::string blobdata
Definition: blobdatatype.h:39
cryptonote::checkpoints m_checkpoints
Definition: wallet2.h:1846
const char *const str
Definition: portlistingparse.c:23
void persistent_rpc_client_id(bool persistent)
Definition: wallet2.h:1393
size_t offset() const
Definition: wallet2.h:197
Definition: wallet2.h:837
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:1840
uint64_t highest_height
Definition: wallet2.h:841
hashchain()
Definition: wallet2.h:194
std::set< uint32_t > m_subaddr_indices
Definition: wallet2.h:483
std::vector< keyV > keyM
Definition: rctTypes.h:90
bool confirm_backlog() const
Definition: wallet2.h:1354
Definition: http.h:45
#define MAGIC_FIELD(m)
Definition: serialization.h:209
cryptonote::account_public_address get_address() const
Definition: wallet2.h:1040
network_type
Definition: cryptonote_config.h:295
randomx_vm * vm
Definition: tests.cpp:20
void segregation_height(uint64_t height)
Definition: wallet2.h:1367
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:2509
uint32_t address
Definition: getifaddr.c:269
POD_CLASS signature
Definition: crypto.h:98
uint64_t ignore_outputs_above() const
Definition: wallet2.h:1372
Definition: wallet2.h:745
void set_export_format(const ExportFormat &export_format)
Definition: wallet2.h:1389
Definition: cryptonote_basic.h:511
uint64_t m_credits_target
Definition: wallet2.h:1934
cryptonote::account_public_address m_account_public_address
Definition: wallet2.h:1853
size_t get_num_subaddress_accounts() const
Definition: wallet2.h:1048
key identity()
Definition: rctOps.h:73
POD_CLASS hash8
Definition: hash.h:51
output
Definition: gmock_output_test.py:175
uint64_t m_block_height
Definition: wallet2.h:510
randomx_cache * cache
Definition: tests.cpp:19
crypto::signature shared_secret_sig
Definition: wallet2.h:781
gamma_picker(const std::vector< uint64_t > &rct_offsets)
Definition: wallet2.cpp:1047
string daemon_address
Definition: transfers.cpp:41
bool m_explicit_refresh_from_block_height
Definition: wallet2.h:1894
bool m_rct
Definition: wallet2.h:341
void on_button_request(uint64_t code=0) override
Definition: wallet2.cpp:1152
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
const std::vector< std::vector< tools::wallet2::multisig_info > > * m_multisig_rescan_info
Definition: wallet2.h:1861
void credit_report(uint64_t &expected_spent, uint64_t &discrepancy) const
Definition: wallet2.h:1714
bool merge_destinations() const
Definition: wallet2.h:1353
#define VARINT_FIELD(f)
tags and serializes the varint f
Definition: serialization.h:189
cryptonote::account_public_address m_original_address
Definition: wallet2.h:1965
#define THROW_WALLET_EXCEPTION_IF(cond, err_type,...)
Definition: wallet_errors.h:994
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
uint64_t m_change
Definition: wallet2.h:476
unsigned version
Definition: wallet2.h:1508
uint64_t segregation_height() const
Definition: wallet2.h:1366
void * memcpy(void *a, const void *b, size_t c)
Definition: glibc_compat.cpp:16
i_wallet2_callback * callback() const
Definition: wallet2.h:1009
bool m_first_refresh_done
Definition: wallet2.h:1890
std::vector< cryptonote::tx_destination_entry > dests
Definition: wallet2.h:552
rct::key mask
Definition: wallet2.h:319
uint64_t m_light_wallet_unlocked_balance
Definition: wallet2.h:1948
uint64_t num_rct_outputs
Definition: wallet2.h:119
bool m_original_keys_available
Definition: wallet2.h:1964
crypto::hash get_transaction_hash(const transaction &t)
Definition: cryptonote_format_utils.cpp:1259
void always_confirm_transfers(bool always)
Definition: wallet2.h:1335
serializable_unordered_map< crypto::hash, std::string > m_tx_notes
Definition: wallet2.h:1856
void crop(size_t height)
Definition: wallet2.h:203
AskPasswordType m_ask_password
Definition: wallet2.h:1901
rct::key m_R
Definition: wallet2.h:296
crypto::hash8 m_payment_id
Definition: wallet2.h:760
confirmed_transfer_details()
Definition: wallet2.h:519
signed __int64 int64_t
Definition: stdint.h:135
std::unordered_set< crypto::public_key > ignore
Definition: wallet2.h:607
conn start()
std::vector< std::pair< crypto::key_image, std::vector< uint64_t > > > m_rings
Definition: wallet2.h:484
tx_entry_data()
Definition: wallet2.h:843
std::pair< serializable_map< std::string, std::string >, std::vector< std::string > > m_account_tags
Definition: wallet2.h:1859
void set_rpc_client_secret_key(const crypto::secret_key &key)
Definition: wallet2.h:1397
std::tuple< uint64_t, uint64_t, wallet2::transfer_container > transfers
Definition: wallet2.h:680
uint64_t m_refresh_from_block_height
Definition: wallet2.h:1891
hashchain m_blockchain
Definition: wallet2.h:1841
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:806
crypto::key_image m_key_image
Definition: wallet2.h:338
float auto_mine_for_rpc_payment_threshold() const
Definition: wallet2.h:1395
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:1896
bool m_allow_mismatched_daemon_version
Definition: wallet2.h:1936
Definition: rctTypes.h:308
uint32_t inactivity_lock_timeout() const
Definition: wallet2.h:1382
serializable_unordered_map< crypto::hash, confirmed_transfer_details > m_confirmed_txs
Definition: wallet2.h:1843
Definition: wallet2.h:830
std::vector< address_book_row > get_address_book() const
GUI Address book get/store.
Definition: wallet2.h:1444
std::shared_ptr< wallet_keys_unlocker > m_encrypt_keys_after_refresh
Definition: wallet2.h:1969
RefreshType get_refresh_type() const
Definition: wallet2.h:1067
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:615
crypto::signature key_image_sig
Definition: wallet2.h:782
Definition: multisig.cpp:45
p
Definition: pymoduletest.py:75
std::vector< cryptonote::tx_extra_field > tx_extra_fields
Definition: wallet2.h:815
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:1942
crypto::hash txid
Definition: wallet2.h:777
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:551
std::set< uint32_t > m_subaddr_indices
Definition: wallet2.h:516
size_t get_num_transfer_details() const
Definition: wallet2.h:1450
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:713
void enable_dns(bool enable)
Definition: wallet2.h:1709
Definition: wallet2.h:813
AskPasswordType
Definition: wallet2.h:247
Definition: wallet2.h:636
bool m_print_ring_members
Definition: wallet2.h:1884
Definition: rctTypes.h:307
std::gamma_distribution< double > gamma
Definition: wallet2.h:116
wallet set_subaddress_lookahead(1, 1)
cryptonote::account_base & get_account()
Definition: wallet2.h:978
POD_CLASS hash
Definition: hash.h:48
Definition: uri.py:1
uint64_t m_amount
Definition: wallet2.h:430
bool m_multisig
Definition: wallet2.h:1877
cryptonote::tx_destination_entry change_dts
Definition: wallet2.h:641
bool is_offline() const
Definition: wallet2.h:1711
void device_name(const std::string &device_name)
Definition: wallet2.h:1385
uint64_t get_blockchain_current_height() const
Definition: wallet2.h:1144
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:839
uint64_t m_global_output_index
Definition: wallet2.h:390
const std::vector< uint64_t > & rct_offsets
Definition: wallet2.h:117
bool m_confirm_non_default_ring_size
Definition: wallet2.h:1900
crypto::secret_key tx_key
Definition: wallet2.h:644
A container for blockchain checkpoints.
Definition: checkpoints.h:52
~wallet_keys_unlocker()
Definition: wallet2.cpp:1130
static int priority(Level level)
Definition: easylogging++.cc:2128
void set_confirm_backlog_threshold(uint32_t threshold)
Definition: wallet2.h:1356
Definition: wallet2.h:734
std::string to_string(t_connection_type type)
Definition: connection_basic.cpp:76
void print_ring_members(bool value)
Definition: wallet2.h:1337
uint32_t m_default_priority
Definition: wallet2.h:1887
crypto::key_image key_image
Definition: wallet2.h:780
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:1166
serializable_unordered_map< crypto::hash, crypto::secret_key > m_tx_keys
Definition: wallet2.h:1845
crypto::chacha_iv iv
Definition: wallet2.h:747
bool is_multisig_enabled() const
Definition: wallet2.h:1400
std::vector< boost::optional< cryptonote::subaddress_receive_info > > received
Definition: wallet2.h:810
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:2023
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:1017
transfer_container m_transfers
Definition: wallet2.h:1849
std::vector< pending_tx > m_ptx
Definition: wallet2.h:725
bool m_track_uses
Definition: wallet2.h:1916
bool is_rct() const
Definition: wallet2.h:351
#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:1342
std::set< uint32_t > unique_index_container
Definition: wallet2.h:602
bool m_key_reuse_mitigation2
Definition: wallet2.h:1911
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:1654
uint64_t m_amount_in
Definition: wallet2.h:474
void push_back(const crypto::hash &hash)
Definition: wallet2.h:199
cryptonote::keypair in_ephemeral
Definition: wallet2.h:317
serializable_unordered_multimap< crypto::hash, pool_payment_details > m_unconfirmed_payments
Definition: wallet2.h:1844
RefreshType m_refresh_type
Definition: wallet2.h:1888
Definition: wallet2.h:797
Definition: wallet2.h:243
bool load_deprecated_formats() const
Definition: wallet2.h:1390
#define FIELD_N(t, f)
serializes a field f tagged t
Definition: serialization.h:158
uint8_t flags
Definition: wallet2.h:403
Definition: core_rpc_server_commands_defs.h:201
uint64_t get_last_block_reward() const
Definition: wallet2.h:1150
void explicit_refresh_from_block_height(bool expl)
Definition: wallet2.h:989
crypto::public_key m_signer
Definition: wallet2.h:304
std::vector< crypto::public_key > m_additional_tx_keys
Definition: wallet2.h:406
Definition: wallet_tools.h:51
static __thread int depth
Definition: threadpool.cpp:34
bool m_key_image_partial
Definition: wallet2.h:346
std::string m_mms_file
Definition: wallet2.h:1839
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:1076
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:1851
void ask_password(AskPasswordType ask)
Definition: wallet2.h:1347
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:267
crypto::hash m_payment_id
Definition: wallet2.h:512
uint32_t default_mixin() const
Definition: wallet2.h:1340
bool m_is_initialized
Definition: wallet2.h:1922
time_t m_sent_time
Definition: wallet2.h:477
Definition: cryptonote_basic.h:204
void set_default_priority(uint32_t p)
Definition: wallet2.h:1343
Definition: wallet2.h:604
uint64_t m_internal_output_index
Definition: wallet2.h:333
#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:1348
std::tuple< uint64_t, uint64_t, std::vector< wallet2::exported_transfer_details > > new_transfers
Definition: wallet2.h:681
serializable_unordered_map< crypto::hash, std::vector< crypto::secret_key > > m_additional_tx_keys
Definition: wallet2.h:1847
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:1926
bool use_rct
Definition: wallet2.h:549
uint64_t m_amount
Definition: wallet2.h:340
static constexpr result_type min()
Definition: wallet2.h:110
Definition: device.hpp:77
bool m_spent
Definition: wallet2.h:335
Definition: wallet2.h:164
message_signature_type_t
Definition: wallet2.h:1506
bool m_trusted_daemon
Definition: wallet2.h:1869
bool auto_low_priority() const
Definition: wallet2.h:1360
bool m_ring_history_saved
Definition: wallet2.h:1956
uint64_t m_spent_height
Definition: wallet2.h:337
cryptonote::block b
Definition: block.cpp:40
uint64_t fee
Definition: wallet2.h:639
uint32_t m_subaddr_index_minor
Definition: wallet2.h:408
Definition: wallet2.h:757
crypto::secret_key get_rpc_client_secret_key() const
Definition: wallet2.h:1396
std::vector< size_t > selected_transfers
Definition: wallet2.h:546
amounts_container m_amounts
Definition: wallet2.h:431
BackgroundMiningSetupType setup_background_mining() const
Definition: wallet2.h:1380
bool m_auto_refresh
Definition: wallet2.h:1889
std::unordered_map< crypto::hash, address_tx > m_light_wallet_address_txs
Definition: wallet2.h:1951
if(!cryptonote::get_account_address_from_str_or_url(info, cryptonote::TESTNET, "9uVsvEryzpN8WH2t1WWhFFCG5tS8cBNdmJYNRuckLENFimfauV5pZKeS1P2CbxGkSDTUPHXWwiYE5ZGSXDAGbaZgDxobqDN"))
Definition: signature.cpp:53
Definition: wallet2.h:328
std::string m_ring_database
Definition: wallet2.h:1955
bool m_ignore_fractional_outputs
Definition: wallet2.h:1913
bool show_wallet_name_when_locked() const
Definition: wallet2.h:1378
void serialize(t_archive &a, const unsigned int ver)
Definition: wallet2.h:1156
bool error
Definition: wallet2.h:803
bool empty() const
Definition: wallet2.h:819
std::vector< multisig_info > m_multisig_info
Definition: wallet2.h:348
serializable_unordered_map< crypto::public_key, crypto::key_image > m_cold_key_images
Definition: wallet2.h:1863
static unsigned int lockers
Definition: wallet2.h:134
std::vector< std::pair< crypto::key_image, std::vector< uint64_t > > > m_rings
Definition: wallet2.h:517