aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core
diff options
context:
space:
mode:
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r--src/cryptonote_core/blockchain.cpp24
-rw-r--r--src/cryptonote_core/cryptonote_core.cpp3
-rw-r--r--src/cryptonote_core/cryptonote_tx_utils.cpp27
-rw-r--r--src/cryptonote_core/cryptonote_tx_utils.h4
4 files changed, 13 insertions, 45 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index 0b09d503c..3e0ffc409 100644
--- a/src/cryptonote_core/blockchain.cpp
+++ b/src/cryptonote_core/blockchain.cpp
@@ -1444,7 +1444,7 @@ bool Blockchain::get_blocks(uint64_t start_offset, size_t count, std::list<std::
{
LOG_PRINT_L3("Blockchain::" << __func__);
CRITICAL_REGION_LOCAL(m_blockchain_lock);
- if(start_offset > m_db->height())
+ if(start_offset >= m_db->height())
return false;
if (!get_blocks(start_offset, count, blocks))
@@ -1466,7 +1466,7 @@ bool Blockchain::get_blocks(uint64_t start_offset, size_t count, std::list<std::
{
LOG_PRINT_L3("Blockchain::" << __func__);
CRITICAL_REGION_LOCAL(m_blockchain_lock);
- if(start_offset > m_db->height())
+ if(start_offset >= m_db->height())
return false;
for(size_t i = start_offset; i < start_offset + count && i < m_db->height();i++)
@@ -2383,26 +2383,6 @@ bool Blockchain::check_tx_outputs(const transaction& tx, tx_verification_context
}
}
- // from v7, sorted outs
- if (m_hardfork->get_current_version() >= 7) {
- const crypto::public_key *last_key = NULL;
- for (size_t n = 0; n < tx.vout.size(); ++n)
- {
- const tx_out &o = tx.vout[n];
- if (o.target.type() == typeid(txout_to_key))
- {
- const txout_to_key& out_to_key = boost::get<txout_to_key>(o.target);
- if (last_key && memcmp(&out_to_key.key, last_key, sizeof(*last_key)) >= 0)
- {
- MERROR_VER("transaction has unsorted outputs");
- tvc.m_invalid_output = true;
- return false;
- }
- last_key = &out_to_key.key;
- }
- }
- }
-
return true;
}
//------------------------------------------------------------------
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp
index 57347fdbc..c1a5ae324 100644
--- a/src/cryptonote_core/cryptonote_core.cpp
+++ b/src/cryptonote_core/cryptonote_core.cpp
@@ -1298,11 +1298,12 @@ namespace cryptonote
bool core::check_updates()
{
static const char software[] = "monero";
- static const char subdir[] = "cli"; // because it can never be simple
#ifdef BUILD_TAG
static const char buildtag[] = BOOST_PP_STRINGIZE(BUILD_TAG);
+ static const char subdir[] = "cli"; // because it can never be simple
#else
static const char buildtag[] = "source";
+ static const char subdir[] = "source"; // because it can never be simple
#endif
if (check_updates_level == UPDATES_DISABLED)
diff --git a/src/cryptonote_core/cryptonote_tx_utils.cpp b/src/cryptonote_core/cryptonote_tx_utils.cpp
index 19ed57aba..fd647a356 100644
--- a/src/cryptonote_core/cryptonote_tx_utils.cpp
+++ b/src/cryptonote_core/cryptonote_tx_utils.cpp
@@ -157,7 +157,7 @@ namespace cryptonote
return destinations[0].addr.m_view_public_key;
}
//---------------------------------------------------------------
- bool construct_tx_and_get_tx_key(const account_keys& sender_account_keys, std::vector<tx_source_entry> sources, const std::vector<tx_destination_entry>& destinations, std::vector<uint8_t> extra, transaction& tx, uint64_t unlock_time, crypto::secret_key &tx_key, bool rct)
+ bool construct_tx_and_get_tx_key(const account_keys& sender_account_keys, std::vector<tx_source_entry>& sources, const std::vector<tx_destination_entry>& destinations, std::vector<uint8_t> extra, transaction& tx, uint64_t unlock_time, crypto::secret_key &tx_key, bool rct)
{
std::vector<rct::key> amount_keys;
tx.set_null();
@@ -245,7 +245,7 @@ namespace cryptonote
{
LOG_ERROR("derived public key mismatch with output public key at index " << idx << ", real out " << src_entr.real_output << "! "<< ENDL << "derived_key:"
<< string_tools::pod_to_hex(in_ephemeral.pub) << ENDL << "real output_public_key:"
- << string_tools::pod_to_hex(src_entr.outputs[src_entr.real_output].second) );
+ << string_tools::pod_to_hex(src_entr.outputs[src_entr.real_output].second.dest) );
LOG_ERROR("amount " << src_entr.amount << ", rct " << src_entr.rct);
LOG_ERROR("tx pubkey " << src_entr.real_out_tx_key << ", real_output_in_tx_index " << src_entr.real_output_in_tx_index);
return false;
@@ -264,6 +264,10 @@ namespace cryptonote
tx.vin.push_back(input_to_key);
}
+ // "Shuffle" outs
+ std::vector<tx_destination_entry> shuffled_dsts(destinations);
+ std::random_shuffle(shuffled_dsts.begin(), shuffled_dsts.end(), [](unsigned int i) { return crypto::rand<unsigned int>() % i; });
+
// sort ins by their key image
std::vector<size_t> ins_order(sources.size());
for (size_t n = 0; n < sources.size(); ++n)
@@ -309,23 +313,6 @@ namespace cryptonote
summary_outs_money += dst_entr.amount;
}
-#if 0
- // sort outs by their public key
- std::vector<size_t> outs_order(tx.vout.size());
- for (size_t n = 0; n < tx.vout.size(); ++n)
- outs_order[n] = n;
- std::sort(outs_order.begin(), outs_order.end(), [&](size_t i0, size_t i1) {
- const txout_to_key &tk0 = boost::get<txout_to_key>(tx.vout[i0].target);
- const txout_to_key &tk1 = boost::get<txout_to_key>(tx.vout[i1].target);
- return memcmp(&tk0.key, &tk1.key, sizeof(tk0.key)) < 0;
- });
- tools::apply_permutation(outs_order, [&] (size_t i0, size_t i1) {
- std::swap(tx.vout[i0], tx.vout[i1]);
- if (!amount_keys.empty())
- std::swap(amount_keys[i0], amount_keys[i1]);
- });
-#endif
-
//check money
if(summary_outs_money > summary_inputs_money )
{
@@ -488,7 +475,7 @@ namespace cryptonote
return true;
}
//---------------------------------------------------------------
- bool construct_tx(const account_keys& sender_account_keys, const std::vector<tx_source_entry>& sources, const std::vector<tx_destination_entry>& destinations, std::vector<uint8_t> extra, transaction& tx, uint64_t unlock_time)
+ bool construct_tx(const account_keys& sender_account_keys, std::vector<tx_source_entry>& sources, const std::vector<tx_destination_entry>& destinations, std::vector<uint8_t> extra, transaction& tx, uint64_t unlock_time)
{
crypto::secret_key tx_key;
return construct_tx_and_get_tx_key(sender_account_keys, sources, destinations, extra, tx, unlock_time, tx_key);
diff --git a/src/cryptonote_core/cryptonote_tx_utils.h b/src/cryptonote_core/cryptonote_tx_utils.h
index 69254fb5f..f2cc73545 100644
--- a/src/cryptonote_core/cryptonote_tx_utils.h
+++ b/src/cryptonote_core/cryptonote_tx_utils.h
@@ -70,8 +70,8 @@ namespace cryptonote
//---------------------------------------------------------------
crypto::public_key get_destination_view_key_pub(const std::vector<tx_destination_entry> &destinations, const account_keys &sender_keys);
- bool construct_tx(const account_keys& sender_account_keys, const std::vector<tx_source_entry>& sources, const std::vector<tx_destination_entry>& destinations, std::vector<uint8_t> extra, transaction& tx, uint64_t unlock_time);
- bool construct_tx_and_get_tx_key(const account_keys& sender_account_keys, std::vector<tx_source_entry> sources, const std::vector<tx_destination_entry>& destinations, std::vector<uint8_t> extra, transaction& tx, uint64_t unlock_time, crypto::secret_key &tx_key, bool rct = false);
+ bool construct_tx(const account_keys& sender_account_keys, std::vector<tx_source_entry>& sources, const std::vector<tx_destination_entry>& destinations, std::vector<uint8_t> extra, transaction& tx, uint64_t unlock_time);
+ bool construct_tx_and_get_tx_key(const account_keys& sender_account_keys, std::vector<tx_source_entry>& sources, const std::vector<tx_destination_entry>& destinations, std::vector<uint8_t> extra, transaction& tx, uint64_t unlock_time, crypto::secret_key &tx_key, bool rct = false);
bool generate_genesis_block(
block& bl