Merge pull request #3065

3e635a3c wallet2: allow failing parse_tx_extra (moneromooo-monero)
This commit is contained in:
Riccardo Spagni 2018-01-25 16:47:08 -08:00
commit 66a2751d68
No known key found for this signature in database
GPG key ID: 55432DF31CCD4FCD

View file

@ -544,8 +544,7 @@ crypto::hash8 get_short_payment_id(const tools::wallet2::pending_tx &ptx)
{ {
crypto::hash8 payment_id8 = null_hash8; crypto::hash8 payment_id8 = null_hash8;
std::vector<tx_extra_field> tx_extra_fields; std::vector<tx_extra_field> tx_extra_fields;
if(!parse_tx_extra(ptx.tx.extra, tx_extra_fields)) parse_tx_extra(ptx.tx.extra, tx_extra_fields); // ok if partially parsed
return payment_id8;
cryptonote::tx_extra_nonce extra_nonce; cryptonote::tx_extra_nonce extra_nonce;
if (find_tx_extra_field_by_type(tx_extra_fields, extra_nonce)) if (find_tx_extra_field_by_type(tx_extra_fields, extra_nonce))
{ {
@ -1460,15 +1459,13 @@ void wallet2::process_outgoing(const crypto::hash &txid, const cryptonote::trans
entry.first->second.m_change = received; entry.first->second.m_change = received;
std::vector<tx_extra_field> tx_extra_fields; std::vector<tx_extra_field> tx_extra_fields;
if(parse_tx_extra(tx.extra, tx_extra_fields)) parse_tx_extra(tx.extra, tx_extra_fields); // ok if partially parsed
{
tx_extra_nonce extra_nonce; tx_extra_nonce extra_nonce;
if (find_tx_extra_field_by_type(tx_extra_fields, extra_nonce)) if (find_tx_extra_field_by_type(tx_extra_fields, extra_nonce))
{ {
// we do not care about failure here // we do not care about failure here
get_payment_id_from_tx_extra_nonce(extra_nonce.nonce, entry.first->second.m_payment_id); get_payment_id_from_tx_extra_nonce(extra_nonce.nonce, entry.first->second.m_payment_id);
} }
}
entry.first->second.m_subaddr_account = subaddr_account; entry.first->second.m_subaddr_account = subaddr_account;
entry.first->second.m_subaddr_indices = subaddr_indices; entry.first->second.m_subaddr_indices = subaddr_indices;
} }
@ -4240,8 +4237,7 @@ std::vector<std::vector<cryptonote::tx_destination_entry>> split_amounts(
crypto::hash wallet2::get_payment_id(const pending_tx &ptx) const crypto::hash wallet2::get_payment_id(const pending_tx &ptx) const
{ {
std::vector<tx_extra_field> tx_extra_fields; std::vector<tx_extra_field> tx_extra_fields;
if(!parse_tx_extra(ptx.tx.extra, tx_extra_fields)) parse_tx_extra(ptx.tx.extra, tx_extra_fields); // ok if partially parsed
return crypto::null_hash;
tx_extra_nonce extra_nonce; tx_extra_nonce extra_nonce;
crypto::hash payment_id = null_hash; crypto::hash payment_id = null_hash;
if (find_tx_extra_field_by_type(tx_extra_fields, extra_nonce)) if (find_tx_extra_field_by_type(tx_extra_fields, extra_nonce))
@ -8883,11 +8879,8 @@ size_t wallet2::import_outputs(const std::vector<tools::wallet2::transfer_detail
// the hot wallet wouldn't have known about key images (except if we already exported them) // the hot wallet wouldn't have known about key images (except if we already exported them)
cryptonote::keypair in_ephemeral; cryptonote::keypair in_ephemeral;
std::vector<tx_extra_field> tx_extra_fields;
THROW_WALLET_EXCEPTION_IF(td.m_tx.vout.empty(), error::wallet_internal_error, "tx with no outputs at index " + boost::lexical_cast<std::string>(i)); THROW_WALLET_EXCEPTION_IF(td.m_tx.vout.empty(), error::wallet_internal_error, "tx with no outputs at index " + boost::lexical_cast<std::string>(i));
THROW_WALLET_EXCEPTION_IF(!parse_tx_extra(td.m_tx.extra, tx_extra_fields), error::wallet_internal_error,
"Transaction extra has unsupported format at index " + boost::lexical_cast<std::string>(i));
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);