aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cryptonote_core/blockchain.cpp20
-rw-r--r--src/cryptonote_core/tx_pool.cpp15
2 files changed, 19 insertions, 16 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index 82691eb6b..c094d1bd9 100644
--- a/src/cryptonote_core/blockchain.cpp
+++ b/src/cryptonote_core/blockchain.cpp
@@ -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);
+ 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
// 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 mixin = std::numeric_limits<size_t>::max();
@@ -2371,6 +2373,22 @@ bool Blockchain::check_tx_inputs(transaction& tx, tx_verification_context &tvc,
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);
diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp
index 2ed12eb5c..46fab4dcf 100644
--- a/src/cryptonote_core/tx_pool.cpp
+++ b/src/cryptonote_core/tx_pool.cpp
@@ -86,21 +86,6 @@ namespace cryptonote
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
// kept_by_block
if (!kept_by_block && m_timed_out_transactions.find(id) != m_timed_out_transactions.end())