From c7229c3062af215bd27a199da1884cb3273fc142 Mon Sep 17 00:00:00 2001 From: sowle Date: Wed, 22 Apr 2020 23:30:03 +0300 Subject: [PATCH] account_keys improvements --- src/currency_core/account.cpp | 26 +++++----- src/currency_core/account.h | 20 +++---- .../account_boost_serialization.h | 6 +-- src/currency_core/currency_format_utils.cpp | 32 ++++++------ src/currency_core/currency_format_utils.h | 2 +- .../currency_format_utils_transactions.cpp | 4 +- src/simplewallet/simplewallet.cpp | 12 ++--- src/wallet/wallet2.cpp | 52 +++++++++---------- src/wallet/wallet2_escrow.cpp | 8 +-- src/wallet/wallet_helpers.h | 2 +- src/wallet/wallet_rpc_server.cpp | 2 +- src/wallet/wallets_manager.cpp | 2 +- 12 files changed, 84 insertions(+), 84 deletions(-) diff --git a/src/currency_core/account.cpp b/src/currency_core/account.cpp index 3fb19b45..543338ed 100644 --- a/src/currency_core/account.cpp +++ b/src/currency_core/account.cpp @@ -35,8 +35,8 @@ namespace currency void account_base::set_null() { // fill sensitive data with random bytes - crypto::generate_random_bytes(sizeof m_keys.m_spend_secret_key, &m_keys.m_spend_secret_key); - crypto::generate_random_bytes(sizeof m_keys.m_view_secret_key, &m_keys.m_view_secret_key); + crypto::generate_random_bytes(sizeof m_keys.spend_secret_key, &m_keys.spend_secret_key); + crypto::generate_random_bytes(sizeof m_keys.view_secret_key, &m_keys.view_secret_key); crypto::generate_random_bytes(m_seed.size(), &m_seed[0]); // clear @@ -47,9 +47,9 @@ namespace currency //----------------------------------------------------------------- void account_base::generate() { - generate_brain_keys(m_keys.m_account_address.spend_public_key, m_keys.m_spend_secret_key, m_seed, BRAINWALLET_DEFAULT_SEED_SIZE); - dependent_key(m_keys.m_spend_secret_key, m_keys.m_view_secret_key); - if (!crypto::secret_key_to_public_key(m_keys.m_view_secret_key, m_keys.m_account_address.view_public_key)) + generate_brain_keys(m_keys.account_address.spend_public_key, m_keys.spend_secret_key, m_seed, BRAINWALLET_DEFAULT_SEED_SIZE); + dependent_key(m_keys.spend_secret_key, m_keys.view_secret_key); + if (!crypto::secret_key_to_public_key(m_keys.view_secret_key, m_keys.account_address.view_public_key)) throw std::runtime_error("Failed to create public view key"); @@ -85,7 +85,7 @@ namespace currency //CHECK_AND_ASSERT_MES(restore_data.size() == ACCOUNT_RESTORE_DATA_SIZE, false, "wrong restore data size"); if (restore_data.size() == BRAINWALLET_DEFAULT_SEED_SIZE) { - crypto::keys_from_default((unsigned char*)restore_data.data(), m_keys.m_account_address.spend_public_key, m_keys.m_spend_secret_key, BRAINWALLET_DEFAULT_SEED_SIZE); + crypto::keys_from_default((unsigned char*)restore_data.data(), m_keys.account_address.spend_public_key, m_keys.spend_secret_key, BRAINWALLET_DEFAULT_SEED_SIZE); } else { @@ -93,8 +93,8 @@ namespace currency return false; } m_seed = restore_data; - crypto::dependent_key(m_keys.m_spend_secret_key, m_keys.m_view_secret_key); - bool r = crypto::secret_key_to_public_key(m_keys.m_view_secret_key, m_keys.m_account_address.view_public_key); + crypto::dependent_key(m_keys.spend_secret_key, m_keys.view_secret_key); + bool r = crypto::secret_key_to_public_key(m_keys.view_secret_key, m_keys.account_address.view_public_key); CHECK_AND_ASSERT_MES(r, false, "failed to secret_key_to_public_key for view key"); set_createtime(0); return true; @@ -126,7 +126,7 @@ namespace currency std::string account_base::get_public_address_str() const { //TODO: change this code into base 58 - return get_account_address_as_str(m_keys.m_account_address); + return get_account_address_as_str(m_keys.account_address); } //----------------------------------------------------------------- void account_base::make_account_watch_only() @@ -138,16 +138,16 @@ namespace currency // store to local tmp uint64_t local_ts = m_creation_timestamp; - account_public_address local_addr = m_keys.m_account_address; - crypto::secret_key local_view_sec = m_keys.m_view_secret_key; + account_public_address local_addr = m_keys.account_address; + crypto::secret_key local_view_sec = m_keys.view_secret_key; // clear set_null(); // restore m_creation_timestamp = local_ts; - m_keys.m_account_address = local_addr; - m_keys.m_view_secret_key = local_view_sec; + m_keys.account_address = local_addr; + m_keys.view_secret_key = local_view_sec; } //----------------------------------------------------------------- std::string transform_addr_to_str(const account_public_address& addr) diff --git a/src/currency_core/account.h b/src/currency_core/account.h index f39e1a61..0a049a89 100644 --- a/src/currency_core/account.h +++ b/src/currency_core/account.h @@ -29,14 +29,14 @@ namespace currency struct account_keys { - account_public_address m_account_address; - crypto::secret_key m_spend_secret_key; - crypto::secret_key m_view_secret_key; + account_public_address account_address; + crypto::secret_key spend_secret_key; + crypto::secret_key view_secret_key; BEGIN_KV_SERIALIZE_MAP() - KV_SERIALIZE(m_account_address) - KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE(m_spend_secret_key) - KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE(m_view_secret_key) + KV_SERIALIZE(account_address) + KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE(spend_secret_key) + KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE(view_secret_key) END_KV_SERIALIZE_MAP() }; @@ -49,7 +49,7 @@ namespace currency account_base(); void generate(); const account_keys& get_keys() const; - const account_public_address& get_public_address() const { return m_keys.m_account_address; }; + const account_public_address& get_public_address() const { return m_keys.account_address; }; std::string get_public_address_str() const; std::string get_restore_data() const; std::string get_restore_braindata() const; @@ -92,9 +92,9 @@ namespace currency inline bool operator==(const account_keys& lhs, const account_keys& rhs) { - return lhs.m_account_address == rhs.m_account_address && - lhs.m_spend_secret_key == rhs.m_spend_secret_key && - lhs.m_view_secret_key == rhs.m_view_secret_key; + return lhs.account_address == rhs.account_address && + lhs.spend_secret_key == rhs.spend_secret_key && + lhs.view_secret_key == rhs.view_secret_key; } inline bool operator!=(const account_keys& lhs, const account_keys& rhs) { diff --git a/src/currency_core/account_boost_serialization.h b/src/currency_core/account_boost_serialization.h index f4d3c616..f0f2d634 100644 --- a/src/currency_core/account_boost_serialization.h +++ b/src/currency_core/account_boost_serialization.h @@ -17,9 +17,9 @@ namespace boost template inline void serialize(Archive &a, currency::account_keys &x, const boost::serialization::version_type ver) { - a & x.m_account_address; - a & x.m_spend_secret_key; - a & x.m_view_secret_key; + a & x.account_address; + a & x.spend_secret_key; + a & x.view_secret_key; } } diff --git a/src/currency_core/currency_format_utils.cpp b/src/currency_core/currency_format_utils.cpp index 8d2058c4..feeab899 100644 --- a/src/currency_core/currency_format_utils.cpp +++ b/src/currency_core/currency_format_utils.cpp @@ -224,13 +224,13 @@ namespace currency bool derive_ephemeral_key_helper(const account_keys& ack, const crypto::public_key& tx_public_key, size_t real_output_index, keypair& in_ephemeral) { crypto::key_derivation recv_derivation = AUTO_VAL_INIT(recv_derivation); - bool r = crypto::generate_key_derivation(tx_public_key, ack.m_view_secret_key, recv_derivation); - CHECK_AND_ASSERT_MES(r, false, "key image helper: failed to generate_key_derivation(" << tx_public_key << ", " << ack.m_view_secret_key << ")"); + bool r = crypto::generate_key_derivation(tx_public_key, ack.view_secret_key, recv_derivation); + CHECK_AND_ASSERT_MES(r, false, "key image helper: failed to generate_key_derivation(" << tx_public_key << ", " << ack.view_secret_key << ")"); - r = crypto::derive_public_key(recv_derivation, real_output_index, ack.m_account_address.spend_public_key, in_ephemeral.pub); - CHECK_AND_ASSERT_MES(r, false, "key image helper: failed to derive_public_key(" << recv_derivation << ", " << real_output_index << ", " << ack.m_account_address.spend_public_key << ")"); + r = crypto::derive_public_key(recv_derivation, real_output_index, ack.account_address.spend_public_key, in_ephemeral.pub); + CHECK_AND_ASSERT_MES(r, false, "key image helper: failed to derive_public_key(" << recv_derivation << ", " << real_output_index << ", " << ack.account_address.spend_public_key << ")"); - crypto::derive_secret_key(recv_derivation, real_output_index, ack.m_spend_secret_key, in_ephemeral.sec); + crypto::derive_secret_key(recv_derivation, real_output_index, ack.spend_secret_key, in_ephemeral.sec); return true; } //--------------------------------------------------------------- @@ -778,15 +778,15 @@ namespace currency { crypto::public_key tx_pub_key = currency::get_tx_pub_key_from_extra(tx); - bool r = crypto::generate_key_derivation(tx_pub_key, acc_keys.m_view_secret_key, derivation); + bool r = crypto::generate_key_derivation(tx_pub_key, acc_keys.view_secret_key, derivation); CHECK_AND_ASSERT_MES(r, null_derivation, "failed to generate_key_derivation"); - LOG_PRINT_GREEN("DECRYPTING ON KEY: " << epee::string_tools::pod_to_hex(derivation) << ", key derived from destination addr: " << currency::get_account_address_as_str(acc_keys.m_account_address), LOG_LEVEL_0); + LOG_PRINT_GREEN("DECRYPTING ON KEY: " << epee::string_tools::pod_to_hex(derivation) << ", key derived from destination addr: " << currency::get_account_address_as_str(acc_keys.account_address), LOG_LEVEL_0); } else { derivation = crypto_info.encrypted_key_derivation; - crypto::chacha_crypt(derivation, acc_keys.m_spend_secret_key); - LOG_PRINT_GREEN("DECRYPTING ON KEY: " << epee::string_tools::pod_to_hex(derivation) << ", key decrypted from sender address: " << currency::get_account_address_as_str(acc_keys.m_account_address), LOG_LEVEL_0); + crypto::chacha_crypt(derivation, acc_keys.spend_secret_key); + LOG_PRINT_GREEN("DECRYPTING ON KEY: " << epee::string_tools::pod_to_hex(derivation) << ", key decrypted from sender address: " << currency::get_account_address_as_str(acc_keys.account_address), LOG_LEVEL_0); } //validate derivation we here. Yoda style @@ -855,7 +855,7 @@ namespace currency chs.derivation_hash = *(uint32_t*)&hash_for_check_sum; //put encrypted derivation to let sender decrypt all this data from attachment/extra chs.encrypted_key_derivation = derivation; - crypto::chacha_crypt(chs.encrypted_key_derivation, sender_keys.m_spend_secret_key); + crypto::chacha_crypt(chs.encrypted_key_derivation, sender_keys.spend_secret_key); if (was_extra_crypted_entries) tx.extra.push_back(chs); else @@ -976,7 +976,7 @@ namespace currency { CHECK_AND_ASSERT_MES(destinations.size() <= CURRENCY_TX_MAX_ALLOWED_OUTS, false, "Too many outs (" << destinations.size() << ")! Tx can't be constructed."); - bool watch_only_mode = sender_account_keys.m_spend_secret_key == null_skey; + bool watch_only_mode = sender_account_keys.spend_secret_key == null_skey; bool append_mode = false; if (flags&TX_FLAG_SIGNATURE_MODE_SEPARATE && tx.vin.size()) @@ -1138,7 +1138,7 @@ namespace currency { CHECK_AND_ASSERT_MES(tsa.security.size() == 1, false, "Wrong tsa.security.size() = " << tsa.security.size()); - bool r = derive_public_key_from_target_address(sender_account_keys.m_account_address, one_time_secret_key, att_count, tsa.security.back()); + bool r = derive_public_key_from_target_address(sender_account_keys.account_address, one_time_secret_key, att_count, tsa.security.back()); CHECK_AND_ASSERT_MES(r, false, "Failed to derive_public_key_from_target_address"); } att_count++; @@ -1524,7 +1524,7 @@ namespace currency bool is_out_to_acc(const account_keys& acc, const txout_to_key& out_key, const crypto::key_derivation& derivation, size_t output_index) { crypto::public_key pk; - if (!derive_public_key(derivation, output_index, acc.m_account_address.spend_public_key, pk)) + if (!derive_public_key(derivation, output_index, acc.account_address.spend_public_key, pk)) return false; return pk == out_key.key; } @@ -1532,7 +1532,7 @@ namespace currency bool is_out_to_acc(const account_keys& acc, const txout_multisig& out_multisig, const crypto::key_derivation& derivation, size_t output_index) { crypto::public_key pk; - if (!derive_public_key(derivation, output_index, acc.m_account_address.spend_public_key, pk)) + if (!derive_public_key(derivation, output_index, acc.account_address.spend_public_key, pk)) return false; auto it = std::find(out_multisig.keys.begin(), out_multisig.keys.end(), pk); if (out_multisig.keys.end() == it) @@ -1576,7 +1576,7 @@ namespace currency bool lookup_acc_outs_genesis(const account_keys& acc, const transaction& tx, const crypto::public_key& tx_pub_key, std::vector& outs, uint64_t& money_transfered, crypto::key_derivation& derivation) { uint64_t offset = 0; - bool r = get_account_genesis_offset_by_address(get_account_address_as_str(acc.m_account_address), offset); + bool r = get_account_genesis_offset_by_address(get_account_address_as_str(acc.account_address), offset); if (!r) return true; @@ -1594,7 +1594,7 @@ namespace currency bool lookup_acc_outs(const account_keys& acc, const transaction& tx, const crypto::public_key& tx_pub_key, std::vector& outs, uint64_t& money_transfered, crypto::key_derivation& derivation) { money_transfered = 0; - bool r = generate_key_derivation(tx_pub_key, acc.m_view_secret_key, derivation); + bool r = generate_key_derivation(tx_pub_key, acc.view_secret_key, derivation); CHECK_AND_ASSERT_MES(r, false, "unable to generate derivation from tx_pub = " << tx_pub_key << " * view_sec, invalid tx_pub?"); if (is_coinbase(tx) && get_block_height(tx) == 0 && tx_pub_key == ggenesis_tx_pub_key) diff --git a/src/currency_core/currency_format_utils.h b/src/currency_core/currency_format_utils.h index 01d08170..4405b24d 100644 --- a/src/currency_core/currency_format_utils.h +++ b/src/currency_core/currency_format_utils.h @@ -348,7 +348,7 @@ namespace currency bool is_out_to_acc(const account_keys& acc, const tx_out_t& out_key, const crypto::public_key& tx_pub_key, size_t output_index) { crypto::key_derivation derivation; - generate_key_derivation(tx_pub_key, acc.m_view_secret_key, derivation); + generate_key_derivation(tx_pub_key, acc.view_secret_key, derivation); return is_out_to_acc(acc, out_key, derivation, output_index); } //---------------------------------------------------------------------------------------------------- diff --git a/src/currency_core/currency_format_utils_transactions.cpp b/src/currency_core/currency_format_utils_transactions.cpp index da78894f..6e84961a 100644 --- a/src/currency_core/currency_format_utils_transactions.cpp +++ b/src/currency_core/currency_format_utils_transactions.cpp @@ -16,10 +16,10 @@ namespace currency { for (const auto& de : destinations) { - if (de.addr.size() == 1 && sender_account_keys.m_account_address != de.addr.back()) + if (de.addr.size() == 1 && sender_account_keys.account_address != de.addr.back()) return de.addr.back(); // return the first destination address that is non-multisig and not equal to the sender's address } - return sender_account_keys.m_account_address; // otherwise, fallback to sender's address + return sender_account_keys.account_address; // otherwise, fallback to sender's address } //------------------------------------------------------------------ bool is_tx_expired(const transaction& tx, uint64_t expiration_ts_median) diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 29616f54..65cdba9e 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -385,7 +385,7 @@ bool simple_wallet::new_wallet(const string &wallet_file, const std::string& pas { m_wallet->generate(epee::string_encoding::utf8_to_wstring(m_wallet_file), password); message_writer(epee::log_space::console_color_white, true) << "Generated new wallet: " << m_wallet->get_account().get_public_address_str(); - std::cout << "view key: " << string_tools::pod_to_hex(m_wallet->get_account().get_keys().m_view_secret_key) << std::endl << std::flush; + std::cout << "view key: " << string_tools::pod_to_hex(m_wallet->get_account().get_keys().view_secret_key) << std::endl << std::flush; if(m_do_not_set_date) m_wallet->reset_creation_time(0); @@ -427,7 +427,7 @@ bool simple_wallet::restore_wallet(const std::string &wallet_file, const std::st { m_wallet->restore(epee::string_encoding::utf8_to_wstring(wallet_file), password, restore_seed); message_writer(epee::log_space::console_color_white, true) << "Wallet restored: " << m_wallet->get_account().get_public_address_str(); - std::cout << "view key: " << string_tools::pod_to_hex(m_wallet->get_account().get_keys().m_view_secret_key) << std::endl << std::flush; + std::cout << "view key: " << string_tools::pod_to_hex(m_wallet->get_account().get_keys().view_secret_key) << std::endl << std::flush; if (m_do_not_set_date) m_wallet->reset_creation_time(0); } @@ -1333,8 +1333,8 @@ bool simple_wallet::spendkey(const std::vector &args) << "WARNING! Anyone who knows the following secret key can access your wallet and spend your coins."; const account_keys& keys = m_wallet->get_account().get_keys(); - std::cout << "secret: " << epee::string_tools::pod_to_hex(keys.m_spend_secret_key) << std::endl; - std::cout << "public: " << epee::string_tools::pod_to_hex(keys.m_account_address.spend_public_key) << std::endl << std::flush; + std::cout << "secret: " << epee::string_tools::pod_to_hex(keys.spend_secret_key) << std::endl; + std::cout << "public: " << epee::string_tools::pod_to_hex(keys.account_address.spend_public_key) << std::endl << std::flush; return true; } @@ -1345,8 +1345,8 @@ bool simple_wallet::viewkey(const std::vector &args) << "WARNING! Anyone who knows the following secret key can view your wallet (but can not spend your coins)."; const account_keys& keys = m_wallet->get_account().get_keys(); - std::cout << "secret: " << epee::string_tools::pod_to_hex(keys.m_view_secret_key) << std::endl; - std::cout << "public: " << epee::string_tools::pod_to_hex(keys.m_account_address.view_public_key) << std::endl << std::flush; + std::cout << "secret: " << epee::string_tools::pod_to_hex(keys.view_secret_key) << std::endl; + std::cout << "public: " << epee::string_tools::pod_to_hex(keys.account_address.view_public_key) << std::endl << std::flush; return true; } diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 3add4a0d..4691854e 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -771,7 +771,7 @@ bool wallet2::handle_proposal(wallet_public::wallet_transfer_info& wti, const bc wallet_public::escrow_contract_details_basic& ed = epee::misc_utils::get_or_insert_value_initialized(m_contracts, ms_id); ed.expiration_time = currency::get_tx_expiration_time(prop.tx_template); ed.timestamp = wti.timestamp; - ed.is_a = cpd.a_addr.spend_public_key == m_account.get_keys().m_account_address.spend_public_key; + ed.is_a = cpd.a_addr.spend_public_key == m_account.get_keys().account_address.spend_public_key; change_contract_state(ed, wallet_public::escrow_contract_details_basic::proposal_sent, ms_id, wti); ed.private_detailes = cpd; currency::get_payment_id_from_tx(decrypted_items, ed.payment_id); @@ -1299,8 +1299,8 @@ bool wallet2::has_related_alias_entry_unconfirmed(const currency::transaction& t if (tei.m_alias.m_alias.size()) { //have some check address involved - if (tei.m_alias.m_address.spend_public_key == m_account.get_keys().m_account_address.spend_public_key && - tei.m_alias.m_address.view_public_key == m_account.get_keys().m_account_address.view_public_key) + if (tei.m_alias.m_address.spend_public_key == m_account.get_keys().account_address.spend_public_key && + tei.m_alias.m_address.view_public_key == m_account.get_keys().account_address.view_public_key) return true; //check if it's update and address before was our address @@ -1972,11 +1972,11 @@ void wallet2::load_keys(const std::string& buff, const std::string& password) const currency::account_keys& keys = m_account.get_keys(); r = epee::serialization::load_t_from_binary(m_account, account_data); - r = r && verify_keys(keys.m_view_secret_key, keys.m_account_address.view_public_key); - if (keys.m_spend_secret_key == currency::null_skey) + r = r && verify_keys(keys.view_secret_key, keys.account_address.view_public_key); + if (keys.spend_secret_key == currency::null_skey) m_watch_only = true; else - r = r && verify_keys(keys.m_spend_secret_key, keys.m_account_address.spend_public_key); + r = r && verify_keys(keys.spend_secret_key, keys.account_address.spend_public_key); if (!r) { WLT_LOG_L0("Wrong password for wallet " << string_encoding::convert_to_ansii(m_wallet_file)); @@ -2404,7 +2404,7 @@ void wallet2::sign_transfer(const std::string& tx_sources_blob, std::string& sig THROW_IF_FALSE_WALLET_EX(!m_watch_only, error::wallet_common_error, "watch-only wallet is unable to sign transfers, you need to use normal wallet for that"); // decrypt the blob - std::string decrypted_src_blob = crypto::chacha_crypt(tx_sources_blob, m_account.get_keys().m_view_secret_key); + std::string decrypted_src_blob = crypto::chacha_crypt(tx_sources_blob, m_account.get_keys().view_secret_key); // deserialize args finalized_tx ft = AUTO_VAL_INIT(ft); @@ -2412,7 +2412,7 @@ void wallet2::sign_transfer(const std::string& tx_sources_blob, std::string& sig THROW_IF_FALSE_WALLET_EX(r, error::wallet_common_error, "Failed to decrypt tx sources blob"); // make sure unsigned tx was created with the same keys - THROW_IF_FALSE_WALLET_EX(ft.ftp.spend_pub_key == m_account.get_keys().m_account_address.spend_public_key, error::wallet_common_error, "The was created in a different wallet, keys missmatch"); + THROW_IF_FALSE_WALLET_EX(ft.ftp.spend_pub_key == m_account.get_keys().account_address.spend_public_key, error::wallet_common_error, "The was created in a different wallet, keys missmatch"); finalize_transaction(ft.ftp, ft.tx, ft.one_time_key, false); @@ -2420,11 +2420,11 @@ void wallet2::sign_transfer(const std::string& tx_sources_blob, std::string& sig crypto::key_derivation derivation = AUTO_VAL_INIT(derivation); WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX( crypto::generate_key_derivation( - m_account.get_keys().m_account_address.view_public_key, + m_account.get_keys().account_address.view_public_key, ft.one_time_key, derivation), "internal error: sign_transfer: failed to generate key derivation(" - << m_account.get_keys().m_account_address.view_public_key + << m_account.get_keys().account_address.view_public_key << ", view secret key: " << ft.one_time_key << ")"); for (size_t i = 0; i < ft.tx.vout.size(); ++i) @@ -2435,7 +2435,7 @@ void wallet2::sign_transfer(const std::string& tx_sources_blob, std::string& sig const txout_to_key& otk = boost::get(out.target); crypto::public_key ephemeral_pub = AUTO_VAL_INIT(ephemeral_pub); - if (!crypto::derive_public_key(derivation, i, m_account.get_keys().m_account_address.spend_public_key, ephemeral_pub)) + if (!crypto::derive_public_key(derivation, i, m_account.get_keys().account_address.spend_public_key, ephemeral_pub)) { WLT_LOG_ERROR("derive_public_key failed for tx " << get_transaction_hash(ft.tx) << ", out # " << i); } @@ -2445,7 +2445,7 @@ void wallet2::sign_transfer(const std::string& tx_sources_blob, std::string& sig // this is the output to the given keys // derive secret key and calculate key image crypto::secret_key ephemeral_sec = AUTO_VAL_INIT(ephemeral_sec); - crypto::derive_secret_key(derivation, i, m_account.get_keys().m_spend_secret_key, ephemeral_sec); + crypto::derive_secret_key(derivation, i, m_account.get_keys().spend_secret_key, ephemeral_sec); crypto::key_image ki = AUTO_VAL_INIT(ki); crypto::generate_key_image(ephemeral_pub, ephemeral_sec, ki); @@ -2455,7 +2455,7 @@ void wallet2::sign_transfer(const std::string& tx_sources_blob, std::string& sig // serialize and encrypt the result signed_tx_blob = t_serializable_object_to_blob(ft); - crypto::chacha_crypt(signed_tx_blob, m_account.get_keys().m_view_secret_key); + crypto::chacha_crypt(signed_tx_blob, m_account.get_keys().view_secret_key); tx = ft.tx; } @@ -2486,7 +2486,7 @@ bool wallet2::get_utxo_distribution(std::map& distribution) void wallet2::submit_transfer(const std::string& signed_tx_blob, currency::transaction& tx) { // decrypt sources - std::string decrypted_src_blob = crypto::chacha_crypt(signed_tx_blob, m_account.get_keys().m_view_secret_key); + std::string decrypted_src_blob = crypto::chacha_crypt(signed_tx_blob, m_account.get_keys().view_secret_key); // deserialize tx data finalized_tx ft = AUTO_VAL_INIT(ft); @@ -2496,7 +2496,7 @@ void wallet2::submit_transfer(const std::string& signed_tx_blob, currency::trans crypto::hash tx_hash = get_transaction_hash(tx); // foolproof - THROW_IF_FALSE_WALLET_CMN_ERR_EX(ft.ftp.spend_pub_key == m_account.get_keys().m_account_address.spend_public_key, "The given tx was created in a different wallet, keys missmatch, tx hash: " << tx_hash); + THROW_IF_FALSE_WALLET_CMN_ERR_EX(ft.ftp.spend_pub_key == m_account.get_keys().account_address.spend_public_key, "The given tx was created in a different wallet, keys missmatch, tx hash: " << tx_hash); try { @@ -2687,17 +2687,17 @@ bool wallet2::prepare_and_sign_pos_block(currency::block& b, //derive secret key crypto::key_derivation pos_coin_derivation = AUTO_VAL_INIT(pos_coin_derivation); bool r = crypto::generate_key_derivation(source_tx_pub_key, - m_account.get_keys().m_view_secret_key, + m_account.get_keys().view_secret_key, pos_coin_derivation); WLT_CHECK_AND_ASSERT_MES(r, false, "internal error: pos coin base generator: failed to generate_key_derivation(" << source_tx_pub_key - << ", view secret key: " << m_account.get_keys().m_view_secret_key << ")"); + << ", view secret key: " << m_account.get_keys().view_secret_key << ")"); crypto::secret_key derived_secret_ephemeral_key = AUTO_VAL_INIT(derived_secret_ephemeral_key); crypto::derive_secret_key(pos_coin_derivation, in_tx_output_index, - m_account.get_keys().m_spend_secret_key, + m_account.get_keys().spend_secret_key, derived_secret_ephemeral_key); // sign block actually in coinbase transaction @@ -2967,7 +2967,7 @@ bool wallet2::is_transfer_unlocked(const transfer_details& td, bool for_pos_mini void wallet2::push_offer(const bc_services::offer_details_ex& od, currency::transaction& res_tx) { currency::tx_destination_entry tx_dest; - tx_dest.addr.push_back(m_account.get_keys().m_account_address); + tx_dest.addr.push_back(m_account.get_keys().account_address); tx_dest.amount = m_core_runtime_config.tx_default_fee; std::vector destinations; std::vector extra; @@ -3012,7 +3012,7 @@ void wallet2::cancel_offer_by_id(const crypto::hash& tx_id, uint64_t of_ind, uin void wallet2::update_offer_by_id(const crypto::hash& tx_id, uint64_t of_ind, const bc_services::offer_details_ex& od, currency::transaction& res_tx) { currency::tx_destination_entry tx_dest; - tx_dest.addr.push_back(m_account.get_keys().m_account_address); + tx_dest.addr.push_back(m_account.get_keys().account_address); tx_dest.amount = m_core_runtime_config.tx_default_fee; std::vector destinations; std::vector extra; @@ -3062,12 +3062,12 @@ void wallet2::request_alias_update(currency::extra_alias_entry& ai, currency::tr { throw std::runtime_error(std::string("wrong alias characters: ") + ai.m_alias); } - bool r = currency::sign_extra_alias_entry(ai, m_account.get_keys().m_account_address.spend_public_key, m_account.get_keys().m_spend_secret_key); + bool r = currency::sign_extra_alias_entry(ai, m_account.get_keys().account_address.spend_public_key, m_account.get_keys().spend_secret_key); CHECK_AND_ASSERT_THROW_MES(r, "Failed to sign alias update"); WLT_LOG_L2("Generated upodate alias info: " << ENDL << "alias: " << ai.m_alias << ENDL << "signature: " << currency::print_t_array(ai.m_sign) << ENDL - << "signed(owner) pub key: " << m_account.get_keys().m_account_address.spend_public_key << ENDL + << "signed(owner) pub key: " << m_account.get_keys().account_address.spend_public_key << ENDL << "transfered to address: " << get_account_address_as_str(ai.m_address) << ENDL << "signed_hash: " << currency::get_sign_buff_hash_for_alias_update(ai) ); @@ -3953,8 +3953,8 @@ bool wallet2::read_money_transfer2_details_from_tx(const transaction& tx, const PROFILE_FUNC("wallet2::read_money_transfer2_details_from_tx"); for (auto& d : splitted_dsts) { - if (d.addr.size() && d.addr.back().spend_public_key == m_account.get_keys().m_account_address.spend_public_key && - d.addr.back().view_public_key == m_account.get_keys().m_account_address.view_public_key) + if (d.addr.size() && d.addr.back().spend_public_key == m_account.get_keys().account_address.spend_public_key && + d.addr.back().view_public_key == m_account.get_keys().account_address.view_public_key) wtd.rcv.push_back(d.amount); } @@ -4128,7 +4128,7 @@ void wallet2::prepare_tx_destinations(uint64_t needed_money, currency::tx_destination_entry change_dts = AUTO_VAL_INIT(change_dts); if (needed_money < found_money) { - change_dts.addr.push_back(m_account.get_keys().m_account_address); + change_dts.addr.push_back(m_account.get_keys().account_address); change_dts.amount = found_money - needed_money; } WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(found_money >= needed_money, "needed_money==" << needed_money << " < found_money==" << found_money); @@ -4330,7 +4330,7 @@ bool wallet2::store_unsigned_tx_to_file_and_reserve_transfers(const finalize_tx_ { TIME_MEASURE_START(store_unsigned_tx_time); blobdata bl = t_serializable_object_to_blob(ftp); - crypto::chacha_crypt(bl, m_account.get_keys().m_view_secret_key); + crypto::chacha_crypt(bl, m_account.get_keys().view_secret_key); if (!filename.empty()) { diff --git a/src/wallet/wallet2_escrow.cpp b/src/wallet/wallet2_escrow.cpp index dc57011f..4c5f1d65 100644 --- a/src/wallet/wallet2_escrow.cpp +++ b/src/wallet/wallet2_escrow.cpp @@ -176,7 +176,7 @@ bool wallet2::validate_escrow_release(const transaction& tx, bool release_type_n // (3/5) outputs crypto::public_key tx_pub_key = get_tx_pub_key_from_extra(tx); crypto::key_derivation der = AUTO_VAL_INIT(der); - r = crypto::generate_key_derivation(tx_pub_key, a_keys.m_view_secret_key, der); + r = crypto::generate_key_derivation(tx_pub_key, a_keys.view_secret_key, der); LOC_CHK(r, "generate_key_derivation failed"); uint64_t total_outputs_amount = 0, outputs_to_A_amount = 0, outputs_to_null_addr_amount = 0; for (size_t i = 0; i != tx.vout.size(); ++i) @@ -223,10 +223,10 @@ bool wallet2::validate_escrow_release(const transaction& tx, bool release_type_n // Having a_keys, we determine index of A key in multisig output keys array. // Thus it's possible to determine the order of signatures (A, B or B, A), and, eventually, validate B signature. crypto::public_key source_tx_pub_key = get_tx_pub_key_from_extra(source_tx); - r = crypto::generate_key_derivation(source_tx_pub_key, a_keys.m_view_secret_key, der); + r = crypto::generate_key_derivation(source_tx_pub_key, a_keys.view_secret_key, der); LOC_CHK(r, "generate_key_derivation failed"); crypto::public_key ephemeral_pub_key = AUTO_VAL_INIT(ephemeral_pub_key); - r = crypto::derive_public_key(der, source_ms_out_index, a_keys.m_account_address.spend_public_key, ephemeral_pub_key); + r = crypto::derive_public_key(der, source_ms_out_index, a_keys.account_address.spend_public_key, ephemeral_pub_key); LOC_CHK(r, "derive_public_key failed"); LOC_CHK(source_ms_out.keys.size() == 2, "internal error: invalid ms output keys array, size: " << source_ms_out.keys.size()); @@ -358,7 +358,7 @@ bool wallet2::validate_escrow_cancel_release(const currency::transaction& tx, co // (3/5) outputs crypto::public_key tx_pub_key = get_tx_pub_key_from_extra(tx); crypto::key_derivation der = AUTO_VAL_INIT(der); - r = crypto::generate_key_derivation(tx_pub_key, b_keys.m_view_secret_key, der); + r = crypto::generate_key_derivation(tx_pub_key, b_keys.view_secret_key, der); LOC_CHK(r, "generate_key_derivation failed"); uint64_t total_outputs_amount = 0, outputs_to_B_amount = 0; for (size_t i = 0; i != tx.vout.size(); ++i) diff --git a/src/wallet/wallet_helpers.h b/src/wallet/wallet_helpers.h index 365890da..be227c62 100644 --- a/src/wallet/wallet_helpers.h +++ b/src/wallet/wallet_helpers.h @@ -15,7 +15,7 @@ namespace tools { wi = AUTO_VAL_INIT_T(view::wallet_info); wi.address = w.get_account().get_public_address_str(); - wi.tracking_hey = epee::string_tools::pod_to_hex(w.get_account().get_keys().m_view_secret_key); + wi.tracking_hey = epee::string_tools::pod_to_hex(w.get_account().get_keys().view_secret_key); uint64_t fake = 0; wi.balance = w.balance(wi.unlocked_balance, fake, fake, wi.mined_total); wi.path = epee::string_encoding::wstring_to_utf8(w.get_wallet_path()); diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index e4d3fb67..040ef071 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -293,7 +293,7 @@ namespace tools if (req.push_payer) { currency::tx_payer txp = AUTO_VAL_INIT(txp); - txp.acc_addr = m_wallet.get_account().get_keys().m_account_address; + txp.acc_addr = m_wallet.get_account().get_keys().account_address; extra.push_back(txp); } if (!req.hide_receiver) diff --git a/src/wallet/wallets_manager.cpp b/src/wallet/wallets_manager.cpp index ec505ff6..019b7ca9 100644 --- a/src/wallet/wallets_manager.cpp +++ b/src/wallet/wallets_manager.cpp @@ -1201,7 +1201,7 @@ std::string wallets_manager::transfer(size_t wallet_id, const view::transfer_par if (tp.push_payer) { currency::tx_payer txp = AUTO_VAL_INIT(txp); - txp.acc_addr = w->get()->get_account().get_keys().m_account_address; + txp.acc_addr = w->get()->get_account().get_keys().account_address; extra.push_back(txp); } if (!tp.hide_receiver)