From fe94ba558c85a6d942784cb03aec5e0a5d96dbbc Mon Sep 17 00:00:00 2001 From: wowario Date: Thu, 10 May 2018 15:27:39 +0300 Subject: [PATCH] static mixin --- src/cryptonote_core/blockchain.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index 732f623e6..6fae322a4 100755 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -2562,7 +2562,7 @@ bool Blockchain::check_tx_inputs(transaction& tx, tx_verification_context &tvc, { size_t n_unmixable = 0, n_mixable = 0; size_t mixin = std::numeric_limits::max(); - const size_t min_mixin = hf_version >= HF_VERSION_MIN_MIXIN_9 ? 9 : hf_version >= HF_VERSION_MIN_MIXIN_7 ? 7 : hf_version >= HF_VERSION_MIN_MIXIN_4 ? 4 : 2; + const size_t min_mixin = hf_version >= HF_VERSION_MIN_MIXIN_7 ? 7 : hf_version >= HF_VERSION_MIN_MIXIN_4 ? 4 : 2; for (const auto& txin : tx.vin) { // non txin_to_key inputs will be rejected below @@ -2591,6 +2591,9 @@ bool Blockchain::check_tx_inputs(transaction& tx, tx_verification_context &tvc, } } + // from v9, mixin is static + if (hf_version < HF_VERSION_MIN_MIXIN_9) + { if (mixin < min_mixin) { if (n_unmixable == 0) @@ -2606,7 +2609,18 @@ bool Blockchain::check_tx_inputs(transaction& tx, tx_verification_context &tvc, return false; } } - + else + { + const size_t mixin = DEFAULT_MIXIN; + const size_t min_mixin = DEFAULT_MIXIN; + if (mixin != min_mixin) + { + MERROR_VER("Tx " << get_transaction_hash(tx) << " has invalid ring size"); + 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)