wallet2: fix double counting outs if the tx pubkey is duplicated
This commit is contained in:
parent
2daf54deeb
commit
8c331a6d26
|
@ -1110,6 +1110,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
|
||||||
// Don't try to extract tx public key if tx has no ouputs
|
// Don't try to extract tx public key if tx has no ouputs
|
||||||
size_t pk_index = 0;
|
size_t pk_index = 0;
|
||||||
std::vector<tx_scan_info_t> tx_scan_info(tx.vout.size());
|
std::vector<tx_scan_info_t> tx_scan_info(tx.vout.size());
|
||||||
|
std::unordered_set<crypto::public_key> public_keys_seen;
|
||||||
while (!tx.vout.empty())
|
while (!tx.vout.empty())
|
||||||
{
|
{
|
||||||
// if tx.vout is not empty, we loop through all tx pubkeys
|
// if tx.vout is not empty, we loop through all tx pubkeys
|
||||||
|
@ -1125,6 +1126,13 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (public_keys_seen.find(pub_key_field.pub_key) != public_keys_seen.end())
|
||||||
|
{
|
||||||
|
MWARNING("The same transaction pubkey is present more than once, ignoring extra instance");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
public_keys_seen.insert(pub_key_field.pub_key);
|
||||||
|
|
||||||
int num_vouts_received = 0;
|
int num_vouts_received = 0;
|
||||||
tx_pub_key = pub_key_field.pub_key;
|
tx_pub_key = pub_key_field.pub_key;
|
||||||
tools::threadpool& tpool = tools::threadpool::getInstance();
|
tools::threadpool& tpool = tools::threadpool::getInstance();
|
||||||
|
@ -1144,13 +1152,16 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
|
||||||
// additional tx pubkeys and derivations for multi-destination transfers involving one or more subaddresses
|
// additional tx pubkeys and derivations for multi-destination transfers involving one or more subaddresses
|
||||||
std::vector<crypto::public_key> additional_tx_pub_keys = get_additional_tx_pub_keys_from_extra(tx);
|
std::vector<crypto::public_key> additional_tx_pub_keys = get_additional_tx_pub_keys_from_extra(tx);
|
||||||
std::vector<crypto::key_derivation> additional_derivations;
|
std::vector<crypto::key_derivation> additional_derivations;
|
||||||
for (size_t i = 0; i < additional_tx_pub_keys.size(); ++i)
|
if (pk_index == 1)
|
||||||
{
|
{
|
||||||
additional_derivations.push_back({});
|
for (size_t i = 0; i < additional_tx_pub_keys.size(); ++i)
|
||||||
if (!hwdev.generate_key_derivation(additional_tx_pub_keys[i], keys.m_view_secret_key, additional_derivations.back()))
|
|
||||||
{
|
{
|
||||||
MWARNING("Failed to generate key derivation from tx pubkey, skipping");
|
additional_derivations.push_back({});
|
||||||
additional_derivations.pop_back();
|
if (!hwdev.generate_key_derivation(additional_tx_pub_keys[i], keys.m_view_secret_key, additional_derivations.back()))
|
||||||
|
{
|
||||||
|
MWARNING("Failed to generate key derivation from tx pubkey, skipping");
|
||||||
|
additional_derivations.pop_back();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hwdev_lock.unlock();
|
hwdev_lock.unlock();
|
||||||
|
|
Loading…
Reference in New Issue