From 3a2be26feb540e0438ad41c9f0763355a5e7f020 Mon Sep 17 00:00:00 2001 From: Some Random Crypto Guy Date: Mon, 10 Jun 2024 18:24:01 +0100 Subject: [PATCH] removed remaining lightwallet code --- src/wallet/api/wallet.cpp | 78 ++------------------------------------- src/wallet/wallet2.h | 39 +------------------- 2 files changed, 4 insertions(+), 113 deletions(-) diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp index eec1de6e4..e2b0e672c 100644 --- a/src/wallet/api/wallet.cpp +++ b/src/wallet/api/wallet.cpp @@ -211,38 +211,6 @@ struct Wallet2CallbackImpl : public tools::i_wallet2_callback // TODO; } - // Light wallet callbacks - virtual void on_lw_new_block(uint64_t height) - { - if (m_listener) { - m_listener->newBlock(height); - } - } - - virtual void on_lw_money_received(uint64_t height, const crypto::hash &txid, uint64_t amount) - { - if (m_listener) { - std::string tx_hash = epee::string_tools::pod_to_hex(txid); - m_listener->moneyReceived(tx_hash, amount); - } - } - - virtual void on_lw_unconfirmed_money_received(uint64_t height, const crypto::hash &txid, uint64_t amount) - { - if (m_listener) { - std::string tx_hash = epee::string_tools::pod_to_hex(txid); - m_listener->unconfirmedMoneyReceived(tx_hash, amount); - } - } - - virtual void on_lw_money_spent(uint64_t height, const crypto::hash &txid, uint64_t amount) - { - if (m_listener) { - std::string tx_hash = epee::string_tools::pod_to_hex(txid); - m_listener->moneySpent(tx_hash, amount); - } - } - virtual void on_device_button_request(uint64_t code) { if (m_listener) { @@ -952,42 +920,11 @@ string WalletImpl::keysFilename() const bool WalletImpl::init(const std::string &daemon_address, uint64_t upper_transaction_size_limit, const std::string &daemon_username, const std::string &daemon_password, bool use_ssl, bool lightWallet, const std::string &proxy_address) { clearStatus(); - m_wallet->set_light_wallet(lightWallet); if(daemon_username != "") m_daemon_login.emplace(daemon_username, daemon_password); return doInit(daemon_address, proxy_address, upper_transaction_size_limit, use_ssl); } -bool WalletImpl::lightWalletLogin(bool &isNewWallet) const -{ - return m_wallet->light_wallet_login(isNewWallet); -} - -bool WalletImpl::lightWalletImportWalletRequest(std::string &payment_id, uint64_t &fee, bool &new_request, bool &request_fulfilled, std::string &payment_address, std::string &status) -{ - try - { - tools::COMMAND_RPC_IMPORT_WALLET_REQUEST::response response; - if(!m_wallet->light_wallet_import_wallet_request(response)){ - setStatusError(tr("Failed to send import wallet request")); - return false; - } - fee = response.import_fee; - payment_id = response.payment_id; - new_request = response.new_request; - request_fulfilled = response.request_fulfilled; - payment_address = response.payment_address; - status = response.status; - } - catch (const std::exception &e) - { - LOG_ERROR("Error sending import wallet request: " << e.what()); - setStatusError(e.what()); - return false; - } - return true; -} - void WalletImpl::setRefreshFromBlockHeight(uint64_t refresh_from_block_height) { m_wallet->set_refresh_from_block_height(refresh_from_block_height); @@ -1020,9 +957,6 @@ uint64_t WalletImpl::unlockedBalance(uint32_t accountIndex) const uint64_t WalletImpl::blockChainHeight() const { - if(m_wallet->light_wallet()) { - return m_wallet->get_light_wallet_scanned_block_height(); - } return m_wallet->get_blockchain_current_height(); } uint64_t WalletImpl::approximateBlockChainHeight() const @@ -1037,9 +971,6 @@ uint64_t WalletImpl::estimateBlockChainHeight() const uint64_t WalletImpl::daemonBlockChainHeight() const { - if(m_wallet->light_wallet()) { - return m_wallet->get_light_wallet_scanned_block_height(); - } if (!m_is_connected) return 0; std::string err; @@ -1056,9 +987,6 @@ uint64_t WalletImpl::daemonBlockChainHeight() const uint64_t WalletImpl::daemonBlockChainTargetHeight() const { - if(m_wallet->light_wallet()) { - return m_wallet->get_light_wallet_blockchain_height(); - } if (!m_is_connected) return 0; std::string err; @@ -2183,13 +2111,13 @@ Wallet::ConnectionStatus WalletImpl::connected() const m_is_connected = m_wallet->check_connection(&version, NULL, DEFAULT_CONNECTION_TIMEOUT_MILLIS, &wallet_is_outdated, &daemon_is_outdated); if (!m_is_connected) { - if (!m_wallet->light_wallet() && (wallet_is_outdated || daemon_is_outdated)) + if (wallet_is_outdated || daemon_is_outdated) return Wallet::ConnectionStatus_WrongVersion; else return Wallet::ConnectionStatus_Disconnected; } // Version check is not implemented in light wallets nodes/wallets - if (!m_wallet->light_wallet() && (version >> 16) != CORE_RPC_VERSION_MAJOR) + if ((version >> 16) != CORE_RPC_VERSION_MAJOR) return Wallet::ConnectionStatus_WrongVersion; return Wallet::ConnectionStatus_Connected; } @@ -2283,7 +2211,7 @@ void WalletImpl::doRefresh() LOG_PRINT_L3(__FUNCTION__ << ": doRefresh, rescan = "<light_wallet() || daemonSynced()) { + if (daemonSynced()) { if(rescan) m_wallet->rescan_blockchain(false); m_wallet->refresh(trustedDaemon()); diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index d296ec653..ab7b1faba 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -1046,14 +1046,6 @@ private: bool is_deterministic() const; bool get_seed(epee::wipeable_string& electrum_words, const epee::wipeable_string &passphrase = epee::wipeable_string()) const; - /*! - * \brief Checks if light wallet. A light wallet sends view key to a server where the blockchain is scanned. - */ - bool light_wallet() const { return m_light_wallet; } - void set_light_wallet(bool light_wallet) { m_light_wallet = light_wallet; } - uint64_t get_light_wallet_scanned_block_height() const { return m_light_wallet_scanned_block_height; } - uint64_t get_light_wallet_blockchain_height() const { return m_light_wallet_blockchain_height; } - /*! * \brief Gets the seed language */ @@ -1187,7 +1179,7 @@ private: void get_unconfirmed_payments_out(std::list>& unconfirmed_payments, const boost::optional& subaddr_account = boost::none, const std::set& subaddr_indices = {}) const; void get_unconfirmed_payments(std::list>& unconfirmed_payments, const boost::optional& subaddr_account = boost::none, const std::set& subaddr_indices = {}) const; - uint64_t get_blockchain_current_height() const { return m_light_wallet_blockchain_height ? m_light_wallet_blockchain_height : m_blockchain.size(); } + uint64_t get_blockchain_current_height() const { return m_blockchain.size(); } void rescan_spent(); void rescan_blockchain(bool hard, bool refresh = true, bool keep_key_images = false); bool is_transfer_unlocked(const transfer_details& td); @@ -1649,24 +1641,6 @@ private: } template void handle_payment_changes(const T &res, std::false_type) {} - // Light wallet specific functions - // fetch unspent outs from lw node and store in m_transfers - void light_wallet_get_unspent_outs(); - // fetch txs and store in m_payments - void light_wallet_get_address_txs(); - // get_address_info - bool light_wallet_get_address_info(tools::COMMAND_RPC_GET_ADDRESS_INFO::response &response); - // Login. new_address is true if address hasn't been used on lw node before. - bool light_wallet_login(bool &new_address); - // Send an import request to lw node. returns info about import fee, address and payment_id - bool light_wallet_import_wallet_request(tools::COMMAND_RPC_IMPORT_WALLET_REQUEST::response &response); - // get random outputs from light wallet server - void light_wallet_get_outs(std::vector> &outs, const std::vector &selected_transfers, size_t fake_outputs_count); - // Parse rct string - 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; - // check if key image is ours - bool light_wallet_key_image_is_ours(const crypto::key_image& key_image, const crypto::public_key& tx_public_key, uint64_t out_index); - /* * "attributes" are a mechanism to store an arbitrary number of string values * on the level of the wallet as a whole, identified by keys. Their introduction, @@ -2000,17 +1974,6 @@ private: // Aux transaction data from device serializable_unordered_map m_tx_device; - // Light wallet - bool m_light_wallet; /* sends view key to daemon for scanning */ - uint64_t m_light_wallet_scanned_block_height; - uint64_t m_light_wallet_blockchain_height; - uint64_t m_light_wallet_per_kb_fee = FEE_PER_KB; - bool m_light_wallet_connected; - uint64_t m_light_wallet_balance; - uint64_t m_light_wallet_unlocked_balance; - // Light wallet info needed to populate m_payment requires 2 separate api calls (get_address_txs and get_unspent_outs) - // We save the info from the first call in m_light_wallet_address_txs for easier lookup. - std::unordered_map m_light_wallet_address_txs; // store calculated key image for faster lookup serializable_unordered_map > m_key_image_cache;