Monero
wallet2.h
Go to the documentation of this file.
1 // Copyright (c) 2014-2018, The Monero Project
2 //
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification, are
6 // permitted provided that the following conditions are met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice, this list of
9 // conditions and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 // of conditions and the following disclaimer in the documentation and/or other
13 // materials provided with the distribution.
14 //
15 // 3. Neither the name of the copyright holder nor the names of its contributors may be
16 // used to endorse or promote products derived from this software without specific
17 // prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27 // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 //
29 // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
30 
31 #pragma once
32 
33 #include <memory>
34 
35 #include <boost/program_options/options_description.hpp>
36 #include <boost/program_options/variables_map.hpp>
37 #include <boost/serialization/list.hpp>
38 #include <boost/serialization/vector.hpp>
39 #include <boost/serialization/deque.hpp>
40 #include <atomic>
41 
42 #include "include_base_utils.h"
46 #include "net/http_client.h"
47 #include "storages/http_abstract_invoke.h"
52 #include "crypto/chacha.h"
53 #include "crypto/hash.h"
54 #include "ringct/rctTypes.h"
55 #include "ringct/rctOps.h"
57 
58 #include "wallet_errors.h"
59 #include "common/password.h"
60 #include "node_rpc_proxy.h"
61 
62 #undef MONERO_DEFAULT_LOG_CATEGORY
63 #define MONERO_DEFAULT_LOG_CATEGORY "wallet.wallet2"
64 
65 class Serialization_portability_wallet_Test;
66 
67 namespace tools
68 {
69  class ringdb;
70  class wallet2;
71 
73  {
74  public:
75  wallet_keys_unlocker(wallet2 &w, const boost::optional<tools::password_container> &password);
76  wallet_keys_unlocker(wallet2 &w, bool locked, const epee::wipeable_string &password);
78  private:
80  bool locked;
81  crypto::chacha_key key;
82  };
83 
85  {
86  public:
87  // Full wallet callbacks
88  virtual void on_new_block(uint64_t height, const cryptonote::block& block) {}
89  virtual void on_money_received(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t amount, const cryptonote::subaddress_index& subaddr_index) {}
90  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) {}
91  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) {}
92  virtual void on_skip_transaction(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx) {}
93  virtual boost::optional<epee::wipeable_string> on_get_password(const char *reason) { return boost::none; }
94  // Light wallet callbacks
95  virtual void on_lw_new_block(uint64_t height) {}
96  virtual void on_lw_money_received(uint64_t height, const crypto::hash &txid, uint64_t amount) {}
97  virtual void on_lw_unconfirmed_money_received(uint64_t height, const crypto::hash &txid, uint64_t amount) {}
98  virtual void on_lw_money_spent(uint64_t height, const crypto::hash &txid, uint64_t amount) {}
99  // Common callbacks
100  virtual void on_pool_tx_removed(const crypto::hash &txid) {}
101  virtual ~i_wallet2_callback() {}
102  };
103 
105  {
106  uint64_t dust_threshold;
109 
110  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())
111  : dust_threshold(a_dust_threshold)
112  , add_to_fee(an_add_to_fee)
113  , addr_for_dust(an_addr_for_dust)
114  {
115  }
116  };
117 
118  class hashchain
119  {
120  public:
122 
123  size_t size() const { return m_blockchain.size() + m_offset; }
124  size_t offset() const { return m_offset; }
125  const crypto::hash &genesis() const { return m_genesis; }
126  void push_back(const crypto::hash &hash) { if (m_offset == 0 && m_blockchain.empty()) m_genesis = hash; m_blockchain.push_back(hash); }
127  bool is_in_bounds(size_t idx) const { return idx >= m_offset && idx < size(); }
128  const crypto::hash &operator[](size_t idx) const { return m_blockchain[idx - m_offset]; }
129  crypto::hash &operator[](size_t idx) { return m_blockchain[idx - m_offset]; }
130  void crop(size_t height) { m_blockchain.resize(height - m_offset); }
131  void clear() { m_offset = 0; m_blockchain.clear(); }
132  bool empty() const { return m_blockchain.empty() && m_offset == 0; }
133  void trim(size_t height) { while (height > m_offset && m_blockchain.size() > 1) { m_blockchain.pop_front(); ++m_offset; } m_blockchain.shrink_to_fit(); }
134  void refill(const crypto::hash &hash) { m_blockchain.push_back(hash); --m_offset; }
135 
136  template <class t_archive>
137  inline void serialize(t_archive &a, const unsigned int ver)
138  {
139  a & m_offset;
140  a & m_genesis;
141  a & m_blockchain;
142  }
143 
144  private:
145  size_t m_offset;
147  std::deque<crypto::hash> m_blockchain;
148  };
149 
150  class wallet_keys_unlocker;
151  class wallet2
152  {
153  friend class ::Serialization_portability_wallet_Test;
154  friend class wallet_keys_unlocker;
155  public:
156  static constexpr const std::chrono::seconds rpc_timeout = std::chrono::minutes(3) + std::chrono::seconds(30);
157 
158  enum RefreshType {
163  };
164 
169  };
170 
171  static const char* tr(const char* str);
172 
173  static bool has_testnet_option(const boost::program_options::variables_map& vm);
174  static bool has_stagenet_option(const boost::program_options::variables_map& vm);
175  static std::string device_name_option(const boost::program_options::variables_map& vm);
176  static void init_options(boost::program_options::options_description& desc_params);
177 
179  static std::unique_ptr<wallet2> 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);
180 
182  static std::pair<std::unique_ptr<wallet2>, password_container>
183  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);
184 
186  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);
187 
189  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);
190 
191  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);
192  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);
193 
194  wallet2(cryptonote::network_type nettype = cryptonote::MAINNET, uint64_t kdf_rounds = 1, bool unattended = false);
195  ~wallet2();
196 
198  {
199  struct LR
200  {
203 
205  FIELD(m_L)
206  FIELD(m_R)
207  END_SERIALIZE()
208  };
209 
211  std::vector<LR> m_LR;
212  std::vector<crypto::key_image> m_partial_key_images; // one per key the participant has
213 
215  FIELD(m_signer)
216  FIELD(m_LR)
218  END_SERIALIZE()
219  };
220 
222  {
226  uint64_t amount;
228  bool error;
229  boost::optional<cryptonote::subaddress_receive_info> received;
230 
231  tx_scan_info_t(): money_transfered(0), error(true) {}
232  };
233 
235  {
236  uint64_t m_block_height;
241  bool m_spent;
242  uint64_t m_spent_height;
243  crypto::key_image m_key_image; //TODO: key_image stored twice :(
245  uint64_t m_amount;
246  bool m_rct;
248  size_t m_pk_index;
251  std::vector<rct::key> m_multisig_k;
252  std::vector<multisig_info> m_multisig_info; // one per other participant
253 
254  bool is_rct() const { return m_rct; }
255  uint64_t amount() const { return m_amount; }
256  const crypto::public_key &get_public_key() const { return boost::get<const cryptonote::txout_to_key>(m_tx.vout[m_internal_output_index].target).key; }
257 
259  FIELD(m_block_height)
260  FIELD(m_tx)
261  FIELD(m_txid)
262  FIELD(m_internal_output_index)
263  FIELD(m_global_output_index)
264  FIELD(m_spent)
265  FIELD(m_spent_height)
266  FIELD(m_key_image)
267  FIELD(m_mask)
268  FIELD(m_amount)
269  FIELD(m_rct)
270  FIELD(m_key_image_known)
271  FIELD(m_pk_index)
272  FIELD(m_subaddr_index)
273  FIELD(m_key_image_partial)
274  FIELD(m_multisig_k)
275  FIELD(m_multisig_info)
276  END_SERIALIZE()
277  };
278 
280  {
282  uint64_t m_amount;
283  uint64_t m_fee;
284  uint64_t m_block_height;
285  uint64_t m_unlock_time;
286  uint64_t m_timestamp;
289  };
290 
292  {
293  bool m_mempool;
295  };
296 
298  {
301  };
302 
304  {
306  uint64_t m_amount_in;
307  uint64_t m_amount_out;
308  uint64_t m_change;
309  time_t m_sent_time;
310  std::vector<cryptonote::tx_destination_entry> m_dests;
312  enum { pending, pending_not_in_pool, failed } m_state;
313  uint64_t m_timestamp;
314  uint32_t m_subaddr_account; // subaddress account of your wallet to be used in this transfer
315  std::set<uint32_t> m_subaddr_indices; // set of address indices used as inputs in this transfer
316  std::vector<std::pair<crypto::key_image, std::vector<uint64_t>>> m_rings; // relative
317  };
318 
320  {
321  uint64_t m_amount_in;
322  uint64_t m_amount_out;
323  uint64_t m_change;
324  uint64_t m_block_height;
325  std::vector<cryptonote::tx_destination_entry> m_dests;
327  uint64_t m_timestamp;
328  uint64_t m_unlock_time;
329  uint32_t m_subaddr_account; // subaddress account of your wallet to be used in this transfer
330  std::set<uint32_t> m_subaddr_indices; // set of address indices used as inputs in this transfer
331  std::vector<std::pair<crypto::key_image, std::vector<uint64_t>>> m_rings; // relative
332 
333  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) {}
335  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) {}
336  };
337 
339  {
340  std::vector<cryptonote::tx_source_entry> sources;
342  std::vector<cryptonote::tx_destination_entry> splitted_dsts; // split, includes change
343  std::vector<size_t> selected_transfers;
344  std::vector<uint8_t> extra;
345  uint64_t unlock_time;
346  bool use_rct;
348  std::vector<cryptonote::tx_destination_entry> dests; // original setup, does not include change
349  uint32_t subaddr_account; // subaddress account of your wallet to be used in this transfer
350  std::set<uint32_t> subaddr_indices; // set of address indices used as inputs in this transfer
351 
353  FIELD(sources)
354  FIELD(change_dts)
355  FIELD(splitted_dsts)
356  FIELD(selected_transfers)
357  FIELD(extra)
358  FIELD(unlock_time)
359  FIELD(use_rct)
360  FIELD(use_bulletproofs)
361  FIELD(dests)
362  FIELD(subaddr_account)
363  FIELD(subaddr_indices)
364  END_SERIALIZE()
365  };
366 
368  typedef std::unordered_multimap<crypto::hash, payment_details> payment_container;
369 
371  {
374  std::unordered_set<rct::key> used_L;
375  std::unordered_set<crypto::public_key> signing_keys;
377  };
378 
379  // The convention for destinations is:
380  // dests does not include change
381  // splitted_dsts (in construction_data) does
382  struct pending_tx
383  {
385  uint64_t dust, fee;
388  std::vector<size_t> selected_transfers;
389  std::string key_images;
391  std::vector<crypto::secret_key> additional_tx_keys;
392  std::vector<cryptonote::tx_destination_entry> dests;
393  std::vector<multisig_sig> multisig_sigs;
394 
396 
398  FIELD(tx)
399  FIELD(dust)
400  FIELD(fee)
401  FIELD(dust_added_to_fee)
402  FIELD(change_dts)
403  FIELD(selected_transfers)
404  FIELD(key_images)
405  FIELD(tx_key)
406  FIELD(additional_tx_keys)
407  FIELD(dests)
408  FIELD(construction_data)
409  FIELD(multisig_sigs)
410  END_SERIALIZE()
411  };
412 
413  // The term "Unsigned tx" is not really a tx since it's not signed yet.
414  // It doesnt have tx hash, key and the integrated address is not separated into addr + payment id.
416  {
417  std::vector<tx_construction_data> txes;
419  };
420 
422  {
423  std::vector<pending_tx> ptx;
424  std::vector<crypto::key_image> key_images;
425  };
426 
428  {
429  std::vector<pending_tx> m_ptx;
430  std::unordered_set<crypto::public_key> m_signers;
431 
433  FIELD(m_ptx)
434  FIELD(m_signers)
435  END_SERIALIZE()
436  };
437 
439  {
440  crypto::chacha_iv iv;
441  std::string account_data;
442 
444  FIELD(iv)
445  FIELD(account_data)
446  END_SERIALIZE()
447  };
448 
450  {
451  crypto::chacha_iv iv;
452  std::string cache_data;
453 
455  FIELD(iv)
456  FIELD(cache_data)
457  END_SERIALIZE()
458  };
459 
460  // GUI Address book
462  {
465  std::string m_description;
467  };
468 
470  {
472  uint64_t index_in_tx;
477  };
478 
479  typedef std::tuple<uint64_t, crypto::public_key, rct::key> get_outs_entry;
480 
482  {
485  std::vector<cryptonote::transaction> txes;
487  bool error;
488  };
489 
490  struct is_out_data
491  {
494  std::vector<boost::optional<cryptonote::subaddress_receive_info>> received;
495  };
496 
498  {
499  std::vector<cryptonote::tx_extra_field> tx_extra_fields;
500  std::vector<is_out_data> primary;
501  std::vector<is_out_data> additional;
502  };
503 
511  void generate(const std::string& wallet_, const epee::wipeable_string& password,
512  const epee::wipeable_string& multisig_data, bool create_address_file = false);
513 
524  crypto::secret_key generate(const std::string& wallet, const epee::wipeable_string& password,
525  const crypto::secret_key& recovery_param = crypto::secret_key(), bool recover = false,
526  bool two_random = false, bool create_address_file = false);
536  void generate(const std::string& wallet, const epee::wipeable_string& password,
537  const cryptonote::account_public_address &account_public_address,
538  const crypto::secret_key& spendkey, const crypto::secret_key& viewkey, bool create_address_file = false);
547  void generate(const std::string& wallet, const epee::wipeable_string& password,
548  const cryptonote::account_public_address &account_public_address,
549  const crypto::secret_key& viewkey = crypto::secret_key(), bool create_address_file = false);
557  void restore(const std::string& wallet_, const epee::wipeable_string& password, const std::string &device_name, bool create_address_file);
558 
564  std::string make_multisig(const epee::wipeable_string &password,
565  const std::vector<std::string> &info,
566  uint32_t threshold);
572  std::string make_multisig(const epee::wipeable_string &password,
573  const std::vector<crypto::secret_key> &view_keys,
574  const std::vector<crypto::public_key> &spend_keys,
575  uint32_t threshold);
579  bool finalize_multisig(const epee::wipeable_string &password, const std::vector<std::string> &info);
583  bool finalize_multisig(const epee::wipeable_string &password, std::unordered_set<crypto::public_key> pkeys, std::vector<crypto::public_key> signers);
587  std::string get_multisig_info() const;
591  static bool verify_multisig_info(const std::string &data, crypto::secret_key &skey, crypto::public_key &pkey);
595  static bool verify_extra_multisig_info(const std::string &data, std::unordered_set<crypto::public_key> &pkeys, crypto::public_key &signer);
605  size_t import_multisig(std::vector<cryptonote::blobdata> info);
611  void rewrite(const std::string& wallet_name, const epee::wipeable_string& password);
612  void write_watch_only_wallet(const std::string& wallet_name, const epee::wipeable_string& password, std::string &new_keys_filename);
613  void load(const std::string& wallet, const epee::wipeable_string& password);
614  void store();
620  void store_to(const std::string &path, const epee::wipeable_string &password);
621 
622  std::string path() const;
623 
627  bool verify_password(const epee::wipeable_string& password);
630 
631  void encrypt_keys(const crypto::chacha_key &key);
632  void encrypt_keys(const epee::wipeable_string &password);
633  void decrypt_keys(const crypto::chacha_key &key);
634  void decrypt_keys(const epee::wipeable_string &password);
635 
638 
641 
642  bool deinit();
643  bool init(std::string daemon_address = "http://localhost:8080",
644  boost::optional<epee::net_utils::http::login> daemon_login = boost::none, uint64_t upper_transaction_weight_limit = 0, bool ssl = false, bool trusted_daemon = false);
645 
646  void stop() { m_run.store(false, std::memory_order_relaxed); }
647 
650 
651  bool is_trusted_daemon() const { return m_trusted_daemon; }
652  void set_trusted_daemon(bool trusted) { m_trusted_daemon = trusted; }
653 
657  bool is_deterministic() const;
658  bool get_seed(epee::wipeable_string& electrum_words, const epee::wipeable_string &passphrase = epee::wipeable_string()) const;
659 
663  bool light_wallet() const { return m_light_wallet; }
667 
671  const std::string &get_seed_language() const;
675  void set_seed_language(const std::string &language);
676 
677  // Subaddress scheme
680  boost::optional<cryptonote::subaddress_index> get_subaddress_index(const cryptonote::account_public_address& address) const;
682  std::vector<crypto::public_key> get_subaddress_spend_public_keys(uint32_t account, uint32_t begin, uint32_t end) const;
683  std::string get_subaddress_as_str(const cryptonote::subaddress_index& index) const;
684  std::string get_address_as_str() const { return get_subaddress_as_str({0, 0}); }
685  std::string get_integrated_address_as_str(const crypto::hash8& payment_id) const;
686  void add_subaddress_account(const std::string& label);
687  size_t get_num_subaddress_accounts() const { return m_subaddress_labels.size(); }
688  size_t get_num_subaddresses(uint32_t index_major) const { return index_major < m_subaddress_labels.size() ? m_subaddress_labels[index_major].size() : 0; }
689  void add_subaddress(uint32_t index_major, const std::string& label); // throws when index is out of bound
691  std::string get_subaddress_label(const cryptonote::subaddress_index& index) const;
692  void set_subaddress_label(const cryptonote::subaddress_index &index, const std::string &label);
693  void set_subaddress_lookahead(size_t major, size_t minor);
698  bool is_deprecated() const;
699  void refresh(bool trusted_daemon);
700  void refresh(bool trusted_daemon, uint64_t start_height, uint64_t & blocks_fetched);
701  void refresh(bool trusted_daemon, uint64_t start_height, uint64_t & blocks_fetched, bool& received_money);
702  bool refresh(bool trusted_daemon, uint64_t & blocks_fetched, bool& received_money, bool& ok);
703 
706 
708  bool watch_only() const { return m_watch_only; }
709  bool multisig(bool *ready = NULL, uint32_t *threshold = NULL, uint32_t *total = NULL) const;
710  bool has_multisig_partial_key_images() const;
711  bool has_unknown_key_images() const;
712  bool get_multisig_seed(epee::wipeable_string& seed, const epee::wipeable_string &passphrase = std::string(), bool raw = true) const;
713  bool key_on_device() const { return get_device_type() != hw::device::device_type::SOFTWARE; }
715  bool reconnect_device();
716 
717  // locked & unlocked balance of given or current subaddress account
718  uint64_t balance(uint32_t subaddr_index_major) const;
719  uint64_t unlocked_balance(uint32_t subaddr_index_major) const;
720  // locked & unlocked balance per subaddress of given or current subaddress account
721  std::map<uint32_t, uint64_t> balance_per_subaddress(uint32_t subaddr_index_major) const;
722  std::map<uint32_t, uint64_t> unlocked_balance_per_subaddress(uint32_t subaddr_index_major) const;
723  // all locked & unlocked balances of all subaddress accounts
724  uint64_t balance_all() const;
725  uint64_t unlocked_balance_all() const;
726  template<typename T>
727  void transfer_selected(const std::vector<cryptonote::tx_destination_entry>& dsts, const std::vector<size_t>& selected_transfers, size_t fake_outputs_count,
728  std::vector<std::vector<tools::wallet2::get_outs_entry>> &outs,
729  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);
730  void transfer_selected_rct(std::vector<cryptonote::tx_destination_entry> dsts, const std::vector<size_t>& selected_transfers, size_t fake_outputs_count,
731  std::vector<std::vector<tools::wallet2::get_outs_entry>> &outs,
732  uint64_t unlock_time, uint64_t fee, const std::vector<uint8_t>& extra, cryptonote::transaction& tx, pending_tx &ptx, rct::RangeProofType range_proof_type);
733 
734  void commit_tx(pending_tx& ptx_vector);
735  void commit_tx(std::vector<pending_tx>& ptx_vector);
736  bool save_tx(const std::vector<pending_tx>& ptx_vector, const std::string &filename) const;
737  std::string dump_tx_to_str(const std::vector<pending_tx> &ptx_vector) const;
738  std::string save_multisig_tx(multisig_tx_set txs);
739  bool save_multisig_tx(const multisig_tx_set &txs, const std::string &filename);
740  std::string save_multisig_tx(const std::vector<pending_tx>& ptx_vector);
741  bool save_multisig_tx(const std::vector<pending_tx>& ptx_vector, const std::string &filename);
742  multisig_tx_set make_multisig_tx_set(const std::vector<pending_tx>& ptx_vector) const;
743  // load unsigned tx from file and sign it. Takes confirmation callback as argument. Used by the cli wallet
744  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);
745  // sign unsigned tx. Takes unsigned_tx_set as argument. Used by GUI
746  bool sign_tx(unsigned_tx_set &exported_txs, const std::string &signed_filename, std::vector<wallet2::pending_tx> &ptx, bool export_raw = false);
747  bool sign_tx(unsigned_tx_set &exported_txs, std::vector<wallet2::pending_tx> &ptx, signed_tx_set &signed_txs);
748  std::string sign_tx_dump_to_str(unsigned_tx_set &exported_txs, std::vector<wallet2::pending_tx> &ptx, signed_tx_set &signed_txes);
749  // load unsigned_tx_set from file.
750  bool load_unsigned_tx(const std::string &unsigned_filename, unsigned_tx_set &exported_txs) const;
751  bool parse_unsigned_tx_from_str(const std::string &unsigned_tx_st, unsigned_tx_set &exported_txs) const;
752  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);
753  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);
754  std::vector<wallet2::pending_tx> create_transactions_2(std::vector<cryptonote::tx_destination_entry> dsts, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector<uint8_t>& extra, uint32_t subaddr_account, std::set<uint32_t> subaddr_indices); // pass subaddr_indices by value on purpose
755  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);
756  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);
757  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);
758  bool load_multisig_tx(cryptonote::blobdata blob, multisig_tx_set &exported_txs, std::function<bool(const multisig_tx_set&)> accept_func = NULL);
759  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);
760  bool sign_multisig_tx_from_file(const std::string &filename, std::vector<crypto::hash> &txids, std::function<bool(const multisig_tx_set&)> accept_func);
761  bool sign_multisig_tx(multisig_tx_set &exported_txs, std::vector<crypto::hash> &txids);
762  bool sign_multisig_tx_to_file(multisig_tx_set &exported_txs, const std::string &filename, std::vector<crypto::hash> &txids);
763  std::vector<pending_tx> create_unmixable_sweep_transactions();
765  bool check_connection(uint32_t *version = NULL, uint32_t timeout = 200000);
766  void get_transfers(wallet2::transfer_container& incoming_transfers) const;
767  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;
768  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;
769  void get_payments_out(std::list<std::pair<crypto::hash,wallet2::confirmed_transfer_details>>& confirmed_payments,
770  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;
771  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;
772  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;
773 
775  void rescan_spent();
776  void rescan_blockchain(bool refresh = true);
777  bool is_transfer_unlocked(const transfer_details& td) const;
778  bool is_transfer_unlocked(uint64_t unlock_time, uint64_t block_height) const;
779 
780  uint64_t get_last_block_reward() const { return m_last_block_reward; }
781 
782  template <class t_archive>
783  inline void serialize(t_archive &a, const unsigned int ver)
784  {
785  uint64_t dummy_refresh_height = 0; // moved to keys file
786  if(ver < 5)
787  return;
788  if (ver < 19)
789  {
790  std::vector<crypto::hash> blockchain;
791  a & blockchain;
792  for (const auto &b: blockchain)
793  {
795  }
796  }
797  else
798  {
799  a & m_blockchain;
800  }
801  a & m_transfers;
803  a & m_key_images;
804  if(ver < 6)
805  return;
807  if(ver < 7)
808  return;
809  a & m_payments;
810  if(ver < 8)
811  return;
812  a & m_tx_keys;
813  if(ver < 9)
814  return;
815  a & m_confirmed_txs;
816  if(ver < 11)
817  return;
818  a & dummy_refresh_height;
819  if(ver < 12)
820  return;
821  a & m_tx_notes;
822  if(ver < 13)
823  return;
824  if (ver < 17)
825  {
826  // we're loading an old version, where m_unconfirmed_payments was a std::map
827  std::unordered_map<crypto::hash, payment_details> m;
828  a & m;
829  for (std::unordered_map<crypto::hash, payment_details>::const_iterator i = m.begin(); i != m.end(); ++i)
830  m_unconfirmed_payments.insert(std::make_pair(i->first, pool_payment_details{i->second, false}));
831  }
832  if(ver < 14)
833  return;
834  if(ver < 15)
835  {
836  // we're loading an older wallet without a pubkey map, rebuild it
837  for (size_t i = 0; i < m_transfers.size(); ++i)
838  {
839  const transfer_details &td = m_transfers[i];
841  const cryptonote::txout_to_key &o = boost::get<const cryptonote::txout_to_key>(out.target);
842  m_pub_keys.emplace(o.key, i);
843  }
844  return;
845  }
846  a & m_pub_keys;
847  if(ver < 16)
848  return;
849  a & m_address_book;
850  if(ver < 17)
851  return;
852  if (ver < 22)
853  {
854  // we're loading an old version, where m_unconfirmed_payments payload was payment_details
855  std::unordered_multimap<crypto::hash, payment_details> m;
856  a & m;
857  for (const auto &i: m)
858  m_unconfirmed_payments.insert(std::make_pair(i.first, pool_payment_details{i.second, false}));
859  }
860  if(ver < 18)
861  return;
862  a & m_scanned_pool_txs[0];
863  a & m_scanned_pool_txs[1];
864  if (ver < 20)
865  return;
866  a & m_subaddresses;
867  std::unordered_map<cryptonote::subaddress_index, crypto::public_key> dummy_subaddresses_inv;
868  a & dummy_subaddresses_inv;
871  if(ver < 21)
872  return;
873  a & m_attributes;
874  if(ver < 22)
875  return;
877  if(ver < 23)
878  return;
879  a & m_account_tags;
880  if(ver < 24)
881  return;
883  if(ver < 25)
884  return;
886  }
887 
894  static void wallet_exists(const std::string& file_path, bool& keys_file_exists, bool& wallet_file_exists);
900  static bool wallet_valid_path_format(const std::string& file_path);
901  static bool parse_long_payment_id(const std::string& payment_id_str, crypto::hash& payment_id);
902  static bool parse_short_payment_id(const std::string& payment_id_str, crypto::hash8& payment_id);
903  static bool parse_payment_id(const std::string& payment_id_str, crypto::hash& payment_id);
904 
906  void always_confirm_transfers(bool always) { m_always_confirm_transfers = always; }
907  bool print_ring_members() const { return m_print_ring_members; }
908  void print_ring_members(bool value) { m_print_ring_members = value; }
909  bool store_tx_info() const { return m_store_tx_info; }
911  uint32_t default_mixin() const { return m_default_mixin; }
912  void default_mixin(uint32_t m) { m_default_mixin = m; }
913  uint32_t get_default_priority() const { return m_default_priority; }
914  void set_default_priority(uint32_t p) { m_default_priority = p; }
915  bool auto_refresh() const { return m_auto_refresh; }
916  void auto_refresh(bool r) { m_auto_refresh = r; }
921  void set_min_output_count(uint32_t count) { m_min_output_count = count; }
922  uint32_t get_min_output_count() const { return m_min_output_count; }
923  void set_min_output_value(uint64_t value) { m_min_output_value = value; }
924  uint64_t get_min_output_value() const { return m_min_output_value; }
925  void merge_destinations(bool merge) { m_merge_destinations = merge; }
926  bool merge_destinations() const { return m_merge_destinations; }
927  bool confirm_backlog() const { return m_confirm_backlog; }
928  void confirm_backlog(bool always) { m_confirm_backlog = always; }
932  void confirm_export_overwrite(bool always) { m_confirm_export_overwrite = always; }
933  bool auto_low_priority() const { return m_auto_low_priority; }
934  void auto_low_priority(bool value) { m_auto_low_priority = value; }
938  void key_reuse_mitigation2(bool value) { m_key_reuse_mitigation2 = value; }
939  uint64_t segregation_height() const { return m_segregation_height; }
945  const std::string & device_name() const { return m_device_name; }
946  void device_name(const std::string & device_name) { m_device_name = device_name; }
947 
948  bool get_tx_key(const crypto::hash &txid, crypto::secret_key &tx_key, std::vector<crypto::secret_key> &additional_tx_keys) const;
949  void set_tx_key(const crypto::hash &txid, const crypto::secret_key &tx_key, const std::vector<crypto::secret_key> &additional_tx_keys);
950  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);
951  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);
952  std::string get_tx_proof(const crypto::hash &txid, const cryptonote::account_public_address &address, bool is_subaddress, const std::string &message);
953  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);
954 
955  std::string get_spend_proof(const crypto::hash &txid, const std::string &message);
956  bool check_spend_proof(const crypto::hash &txid, const std::string &message, const std::string &sig_str);
957 
965  std::string get_reserve_proof(const boost::optional<std::pair<uint32_t, uint64_t>> &account_minreserve, const std::string &message);
975  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);
976 
980  std::vector<address_book_row> get_address_book() const { return m_address_book; }
981  bool add_address_book_row(const cryptonote::account_public_address &address, const crypto::hash &payment_id, const std::string &description, bool is_subaddress);
982  bool delete_address_book_row(std::size_t row_id);
983 
984  uint64_t get_num_rct_outputs();
985  size_t get_num_transfer_details() const { return m_transfers.size(); }
986  const transfer_details &get_transfer_details(size_t idx) const;
987 
988  void get_hard_fork_info(uint8_t version, uint64_t &earliest_height) const;
989  bool use_fork_rules(uint8_t version, int64_t early_blocks = 0) const;
990  int get_fee_algorithm() const;
991 
992  std::string get_wallet_file() const;
993  std::string get_keys_file() const;
994  std::string get_daemon_address() const;
995  const boost::optional<epee::net_utils::http::login>& get_daemon_login() const { return m_daemon_login; }
996  uint64_t get_daemon_blockchain_height(std::string& err) const;
997  uint64_t get_daemon_blockchain_target_height(std::string& err);
1001  uint64_t get_approximate_blockchain_height() const;
1002  uint64_t estimate_blockchain_height();
1003  std::vector<size_t> select_available_outputs_from_histogram(uint64_t count, bool atleast, bool unlocked, bool allow_rct);
1004  std::vector<size_t> select_available_outputs(const std::function<bool(const transfer_details &td)> &f) const;
1005  std::vector<size_t> select_available_unmixable_outputs();
1006  std::vector<size_t> select_available_mixable_outputs();
1007 
1008  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;
1009  size_t pop_best_value(std::vector<size_t> &unused_dust_indices, const std::vector<size_t>& selected_transfers, bool smallest = false) const;
1010 
1011  void set_tx_note(const crypto::hash &txid, const std::string &note);
1012  std::string get_tx_note(const crypto::hash &txid) const;
1013 
1014  void set_description(const std::string &description);
1015  std::string get_description() const;
1016 
1021  const std::pair<std::map<std::string, std::string>, std::vector<std::string>>& get_account_tags();
1027  void set_account_tag(const std::set<uint32_t> account_indices, const std::string& tag);
1033  void set_account_tag_description(const std::string& tag, const std::string& description);
1034 
1035  std::string sign(const std::string &data) const;
1036  bool verify(const std::string &data, const cryptonote::account_public_address &address, const std::string &signature) const;
1037 
1044  std::string sign_multisig_participant(const std::string& data) const;
1052  bool verify_with_public_key(const std::string &data, const crypto::public_key &public_key, const std::string &signature) const;
1053 
1054  // Import/Export wallet data
1055  std::vector<tools::wallet2::transfer_details> export_outputs() const;
1056  std::string export_outputs_to_str() const;
1057  size_t import_outputs(const std::vector<tools::wallet2::transfer_details> &outputs);
1058  size_t import_outputs_from_str(const std::string &outputs_st);
1060  void import_payments(const payment_container &payments);
1061  void import_payments_out(const std::list<std::pair<crypto::hash,wallet2::confirmed_transfer_details>> &confirmed_payments);
1062  std::tuple<size_t, crypto::hash, std::vector<crypto::hash>> export_blockchain() const;
1063  void import_blockchain(const std::tuple<size_t, crypto::hash, std::vector<crypto::hash>> &bc);
1064  bool export_key_images(const std::string &filename) const;
1065  std::vector<std::pair<crypto::key_image, crypto::signature>> export_key_images() const;
1066  uint64_t import_key_images(const std::vector<std::pair<crypto::key_image, crypto::signature>> &signed_key_images, uint64_t &spent, uint64_t &unspent, bool check_spent = true);
1067  uint64_t import_key_images(const std::string &filename, uint64_t &spent, uint64_t &unspent);
1068 
1069  void update_pool_state(bool refreshed = false);
1070  void remove_obsolete_pool_txs(const std::vector<crypto::hash> &tx_hashes);
1071 
1072  std::string encrypt(const char *plaintext, size_t len, const crypto::secret_key &skey, bool authenticated = true) const;
1073  std::string encrypt(const epee::span<char> &span, const crypto::secret_key &skey, bool authenticated = true) const;
1074  std::string encrypt(const std::string &plaintext, const crypto::secret_key &skey, bool authenticated = true) const;
1075  std::string encrypt(const epee::wipeable_string &plaintext, const crypto::secret_key &skey, bool authenticated = true) const;
1076  std::string encrypt_with_view_secret_key(const std::string &plaintext, bool authenticated = true) const;
1077  template<typename T=std::string> T decrypt(const std::string &ciphertext, const crypto::secret_key &skey, bool authenticated = true) const;
1078  std::string decrypt_with_view_secret_key(const std::string &ciphertext, bool authenticated = true) const;
1079 
1080  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;
1081  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);
1082 
1083  uint64_t get_blockchain_height_by_date(uint16_t year, uint8_t month, uint8_t day); // 1<=month<=12, 1<=day<=31
1084 
1085  bool is_synced() const;
1086 
1087  std::vector<std::pair<uint64_t, uint64_t>> estimate_backlog(const std::vector<std::pair<double, double>> &fee_levels);
1088  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);
1089 
1090  uint64_t get_fee_multiplier(uint32_t priority, int fee_algorithm = -1) const;
1091  uint64_t get_base_fee() const;
1092  uint64_t get_fee_quantization_mask() const;
1093  uint64_t get_min_ring_size() const;
1094  uint64_t get_max_ring_size() const;
1095  uint64_t adjust_mixin(uint64_t mixin) const;
1096  uint32_t adjust_priority(uint32_t priority);
1097 
1098  bool is_unattended() const { return m_unattended; }
1099 
1100  // Light wallet specific functions
1101  // fetch unspent outs from lw node and store in m_transfers
1103  // fetch txs and store in m_payments
1105  // get_address_info
1107  // Login. new_address is true if address hasn't been used on lw node before.
1108  bool light_wallet_login(bool &new_address);
1109  // Send an import request to lw node. returns info about import fee, address and payment_id
1111  // get random outputs from light wallet server
1112  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);
1113  // Parse rct string
1114  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;
1115  // check if key image is ours
1116  bool light_wallet_key_image_is_ours(const crypto::key_image& key_image, const crypto::public_key& tx_public_key, uint64_t out_index);
1117 
1118  /*
1119  * "attributes" are a mechanism to store an arbitrary number of string values
1120  * on the level of the wallet as a whole, identified by keys. Their introduction,
1121  * technically the unordered map m_attributes stored as part of a wallet file,
1122  * led to a new wallet file version, but now new singular pieces of info may be added
1123  * without the need for a new version.
1124  *
1125  * The first and so far only value stored as such an attribute is the description.
1126  * It's stored under the standard key ATTRIBUTE_DESCRIPTION (see method set_description).
1127  *
1128  * The mechanism is open to all clients and allows them to use it for storing basically any
1129  * single string values in a wallet. To avoid the problem that different clients possibly
1130  * overwrite or misunderstand each other's attributes, a two-part key scheme is
1131  * proposed: <client name>.<value name>
1132  */
1133  const char* const ATTRIBUTE_DESCRIPTION = "wallet2.description";
1134  void set_attribute(const std::string &key, const std::string &value);
1135  std::string get_attribute(const std::string &key) const;
1136 
1141 
1142  template<class t_request, class t_response>
1143  inline bool invoke_http_json(const boost::string_ref uri, const t_request& req, t_response& res, std::chrono::milliseconds timeout = std::chrono::seconds(15), const boost::string_ref http_method = "GET")
1144  {
1145  boost::lock_guard<boost::mutex> lock(m_daemon_rpc_mutex);
1146  return epee::net_utils::invoke_http_json(uri, req, res, m_http_client, timeout, http_method);
1147  }
1148  template<class t_request, class t_response>
1149  inline bool invoke_http_bin(const boost::string_ref uri, const t_request& req, t_response& res, std::chrono::milliseconds timeout = std::chrono::seconds(15), const boost::string_ref http_method = "GET")
1150  {
1151  boost::lock_guard<boost::mutex> lock(m_daemon_rpc_mutex);
1152  return epee::net_utils::invoke_http_bin(uri, req, res, m_http_client, timeout, http_method);
1153  }
1154  template<class t_request, class t_response>
1155  inline bool invoke_http_json_rpc(const boost::string_ref uri, const std::string& method_name, const t_request& req, t_response& res, std::chrono::milliseconds timeout = std::chrono::seconds(15), const boost::string_ref http_method = "GET", const std::string& req_id = "0")
1156  {
1157  boost::lock_guard<boost::mutex> lock(m_daemon_rpc_mutex);
1158  return epee::net_utils::invoke_http_json_rpc(uri, method_name, req, res, m_http_client, timeout, http_method, req_id);
1159  }
1160 
1161  bool set_ring_database(const std::string &filename);
1162  const std::string get_ring_database() const { return m_ring_database; }
1163  bool get_ring(const crypto::key_image &key_image, std::vector<uint64_t> &outs);
1164  bool get_rings(const crypto::hash &txid, std::vector<std::pair<crypto::key_image, std::vector<uint64_t>>> &outs);
1165  bool set_ring(const crypto::key_image &key_image, const std::vector<uint64_t> &outs, bool relative);
1166  bool find_and_save_rings(bool force = true);
1167 
1168  bool blackball_output(const std::pair<uint64_t, uint64_t> &output);
1169  bool set_blackballed_outputs(const std::vector<std::pair<uint64_t, uint64_t>> &outputs, bool add = false);
1170  bool unblackball_output(const std::pair<uint64_t, uint64_t> &output);
1171  bool is_output_blackballed(const std::pair<uint64_t, uint64_t> &output) const;
1172 
1173  bool lock_keys_file();
1174  bool unlock_keys_file();
1175  bool is_keys_file_locked() const;
1176 
1177  void change_password(const std::string &filename, const epee::wipeable_string &original_password, const epee::wipeable_string &new_password);
1178 
1179  private:
1187  bool store_keys(const std::string& keys_file_name, const epee::wipeable_string& password, bool watch_only = false);
1193  bool load_keys(const std::string& keys_file_name, const epee::wipeable_string& password);
1194  void process_new_transaction(const crypto::hash &txid, const cryptonote::transaction& tx, const std::vector<uint64_t> &o_indices, uint64_t height, uint64_t ts, bool miner_tx, bool pool, bool double_spend_seen, const tx_cache_data &tx_cache_data);
1195  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);
1196  void detach_blockchain(uint64_t height);
1197  void get_short_chain_history(std::list<crypto::hash>& ids, uint64_t granularity = 1) const;
1198  bool is_tx_spendtime_unlocked(uint64_t unlock_time, uint64_t block_height) const;
1199  bool clear();
1200  void pull_blocks(uint64_t start_height, uint64_t& blocks_start_height, const std::list<crypto::hash> &short_chain_history, std::vector<cryptonote::block_complete_entry> &blocks, std::vector<cryptonote::COMMAND_RPC_GET_BLOCKS_FAST::block_output_indices> &o_indices);
1201  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);
1202  void fast_refresh(uint64_t stop_height, uint64_t &blocks_start_height, std::list<crypto::hash> &short_chain_history, bool force = false);
1203  void pull_and_parse_next_blocks(uint64_t start_height, uint64_t &blocks_start_height, std::list<crypto::hash> &short_chain_history, const std::vector<cryptonote::block_complete_entry> &prev_blocks, const std::vector<parsed_block> &prev_parsed_blocks, std::vector<cryptonote::block_complete_entry> &blocks, std::vector<parsed_block> &parsed_blocks, bool &error);
1204  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);
1205  uint64_t select_transfers(uint64_t needed_money, std::vector<size_t> unused_transfers_indices, std::vector<size_t>& selected_transfers) const;
1206  bool prepare_file_names(const std::string& file_path);
1207  void process_unconfirmed(const crypto::hash &txid, const cryptonote::transaction& tx, uint64_t height);
1208  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);
1209  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);
1210  void generate_genesis(cryptonote::block& b) const;
1211  void check_genesis(const crypto::hash& genesis_hash) const; //throws
1212  bool generate_chacha_key_from_secret_keys(crypto::chacha_key &key) const;
1213  void generate_chacha_key_from_password(const epee::wipeable_string &pass, crypto::chacha_key &key) const;
1214  crypto::hash get_payment_id(const pending_tx &ptx) const;
1215  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;
1216  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;
1217  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;
1218  void parse_block_round(const cryptonote::blobdata &blob, cryptonote::block &bl, crypto::hash &bl_id, bool &error) const;
1219  uint64_t get_upper_transaction_weight_limit() const;
1220  std::vector<uint64_t> get_unspent_amounts_vector() const;
1221  uint64_t get_dynamic_base_fee_estimate() const;
1222  float get_output_relatedness(const transfer_details &td0, const transfer_details &td1) const;
1223  std::vector<size_t> pick_preferred_rct_inputs(uint64_t needed_money, uint32_t subaddr_account, const std::set<uint32_t> &subaddr_indices) const;
1224  void set_spent(size_t idx, uint64_t height);
1225  void set_unspent(size_t idx);
1226  void get_outs(std::vector<std::vector<get_outs_entry>> &outs, const std::vector<size_t> &selected_transfers, size_t fake_outputs_count);
1227  bool tx_add_fake_output(std::vector<std::vector<tools::wallet2::get_outs_entry>> &outs, uint64_t global_index, const crypto::public_key& tx_public_key, const rct::key& mask, uint64_t real_index, bool unlocked) const;
1229  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;
1230  std::vector<size_t> get_only_rct(const std::vector<size_t> &unused_dust_indices, const std::vector<size_t> &unused_transfers_indices) const;
1231  void scan_output(const cryptonote::transaction &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);
1232  void trim_hashchain();
1234  rct::multisig_kLRki get_multisig_composite_kLRki(size_t n, const crypto::public_key &ignore, std::unordered_set<rct::key> &used_L, std::unordered_set<rct::key> &new_used_L) const;
1235  rct::multisig_kLRki get_multisig_kLRki(size_t n, const rct::key &k) const;
1236  rct::key get_multisig_k(size_t idx, const std::unordered_set<rct::key> &used_L) const;
1237  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);
1238  bool add_rings(const crypto::chacha_key &key, const cryptonote::transaction_prefix &tx);
1239  bool add_rings(const cryptonote::transaction_prefix &tx);
1241  bool get_ring(const crypto::chacha_key &key, const crypto::key_image &key_image, std::vector<uint64_t> &outs);
1242  crypto::chacha_key get_ringdb_key();
1243  void setup_keys(const epee::wipeable_string &password);
1244 
1245  bool get_rct_distribution(uint64_t &start_height, std::vector<uint64_t> &distribution);
1246 
1247  uint64_t get_segregation_fork_height() const;
1248 
1249  void cache_tx_data(const cryptonote::transaction& tx, const crypto::hash &txid, tx_cache_data &tx_cache_data) const;
1250 
1251  void setup_new_blockchain();
1252  void create_keys_file(const std::string &wallet_, bool watch_only, const epee::wipeable_string &password, bool create_address_file);
1253 
1255  boost::optional<epee::net_utils::http::login> m_daemon_login;
1256  std::string m_daemon_address;
1257  std::string m_wallet_file;
1258  std::string m_keys_file;
1259  epee::net_utils::http::http_simple_client m_http_client;
1261  std::unordered_map<crypto::hash, unconfirmed_transfer_details> m_unconfirmed_txs;
1262  std::unordered_map<crypto::hash, confirmed_transfer_details> m_confirmed_txs;
1263  std::unordered_multimap<crypto::hash, pool_payment_details> m_unconfirmed_payments;
1264  std::unordered_map<crypto::hash, crypto::secret_key> m_tx_keys;
1266  std::unordered_map<crypto::hash, std::vector<crypto::secret_key>> m_additional_tx_keys;
1267 
1270  std::unordered_map<crypto::key_image, size_t> m_key_images;
1271  std::unordered_map<crypto::public_key, size_t> m_pub_keys;
1273  std::unordered_map<crypto::public_key, cryptonote::subaddress_index> m_subaddresses;
1274  std::vector<std::vector<std::string>> m_subaddress_labels;
1275  std::unordered_map<crypto::hash, std::string> m_tx_notes;
1276  std::unordered_map<std::string, std::string> m_attributes;
1277  std::vector<tools::wallet2::address_book_row> m_address_book;
1278  std::pair<std::map<std::string, std::string>, std::vector<std::string>> m_account_tags;
1279  uint64_t m_upper_transaction_weight_limit; //TODO: auto-calc this value or request from daemon, now use some fixed value
1280  const std::vector<std::vector<tools::wallet2::multisig_info>> *m_multisig_rescan_info;
1281  const std::vector<std::vector<rct::key>> *m_multisig_rescan_k;
1282 
1283  std::atomic<bool> m_run;
1284 
1285  boost::mutex m_daemon_rpc_mutex;
1286 
1291  uint64_t m_kdf_rounds;
1292  std::string seed_language;
1295  bool m_multisig;
1297  std::vector<crypto::public_key> m_multisig_signers;
1307  // If m_refresh_from_block_height is explicitly set to zero we need this to differentiate it from the case that
1308  // m_refresh_from_block_height was defaulted to zero.*/
1326  std::unordered_set<crypto::hash> m_scanned_pool_txs[2];
1328  std::string m_device_name;
1329 
1330  // Light wallet
1331  bool m_light_wallet; /* sends view key to daemon for scanning */
1338  // Light wallet info needed to populate m_payment requires 2 separate api calls (get_address_txs and get_unspent_outs)
1339  // We save the info from the first call in m_light_wallet_address_txs for easier lookup.
1340  std::unordered_map<crypto::hash, address_tx> m_light_wallet_address_txs;
1341  // store calculated key image for faster lookup
1342  std::unordered_map<crypto::public_key, std::map<uint64_t, crypto::key_image> > m_key_image_cache;
1343 
1344  std::string m_ring_database;
1346  std::unique_ptr<ringdb> m_ringdb;
1347  boost::optional<crypto::chacha_key> m_ringdb_key;
1348 
1350  std::unique_ptr<tools::file_locker> m_keys_file_locker;
1351 
1352  crypto::chacha_key m_cache_key;
1353  boost::optional<epee::wipeable_string> m_encrypt_keys_after_refresh;
1354 
1356  };
1357 }
1359 BOOST_CLASS_VERSION(tools::wallet2::transfer_details, 9)
1360 BOOST_CLASS_VERSION(tools::wallet2::multisig_info, 1)
1361 BOOST_CLASS_VERSION(tools::wallet2::multisig_info::LR, 0)
1362 BOOST_CLASS_VERSION(tools::wallet2::multisig_tx_set, 1)
1363 BOOST_CLASS_VERSION(tools::wallet2::payment_details, 4)
1364 BOOST_CLASS_VERSION(tools::wallet2::pool_payment_details, 1)
1365 BOOST_CLASS_VERSION(tools::wallet2::unconfirmed_transfer_details, 8)
1366 BOOST_CLASS_VERSION(tools::wallet2::confirmed_transfer_details, 6)
1367 BOOST_CLASS_VERSION(tools::wallet2::address_book_row, 17)
1368 BOOST_CLASS_VERSION(tools::wallet2::reserve_proof_entry, 0)
1369 BOOST_CLASS_VERSION(tools::wallet2::unsigned_tx_set, 0)
1370 BOOST_CLASS_VERSION(tools::wallet2::signed_tx_set, 0)
1371 BOOST_CLASS_VERSION(tools::wallet2::tx_construction_data, 3)
1372 BOOST_CLASS_VERSION(tools::wallet2::pending_tx, 3)
1373 BOOST_CLASS_VERSION(tools::wallet2::multisig_sig, 0)
1374 
1375 namespace boost
1376 {
1377  namespace serialization
1378  {
1379  template <class Archive>
1380  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)
1381  {
1382  }
1383  template <class Archive>
1384  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)
1385  {
1386  if (ver < 1)
1387  {
1388  x.m_mask = rct::identity();
1389  x.m_amount = x.m_tx.vout[x.m_internal_output_index].amount;
1390  }
1391  if (ver < 2)
1392  {
1393  x.m_spent_height = 0;
1394  }
1395  if (ver < 4)
1396  {
1397  x.m_rct = x.m_tx.vout[x.m_internal_output_index].amount == 0;
1398  }
1399  if (ver < 6)
1400  {
1401  x.m_key_image_known = true;
1402  }
1403  if (ver < 7)
1404  {
1405  x.m_pk_index = 0;
1406  }
1407  if (ver < 8)
1408  {
1409  x.m_subaddr_index = {};
1410  }
1411  if (ver < 9)
1412  {
1413  x.m_key_image_partial = false;
1414  x.m_multisig_k.clear();
1415  x.m_multisig_info.clear();
1416  }
1417  }
1418 
1419  template <class Archive>
1420  inline void serialize(Archive &a, tools::wallet2::transfer_details &x, const boost::serialization::version_type ver)
1421  {
1422  a & x.m_block_height;
1425  if (ver < 3)
1426  {
1428  a & tx;
1429  x.m_tx = (const cryptonote::transaction_prefix&)tx;
1431  }
1432  else
1433  {
1434  a & x.m_tx;
1435  }
1436  a & x.m_spent;
1437  a & x.m_key_image;
1438  if (ver < 1)
1439  {
1440  // ensure mask and amount are set
1441  initialize_transfer_details(a, x, ver);
1442  return;
1443  }
1444  a & x.m_mask;
1445  a & x.m_amount;
1446  if (ver < 2)
1447  {
1448  initialize_transfer_details(a, x, ver);
1449  return;
1450  }
1451  a & x.m_spent_height;
1452  if (ver < 3)
1453  {
1454  initialize_transfer_details(a, x, ver);
1455  return;
1456  }
1457  a & x.m_txid;
1458  if (ver < 4)
1459  {
1460  initialize_transfer_details(a, x, ver);
1461  return;
1462  }
1463  a & x.m_rct;
1464  if (ver < 5)
1465  {
1466  initialize_transfer_details(a, x, ver);
1467  return;
1468  }
1469  if (ver < 6)
1470  {
1471  // v5 did not properly initialize
1472  uint8_t u;
1473  a & u;
1474  x.m_key_image_known = true;
1475  return;
1476  }
1477  a & x.m_key_image_known;
1478  if (ver < 7)
1479  {
1480  initialize_transfer_details(a, x, ver);
1481  return;
1482  }
1483  a & x.m_pk_index;
1484  if (ver < 8)
1485  {
1486  initialize_transfer_details(a, x, ver);
1487  return;
1488  }
1489  a & x.m_subaddr_index;
1490  if (ver < 9)
1491  {
1492  initialize_transfer_details(a, x, ver);
1493  return;
1494  }
1495  a & x.m_multisig_info;
1496  a & x.m_multisig_k;
1497  a & x.m_key_image_partial;
1498  }
1499 
1500  template <class Archive>
1501  inline void serialize(Archive &a, tools::wallet2::multisig_info::LR &x, const boost::serialization::version_type ver)
1502  {
1503  a & x.m_L;
1504  a & x.m_R;
1505  }
1506 
1507  template <class Archive>
1508  inline void serialize(Archive &a, tools::wallet2::multisig_info &x, const boost::serialization::version_type ver)
1509  {
1510  a & x.m_signer;
1511  a & x.m_LR;
1512  a & x.m_partial_key_images;
1513  }
1514 
1515  template <class Archive>
1516  inline void serialize(Archive &a, tools::wallet2::multisig_tx_set &x, const boost::serialization::version_type ver)
1517  {
1518  a & x.m_ptx;
1519  a & x.m_signers;
1520  }
1521 
1522  template <class Archive>
1523  inline void serialize(Archive &a, tools::wallet2::unconfirmed_transfer_details &x, const boost::serialization::version_type ver)
1524  {
1525  a & x.m_change;
1526  a & x.m_sent_time;
1527  if (ver < 5)
1528  {
1530  a & tx;
1531  x.m_tx = (const cryptonote::transaction_prefix&)tx;
1532  }
1533  else
1534  {
1535  a & x.m_tx;
1536  }
1537  if (ver < 1)
1538  return;
1539  a & x.m_dests;
1540  a & x.m_payment_id;
1541  if (ver < 2)
1542  return;
1543  a & x.m_state;
1544  if (ver < 3)
1545  return;
1546  a & x.m_timestamp;
1547  if (ver < 4)
1548  return;
1549  a & x.m_amount_in;
1550  a & x.m_amount_out;
1551  if (ver < 6)
1552  {
1553  // v<6 may not have change accumulated in m_amount_out, which is a pain,
1554  // as it's readily understood to be sum of outputs.
1555  // We convert it to include change from v6
1556  if (!typename Archive::is_saving() && x.m_change != (uint64_t)-1)
1557  x.m_amount_out += x.m_change;
1558  }
1559  if (ver < 7)
1560  {
1561  x.m_subaddr_account = 0;
1562  return;
1563  }
1564  a & x.m_subaddr_account;
1565  a & x.m_subaddr_indices;
1566  if (ver < 8)
1567  return;
1568  a & x.m_rings;
1569  }
1570 
1571  template <class Archive>
1572  inline void serialize(Archive &a, tools::wallet2::confirmed_transfer_details &x, const boost::serialization::version_type ver)
1573  {
1574  a & x.m_amount_in;
1575  a & x.m_amount_out;
1576  a & x.m_change;
1577  a & x.m_block_height;
1578  if (ver < 1)
1579  return;
1580  a & x.m_dests;
1581  a & x.m_payment_id;
1582  if (ver < 2)
1583  return;
1584  a & x.m_timestamp;
1585  if (ver < 3)
1586  {
1587  // v<3 may not have change accumulated in m_amount_out, which is a pain,
1588  // as it's readily understood to be sum of outputs. Whether it got added
1589  // or not depends on whether it came from a unconfirmed_transfer_details
1590  // (not included) or not (included). We can't reliably tell here, so we
1591  // check whether either yields a "negative" fee, or use the other if so.
1592  // We convert it to include change from v3
1593  if (!typename Archive::is_saving() && x.m_change != (uint64_t)-1)
1594  {
1595  if (x.m_amount_in > (x.m_amount_out + x.m_change))
1596  x.m_amount_out += x.m_change;
1597  }
1598  }
1599  if (ver < 4)
1600  {
1601  if (!typename Archive::is_saving())
1602  x.m_unlock_time = 0;
1603  return;
1604  }
1605  a & x.m_unlock_time;
1606  if (ver < 5)
1607  {
1608  x.m_subaddr_account = 0;
1609  return;
1610  }
1611  a & x.m_subaddr_account;
1612  a & x.m_subaddr_indices;
1613  if (ver < 6)
1614  return;
1615  a & x.m_rings;
1616  }
1617 
1618  template <class Archive>
1619  inline void serialize(Archive& a, tools::wallet2::payment_details& x, const boost::serialization::version_type ver)
1620  {
1621  a & x.m_tx_hash;
1622  a & x.m_amount;
1623  a & x.m_block_height;
1624  a & x.m_unlock_time;
1625  if (ver < 1)
1626  return;
1627  a & x.m_timestamp;
1628  if (ver < 2)
1629  {
1630  x.m_coinbase = false;
1631  x.m_subaddr_index = {};
1632  return;
1633  }
1634  a & x.m_subaddr_index;
1635  if (ver < 3)
1636  {
1637  x.m_coinbase = false;
1638  x.m_fee = 0;
1639  return;
1640  }
1641  a & x.m_fee;
1642  if (ver < 4)
1643  {
1644  x.m_coinbase = false;
1645  return;
1646  }
1647  a & x.m_coinbase;
1648  }
1649 
1650  template <class Archive>
1651  inline void serialize(Archive& a, tools::wallet2::pool_payment_details& x, const boost::serialization::version_type ver)
1652  {
1653  a & x.m_pd;
1654  a & x.m_double_spend_seen;
1655  }
1656 
1657  template <class Archive>
1658  inline void serialize(Archive& a, tools::wallet2::address_book_row& x, const boost::serialization::version_type ver)
1659  {
1660  a & x.m_address;
1661  a & x.m_payment_id;
1662  a & x.m_description;
1663  if (ver < 17)
1664  {
1665  x.m_is_subaddress = false;
1666  return;
1667  }
1668  a & x.m_is_subaddress;
1669  }
1670 
1671  template <class Archive>
1672  inline void serialize(Archive& a, tools::wallet2::reserve_proof_entry& x, const boost::serialization::version_type ver)
1673  {
1674  a & x.txid;
1675  a & x.index_in_tx;
1676  a & x.shared_secret;
1677  a & x.key_image;
1678  a & x.shared_secret_sig;
1679  a & x.key_image_sig;
1680  }
1681 
1682  template <class Archive>
1683  inline void serialize(Archive &a, tools::wallet2::unsigned_tx_set &x, const boost::serialization::version_type ver)
1684  {
1685  a & x.txes;
1686  a & x.transfers;
1687  }
1688 
1689  template <class Archive>
1690  inline void serialize(Archive &a, tools::wallet2::signed_tx_set &x, const boost::serialization::version_type ver)
1691  {
1692  a & x.ptx;
1693  a & x.key_images;
1694  }
1695 
1696  template <class Archive>
1697  inline void serialize(Archive &a, tools::wallet2::tx_construction_data &x, const boost::serialization::version_type ver)
1698  {
1699  a & x.sources;
1700  a & x.change_dts;
1701  a & x.splitted_dsts;
1702  if (ver < 2)
1703  {
1704  // load list to vector
1705  std::list<size_t> selected_transfers;
1706  a & selected_transfers;
1707  x.selected_transfers.clear();
1708  x.selected_transfers.reserve(selected_transfers.size());
1709  for (size_t t: selected_transfers)
1710  x.selected_transfers.push_back(t);
1711  }
1712  a & x.extra;
1713  a & x.unlock_time;
1714  a & x.use_rct;
1715  a & x.dests;
1716  if (ver < 1)
1717  {
1718  x.subaddr_account = 0;
1719  return;
1720  }
1721  a & x.subaddr_account;
1722  a & x.subaddr_indices;
1723  if (ver < 2)
1724  return;
1725  a & x.selected_transfers;
1726  if (ver < 3)
1727  return;
1728  a & x.use_bulletproofs;
1729  }
1730 
1731  template <class Archive>
1732  inline void serialize(Archive &a, tools::wallet2::multisig_sig &x, const boost::serialization::version_type ver)
1733  {
1734  a & x.sigs;
1735  a & x.ignore;
1736  a & x.used_L;
1737  a & x.signing_keys;
1738  a & x.msout;
1739  }
1740 
1741  template <class Archive>
1742  inline void serialize(Archive &a, tools::wallet2::pending_tx &x, const boost::serialization::version_type ver)
1743  {
1744  a & x.tx;
1745  a & x.dust;
1746  a & x.fee;
1747  a & x.dust_added_to_fee;
1748  a & x.change_dts;
1749  if (ver < 2)
1750  {
1751  // load list to vector
1752  std::list<size_t> selected_transfers;
1753  a & selected_transfers;
1754  x.selected_transfers.clear();
1755  x.selected_transfers.reserve(selected_transfers.size());
1756  for (size_t t: selected_transfers)
1757  x.selected_transfers.push_back(t);
1758  }
1759  a & x.key_images;
1760  a & x.tx_key;
1761  a & x.dests;
1762  a & x.construction_data;
1763  if (ver < 1)
1764  return;
1765  a & x.additional_tx_keys;
1766  if (ver < 2)
1767  return;
1768  a & x.selected_transfers;
1769  if (ver < 3)
1770  return;
1771  a & x.multisig_sigs;
1772  }
1773  }
1774 }
1775 
1776 namespace tools
1777 {
1778 
1779  namespace detail
1780  {
1781  //----------------------------------------------------------------------------------------------------
1782  inline void digit_split_strategy(const std::vector<cryptonote::tx_destination_entry>& dsts,
1783  const cryptonote::tx_destination_entry& change_dst, uint64_t dust_threshold,
1784  std::vector<cryptonote::tx_destination_entry>& splitted_dsts, std::vector<cryptonote::tx_destination_entry> &dust_dsts)
1785  {
1786  splitted_dsts.clear();
1787  dust_dsts.clear();
1788 
1789  for(auto& de: dsts)
1790  {
1792  [&](uint64_t chunk) { splitted_dsts.push_back(cryptonote::tx_destination_entry(chunk, de.addr, de.is_subaddress)); },
1793  [&](uint64_t a_dust) { splitted_dsts.push_back(cryptonote::tx_destination_entry(a_dust, de.addr, de.is_subaddress)); } );
1794  }
1795 
1797  [&](uint64_t chunk) {
1798  if (chunk <= dust_threshold)
1799  dust_dsts.push_back(cryptonote::tx_destination_entry(chunk, change_dst.addr, false));
1800  else
1801  splitted_dsts.push_back(cryptonote::tx_destination_entry(chunk, change_dst.addr, false));
1802  },
1803  [&](uint64_t a_dust) { dust_dsts.push_back(cryptonote::tx_destination_entry(a_dust, change_dst.addr, false)); } );
1804  }
1805  //----------------------------------------------------------------------------------------------------
1806  inline void null_split_strategy(const std::vector<cryptonote::tx_destination_entry>& dsts,
1807  const cryptonote::tx_destination_entry& change_dst, uint64_t dust_threshold,
1808  std::vector<cryptonote::tx_destination_entry>& splitted_dsts, std::vector<cryptonote::tx_destination_entry> &dust_dsts)
1809  {
1810  splitted_dsts = dsts;
1811 
1812  dust_dsts.clear();
1813  uint64_t change = change_dst.amount;
1814 
1815  if (0 != change)
1816  {
1817  splitted_dsts.push_back(cryptonote::tx_destination_entry(change, change_dst.addr, false));
1818  }
1819  }
1820  //----------------------------------------------------------------------------------------------------
1822  {
1823  std::string indexes;
1824  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) + " "; });
1825  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);
1826  }
1827  //----------------------------------------------------------------------------------------------------
1828  }
1829  //----------------------------------------------------------------------------------------------------
1830 }
uint64_t m_upper_transaction_weight_limit
Definition: wallet2.h:1279
bool reconnect_device()
Definition: wallet2.cpp:995
bool watch_only() const
Definition: wallet2.h:708
uint32_t subaddr_account
Definition: wallet2.h:349
uint64_t unlock_time
Definition: wallet2.h:345
static bool parse_long_payment_id(const std::string &payment_id_str, crypto::hash &payment_id)
Definition: wallet2.cpp:4230
void rescan_spent()
Definition: wallet2.cpp:4773
Definition: binary_utils.h:36
Definition: wallet2.h:427
std::vector< crypto::public_key > get_subaddress_spend_public_keys(uint32_t account, uint32_t begin, uint32_t end) const
Definition: wallet2.h:167
epee::net_utils::http::http_simple_client m_http_client
Definition: wallet2.h:1259
std::vector< crypto::key_image > key_images
Definition: wallet2.h:424
bool error
Definition: wallet2.h:228
uint64_t m_segregation_height
Definition: wallet2.h:1322
void get_outs(std::vector< std::vector< get_outs_entry >> &outs, const std::vector< size_t > &selected_transfers, size_t fake_outputs_count)
Definition: wallet2.cpp:6416
void set_unspent(size_t idx)
Definition: wallet2.cpp:1157
std::string get_reserve_proof(const boost::optional< std::pair< uint32_t, uint64_t >> &account_minreserve, const std::string &message)
Generates a proof that proves the reserve of unspent funds.
Definition: wallet2.cpp:9609
void get_unconfirmed_payments(std::list< std::pair< crypto::hash, wallet2::pool_payment_details >> &unconfirmed_payments, const boost::optional< uint32_t > &subaddr_account=boost::none, const std::set< uint32_t > &subaddr_indices={}) const
Definition: wallet2.cpp:4764
cryptonote::transaction tx
Definition: wallet2.h:384
crypto::chacha_iv iv
Definition: wallet2.h:440
bool m_always_confirm_transfers
Definition: wallet2.h:1298
void setup_new_blockchain()
Definition: wallet2.cpp:3450
AskPasswordType ask_password() const
Definition: wallet2.h:919
bool sign_multisig_tx(multisig_tx_set &exported_txs, std::vector< crypto::hash > &txids)
Definition: wallet2.cpp:5715
uint64_t unlocked_balance(uint32_t subaddr_index_major) const
Definition: wallet2.cpp:4636
crypto::public_key ignore
Definition: wallet2.h:373
void callback(i_wallet2_callback *callback)
Definition: wallet2.h:649
rct::multisig_kLRki get_multisig_kLRki(size_t n, const rct::key &k) const
Definition: wallet2.cpp:10706
Definition: wallet2.h:421
const boost::optional< epee::net_utils::http::login > & get_daemon_login() const
Definition: wallet2.h:995
const uint32_t T[512]
Definition: groestl_tables.h:33
hw::device::device_type m_key_device_type
Definition: wallet2.h:1289
size_t get_num_subaddresses(uint32_t index_major) const
Definition: wallet2.h:688
std::string cache_data
Definition: wallet2.h:452
std::unordered_map< crypto::hash, std::vector< crypto::secret_key > > m_additional_tx_keys
Definition: wallet2.h:1266
bool m_confirm_export_overwrite
Definition: wallet2.h:1318
void update_multisig_rescan_info(const std::vector< std::vector< rct::key >> &multisig_k, const std::vector< std::vector< tools::wallet2::multisig_info >> &info, size_t n)
Definition: wallet2.cpp:10813
void process_parsed_blocks(uint64_t start_height, const std::vector< cryptonote::block_complete_entry > &blocks, const std::vector< parsed_block > &parsed_blocks, uint64_t &blocks_added)
Definition: wallet2.cpp:1977
void add_unconfirmed_tx(const cryptonote::transaction &tx, uint64_t amount_in, const std::vector< cryptonote::tx_destination_entry > &dests, const crypto::hash &payment_id, uint64_t change_amount, uint32_t subaddr_account, const std::set< uint32_t > &subaddr_indices)
Definition: wallet2.cpp:5032
void restore(const std::string &wallet_, const epee::wipeable_string &password, const std::string &device_name, bool create_address_file)
Restore a wallet hold by an HW.
Definition: wallet2.cpp:3787
Definition: rctTypes.h:111
const crypto::hash & operator[](size_t idx) const
Definition: wallet2.h:128
void get_payments(const crypto::hash &payment_id, std::list< wallet2::payment_details > &payments, uint64_t min_height=0, const boost::optional< uint32_t > &subaddr_account=boost::none, const std::set< uint32_t > &subaddr_indices={}) const
Definition: wallet2.cpp:4713
crypto::public_key get_tx_pub_key_from_received_outs(const tools::wallet2::transfer_details &td) const
Definition: wallet2.cpp:10061
Definition: cryptonote_config.h:206
cryptonote::blobdata export_multisig()
Definition: wallet2.cpp:10763
bool invoke_http_json(const boost::string_ref uri, const t_request &req, t_response &res, std::chrono::milliseconds timeout=std::chrono::seconds(15), const boost::string_ref http_method="GET")
Definition: wallet2.h:1143
bool get_seed(epee::wipeable_string &electrum_words, const epee::wipeable_string &passphrase=epee::wipeable_string()) const
Definition: wallet2.cpp:906
std::atomic< bool > m_run
Definition: wallet2.h:1283
payment_container export_payments() const
Definition: wallet2.cpp:10476
uint64_t m_block_height
Definition: wallet2.h:284
bool m_is_subaddress
Definition: wallet2.h:466
bool key_on_device() const
Definition: wallet2.h:713
void auto_low_priority(bool value)
Definition: wallet2.h:934
std::map< uint32_t, uint64_t > unlocked_balance_per_subaddress(uint32_t subaddr_index_major) const
Definition: wallet2.cpp:4675
std::string export_outputs_to_str() const
Definition: wallet2.cpp:10549
uint64_t m_unlock_time
Definition: wallet2.h:285
void commit_tx(pending_tx &ptx_vector)
Definition: wallet2.cpp:5090
void scan_output(const cryptonote::transaction &tx, const crypto::public_key &tx_pub_key, size_t i, tx_scan_info_t &tx_scan_info, int &num_vouts_received, std::unordered_map< cryptonote::subaddress_index, uint64_t > &tx_money_got_in_outs, std::vector< size_t > &outs)
Definition: wallet2.cpp:1240
static std::unique_ptr< wallet2 > make_dummy(const boost::program_options::variables_map &vm, bool unattended, const std::function< boost::optional< password_container >(const char *, bool)> &password_prompter)
Just parses variables.
Definition: wallet2.cpp:877
virtual boost::optional< epee::wipeable_string > on_get_password(const char *reason)
Definition: wallet2.h:93
cryptonote::subaddress_index m_subaddr_index
Definition: wallet2.h:288
bool is_old_file_format
Definition: wallet2.h:1293
Definition: unordered_containers_boost_serialization.h:37
bool ignore_fractional_outputs() const
Definition: wallet2.h:941
void trim(size_t height)
Definition: wallet2.h:133
const std::string & get_seed_language() const
Gets the seed language.
Definition: wallet2.cpp:1019
cryptonote::network_type m_nettype
Definition: wallet2.h:1290
uint64_t m_change
Definition: wallet2.h:323
size_t import_outputs(const std::vector< tools::wallet2::transfer_details > &outputs)
Definition: wallet2.cpp:10566
std::vector< wallet2::pending_tx > create_transactions_from(const cryptonote::account_public_address &address, bool is_subaddress, const size_t outputs, std::vector< size_t > unused_transfers_indices, std::vector< size_t > unused_dust_indices, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector< uint8_t > &extra)
Definition: wallet2.cpp:8567
void confirm_non_default_ring_size(bool always)
Definition: wallet2.h:944
std::pair< size_t, size_t > get_subaddress_lookahead() const
Definition: wallet2.h:694
bool is_output_blackballed(const std::pair< uint64_t, uint64_t > &output) const
Definition: wallet2.cpp:6261
Definition: wallet2.h:151
Definition: node_rpc_proxy.h:39
bool dust_added_to_fee
Definition: wallet2.h:386
void process_new_transaction(const crypto::hash &txid, const cryptonote::transaction &tx, const std::vector< uint64_t > &o_indices, uint64_t height, uint64_t ts, bool miner_tx, bool pool, bool double_spend_seen, const tx_cache_data &tx_cache_data)
Definition: wallet2.cpp:1322
void expand_subaddresses(const cryptonote::subaddress_index &index)
Definition: wallet2.cpp:1078
static void wallet_exists(const std::string &file_path, bool &keys_file_exists, bool &wallet_file_exists)
Check if wallet keys and bin files exist.
Definition: wallet2.cpp:4215
cryptonote::subaddress_index m_subaddr_index
Definition: wallet2.h:249
const std::string get_ring_database() const
Definition: wallet2.h:1162
std::vector< size_t > select_available_unmixable_outputs()
Definition: wallet2.cpp:8912
void confirm_missing_payment_id(bool always)
Definition: wallet2.h:918
Definition: wallet2.h:279
Definition: cryptonote_basic.h:427
void default_mixin(uint32_t m)
Definition: wallet2.h:912
uint64_t get_approximate_blockchain_height() const
Calculates the approximate blockchain height from current date/time.
Definition: wallet2.cpp:9900
bool sign_tx(const std::string &unsigned_filename, const std::string &signed_filename, std::vector< wallet2::pending_tx > &ptx, std::function< bool(const unsigned_tx_set &)> accept_func=NULL, bool export_raw=false)
Definition: wallet2.cpp:5291
bool confirm_export_overwrite() const
Definition: wallet2.h:931
void parse_block_round(const cryptonote::blobdata &blob, cryptonote::block &bl, crypto::hash &bl_id, bool &error) const
Definition: wallet2.cpp:1928
Definition: cryptonote_protocol_defs.h:109
uint64_t amount
Definition: wallet2.h:226
static const unsigned char iv[64]
Definition: sha512-hash.c:13
Definition: wallet2.h:118
std::vector< cryptonote::tx_destination_entry > dests
Definition: wallet2.h:392
std::vector< crypto::secret_key > additional_tx_keys
Definition: wallet2.h:391
std::vector< rct::key > m_multisig_k
Definition: wallet2.h:251
std::vector< LR > m_LR
Definition: wallet2.h:211
size_t import_multisig(std::vector< cryptonote::blobdata > info)
Definition: wallet2.cpp:10834
int get_fee_algorithm() const
Definition: wallet2.cpp:5933
void auto_refresh(bool r)
Definition: wallet2.h:916
crypto::public_key shared_secret
Definition: wallet2.h:473
crypto::public_key get_multisig_signing_public_key(size_t idx) const
Definition: wallet2.cpp:10684
uint32_t m_confirm_backlog_threshold
Definition: wallet2.h:1317
uint64_t balance(uint32_t subaddr_index_major) const
Definition: wallet2.cpp:4626
POD_CLASS key_derivation
Definition: crypto.h:85
void get_hard_fork_info(uint8_t version, uint64_t &earliest_height) const
Definition: wallet2.cpp:8775
Definition: cryptonote_basic.h:366
static bool query_device(hw::device::device_type &device_type, const std::string &keys_file_name, const epee::wipeable_string &password, uint64_t kdf_rounds=1)
determine the key storage for the specified wallet file
Definition: wallet2.cpp:3485
void merge_destinations(bool merge)
Definition: wallet2.h:925
bool save_tx(const std::vector< pending_tx > &ptx_vector, const std::string &filename) const
Definition: wallet2.cpp:5175
std::string path() const
Definition: wallet2.cpp:4509
bool is_transfer_unlocked(const transfer_details &td) const
Definition: wallet2.cpp:4835
std::vector< size_t > selected_transfers
Definition: wallet2.h:388
boost::optional< crypto::chacha_key > m_ringdb_key
Definition: wallet2.h:1347
std::unordered_map< crypto::public_key, cryptonote::subaddress_index > m_subaddresses
Definition: wallet2.h:1273
bool is_unattended() const
Definition: wallet2.h:1098
bool parse_uri(const std::string &uri, std::string &address, std::string &payment_id, uint64_t &amount, std::string &tx_description, std::string &recipient_name, std::vector< std::string > &unknown_parameters, std::string &error)
Definition: wallet2.cpp:11076
uint64_t m_kdf_rounds
Definition: wallet2.h:1291
crypto::hash hash
Definition: wallet2.h:483
bool segregate_pre_fork_outputs() const
Definition: wallet2.h:935
std::deque< crypto::hash > m_blockchain
Definition: wallet2.h:147
std::string sign(const std::string &data) const
Definition: wallet2.cpp:9994
static constexpr const std::chrono::seconds rpc_timeout
Definition: wallet2.h:156
void decompose_amount_into_digits(uint64_t amount, uint64_t dust_threshold, const chunk_handler_t &chunk_handler, const dust_handler_t &dust_handler)
Definition: cryptonote_format_utils.h:187
wallet2(cryptonote::network_type nettype=cryptonote::MAINNET, uint64_t kdf_rounds=1, bool unattended=false)
Definition: wallet2.cpp:754
std::vector< crypto::public_key > m_multisig_signers
Definition: wallet2.h:1297
void decrypt_keys(const crypto::chacha_key &key)
Definition: wallet2.cpp:3430
void transfer_selected_rct(std::vector< cryptonote::tx_destination_entry > dsts, const std::vector< size_t > &selected_transfers, size_t fake_outputs_count, std::vector< std::vector< tools::wallet2::get_outs_entry >> &outs, uint64_t unlock_time, uint64_t fee, const std::vector< uint8_t > &extra, cryptonote::transaction &tx, pending_tx &ptx, rct::RangeProofType range_proof_type)
Definition: wallet2.cpp:7111
uint64_t height
Definition: blockchain.cpp:88
void process_unconfirmed(const crypto::hash &txid, const cryptonote::transaction &tx, uint64_t height)
Definition: wallet2.cpp:1795
void stop()
Definition: wallet2.h:646
bool use_bulletproofs
Definition: wallet2.h:347
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:90
Definition: wallet2.h:199
void generate_genesis(cryptonote::block &b) const
Definition: wallet2.cpp:11379
uint64_t dust
Definition: wallet2.h:385
const cryptonote::account_base & get_account() const
Definition: wallet2.h:629
bool is_synced() const
Definition: wallet2.cpp:11247
std::string key_images
Definition: wallet2.h:389
std::vector< cryptonote::transaction > txes
Definition: wallet2.h:485
uint64_t m_timestamp
Definition: wallet2.h:286
std::vector< uint64_t > get_unspent_amounts_vector() const
Definition: wallet2.cpp:8829
boost::optional< cryptonote::subaddress_receive_info > received
Definition: wallet2.h:229
bool load_multisig_tx(cryptonote::blobdata blob, multisig_tx_set &exported_txs, std::function< bool(const multisig_tx_set &)> accept_func=NULL)
Definition: wallet2.cpp:5624
static std::unique_ptr< wallet2 > make_from_json(const boost::program_options::variables_map &vm, bool unattended, const std::string &json_file, const std::function< boost::optional< password_container >(const char *, bool)> &password_prompter)
Uses stdin and stdout. Returns a wallet2 if no errors.
Definition: wallet2.cpp:843
uint64_t m_light_wallet_blockchain_height
Definition: wallet2.h:1333
std::string get_daemon_address() const
Definition: wallet2.cpp:9867
uint64_t m_last_block_reward
Definition: wallet2.h:1349
rct::key m_mask
Definition: wallet2.h:244
std::string make_multisig(const epee::wipeable_string &password, const std::vector< std::string > &info, uint32_t threshold)
Creates a multisig wallet.
Definition: wallet2.cpp:3924
uint64_t unlocked_balance_all() const
Definition: wallet2.cpp:4700
std::vector< pending_tx > ptx
Definition: wallet2.h:423
crypto::key_derivation derivation
Definition: wallet2.h:493
void refill(const crypto::hash &hash)
Definition: wallet2.h:134
void light_wallet_get_outs(std::vector< std::vector< get_outs_entry >> &outs, const std::vector< size_t > &selected_transfers, size_t fake_outputs_count)
Definition: wallet2.cpp:6312
uint64_t index_in_tx
Definition: wallet2.h:472
crypto::key_image ki
Definition: wallet2.h:224
cryptonote::tx_destination_entry change_dts
Definition: wallet2.h:341
void print_source_entry(const cryptonote::tx_source_entry &src)
Definition: wallet2.h:1821
wallet_keys_unlocker(wallet2 &w, const boost::optional< tools::password_container > &password)
Definition: wallet2.cpp:723
crypto namespace.
Definition: crypto.cpp:59
epee::mlocked< tools::scrubbed< ec_scalar > > secret_key
Definition: crypto.h:69
size_t m_subaddress_lookahead_minor
Definition: wallet2.h:1327
void store_tx_info(bool store)
Definition: wallet2.h:910
Definition: blockchain_ancestry.cpp:70
crypto::hash m_txid
Definition: wallet2.h:238
std::string get_keys_file() const
Definition: wallet2.cpp:9862
Definition: wallet2.h:197
Definition: wallet2.h:469
uint64_t m_min_output_value
Definition: wallet2.h:1314
void check_acc_out_precomp_once(const cryptonote::tx_out &o, const crypto::key_derivation &derivation, const std::vector< crypto::key_derivation > &additional_derivations, size_t i, const is_out_data *is_out_data, tx_scan_info_t &tx_scan_info, bool &already_seen) const
Definition: wallet2.cpp:1205
uint64_t balance_all() const
Definition: wallet2.cpp:4692
cryptonote::account_public_address m_address
Definition: wallet2.h:463
bool tx_add_fake_output(std::vector< std::vector< tools::wallet2::get_outs_entry >> &outs, uint64_t global_index, const crypto::public_key &tx_public_key, const rct::key &mask, uint64_t real_index, bool unlocked) const
Definition: wallet2.cpp:6296
bool explicit_refresh_from_block_height() const
Definition: wallet2.h:640
Definition: wallet2.h:104
uint64_t m_timestamp
Definition: wallet2.h:327
void rescan_blockchain(bool refresh=true)
Definition: wallet2.cpp:4825
Definition: cryptonote_basic.h:77
std::vector< cryptonote::tx_destination_entry > m_dests
Definition: wallet2.h:325
bool load_tx(const std::string &signed_filename, std::vector< tools::wallet2::pending_tx > &ptx, std::function< bool(const signed_tx_set &)> accept_func=NULL)
Definition: wallet2.cpp:5440
#define FEE_PER_KB
Definition: cryptonote_config.h:67
bool confirm_non_default_ring_size() const
Definition: wallet2.h:943
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:663
uint64_t m_amount_out
Definition: wallet2.h:307
std::string account_data
Definition: wallet2.h:441
void change_password(const std::string &filename, const epee::wipeable_string &original_password, const epee::wipeable_string &new_password)
Definition: wallet2.cpp:3084
std::unordered_multimap< crypto::hash, payment_details > payment_container
Definition: wallet2.h:368
crypto::hash m_tx_hash
Definition: wallet2.h:281
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:1806
const std::string & device_name() const
Definition: wallet2.h:945
std::string get_spend_proof(const crypto::hash &txid, const std::string &message)
Definition: wallet2.cpp:9025
uint64_t get_light_wallet_scanned_block_height() const
Definition: wallet2.h:665
uint64_t m_fee
Definition: wallet2.h:283
void get_unconfirmed_payments_out(std::list< std::pair< crypto::hash, wallet2::unconfirmed_transfer_details >> &unconfirmed_payments, const boost::optional< uint32_t > &subaddr_account=boost::none, const std::set< uint32_t > &subaddr_indices={}) const
Definition: wallet2.cpp:4753
rct::key m_L
Definition: wallet2.h:201
uint64_t select_transfers(uint64_t needed_money, std::vector< size_t > unused_transfers_indices, std::vector< size_t > &selected_transfers) const
Definition: wallet2.cpp:5016
void key_reuse_mitigation2(bool value)
Definition: wallet2.h:938
bool check_connection(uint32_t *version=NULL, uint32_t timeout=200000)
Definition: wallet2.cpp:4276
uint32_t m_default_mixin
Definition: wallet2.h:1301
crypto::hash m_genesis
Definition: wallet2.h:146
cryptonote::network_type nettype() const
Definition: wallet2.h:707
boost::optional< cryptonote::subaddress_index > get_subaddress_index(const cryptonote::account_public_address &address) const
Definition: wallet2.cpp:1038
tools::wallet2::RefreshType refresh_type
Definition: simplewallet.cpp:320
boost::optional< tools::password_container > password_prompter(const char *prompt, bool verify)
Definition: simplewallet.cpp:219
uint64_t amount
Definition: cryptonote_tx_utils.h:51
std::vector< std::pair< uint64_t, uint64_t > > estimate_backlog(const std::vector< std::pair< double, double >> &fee_levels)
Definition: wallet2.cpp:11256
rct::rctSig sigs
Definition: wallet2.h:372
size_t import_outputs_from_str(const std::string &outputs_st)
Definition: wallet2.cpp:10600
std::string m_daemon_address
Definition: wallet2.h:1256
static const crypto::hash null_hash
Definition: hash.h:93
cryptonote::account_public_address addr_for_dust
Definition: wallet2.h:108
bool m_merge_destinations
Definition: wallet2.h:1315
crypto::public_key pkey
Definition: wallet2.h:492
uint64_t money_transfered
Definition: wallet2.h:227
std::unordered_set< crypto::public_key > m_signers
Definition: wallet2.h:430
bool clear()
Definition: wallet2.cpp:2871
std::unordered_map< crypto::hash, confirmed_transfer_details > m_confirmed_txs
Definition: wallet2.h:1262
void get_short_chain_history(std::list< crypto::hash > &ids, uint64_t granularity=1) const
Definition: wallet2.cpp:1895
void get_payments_out(std::list< std::pair< crypto::hash, wallet2::confirmed_transfer_details >> &confirmed_payments, uint64_t min_height, uint64_t max_height=(uint64_t) -1, const boost::optional< uint32_t > &subaddr_account=boost::none, const std::set< uint32_t > &subaddr_indices={}) const
Definition: wallet2.cpp:4739
void trim_hashchain()
Definition: wallet2.cpp:4467
uint64_t get_dynamic_base_fee_estimate() const
Definition: wallet2.cpp:5889
uint64_t m_amount_in
Definition: wallet2.h:321
std::unordered_map< crypto::public_key, std::map< uint64_t, crypto::key_image > > m_key_image_cache
Definition: wallet2.h:1342
void set_trusted_daemon(bool trusted)
Definition: wallet2.h:652
void set_attribute(const std::string &key, const std::string &value)
Definition: wallet2.cpp:9931
std::string get_tx_note(const crypto::hash &txid) const
Definition: wallet2.cpp:9923
bool add_to_fee
Definition: wallet2.h:107
void confirm_backlog(bool always)
Definition: wallet2.h:928
size_t real_output
Definition: cryptonote_tx_utils.h:47
static std::string device_name_option(const boost::program_options::variables_map &vm)
Definition: wallet2.cpp:820
bool m_segregate_pre_fork_outputs
Definition: wallet2.h:1320
bool load_multisig_tx_from_file(const std::string &filename, multisig_tx_set &exported_txs, std::function< bool(const multisig_tx_set &)> accept_func=NULL)
Definition: wallet2.cpp:5691
std::unordered_set< crypto::public_key > signing_keys
Definition: wallet2.h:375
static bool verify_extra_multisig_info(const std::string &data, std::unordered_set< crypto::public_key > &pkeys, crypto::public_key &signer)
Definition: wallet2.cpp:4103
Definition: rctTypes.h:104
std::unique_ptr< ringdb > m_ringdb
Definition: wallet2.h:1346
std::unordered_map< crypto::hash, crypto::secret_key > m_tx_keys
Definition: wallet2.h:1264
bool key_reuse_mitigation2() const
Definition: wallet2.h:937
bool print_ring_members() const
Definition: wallet2.h:907
void set_seed_language(const std::string &language)
Sets the seed language.
Definition: wallet2.cpp:1027
uint64_t get_base_fee() const
Definition: wallet2.cpp:5900
void check_acc_out_precomp(const cryptonote::tx_out &o, const crypto::key_derivation &derivation, const std::vector< crypto::key_derivation > &additional_derivations, size_t i, tx_scan_info_t &tx_scan_info) const
Definition: wallet2.cpp:1165
bool m_light_wallet_connected
Definition: wallet2.h:1335
RefreshType
Definition: wallet2.h:158
uint32_t m_multisig_threshold
Definition: wallet2.h:1296
float get_output_relatedness(const transfer_details &td0, const transfer_details &td1) const
Definition: wallet2.cpp:4931
virtual void on_pool_tx_removed(const crypto::hash &txid)
Definition: wallet2.h:100
Definition: wallet2.h:84
bool always_confirm_transfers() const
Definition: wallet2.h:905
#define END_SERIALIZE()
self-explanatory
Definition: serialization.h:214
bool use_fork_rules(uint8_t version, int64_t early_blocks=0) const
Definition: wallet2.cpp:8781
uint32_t get_confirm_backlog_threshold() const
Definition: wallet2.h:930
std::vector< cryptonote::tx_destination_entry > m_dests
Definition: wallet2.h:310
std::vector< cryptonote::tx_source_entry > sources
Definition: wallet2.h:340
std::vector< std::pair< crypto::key_image, crypto::signature > > export_key_images() const
Definition: wallet2.cpp:10140
void generate_chacha_key_from_password(const epee::wipeable_string &pass, crypto::chacha_key &key) const
Definition: wallet2.cpp:4319
const std::vector< std::vector< rct::key > > * m_multisig_rescan_k
Definition: wallet2.h:1281
size_t m_subaddress_lookahead_major
Definition: wallet2.h:1327
std::vector< crypto::key_image > m_partial_key_images
Definition: wallet2.h:212
rct::key get_multisig_k(size_t idx, const std::unordered_set< rct::key > &used_L) const
Definition: wallet2.cpp:10691
tx_scan_info_t()
Definition: wallet2.h:231
bool unblackball_output(const std::pair< uint64_t, uint64_t > &output)
Definition: wallet2.cpp:6253
bool is_in_bounds(size_t idx) const
Definition: wallet2.h:127
Definition: cryptonote_basic.h:156
BOOST_CLASS_VERSION(nodetool::node_server< cryptonote::t_cryptonote_protocol_handler< cryptonote::core > >, 1)
std::vector< tx_out > vout
Definition: cryptonote_basic.h:165
~wallet2()
Definition: wallet2.cpp:806
virtual void on_money_received(uint64_t height, const crypto::hash &txid, const cryptonote::transaction &tx, uint64_t amount, const cryptonote::subaddress_index &subaddr_index)
Definition: wallet2.h:89
bool has_multisig_partial_key_images() const
Definition: wallet2.cpp:4165
void process_outgoing(const crypto::hash &txid, const cryptonote::transaction &tx, uint64_t height, uint64_t ts, uint64_t spent, uint64_t received, uint32_t subaddr_account, const std::set< uint32_t > &subaddr_indices)
Definition: wallet2.cpp:1815
Definition: core_rpc_server_commands_defs.h:542
bool is_deprecated() const
Tells if the wallet file is deprecated.
Definition: wallet2.cpp:1144
std::vector< tx_construction_data > txes
Definition: wallet2.h:417
crypto::chacha_key m_cache_key
Definition: wallet2.h:1352
std::vector< is_out_data > primary
Definition: wallet2.h:500
uint64_t get_max_ring_size() const
Definition: wallet2.cpp:5958
bool light_wallet_login(bool &new_address)
Definition: wallet2.cpp:7481
rct::multisig_kLRki get_multisig_composite_kLRki(size_t n, const crypto::public_key &ignore, std::unordered_set< rct::key > &used_L, std::unordered_set< rct::key > &new_used_L) const
Definition: wallet2.cpp:10716
bool light_wallet_parse_rct_str(const std::string &rct_string, const crypto::public_key &tx_pub_key, uint64_t internal_output_index, rct::key &decrypted_mask, rct::key &rct_commit, bool decrypt) const
Definition: wallet2.cpp:7882
std::map< uint32_t, uint64_t > balance_per_subaddress(uint32_t subaddr_index_major) const
Definition: wallet2.cpp:4646
uint64_t get_segregation_fork_height() const
Definition: wallet2.cpp:11327
std::vector< tools::wallet2::address_book_row > m_address_book
Definition: wallet2.h:1277
std::vector< size_t > select_available_outputs_from_histogram(uint64_t count, bool atleast, bool unlocked, bool allow_rct)
Definition: wallet2.cpp:8846
virtual void on_skip_transaction(uint64_t height, const crypto::hash &txid, const cryptonote::transaction &tx)
Definition: wallet2.h:92
std::unordered_set< rct::key > used_L
Definition: wallet2.h:374
NodeRPCProxy m_node_rpc_proxy
Definition: wallet2.h:1325
std::unordered_map< crypto::public_key, size_t > m_pub_keys
Definition: wallet2.h:1271
size_t m_pk_index
Definition: wallet2.h:248
const crypto::hash & genesis() const
Definition: wallet2.h:125
i_wallet2_callback * m_callback
Definition: wallet2.h:1288
uint64_t amount() const
Definition: wallet2.h:255
void fast_refresh(uint64_t stop_height, uint64_t &blocks_start_height, std::list< crypto::hash > &short_chain_history, bool force=false)
Definition: wallet2.cpp:2439
void detach_blockchain(uint64_t height)
Definition: wallet2.cpp:2800
bool m_confirm_backlog
Definition: wallet2.h:1316
std::vector< wallet2::pending_tx > create_transactions_2(std::vector< cryptonote::tx_destination_entry > dsts, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector< uint8_t > &extra, uint32_t subaddr_account, std::set< uint32_t > subaddr_indices)
Definition: wallet2.cpp:7965
virtual void on_lw_new_block(uint64_t height)
Definition: wallet2.h:95
size_t pop_best_value_from(const transfer_container &transfers, std::vector< size_t > &unused_dust_indices, const std::vector< size_t > &selected_transfers, bool smallest=false) const
Definition: wallet2.cpp:4958
uint64_t m_light_wallet_per_kb_fee
Definition: wallet2.h:1334
bool m_double_spend_seen
Definition: wallet2.h:300
cryptonote::account_public_address get_subaddress(const cryptonote::subaddress_index &index) const
Definition: wallet2.cpp:1032
bool m_key_image_known
Definition: wallet2.h:247
Definition: wallet2.h:338
std::string get_address_as_str() const
Definition: wallet2.h:684
bool m_incoming
Definition: wallet2.h:294
void set_refresh_type(RefreshType refresh_type)
Definition: wallet2.h:704
Definition: wallet2.h:159
std::vector< transfer_details > transfer_container
Definition: wallet2.h:367
uint64_t m_amount_out
Definition: wallet2.h:322
declaration and default definition for the functions used the API
Definition: expect.cpp:33
void segregate_pre_fork_outputs(bool value)
Definition: wallet2.h:936
bool finalize_multisig(const epee::wipeable_string &password, const std::vector< std::string > &info)
Finalizes creation of a multisig wallet.
Definition: wallet2.cpp:4030
static void add(ge_p3 &p3, const ge_cached &other)
Definition: multiexp.cc:124
std::unordered_map< std::string, std::string > m_attributes
Definition: wallet2.h:1276
bool m_unattended
Definition: wallet2.h:1355
void store_to(const std::string &path, const epee::wipeable_string &password)
store_to Stores wallet to another file(s), deleting old ones
Definition: wallet2.cpp:4519
bool unlock_keys_file()
Definition: wallet2.cpp:6280
crypto::hash m_payment_id
Definition: wallet2.h:311
bool m_auto_low_priority
Definition: wallet2.h:1319
std::vector< std::vector< std::string > > m_subaddress_labels
Definition: wallet2.h:1274
bool is_tx_spendtime_unlocked(uint64_t unlock_time, uint64_t block_height) const
Definition: wallet2.cpp:4851
std::unordered_set< crypto::hash > m_scanned_pool_txs[2]
Definition: wallet2.h:1326
bool m_coinbase
Definition: wallet2.h:287
size_t m_internal_output_index
Definition: wallet2.h:239
uint32_t get_min_output_count() const
Definition: wallet2.h:922
uint32_t m_min_output_count
Definition: wallet2.h:1313
device_type
Definition: device.hpp:99
std::vector< size_t > select_available_outputs(const std::function< bool(const transfer_details &td)> &f) const
Definition: wallet2.cpp:8811
payment_details m_pd
Definition: wallet2.h:299
uint64_t m_timestamp
Definition: wallet2.h:313
bool auto_refresh() const
Definition: wallet2.h:915
std::set< uint32_t > subaddr_indices
Definition: wallet2.h:350
Various Tools.
Definition: apply_permutation.h:39
boost::optional< epee::net_utils::http::login > m_daemon_login
Definition: wallet2.h:1255
bool locked
Definition: wallet2.h:80
confirmed_transfer_details(const unconfirmed_transfer_details &utd, uint64_t height)
Definition: wallet2.h:334
wallet2 & w
Definition: wallet2.h:79
uint64_t m_global_output_index
Definition: wallet2.h:240
wallet2::transfer_container transfers
Definition: wallet2.h:418
void set_tx_note(const crypto::hash &txid, const std::string &note)
Definition: wallet2.cpp:9918
Definition: wallet2.h:221
Definition: cryptonote_tx_utils.h:42
void set_light_wallet(bool light_wallet)
Definition: wallet2.h:664
crypto::chacha_key key
Definition: wallet2.h:81
Definition: account.h:75
bool is_trusted_daemon() const
Definition: wallet2.h:651
uint64_t m_unlock_time
Definition: wallet2.h:328
void confirm_export_overwrite(bool always)
Definition: wallet2.h:932
uint64_t get_refresh_from_block_height() const
Definition: wallet2.h:637
uint64_t get_daemon_blockchain_height(std::string &err) const
Definition: wallet2.cpp:9872
uint64_t get_min_output_value() const
Definition: wallet2.h:924
Definition: wallet2.h:162
std::vector< wallet2::pending_tx > create_transactions_all(uint64_t below, const cryptonote::account_public_address &address, bool is_subaddress, const size_t outputs, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector< uint8_t > &extra, uint32_t subaddr_account, std::set< uint32_t > subaddr_indices)
Definition: wallet2.cpp:8492
static bool verify_password(const std::string &keys_file_name, const epee::wipeable_string &password, bool no_spend_key, hw::device &hwdev, uint64_t kdf_rounds)
verify password for specified wallet keys file.
Definition: wallet2.cpp:3377
std::pair< std::map< std::string, std::string >, std::vector< std::string > > m_account_tags
Definition: wallet2.h:1278
Definition: rctTypes.h:78
uint64_t m_light_wallet_scanned_block_height
Definition: wallet2.h:1332
#define ts
Definition: skein.c:522
uint32_t m_subaddr_account
Definition: wallet2.h:329
uint64_t get_upper_transaction_weight_limit() const
Definition: wallet2.cpp:8800
int b
Definition: base.py:1
std::vector< cryptonote::tx_destination_entry > splitted_dsts
Definition: wallet2.h:342
std::string get_subaddress_as_str(const cryptonote::subaddress_index &index) const
Definition: wallet2.cpp:1052
std::vector< multisig_sig > multisig_sigs
Definition: wallet2.h:393
Definition: subaddress_index.h:38
std::string sign_tx_dump_to_str(unsigned_tx_set &exported_txs, std::vector< wallet2::pending_tx > &ptx, signed_tx_set &signed_txes)
Definition: wallet2.cpp:5414
#define BEGIN_SERIALIZE_OBJECT()
begins the environment of the DSL for described the serialization of an object
Definition: serialization.h:190
void ignore_fractional_outputs(bool value)
Definition: wallet2.h:942
Definition: wallet2.h:291
void remove_obsolete_pool_txs(const std::vector< crypto::hash > &tx_hashes)
Definition: wallet2.cpp:2184
Definition: rctTypes.h:416
cryptonote::COMMAND_RPC_GET_BLOCKS_FAST::block_output_indices o_indices
Definition: wallet2.h:486
Definition: password.h:40
bool empty() const
Definition: wallet2.h:132
std::vector< is_out_data > additional
Definition: wallet2.h:501
bool store_tx_info() const
Definition: wallet2.h:909
cryptonote::transaction_prefix m_tx
Definition: wallet2.h:237
bool should_pick_a_second_output(bool use_rct, size_t n_transfers, const std::vector< size_t > &unused_transfers_indices, const std::vector< size_t > &unused_dust_indices) const
Definition: wallet2.cpp:7427
bool add_address_book_row(const cryptonote::account_public_address &address, const crypto::hash &payment_id, const std::string &description, bool is_subaddress)
Definition: wallet2.cpp:2504
uint64_t amount
Definition: cryptonote_tx_utils.h:76
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:110
void clear()
Definition: wallet2.h:131
bool parse_tx_from_str(const std::string &signed_tx_st, std::vector< tools::wallet2::pending_tx > &ptx, std::function< bool(const signed_tx_set &)> accept_func)
Definition: wallet2.cpp:5461
bool m_mempool
Definition: wallet2.h:293
Definition: device.hpp:82
std::string m_wallet_file
Definition: wallet2.h:1257
void pull_and_parse_next_blocks(uint64_t start_height, uint64_t &blocks_start_height, std::list< crypto::hash > &short_chain_history, const std::vector< cryptonote::block_complete_entry > &prev_blocks, const std::vector< parsed_block > &prev_parsed_blocks, std::vector< cryptonote::block_complete_entry > &blocks, std::vector< parsed_block > &parsed_blocks, bool &error)
Definition: wallet2.cpp:2119
std::string seed_language
Definition: wallet2.h:1292
std::string decrypt_with_view_secret_key(const std::string &ciphertext, bool authenticated=true) const
Definition: wallet2.cpp:11017
std::string get_wallet_file() const
Definition: wallet2.cpp:9857
uint64_t m_block_height
Definition: wallet2.h:236
static void init_options(boost::program_options::options_description &desc_params)
Definition: wallet2.cpp:825
Definition: wallet2.h:297
uint32_t m_subaddr_account
Definition: wallet2.h:314
std::vector< tools::wallet2::transfer_details > export_outputs() const
Definition: wallet2.cpp:10534
uint64_t get_light_wallet_blockchain_height() const
Definition: wallet2.h:666
std::vector< uint8_t > extra
Definition: wallet2.h:344
crypto::hash & operator[](size_t idx)
Definition: wallet2.h:129
void cache_tx_data(const cryptonote::transaction &tx, const crypto::hash &txid, tx_cache_data &tx_cache_data) const
Definition: wallet2.cpp:1283
std::tuple< uint64_t, crypto::public_key, rct::key > get_outs_entry
Definition: wallet2.h:479
void store()
Definition: wallet2.cpp:4514
crypto::hash get_payment_id(const pending_tx &ptx) const
Definition: wallet2.cpp:5059
bool light_wallet_import_wallet_request(cryptonote::COMMAND_RPC_IMPORT_WALLET_REQUEST::response &response)
Definition: wallet2.cpp:7510
std::unique_ptr< tools::file_locker > m_keys_file_locker
Definition: wallet2.h:1350
void set_subaddress_lookahead(size_t major, size_t minor)
Definition: wallet2.cpp:1133
bool set_ring_database(const std::string &filename)
Definition: wallet2.cpp:6058
void serialize(t_archive &a, const unsigned int ver)
Definition: wallet2.h:137
tx_construction_data construction_data
Definition: wallet2.h:395
void discard_unmixable_outputs()
Definition: wallet2.cpp:8954
Definition: wallet2.h:72
bool set_blackballed_outputs(const std::vector< std::pair< uint64_t, uint64_t >> &outputs, bool add=false)
Definition: wallet2.cpp:6238
POD_CLASS public_key
Definition: crypto.h:63
uint64_t get_num_rct_outputs()
Definition: wallet2.cpp:8885
void light_wallet_get_unspent_outs()
Definition: wallet2.cpp:7525
bool deinit()
Definition: wallet2.cpp:2864
size_t size() const
Definition: wallet2.h:123
static bool wallet_valid_path_format(const std::string &file_path)
Check if wallet file path is valid format.
Definition: wallet2.cpp:4225
cryptonote::account_base m_account
Definition: wallet2.h:1254
cryptonote::block block
Definition: wallet2.h:484
void pull_blocks(uint64_t start_height, uint64_t &blocks_start_height, const std::list< crypto::hash > &short_chain_history, std::vector< cryptonote::block_complete_entry > &blocks, std::vector< cryptonote::COMMAND_RPC_GET_BLOCKS_FAST::block_output_indices > &o_indices)
Definition: wallet2.cpp:1935
bool is_keys_file_locked() const
Definition: wallet2.cpp:6291
bool m_store_tx_info
Definition: wallet2.h:1300
enum tools::wallet2::unconfirmed_transfer_details::@16 m_state
std::vector< size_t > pick_preferred_rct_inputs(uint64_t needed_money, uint32_t subaddr_account, const std::set< uint32_t > &subaddr_indices) const
Definition: wallet2.cpp:7367
Definition: core_rpc_server_commands_defs.h:327
static bool parse_short_payment_id(const std::string &payment_id_str, crypto::hash8 &payment_id)
Definition: wallet2.cpp:4243
size_t pop_best_value(std::vector< size_t > &unused_dust_indices, const std::vector< size_t > &selected_transfers, bool smallest=false) const
Definition: wallet2.cpp:5007
bool generate_chacha_key_from_secret_keys(crypto::chacha_key &key) const
Definition: wallet2.cpp:4313
void set_subaddress_label(const cryptonote::subaddress_index &index, const std::string &label)
Definition: wallet2.cpp:1126
void set_account_tag_description(const std::string &tag, const std::string &description)
Set the label of the given tag.
Definition: wallet2.cpp:9987
void set_refresh_from_block_height(uint64_t height)
Definition: wallet2.h:636
std::string get_multisig_info() const
Definition: wallet2.cpp:4046
uint8_t version
Definition: blockchain.cpp:87
uint64_t m_light_wallet_balance
Definition: wallet2.h:1336
Definition: wallet2.h:415
payment_container m_payments
Definition: wallet2.h:1269
void set_min_output_value(uint64_t value)
Definition: wallet2.h:923
std::string m_keys_file
Definition: wallet2.h:1258
bool check_tx_proof(const crypto::hash &txid, const cryptonote::account_public_address &address, bool is_subaddress, const std::string &message, const std::string &sig_str, uint64_t &received, bool &in_pool, uint64_t &confirmations)
Definition: wallet2.cpp:9493
bool m_watch_only
Definition: wallet2.h:1294
rct::multisig_out msout
Definition: wallet2.h:376
std::string m_description
Definition: wallet2.h:465
account_public_address addr
Definition: cryptonote_tx_utils.h:77
cryptonote::transaction_prefix m_tx
Definition: wallet2.h:305
std::string blobdata
Definition: blobdatatype.h:35
void add_subaddress_account(const std::string &label)
Definition: wallet2.cpp:1063
cryptonote::checkpoints m_checkpoints
Definition: wallet2.h:1265
crypto::public_key get_subaddress_spend_public_key(const cryptonote::subaddress_index &index) const
Definition: wallet2.cpp:1046
static std::pair< std::unique_ptr< wallet2 >, password_container > make_new(const boost::program_options::variables_map &vm, bool unattended, const std::function< boost::optional< password_container >(const char *, bool)> &password_prompter)
Uses stdin and stdout. Returns a wallet2 and password for wallet with no file if no errors...
Definition: wallet2.cpp:866
const transfer_details & get_transfer_details(size_t idx) const
Definition: wallet2.cpp:8906
CXA_THROW_INFO_T * info
Definition: stack_trace.cpp:90
size_t offset() const
Definition: wallet2.h:124
static std::pair< std::unique_ptr< wallet2 >, password_container > make_from_file(const boost::program_options::variables_map &vm, bool unattended, const std::string &wallet_file, const std::function< boost::optional< password_container >(const char *, bool)> &password_prompter)
Uses stdin and stdout. Returns a wallet2 and password for wallet_file if no errors.
Definition: wallet2.cpp:849
virtual void on_new_block(uint64_t height, const cryptonote::block &block)
Definition: wallet2.h:88
#define blocks
Definition: sha512-hash.c:11
void create_keys_file(const std::string &wallet_, bool watch_only, const epee::wipeable_string &password, bool create_address_file)
Definition: wallet2.cpp:3459
void rewrite(const std::string &wallet_name, const epee::wipeable_string &password)
Rewrites to the wallet file for wallet upgrade (doesn&#39;t generate key, assumes it&#39;s already there) ...
Definition: wallet2.cpp:4188
hashchain()
Definition: wallet2.h:121
std::set< uint32_t > m_subaddr_indices
Definition: wallet2.h:315
void process_new_blockchain_entry(const cryptonote::block &b, const cryptonote::block_complete_entry &bche, const parsed_block &parsed_block, const crypto::hash &bl_id, uint64_t height, const std::vector< tx_cache_data > &tx_cache_data, size_t tx_cache_data_offset)
Definition: wallet2.cpp:1857
crypto::public_key get_multisig_signer_public_key() const
Definition: wallet2.cpp:10668
bool confirm_backlog() const
Definition: wallet2.h:927
bool is_deterministic() const
Checks if deterministic wallet.
Definition: wallet2.cpp:898
bool invoke_http_bin(const boost::string_ref uri, const t_request &req, t_response &res, std::chrono::milliseconds timeout=std::chrono::seconds(15), const boost::string_ref http_method="GET")
Definition: wallet2.h:1149
cryptonote::account_public_address get_address() const
Definition: wallet2.h:679
network_type
Definition: cryptonote_config.h:204
bool check_reserve_proof(const cryptonote::account_public_address &address, const std::string &message, const std::string &sig_str, uint64_t &total, uint64_t &spent)
Verifies a proof of reserve.
Definition: wallet2.cpp:9728
void segregation_height(uint64_t height)
Definition: wallet2.h:940
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:1782
POD_CLASS signature
Definition: crypto.h:95
Definition: wallet2.h:449
Definition: cryptonote_basic.h:400
Definition: wallet2.h:168
cryptonote::account_public_address m_account_public_address
Definition: wallet2.h:1272
void set_account_tag(const std::set< uint32_t > account_indices, const std::string &tag)
Set a tag to the given accounts.
Definition: wallet2.cpp:9974
size_t get_num_subaddress_accounts() const
Definition: wallet2.h:687
key identity()
Definition: rctOps.h:73
POD_CLASS hash8
Definition: hash.h:52
void encrypt_keys(const crypto::chacha_key &key)
Definition: wallet2.cpp:3424
uint64_t m_block_height
Definition: wallet2.h:324
crypto::public_key key
Definition: cryptonote_basic.h:81
crypto::signature shared_secret_sig
Definition: wallet2.h:475
bool m_explicit_refresh_from_block_height
Definition: wallet2.h:1309
std::string make_uri(const std::string &address, const std::string &payment_id, uint64_t amount, const std::string &tx_description, const std::string &recipient_name, std::string &error) const
Definition: wallet2.cpp:11022
bool prepare_file_names(const std::string &file_path)
Definition: wallet2.cpp:4270
bool m_rct
Definition: wallet2.h:246
uint64_t get_fee_multiplier(uint32_t priority, int fee_algorithm=-1) const
Definition: wallet2.cpp:5847
bool light_wallet_key_image_is_ours(const crypto::key_image &key_image, const crypto::public_key &tx_public_key, uint64_t out_index)
Definition: wallet2.cpp:7907
bool parse_unsigned_tx_from_str(const std::string &unsigned_tx_st, unsigned_tx_set &exported_txs) const
Definition: wallet2.cpp:5232
void load(const std::string &wallet, const epee::wipeable_string &password)
Definition: wallet2.cpp:4324
void check_genesis(const crypto::hash &genesis_hash) const
Definition: wallet2.cpp:4503
uint64_t estimate_blockchain_height()
Definition: wallet2.cpp:3660
POD_CLASS key_image
Definition: crypto.h:89
bool get_rings(const crypto::hash &txid, std::vector< std::pair< crypto::key_image, std::vector< uint64_t >>> &outs)
Definition: wallet2.cpp:6123
bool get_ring(const crypto::key_image &key_image, std::vector< uint64_t > &outs)
Definition: wallet2.cpp:6146
const std::vector< std::vector< tools::wallet2::multisig_info > > * m_multisig_rescan_info
Definition: wallet2.h:1280
bool confirm_missing_payment_id() const
Definition: wallet2.h:917
uint64_t get_blockchain_height_by_date(uint16_t year, uint8_t month, uint8_t day)
Definition: wallet2.cpp:11160
static const char * tr(const char *str)
Definition: wallet2.cpp:721
T decrypt(const std::string &ciphertext, const crypto::secret_key &skey, bool authenticated=true) const
Definition: wallet2.cpp:10990
void import_blockchain(const std::tuple< size_t, crypto::hash, std::vector< crypto::hash >> &bc)
Definition: wallet2.cpp:10514
bool merge_destinations() const
Definition: wallet2.h:926
void set_description(const std::string &description)
Definition: wallet2.cpp:9944
uint64_t m_change
Definition: wallet2.h:308
uint64_t segregation_height() const
Definition: wallet2.h:939
std::vector< size_t > select_available_mixable_outputs()
Definition: wallet2.cpp:8918
i_wallet2_callback * callback() const
Definition: wallet2.h:648
bool m_first_refresh_done
Definition: wallet2.h:1305
txout_target_v target
Definition: cryptonote_basic.h:146
std::vector< cryptonote::tx_destination_entry > dests
Definition: wallet2.h:348
rct::key mask
Definition: wallet2.h:225
uint64_t m_light_wallet_unlocked_balance
Definition: wallet2.h:1337
std::unordered_map< crypto::hash, std::string > m_tx_notes
Definition: wallet2.h:1275
crypto::hash m_payment_id
Definition: wallet2.h:464
size_t real_output_in_tx_index
Definition: cryptonote_tx_utils.h:50
string a
Definition: MakeCryptoOps.py:15
std::string dump_tx_to_str(const std::vector< pending_tx > &ptx_vector) const
Definition: wallet2.cpp:5184
static bool has_testnet_option(const boost::program_options::variables_map &vm)
Definition: wallet2.cpp:810
bool check_spend_proof(const crypto::hash &txid, const std::string &message, const std::string &sig_str)
Definition: wallet2.cpp:9143
crypto::hash get_transaction_hash(const transaction &t)
Definition: cryptonote_format_utils.cpp:829
void always_confirm_transfers(bool always)
Definition: wallet2.h:906
void crop(size_t height)
Definition: wallet2.h:130
AskPasswordType m_ask_password
Definition: wallet2.h:1312
rct::key m_R
Definition: wallet2.h:202
confirmed_transfer_details()
Definition: wallet2.h:333
void set_spent(size_t idx, uint64_t height)
Definition: wallet2.cpp:1149
std::vector< std::pair< crypto::key_image, std::vector< uint64_t > > > m_rings
Definition: wallet2.h:316
bool verify(const std::string &data, const cryptonote::account_public_address &address, const std::string &signature) const
Definition: wallet2.cpp:10004
static bool has_stagenet_option(const boost::program_options::variables_map &vm)
Definition: wallet2.cpp:815
bool get_tx_key(const crypto::hash &txid, crypto::secret_key &tx_key, std::vector< crypto::secret_key > &additional_tx_keys) const
Definition: wallet2.cpp:8964
uint64_t m_refresh_from_block_height
Definition: wallet2.h:1306
hashchain m_blockchain
Definition: wallet2.h:1260
bool has_unknown_key_images() const
Definition: wallet2.cpp:4175
Definition: wallet2.h:490
Definition: wallet2.h:166
crypto::key_image m_key_image
Definition: wallet2.h:243
std::vector< output_entry > outputs
Definition: cryptonote_tx_utils.h:46
bool remove_rings(const cryptonote::transaction_prefix &tx)
Definition: wallet2.cpp:6107
std::vector< address_book_row > get_address_book() const
GUI Address book get/store.
Definition: wallet2.h:980
bool invoke_http_json_rpc(const boost::string_ref uri, const std::string &method_name, const t_request &req, t_response &res, std::chrono::milliseconds timeout=std::chrono::seconds(15), const boost::string_ref http_method="GET", const std::string &req_id="0")
Definition: wallet2.h:1155
RefreshType get_refresh_type() const
Definition: wallet2.h:705
Definition: cryptonote_tx_utils.h:74
crypto::signature key_image_sig
Definition: wallet2.h:476
std::vector< cryptonote::tx_extra_field > tx_extra_fields
Definition: wallet2.h:499
uint64_t dust_threshold
Definition: wallet2.h:106
size_t m_offset
Definition: wallet2.h:145
std::string save_multisig_tx(multisig_tx_set txs)
Definition: wallet2.cpp:5550
bool m_light_wallet
Definition: wallet2.h:1331
crypto::hash txid
Definition: wallet2.h:471
std::set< uint32_t > m_subaddr_indices
Definition: wallet2.h:330
void check_tx_key(const crypto::hash &txid, const crypto::secret_key &tx_key, const std::vector< crypto::secret_key > &additional_tx_keys, const cryptonote::account_public_address &address, uint64_t &received, bool &in_pool, uint64_t &confirmations)
Definition: wallet2.cpp:9258
std::unordered_multimap< crypto::hash, pool_payment_details > m_unconfirmed_payments
Definition: wallet2.h:1263
size_t get_num_transfer_details() const
Definition: wallet2.h:985
Definition: wallet2.h:497
AskPasswordType
Definition: wallet2.h:165
Definition: wallet2.h:382
std::unordered_map< crypto::hash, unconfirmed_transfer_details > m_unconfirmed_txs
Definition: wallet2.h:1261
bool m_print_ring_members
Definition: wallet2.h:1299
bool delete_address_book_row(std::size_t row_id)
Definition: wallet2.cpp:2519
std::string sign_multisig_participant(const std::string &data) const
sign_multisig_participant signs given message with the multisig public signer key ...
Definition: wallet2.cpp:10027
cryptonote::account_base & get_account()
Definition: wallet2.h:628
POD_CLASS hash
Definition: hash.h:49
uint64_t m_amount
Definition: wallet2.h:282
bool m_multisig
Definition: wallet2.h:1295
cryptonote::tx_destination_entry change_dts
Definition: wallet2.h:387
void device_name(const std::string &device_name)
Definition: wallet2.h:946
uint64_t get_blockchain_current_height() const
Definition: wallet2.h:774
std::string get_integrated_address_as_str(const crypto::hash8 &payment_id) const
Definition: wallet2.cpp:1058
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:91
bool get_rct_distribution(uint64_t &start_height, std::vector< uint64_t > &distribution)
Definition: wallet2.cpp:2732
bool load_unsigned_tx(const std::string &unsigned_filename, unsigned_tx_set &exported_txs) const
Definition: wallet2.cpp:5213
bool m_confirm_non_default_ring_size
Definition: wallet2.h:1311
crypto::secret_key tx_key
Definition: wallet2.h:390
const char *const ATTRIBUTE_DESCRIPTION
Definition: wallet2.h:1133
bool add_rings(const crypto::chacha_key &key, const cryptonote::transaction_prefix &tx)
Definition: wallet2.cpp:6093
A container for blockchain checkpoints.
Definition: checkpoints.h:51
~wallet_keys_unlocker()
Definition: wallet2.cpp:747
bool load_keys(const std::string &keys_file_name, const epee::wipeable_string &password)
Load wallet information from wallet file.
Definition: wallet2.cpp:3098
void set_confirm_backlog_threshold(uint32_t threshold)
Definition: wallet2.h:929
Definition: wallet2.h:438
void print_ring_members(bool value)
Definition: wallet2.h:908
bool find_and_save_rings(bool force=true)
Definition: wallet2.cpp:6161
uint32_t m_default_priority
Definition: wallet2.h:1302
crypto::key_image key_image
Definition: wallet2.h:474
virtual void on_lw_unconfirmed_money_received(uint64_t height, const crypto::hash &txid, uint64_t amount)
Definition: wallet2.h:97
boost::optional< epee::wipeable_string > m_encrypt_keys_after_refresh
Definition: wallet2.h:1353
std::vector< size_t > get_only_rct(const std::vector< size_t > &unused_dust_indices, const std::vector< size_t > &unused_transfers_indices) const
Definition: wallet2.cpp:7460
std::vector< pending_tx > create_unmixable_sweep_transactions()
Definition: wallet2.cpp:8924
std::pair< uint64_t, rct::ctkey > output_entry
Definition: cryptonote_tx_utils.h:44
std::string print_money(uint64_t amount, unsigned int decimal_point)
Definition: cryptonote_format_utils.cpp:808
void set_tx_key(const crypto::hash &txid, const crypto::secret_key &tx_key, const std::vector< crypto::secret_key > &additional_tx_keys)
Definition: wallet2.cpp:8977
RangeProofType
Definition: rctTypes.h:234
crypto::chacha_iv iv
Definition: wallet2.h:451
bool get_multisig_seed(epee::wipeable_string &seed, const epee::wipeable_string &passphrase=std::string(), bool raw=true) const
Definition: wallet2.cpp:932
std::vector< boost::optional< cryptonote::subaddress_receive_info > > received
Definition: wallet2.h:494
std::vector< wallet2::pending_tx > create_transactions_single(const crypto::key_image &ki, const cryptonote::account_public_address &address, bool is_subaddress, const size_t outputs, const size_t fake_outs_count, const uint64_t unlock_time, uint32_t priority, const std::vector< uint8_t > &extra)
Definition: wallet2.cpp:8546
crypto::key_image get_multisig_composite_key_image(size_t n) const
Definition: wallet2.cpp:10746
Definition: cryptonote_basic.h:143
void refresh(bool trusted_daemon)
Definition: wallet2.cpp:2107
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:1384
virtual void on_lw_money_received(uint64_t height, const crypto::hash &txid, uint64_t amount)
Definition: wallet2.h:96
bool set_ring(const crypto::key_image &key_image, const std::vector< uint64_t > &outs, bool relative)
Definition: wallet2.cpp:6152
transfer_container m_transfers
Definition: wallet2.h:1268
std::vector< pending_tx > m_ptx
Definition: wallet2.h:429
const std::pair< std::map< std::string, std::string >, std::vector< std::string > > & get_account_tags()
Get the list of registered account tags.
Definition: wallet2.cpp:9954
bool light_wallet_get_address_info(cryptonote::COMMAND_RPC_GET_ADDRESS_INFO::response &response)
Definition: wallet2.cpp:7677
bool blackball_output(const std::pair< uint64_t, uint64_t > &output)
Definition: wallet2.cpp:6230
bool is_rct() const
Definition: wallet2.h:254
#define FIELD(f)
tags the field with the variable name and then serializes it
Definition: serialization.h:243
uint32_t get_default_priority() const
Definition: wallet2.h:913
bool m_key_reuse_mitigation2
Definition: wallet2.h:1321
uint64_t m_amount_in
Definition: wallet2.h:306
void import_payments_out(const std::list< std::pair< crypto::hash, wallet2::confirmed_transfer_details >> &confirmed_payments)
Definition: wallet2.cpp:10493
void push_back(const crypto::hash &hash)
Definition: wallet2.h:126
cryptonote::keypair in_ephemeral
Definition: wallet2.h:223
uint64_t adjust_mixin(uint64_t mixin) const
Definition: wallet2.cpp:5965
RefreshType m_refresh_type
Definition: wallet2.h:1303
bool init(std::string daemon_address="http://localhost:8080", boost::optional< epee::net_utils::http::login > daemon_login=boost::none, uint64_t upper_transaction_weight_limit=0, bool ssl=false, bool trusted_daemon=false)
Definition: wallet2.cpp:884
std::unordered_map< crypto::key_image, size_t > m_key_images
Definition: wallet2.h:1270
Definition: wallet2.h:481
bool m_confirm_missing_payment_id
Definition: wallet2.h:1310
Definition: wallet2.h:161
uint64_t get_fee_quantization_mask() const
Definition: wallet2.cpp:5916
std::string get_description() const
Definition: wallet2.cpp:9949
Definition: core_rpc_server_commands_defs.h:104
void write_watch_only_wallet(const std::string &wallet_name, const epee::wipeable_string &password, std::string &new_keys_filename)
Writes to a file named based on the normal wallet (doesn&#39;t generate key, assumes it&#39;s already there) ...
Definition: wallet2.cpp:4204
std::string get_attribute(const std::string &key) const
Definition: wallet2.cpp:9936
uint64_t get_last_block_reward() const
Definition: wallet2.h:780
bool sign_multisig_tx_from_file(const std::string &filename, std::vector< crypto::hash > &txids, std::function< bool(const multisig_tx_set &)> accept_func)
Definition: wallet2.cpp:5833
void explicit_refresh_from_block_height(bool expl)
Definition: wallet2.h:639
crypto::chacha_key get_ringdb_key()
Definition: wallet2.cpp:6081
crypto::public_key m_signer
Definition: wallet2.h:210
uint32_t adjust_priority(uint32_t priority)
Definition: wallet2.cpp:5982
bool m_key_image_partial
Definition: wallet2.h:250
hw::device::device_type get_device_type() const
Definition: wallet2.h:714
virtual void on_lw_money_spent(uint64_t height, const crypto::hash &txid, uint64_t amount)
Definition: wallet2.h:98
bool lock_keys_file()
Definition: wallet2.cpp:6269
void ask_password(AskPasswordType ask)
Definition: wallet2.h:920
crypto::hash m_payment_id
Definition: wallet2.h:326
uint32_t default_mixin() const
Definition: wallet2.h:911
void check_tx_key_helper(const crypto::hash &txid, const crypto::key_derivation &derivation, const std::vector< crypto::key_derivation > &additional_derivations, const cryptonote::account_public_address &address, uint64_t &received, bool &in_pool, uint64_t &confirmations)
Definition: wallet2.cpp:9273
const crypto::public_key & get_public_key() const
Definition: wallet2.h:256
std::tuple< size_t, crypto::hash, std::vector< crypto::hash > > export_blockchain() const
Definition: wallet2.cpp:10502
void transfer_selected(const std::vector< cryptonote::tx_destination_entry > &dsts, const std::vector< size_t > &selected_transfers, size_t fake_outputs_count, std::vector< std::vector< tools::wallet2::get_outs_entry >> &outs, uint64_t unlock_time, uint64_t fee, const std::vector< uint8_t > &extra, T destination_split_strategy, const tx_dust_policy &dust_policy, cryptonote::transaction &tx, pending_tx &ptx)
std::string encrypt(const char *plaintext, size_t len, const crypto::secret_key &skey, bool authenticated=true) const
Definition: wallet2.cpp:10948
bool m_is_initialized
Definition: wallet2.h:1324
time_t m_sent_time
Definition: wallet2.h:309
Definition: cryptonote_basic.h:182
std::string get_tx_proof(const crypto::hash &txid, const cryptonote::account_public_address &address, bool is_subaddress, const std::string &message)
Definition: wallet2.cpp:9361
void set_default_priority(uint32_t p)
Definition: wallet2.h:914
bool sign_multisig_tx_to_file(multisig_tx_set &exported_txs, const std::string &filename, std::vector< crypto::hash > &txids)
Definition: wallet2.cpp:5825
std::string encrypt_with_view_secret_key(const std::string &plaintext, bool authenticated=true) const
Definition: wallet2.cpp:10984
Definition: wallet2.h:370
#define true
Definition: stdbool.h:36
void set_min_output_count(uint32_t count)
Definition: wallet2.h:921
void generate(const std::string &wallet_, const epee::wipeable_string &password, const epee::wipeable_string &multisig_data, bool create_address_file=false)
Generates a wallet or restores one.
Definition: wallet2.cpp:3535
virtual ~i_wallet2_callback()
Definition: wallet2.h:101
std::string m_device_name
Definition: wallet2.h:1328
boost::mutex m_daemon_rpc_mutex
Definition: wallet2.h:1285
void update_pool_state(bool refreshed=false)
Definition: wallet2.cpp:2212
static bool parse_payment_id(const std::string &payment_id_str, crypto::hash &payment_id)
Definition: wallet2.cpp:4256
uint64_t import_key_images(const std::vector< std::pair< crypto::key_image, crypto::signature >> &signed_key_images, uint64_t &spent, uint64_t &unspent, bool check_spent=true)
Definition: wallet2.cpp:10243
bool use_rct
Definition: wallet2.h:346
uint64_t m_amount
Definition: wallet2.h:245
bool store_keys(const std::string &keys_file_name, const epee::wipeable_string &password, bool watch_only=false)
Stores wallet information to wallet file.
Definition: wallet2.cpp:2898
static bool verify_multisig_info(const std::string &data, crypto::secret_key &skey, crypto::public_key &pkey)
Definition: wallet2.cpp:4065
void add_subaddress(uint32_t index_major, const std::string &label)
Definition: wallet2.cpp:1070
bool m_spent
Definition: wallet2.h:241
void pull_hashes(uint64_t start_height, uint64_t &blocks_start_height, const std::list< crypto::hash > &short_chain_history, std::vector< crypto::hash > &hashes)
Definition: wallet2.cpp:1959
bool m_trusted_daemon
Definition: wallet2.h:1287
bool auto_low_priority() const
Definition: wallet2.h:933
bool m_ring_history_saved
Definition: wallet2.h:1345
uint64_t m_spent_height
Definition: wallet2.h:242
void setup_keys(const epee::wipeable_string &password)
Definition: wallet2.cpp:3064
uint64_t fee
Definition: wallet2.h:385
multisig_tx_set make_multisig_tx_set(const std::vector< pending_tx > &ptx_vector) const
Definition: wallet2.cpp:5596
Definition: wallet2.h:461
uint64_t get_daemon_blockchain_target_height(std::string &err)
Definition: wallet2.cpp:9887
std::vector< size_t > selected_transfers
Definition: wallet2.h:343
bool verify_with_public_key(const std::string &data, const crypto::public_key &public_key, const std::string &signature) const
verify_with_public_key verifies message was signed with given public key
Definition: wallet2.cpp:10039
bool m_auto_refresh
Definition: wallet2.h:1304
std::unordered_map< crypto::hash, address_tx > m_light_wallet_address_txs
Definition: wallet2.h:1340
void import_payments(const payment_container &payments)
Definition: wallet2.cpp:10485
Definition: wallet2.h:234
std::string get_subaddress_label(const cryptonote::subaddress_index &index) const
Definition: wallet2.cpp:1116
std::string m_ring_database
Definition: wallet2.h:1344
bool m_ignore_fractional_outputs
Definition: wallet2.h:1323
void light_wallet_get_address_txs()
Definition: wallet2.cpp:7693
void serialize(t_archive &a, const unsigned int ver)
Definition: wallet2.h:783
bool multisig(bool *ready=NULL, uint32_t *threshold=NULL, uint32_t *total=NULL) const
Definition: wallet2.cpp:4152
bool error
Definition: wallet2.h:487
std::vector< multisig_info > m_multisig_info
Definition: wallet2.h:252
uint64_t get_min_ring_size() const
Definition: wallet2.cpp:5945
void get_transfers(wallet2::transfer_container &incoming_transfers) const
Definition: wallet2.cpp:4708
uint8_t threshold
Definition: blockchain.cpp:89
std::vector< std::pair< crypto::key_image, std::vector< uint64_t > > > m_rings
Definition: wallet2.h:331