From ebbf84900d09e1b604dc0cd29bcd05f8d3c34a95 Mon Sep 17 00:00:00 2001 From: stoffu Date: Sat, 31 Mar 2018 16:19:14 +0900 Subject: [PATCH] cryptonote_tx_util: make destinations properly shuffled --- src/cryptonote_core/cryptonote_tx_utils.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/cryptonote_core/cryptonote_tx_utils.cpp b/src/cryptonote_core/cryptonote_tx_utils.cpp index 071ce591e..04a10044f 100644 --- a/src/cryptonote_core/cryptonote_tx_utils.cpp +++ b/src/cryptonote_core/cryptonote_tx_utils.cpp @@ -315,10 +315,9 @@ namespace cryptonote tx.vin.push_back(input_to_key); } - if (shuffle_outs) - { - std::shuffle(destinations.begin(), destinations.end(), std::default_random_engine(crypto::rand())); - } + // "Shuffle" outs + std::vector shuffled_dsts(destinations); + std::shuffle(shuffled_dsts.begin(), shuffled_dsts.end(), std::default_random_engine(crypto::rand())); // sort ins by their key image std::vector ins_order(sources.size()); @@ -365,7 +364,7 @@ namespace cryptonote uint64_t summary_outs_money = 0; //fill outputs size_t output_index = 0; - for(const tx_destination_entry& dst_entr: destinations) + for(const tx_destination_entry& dst_entr: shuffled_dsts) { CHECK_AND_ASSERT_MES(dst_entr.amount > 0 || tx.version > 1, false, "Destination with wrong amount: " << dst_entr.amount); crypto::key_derivation derivation;