diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2016-11-15 19:12:12 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2016-11-16 09:22:05 +0000 |
commit | 11ae1873f8cd4e041abf25f08fa4969e75aa8b40 (patch) | |
tree | 68d672c0f68ced993c49bdd6fe4a206e02b2db6a /src | |
parent | wallet2: fill in key image map when importing key images (diff) | |
download | monero-11ae1873f8cd4e041abf25f08fa4969e75aa8b40.tar.xz |
wallet2: try all tx keys when scanning a new transaction
The vast majority of transactions will have just one tx pubkey,
but a bug with cold wallet signing caused two such keys to be
there, with the second one being the real one.
Diffstat (limited to 'src')
-rw-r--r-- | src/cryptonote_core/cryptonote_format_utils.h | 4 | ||||
-rw-r--r-- | src/wallet/wallet2.cpp | 9 |
2 files changed, 9 insertions, 4 deletions
diff --git a/src/cryptonote_core/cryptonote_format_utils.h b/src/cryptonote_core/cryptonote_format_utils.h index d5dd6494d..9f9ed8625 100644 --- a/src/cryptonote_core/cryptonote_format_utils.h +++ b/src/cryptonote_core/cryptonote_format_utils.h @@ -93,9 +93,9 @@ namespace cryptonote bool construct_tx_and_get_tx_key(const account_keys& sender_account_keys, const std::vector<tx_source_entry>& sources, const std::vector<tx_destination_entry>& destinations, std::vector<uint8_t> extra, transaction& tx, uint64_t unlock_time, crypto::secret_key &tx_key, bool rct = false); template<typename T> - bool find_tx_extra_field_by_type(const std::vector<tx_extra_field>& tx_extra_fields, T& field) + bool find_tx_extra_field_by_type(const std::vector<tx_extra_field>& tx_extra_fields, T& field, size_t index = 0) { - auto it = std::find_if(tx_extra_fields.begin(), tx_extra_fields.end(), [](const tx_extra_field& f) { return typeid(T) == f.type(); }); + auto it = std::find_if(tx_extra_fields.begin(), tx_extra_fields.end(), [&index](const tx_extra_field& f) { return typeid(T) == f.type() && !index--; }); if(tx_extra_fields.end() == it) return false; diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 1afdffbc0..b4a639324 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -631,11 +631,16 @@ void wallet2::process_new_transaction(const cryptonote::transaction& tx, const s } // Don't try to extract tx public key if tx has no ouputs - if (!tx.vout.empty()) + size_t pk_index = 0; + while (!tx.vout.empty()) { + // if tx.vout is not empty, we loop through all tx pubkeys + tx_extra_pub_key pub_key_field; - if(!find_tx_extra_field_by_type(tx_extra_fields, pub_key_field)) + if(!find_tx_extra_field_by_type(tx_extra_fields, pub_key_field, pk_index++)) { + if (pk_index > 1) + break; LOG_PRINT_L0("Public key wasn't found in the transaction extra. Skipping transaction " << txid()); if(0 != m_callback) m_callback->on_skip_transaction(height, tx); |