mirror of
https://github.com/monero-project/monero.git
synced 2024-12-13 20:06:32 +02:00
wallet2: guard against bad outputs in import_outputs
also some minor speedup
This commit is contained in:
parent
0dddfeacc9
commit
4520cfd978
@ -10172,18 +10172,20 @@ size_t wallet2::import_outputs(const std::vector<tools::wallet2::transfer_detail
|
|||||||
crypto::public_key tx_pub_key = get_tx_pub_key_from_received_outs(td);
|
crypto::public_key tx_pub_key = get_tx_pub_key_from_received_outs(td);
|
||||||
const std::vector<crypto::public_key> additional_tx_pub_keys = get_additional_tx_pub_keys_from_extra(td.m_tx);
|
const std::vector<crypto::public_key> additional_tx_pub_keys = get_additional_tx_pub_keys_from_extra(td.m_tx);
|
||||||
|
|
||||||
|
THROW_WALLET_EXCEPTION_IF(td.m_tx.vout[td.m_internal_output_index].target.type() != typeid(cryptonote::txout_to_key),
|
||||||
|
error::wallet_internal_error, "Unsupported output type");
|
||||||
const crypto::public_key& out_key = boost::get<cryptonote::txout_to_key>(td.m_tx.vout[td.m_internal_output_index].target).key;
|
const crypto::public_key& out_key = boost::get<cryptonote::txout_to_key>(td.m_tx.vout[td.m_internal_output_index].target).key;
|
||||||
bool r = cryptonote::generate_key_image_helper(m_account.get_keys(), m_subaddresses, out_key, tx_pub_key, additional_tx_pub_keys, td.m_internal_output_index, in_ephemeral, td.m_key_image, m_account.get_device());
|
bool r = cryptonote::generate_key_image_helper(m_account.get_keys(), m_subaddresses, out_key, tx_pub_key, additional_tx_pub_keys, td.m_internal_output_index, in_ephemeral, td.m_key_image, m_account.get_device());
|
||||||
THROW_WALLET_EXCEPTION_IF(!r, error::wallet_internal_error, "Failed to generate key image");
|
THROW_WALLET_EXCEPTION_IF(!r, error::wallet_internal_error, "Failed to generate key image");
|
||||||
expand_subaddresses(td.m_subaddr_index);
|
expand_subaddresses(td.m_subaddr_index);
|
||||||
td.m_key_image_known = true;
|
td.m_key_image_known = true;
|
||||||
td.m_key_image_partial = false;
|
td.m_key_image_partial = false;
|
||||||
THROW_WALLET_EXCEPTION_IF(in_ephemeral.pub != boost::get<cryptonote::txout_to_key>(td.m_tx.vout[td.m_internal_output_index].target).key,
|
THROW_WALLET_EXCEPTION_IF(in_ephemeral.pub != out_key,
|
||||||
error::wallet_internal_error, "key_image generated ephemeral public key not matched with output_key at index " + boost::lexical_cast<std::string>(i));
|
error::wallet_internal_error, "key_image generated ephemeral public key not matched with output_key at index " + boost::lexical_cast<std::string>(i));
|
||||||
|
|
||||||
m_key_images[td.m_key_image] = m_transfers.size();
|
m_key_images[td.m_key_image] = m_transfers.size();
|
||||||
m_pub_keys[td.get_public_key()] = m_transfers.size();
|
m_pub_keys[td.get_public_key()] = m_transfers.size();
|
||||||
m_transfers.push_back(td);
|
m_transfers.push_back(std::move(td));
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_transfers.size();
|
return m_transfers.size();
|
||||||
|
Loading…
Reference in New Issue
Block a user