aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-10-06 16:22:19 +0100
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-10-11 13:02:55 +0100
commitac90d488e75592f215e8604e5faaf02c1d9cbfc3 (patch)
treee1279eaa4bb507416096820e2e12763d85403450 /src/cryptonote_core
parentfrom hard fork 2, claim a quantized reward in coinbase (diff)
downloadmonero-ac90d488e75592f215e8604e5faaf02c1d9cbfc3.tar.xz
from hard fork 2, all outputs must be decomposed
The wallet decomposes fully as of now too.
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r--src/cryptonote_core/blockchain.cpp17
-rw-r--r--src/cryptonote_core/blockchain.h1
-rw-r--r--src/cryptonote_core/cryptonote_format_utils.cpp2
-rw-r--r--src/cryptonote_core/tx_pool.cpp6
4 files changed, 25 insertions, 1 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index b76cce9d1..e06c3c08c 100644
--- a/src/cryptonote_core/blockchain.cpp
+++ b/src/cryptonote_core/blockchain.cpp
@@ -1972,6 +1972,23 @@ bool Blockchain::check_tx_inputs(const transaction& tx, uint64_t& max_used_block
return true;
}
//------------------------------------------------------------------
+bool Blockchain::check_tx_outputs(const transaction& tx)
+{
+ LOG_PRINT_L3("Blockchain::" << __func__);
+ CRITICAL_REGION_LOCAL(m_blockchain_lock);
+
+ // from hard fork 2, we forbid dust and compound outputs
+ if (m_hardfork->get_current_version() >= 2) {
+ BOOST_FOREACH(auto &o, tx.vout) {
+ if (!is_valid_decomposed_amount(o.amount)) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+//------------------------------------------------------------------
bool Blockchain::have_tx_keyimges_as_spent(const transaction &tx) const
{
LOG_PRINT_L3("Blockchain::" << __func__);
diff --git a/src/cryptonote_core/blockchain.h b/src/cryptonote_core/blockchain.h
index a248682fc..3a663a342 100644
--- a/src/cryptonote_core/blockchain.h
+++ b/src/cryptonote_core/blockchain.h
@@ -134,6 +134,7 @@ namespace cryptonote
bool store_blockchain();
bool check_tx_inputs(const transaction& tx, uint64_t& pmax_used_block_height, crypto::hash& max_used_block_id, bool kept_by_block = false);
+ bool check_tx_outputs(const transaction& tx);
uint64_t get_current_cumulative_blocksize_limit() const;
bool is_storing_blockchain()const{return m_is_blockchain_storing;}
uint64_t block_difficulty(uint64_t i) const;
diff --git a/src/cryptonote_core/cryptonote_format_utils.cpp b/src/cryptonote_core/cryptonote_format_utils.cpp
index 0d1c6b14f..56a3dd8de 100644
--- a/src/cryptonote_core/cryptonote_format_utils.cpp
+++ b/src/cryptonote_core/cryptonote_format_utils.cpp
@@ -141,7 +141,7 @@ namespace cryptonote
block_reward += fee;
std::vector<uint64_t> out_amounts;
- decompose_amount_into_digits(block_reward, ::config::DEFAULT_DUST_THRESHOLD,
+ decompose_amount_into_digits(block_reward, hard_fork_version >= 2 ? 0 : ::config::DEFAULT_DUST_THRESHOLD,
[&out_amounts](uint64_t a_chunk) { out_amounts.push_back(a_chunk); },
[&out_amounts](uint64_t a_dust) { out_amounts.push_back(a_dust); });
diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp
index 12fd3fe62..dce64db99 100644
--- a/src/cryptonote_core/tx_pool.cpp
+++ b/src/cryptonote_core/tx_pool.cpp
@@ -125,6 +125,12 @@ namespace cryptonote
}
}
+ if (!m_blockchain.check_tx_outputs(tx))
+ {
+ LOG_PRINT_L1("Transaction with id= "<< id << " has at least one invalid outout");
+ tvc.m_verifivation_failed = true;
+ return false;
+ }
crypto::hash max_used_block_id = null_hash;
uint64_t max_used_block_height = 0;