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