34#include <unordered_set>
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>
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>
77#undef MONERO_DEFAULT_LOG_CATEGORY
78#define MONERO_DEFAULT_LOG_CATEGORY "wallet.wallet2"
80#define THROW_ON_RPC_RESPONSE_ERROR(r, error, res, method, ...) \
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__); \
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)
90class Serialization_portability_wallet_Test;
112 static constexpr result_type max() {
return std::numeric_limits<result_type>::max(); }
117 std::gamma_distribution<double>
gamma;
148 virtual boost::optional<epee::wipeable_string>
on_get_password(
const char *reason) {
return boost::none; }
210 template <
class t_archive>
234 friend class ::Serialization_portability_wallet_Test;
235 friend class ::wallet_accessor_test;
239 static constexpr const std::chrono::seconds
rpc_timeout = std::chrono::minutes(3) + std::chrono::seconds(30);
271 throw std::logic_error(
"Unknown background sync type");
279 static const char*
tr(
const char* str);
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);
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);
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);
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);
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);
304 return verify_password(keys_file_name, password, no_spend_key, hwdev, kdf_rounds, spend_key);
344 boost::optional<cryptonote::subaddress_receive_info>
received;
370 std::vector<std::pair<uint64_t, crypto::hash>>
m_uses;
380 return output_public_key;
384 FIELD(m_block_height)
387 FIELD(m_internal_output_index)
388 FIELD(m_global_output_index)
391 FIELD(m_spent_height)
396 FIELD(m_key_image_known)
397 FIELD(m_key_image_request)
399 FIELD(m_subaddr_index)
400 FIELD(m_key_image_partial)
402 FIELD(m_multisig_info)
499 std::vector<cryptonote::tx_destination_entry>
m_dests;
505 std::vector<std::pair<crypto::key_image, std::vector<uint64_t>>>
m_rings;
532 std::vector<cryptonote::tx_destination_entry>
m_dests;
538 std::vector<std::pair<crypto::key_image, std::vector<uint64_t>>>
m_rings;
542 m_tx(utd.
m_tx),
m_amount_in(utd.
m_amount_in),
m_amount_out(utd.
m_amount_out),
m_change(utd.
m_change),
m_block_height(height),
m_dests(utd.
m_dests),
m_payment_id(utd.
m_payment_id),
m_timestamp(utd.
m_timestamp),
m_unlock_time(utd.
m_tx.unlock_time),
m_subaddr_account(utd.
m_subaddr_account),
m_subaddr_indices(utd.
m_subaddr_indices),
m_rings(utd.
m_rings) {}
557 FIELD(m_subaddr_indices)
564 std::vector<cryptonote::tx_source_entry>
sources;
573 std::vector<cryptonote::tx_destination_entry>
dests;
597 if (!typename Archive<W>::is_saving())
616 FIELD(subaddr_account)
617 FIELD(subaddr_indices)
628 std::unordered_set<crypto::public_key>
ignore;
667 std::vector<cryptonote::tx_destination_entry>
dests;
692 FIELD(multisig_tx_key_entropy)
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;
709 std::pair<size_t, wallet2::transfer_container> 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);
718 std::pair<size_t, std::vector<wallet2::exported_transfer_details>> v1_transfers;
721 std::get<1>(
new_transfers) = std::get<0>(v1_transfers) + std::get<1>(v1_transfers).size();
732 std::vector<pending_tx>
ptx;
758 crypto::chacha_iv
iv;
769 crypto::chacha_iv
iv;
871 std::vector<cryptonote::transaction>
txes;
880 std::vector<boost::optional<cryptonote::subaddress_receive_info>>
received;
939 bool two_random =
false,
bool create_address_file =
false);
978 const std::vector<std::string> &kex_messages,
979 const std::uint32_t threshold);
986 const std::vector<std::string> &kex_messages,
987 const bool force_update_use_with_caution =
false);
1004 size_t import_multisig(std::vector<cryptonote::blobdata>
info,
bool refresh_after_import =
true);
1044 std::string
path()
const;
1060 void encrypt_keys(
const crypto::chacha_key &key);
1062 void decrypt_keys(
const crypto::chacha_key &key);
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);
1100 bool is_deterministic()
const;
1114 const std::string &get_seed_language()
const;
1118 void set_seed_language(
const std::string &language);
1128 std::string get_integrated_address_as_str(
const crypto::hash8& payment_id)
const;
1129 void add_subaddress_account(
const std::string& label);
1132 void add_subaddress(
uint32_t index_major,
const std::string& label);
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);
1162 bool has_multisig_partial_key_images()
const;
1163 bool has_unknown_key_images()
const;
1167 bool reconnect_device();
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);
1176 uint64_t balance_all(
bool strict)
const;
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,
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,
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;
1193 bool save_multisig_tx(
const std::vector<pending_tx>& ptx_vector,
const std::string &filename);
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);
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);
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 = {});
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);
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;
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;
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);
1245 std::vector<cryptonote::public_node> get_public_nodes(
bool white_only =
true);
1247 template <
class t_archive>
1284 a & dummy_refresh_height;
1293 std::unordered_map<crypto::hash, payment_details> m;
1296 for (std::unordered_map<crypto::hash, payment_details>::const_iterator i = m.begin(); i != m.end(); ++i)
1321 std::unordered_multimap<crypto::hash, payment_details> m;
1324 for (
const auto &i: m)
1334 std::unordered_map<cryptonote::subaddress_index, crypto::public_key> dummy_subaddresses_inv;
1335 a & dummy_subaddresses_inv;
1346 a & (std::pair<std::map<std::string, std::string>, std::vector<std::string>>&)
m_account_tags;
1384 FIELD(m_account_public_address)
1386 FIELD(m_unconfirmed_txs)
1389 FIELD(m_confirmed_txs)
1391 FIELD(m_unconfirmed_payments)
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)
1400 FIELD(m_account_tags)
1401 FIELD(m_ring_history_saved)
1402 FIELD(m_last_block_reward)
1404 FIELD(m_device_last_key_image_sync)
1405 FIELD(m_cold_key_images)
1406 FIELD(m_rpc_client_secret_key)
1412 FIELD(m_has_ever_refreshed_from_node)
1418 FIELD(m_background_sync_data)
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);
1485 void setup_background_sync(BackgroundSyncType background_sync_type,
const epee::wipeable_string &wallet_password,
const boost::optional<epee::wipeable_string> &background_cache_password);
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);
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);
1529 void scan_tx(
const std::unordered_set<crypto::hash> &txids);
1538 std::string get_reserve_proof(
const boost::optional<std::pair<uint32_t, uint64_t>> &account_minreserve,
const std::string &message);
1556 bool delete_address_book_row(std::size_t row_id);
1560 const transfer_details &get_transfer_details(
size_t idx)
const;
1562 uint8_t get_current_hard_fork();
1565 int get_fee_algorithm();
1567 std::string get_wallet_file()
const;
1568 std::string get_keys_file()
const;
1569 std::string get_daemon_address()
const;
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();
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();
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;
1589 void set_tx_note(
const crypto::hash &txid,
const std::string ¬e);
1590 std::string get_tx_note(
const crypto::hash &txid)
const;
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;
1595 void set_description(
const std::string &description);
1596 std::string get_description()
const;
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);
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;
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;
1649 std::pair<uint64_t, std::vector<std::pair<crypto::key_image, crypto::signature>>>
export_key_images(
bool all =
false)
const;
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);
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);
1661 std::string
encrypt(
const char *plaintext,
size_t len,
const crypto::secret_key &skey,
bool authenticated =
true)
const;
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);
1677 std::vector<std::pair<uint64_t, uint64_t>>
estimate_backlog(
const std::vector<std::pair<double, double>> &fee_levels);
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);
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);
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();
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);
1712 void light_wallet_get_unspent_outs();
1714 void light_wallet_get_address_txs();
1718 bool light_wallet_login(
bool &new_address);
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);
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")
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")
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")
1773 bool set_ring_database(
const std::string &filename);
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);
1782 [[deprecated]]
bool find_and_save_rings(
bool force =
true);
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;
1789 void freeze(
size_t idx);
1790 void thaw(
size_t idx);
1791 bool frozen(
size_t idx)
const;
1795 bool frozen(
const transfer_details &td)
const;
1796 bool frozen(
const multisig_tx_set& txs)
const;
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);
1802 uint64_t get_bytes_received()
const;
1804 void start_background_sync();
1812 bool lock_keys_file();
1813 bool unlock_keys_file();
1814 bool is_keys_file_locked()
const;
1820 bool is_tx_spendtime_unlocked(
uint64_t unlock_time,
uint64_t block_height);
1822 uint64_t hash_m_transfers(boost::optional<uint64_t> transfer_height,
crypto::hash &hash)
const;
1825 void set_offline(
bool offline =
true);
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);
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);
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;
1867 void clear_soft(
bool keep_key_images=
false);
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 ¤t_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);
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);
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);
1894 void check_genesis(
const crypto::hash& genesis_hash)
const;
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;
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;
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);
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;
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);
1941 void store_background_cache(
const crypto::chacha_key &custom_background_key,
const bool do_reset_background_sync_data =
true);
1985 const std::unique_ptr<epee::net_utils::http::abstract_http_client>
m_http_client;
2004 std::pair<serializable_map<std::string, std::string>, std::vector<std::string>>
m_account_tags;
2163 template<
class Archive,
class F,
class S,
class T>
2166 std::tuple<F, S, T> & t,
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));
2174 template <
class Archive>
2178 template <
class Archive>
2222 template <
class Archive>
2321 template <
class Archive>
2328 template <
class Archive>
2336 template <
class Archive>
2343 template <
class Archive>
2392 template <
class Archive>
2422 if (!
typename Archive::is_saving())
2439 template <
class Archive>
2474 template <
class Archive>
2481 template <
class Archive>
2492 bool is_long =
false;
2493 for (
int i = 8; i < 32; ++i)
2494 is_long |= payment_id.data[i];
2497 MWARNING(
"Long payment ID ignored on address book load");
2519 template <
class Archive>
2530 template <
class Archive>
2537 std::pair<size_t, tools::wallet2::transfer_container> 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);
2544 throw std::runtime_error(
"Boost serialization not supported for newest unsigned_tx_set");
2547 template <
class Archive>
2557 template <
class Archive>
2566 std::list<size_t> selected_transfers;
2567 a & selected_transfers;
2570 for (
size_t t: selected_transfers)
2586 if (!
typename Archive::is_saving())
2593 if (!
typename Archive::is_saving())
2600 a & use_bulletproofs;
2601 if (!
typename Archive::is_saving())
2608 template <
class Archive>
2624 template <
class Archive>
2635 std::list<size_t> selected_transfers;
2636 a & selected_transfers;
2639 for (
size_t t: selected_transfers)
2657 template <
class Archive>
2668 template <
class Archive>
2690 std::vector<cryptonote::tx_destination_entry>& splitted_dsts, std::vector<cryptonote::tx_destination_entry> &dust_dsts)
2692 splitted_dsts.clear();
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)); } );
2704 if (chunk <= dust_threshold)
2705 dust_dsts.push_back(cryptonote::tx_destination_entry(chunk, change_dst.addr, false));
2707 splitted_dsts.push_back(cryptonote::tx_destination_entry(chunk, change_dst.addr, false));
2709 [&](
uint64_t a_dust) { dust_dsts.push_back(cryptonote::tx_destination_entry(a_dust, change_dst.addr, false)); } );
2714 std::vector<cryptonote::tx_destination_entry>& splitted_dsts, std::vector<cryptonote::tx_destination_entry> &dust_dsts)
2716 splitted_dsts = dsts;
2729 std::string indexes;
#define s(x, c)
Definition aesb.c:47
cryptonote::block b
Definition block.cpp:40
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
Non-owning sequence of data. Does not deep copy.
Definition span.h:55
Definition wipeable_string.h:41
device_type
Definition device.hpp:104
@ SOFTWARE
Definition device.hpp:105
Definition message_store.h:268
Definition containers.h:49
std::unordered_map< K, V > & parent()
Definition containers.h:52
Definition containers.h:71
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
void * memcpy(void *a, const void *b, size_t c)
Definition glibc_compat.cpp:16
#define BEGIN_SERIALIZE_OBJECT()
Definition blockchain.py:1
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 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
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:113
Definition rctTypes.h:122
Definition rctTypes.h:625
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
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
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 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