core: allow v1 txes after HF 5 when sweeping unmixable outputs

This commit is contained in:
moneromooo-monero 2016-08-14 11:30:44 +01:00
parent f782d45827
commit 0815c72df7
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3
2 changed files with 19 additions and 16 deletions

View File

@ -2322,9 +2322,11 @@ bool Blockchain::check_tx_inputs(transaction& tx, tx_verification_context &tvc,
crypto::hash tx_prefix_hash = get_transaction_prefix_hash(tx); crypto::hash tx_prefix_hash = get_transaction_prefix_hash(tx);
const uint8_t hf_version = m_hardfork->get_current_version();
// from hard fork 2, we require mixin at least 2 unless one output cannot mix with 2 others // from hard fork 2, we require mixin at least 2 unless one output cannot mix with 2 others
// if one output cannot mix with 2 others, we accept at most 1 output that can mix // if one output cannot mix with 2 others, we accept at most 1 output that can mix
if (m_hardfork->get_current_version() >= 2) if (hf_version >= 2)
{ {
size_t n_unmixable = 0, n_mixable = 0; size_t n_unmixable = 0, n_mixable = 0;
size_t mixin = std::numeric_limits<size_t>::max(); size_t mixin = std::numeric_limits<size_t>::max();
@ -2371,6 +2373,22 @@ bool Blockchain::check_tx_inputs(transaction& tx, tx_verification_context &tvc,
return false; return false;
} }
} }
// min/max tx version based on HF, and we accept v1 txes if having a non mixable
const size_t max_tx_version = (hf_version <= 3) ? 1 : 2;
if (tx.version > max_tx_version)
{
LOG_PRINT_L1("transaction version " << (unsigned)tx.version << " is higher than max accepted version " << max_tx_version);
tvc.m_verifivation_failed = true;
return false;
}
const size_t min_tx_version = (n_unmixable > 0 ? 1 : (hf_version >= 5) ? 2 : 1);
if (tx.version < min_tx_version)
{
LOG_PRINT_L1("transaction version " << (unsigned)tx.version << " is lower than min accepted version " << min_tx_version);
tvc.m_verifivation_failed = true;
return false;
}
} }
auto it = m_check_txin_table.find(tx_prefix_hash); auto it = m_check_txin_table.find(tx_prefix_hash);

View File

@ -86,21 +86,6 @@ namespace cryptonote
return false; return false;
} }
const size_t max_tx_version = (version <= 3) ? 1 : 2;
if (tx.version > max_tx_version)
{
LOG_PRINT_L1("transaction version " << (unsigned)tx.version << " is higher than max accepted version " << max_tx_version);
tvc.m_verifivation_failed = true;
return false;
}
const size_t min_tx_version = (version >= 5) ? 2 : 1;
if (tx.version < min_tx_version)
{
LOG_PRINT_L1("transaction version " << (unsigned)tx.version << " is lower than min accepted version " << min_tx_version);
tvc.m_verifivation_failed = true;
return false;
}
// we do not accept transactions that timed out before, unless they're // we do not accept transactions that timed out before, unless they're
// kept_by_block // kept_by_block
if (!kept_by_block && m_timed_out_transactions.find(id) != m_timed_out_transactions.end()) if (!kept_by_block && m_timed_out_transactions.find(id) != m_timed_out_transactions.end())