with all security checks in place, the code is now accepting protocol_tx outputs as valid in-wallet; only the asset_type is misreported now
This commit is contained in:
+284
-693
File diff suppressed because it is too large
Load Diff
+7
-48
@@ -71,7 +71,6 @@
|
||||
#include "common/password.h"
|
||||
#include "node_rpc_proxy.h"
|
||||
#include "message_store.h"
|
||||
#include "wallet_light_rpc.h"
|
||||
#include "wallet_rpc_helpers.h"
|
||||
|
||||
#undef MONERO_DEFAULT_LOG_CATEGORY
|
||||
@@ -140,16 +139,12 @@ private:
|
||||
public:
|
||||
// Full wallet callbacks
|
||||
virtual void on_new_block(uint64_t height, const cryptonote::block& block) {}
|
||||
virtual void on_reorg(uint64_t height, uint64_t blocks_detached, size_t transfers_detached) {}
|
||||
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) {}
|
||||
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) {}
|
||||
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) {}
|
||||
virtual void on_skip_transaction(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& tx) {}
|
||||
virtual boost::optional<epee::wipeable_string> on_get_password(const char *reason) { return boost::none; }
|
||||
// Light wallet callbacks
|
||||
virtual void on_lw_new_block(uint64_t height) {}
|
||||
virtual void on_lw_money_received(uint64_t height, const crypto::hash &txid, uint64_t amount) {}
|
||||
virtual void on_lw_unconfirmed_money_received(uint64_t height, const crypto::hash &txid, uint64_t amount) {}
|
||||
virtual void on_lw_money_spent(uint64_t height, const crypto::hash &txid, uint64_t amount) {}
|
||||
// Device callbacks
|
||||
virtual void on_device_button_request(uint64_t code) {}
|
||||
virtual void on_device_button_pressed() {}
|
||||
@@ -320,10 +315,11 @@ private:
|
||||
uint64_t amount;
|
||||
uint64_t money_transfered;
|
||||
std::string asset_type;
|
||||
crypto::hash uniqueness;
|
||||
bool error;
|
||||
boost::optional<cryptonote::subaddress_receive_info> received;
|
||||
|
||||
tx_scan_info_t(): amount(0), asset_type(""), money_transfered(0), error(true) {}
|
||||
tx_scan_info_t(): amount(0), asset_type(""), money_transfered(0), uniqueness(crypto::null_hash), error(true) {}
|
||||
};
|
||||
|
||||
struct transfer_details
|
||||
@@ -992,14 +988,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
|
||||
*/
|
||||
@@ -1128,7 +1116,7 @@ private:
|
||||
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;
|
||||
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;
|
||||
|
||||
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);
|
||||
@@ -1582,24 +1570,6 @@ private:
|
||||
}
|
||||
template<typename T> 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<std::vector<get_outs_entry>> &outs, const std::vector<size_t> &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,
|
||||
@@ -1767,6 +1737,7 @@ private:
|
||||
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;
|
||||
std::vector<size_t> get_only_rct(const std::vector<size_t> &unused_dust_indices, const std::vector<size_t> &unused_transfers_indices) const;
|
||||
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, std::map<std::string, uint64_t>> &tx_money_got_in_outs, std::vector<size_t> &outs, bool pool);
|
||||
void scan_protocol_tx_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, std::map<std::string, uint64_t>> &tx_money_got_in_outs, std::vector<size_t> &outs, bool pool);
|
||||
void trim_hashchain();
|
||||
crypto::key_image get_multisig_composite_key_image(size_t n) const;
|
||||
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;
|
||||
@@ -1913,20 +1884,6 @@ private:
|
||||
// Aux transaction data from device
|
||||
serializable_unordered_map<crypto::hash, std::string> 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<crypto::hash, address_tx> m_light_wallet_address_txs;
|
||||
// store calculated key image for faster lookup
|
||||
serializable_unordered_map<crypto::public_key, serializable_map<uint64_t, crypto::key_image> > m_key_image_cache;
|
||||
|
||||
std::string m_ring_database;
|
||||
bool m_ring_history_saved;
|
||||
std::unique_ptr<ringdb> m_ringdb;
|
||||
@@ -1956,6 +1913,8 @@ private:
|
||||
|
||||
static boost::mutex default_daemon_address_lock;
|
||||
static std::string default_daemon_address;
|
||||
|
||||
serializable_map<crypto::public_key, size_t> m_protocol_txs;
|
||||
};
|
||||
}
|
||||
BOOST_CLASS_VERSION(tools::wallet2, 30)
|
||||
|
||||
Reference in New Issue
Block a user