From f2cd4a45a790ea2889af06c94a6830377e762310 Mon Sep 17 00:00:00 2001 From: cslashm Date: Mon, 26 Mar 2018 12:55:48 +0200 Subject: [PATCH] Add the possibility to export private view key for fast scan. On client startup the device asks for authorization to export the private view key. If user agree, the client hold the private view key allowing a fast blockchain scan. If the user does not agree, the blockchain scan is fully done via the device. --- src/device/device_ledger.cpp | 4 ---- src/wallet/wallet2.cpp | 14 +++++++------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/device/device_ledger.cpp b/src/device/device_ledger.cpp index aedaf8382..373f4a282 100644 --- a/src/device/device_ledger.cpp +++ b/src/device/device_ledger.cpp @@ -135,10 +135,6 @@ namespace hw { return sec == crypto::null_skey; } - bool operator==(const crypto::key_derivation &d0, const crypto::key_derivation &d1) { - return !memcmp(&d0, &d1, sizeof(d0)); - } - /* ===================================================================== */ /* === Device ==== */ /* ===================================================================== */ diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 1d5626059..b8d6bec01 100755 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -1007,7 +1007,7 @@ void wallet2::set_unspent(size_t idx) void wallet2::check_acc_out_precomp(const tx_out &o, const crypto::key_derivation &derivation, const std::vector &additional_derivations, size_t i, tx_scan_info_t &tx_scan_info) const { hw::device &hwdev = m_account.get_device(); - boost::unique_lock hwdev_lock (hwdev); + std::unique_lock hwdev_lock (hwdev); hwdev.set_mode(hw::device::TRANSACTION_PARSE); if (o.target.type() != typeid(txout_to_key)) { @@ -1085,7 +1085,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote //ensure device is let in NONE mode in any case hw::device &hwdev = m_account.get_device(); - boost::unique_lock hwdev_lock (hwdev); + std::unique_lock hwdev_lock (hwdev); hw::reset_mode rst(hwdev); hwdev_lock.unlock(); @@ -1180,7 +1180,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote THROW_WALLET_EXCEPTION_IF(tx_scan_info[i].error, error::acc_outs_lookup_error, tx, tx_pub_key, m_account.get_keys()); if (tx_scan_info[i].received) { - hwdev.conceal_derivation(tx_scan_info[i].received->derivation, tx_pub_key, additional_tx_pub_keys, derivation, additional_derivations); + hwdev.generate_key_derivation(tx_pub_key, keys.m_view_secret_key, tx_scan_info[i].received->derivation); scan_output(tx, tx_pub_key, i, tx_scan_info[i], num_vouts_received, tx_money_got_in_outs, outs); } } @@ -1203,7 +1203,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote THROW_WALLET_EXCEPTION_IF(tx_scan_info[i].error, error::acc_outs_lookup_error, tx, tx_pub_key, m_account.get_keys()); if (tx_scan_info[i].received) { - hwdev.conceal_derivation(tx_scan_info[i].received->derivation, tx_pub_key, additional_tx_pub_keys, derivation, additional_derivations); + hwdev.generate_key_derivation(tx_pub_key, keys.m_view_secret_key, tx_scan_info[i].received->derivation); scan_output(tx, tx_pub_key, i, tx_scan_info[i], num_vouts_received, tx_money_got_in_outs, outs); } } @@ -1219,7 +1219,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote { hwdev_lock.lock(); hwdev.set_mode(hw::device::NONE); - hwdev.conceal_derivation(tx_scan_info[i].received->derivation, tx_pub_key, additional_tx_pub_keys, derivation, additional_derivations); + hwdev.generate_key_derivation(tx_pub_key, keys.m_view_secret_key, tx_scan_info[i].received->derivation); scan_output(tx, tx_pub_key, i, tx_scan_info[i], num_vouts_received, tx_money_got_in_outs, outs); hwdev_lock.unlock(); } @@ -7302,7 +7302,7 @@ std::vector wallet2::create_transactions_2(std::vector hwdev_lock (hwdev); + std::unique_lock hwdev_lock (hwdev); hw::reset_mode rst(hwdev); if(m_light_wallet) { @@ -7885,7 +7885,7 @@ std::vector wallet2::create_transactions_from(const crypton { //ensure device is let in NONE mode in any case hw::device &hwdev = m_account.get_device(); - boost::unique_lock hwdev_lock (hwdev); + std::unique_lock hwdev_lock (hwdev); hw::reset_mode rst(hwdev); uint64_t accumulated_fee, accumulated_outputs, accumulated_change;