diff options
author | luigi1111 <luigi1111w@gmail.com> | 2019-09-24 10:27:22 -0500 |
---|---|---|
committer | luigi1111 <luigi1111w@gmail.com> | 2019-09-24 10:27:22 -0500 |
commit | 44aa7d543941c0e79e59046591d7ca0cd3b4383a (patch) | |
tree | 5a4fb12986fd0514da8a085093ba67b1dc0e8f28 /src | |
parent | Merge pull request #5881 (diff) | |
parent | blockchain: enforce 10 block age for spending outputs (diff) | |
download | monero-44aa7d543941c0e79e59046591d7ca0cd3b4383a.tar.xz |
Merge pull request #5882
a444f06 blockchain: enforce 10 block age for spending outputs (moneromooo-monero)
Diffstat (limited to 'src')
-rw-r--r-- | src/cryptonote_config.h | 1 | ||||
-rw-r--r-- | src/cryptonote_core/blockchain.cpp | 10 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/cryptonote_config.h b/src/cryptonote_config.h index 4147b48ee..53c487d02 100644 --- a/src/cryptonote_config.h +++ b/src/cryptonote_config.h @@ -163,6 +163,7 @@ #define HF_VERSION_MIN_V2_COINBASE_TX 12 #define HF_VERSION_SAME_MIXIN 12 #define HF_VERSION_REJECT_SIGS_IN_COINBASE 12 +#define HF_VERSION_ENFORCE_MIN_AGE 12 #define PER_KB_FEE_QUANTIZATION_DECIMALS 8 diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index 82f7d1423..5cf4952ae 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -2894,6 +2894,9 @@ bool Blockchain::check_tx_inputs(transaction& tx, tx_verification_context &tvc, const auto waiter_guard = epee::misc_utils::create_scope_leave_handler([&]() { waiter.wait(&tpool); }); int threads = tpool.get_max_concurrency(); + uint64_t max_used_block_height = 0; + if (!pmax_used_block_height) + pmax_used_block_height = &max_used_block_height; for (const auto& txin : tx.vin) { // make sure output being spent is of type txin_to_key, rather than @@ -2960,6 +2963,13 @@ bool Blockchain::check_tx_inputs(transaction& tx, tx_verification_context &tvc, if (tx.version == 1 && threads > 1) waiter.wait(&tpool); + // enforce min output age + if (hf_version >= HF_VERSION_ENFORCE_MIN_AGE) + { + CHECK_AND_ASSERT_MES(*pmax_used_block_height + CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE <= m_db->height(), + false, "Transaction spends at least one output which is too young"); + } + if (tx.version == 1) { if (threads > 1) |