diff --git a/src/darksend.cpp b/src/darksend.cpp index 4762c1130d..aa752f347d 100644 --- a/src/darksend.cpp +++ b/src/darksend.cpp @@ -1587,9 +1587,9 @@ bool CDarksendPool::DoAutomaticDenominating(bool fDryRun, bool ready) std::vector vecAmounts; pwalletMain->ConvertList(vCoins, vecAmounts); - // try to get random denoms out of vecAmounts + // try to get a single random denom out of vecAmounts while(sessionDenom == 0) - sessionDenom = GetDenominationsByAmounts(vecAmounts, true); + sessionDenom = GetDenominationsByAmounts(vecAmounts); pnode->PushMessage("dsa", sessionDenom, txCollateral); LogPrintf("DoAutomaticDenominating --- connected, sending dsa for %d\n", sessionDenom); @@ -1914,7 +1914,7 @@ int CDarksendPool::GetDenominations(const std::vector& vout){ } // return a bitshifted integer representing the denominations in this list -int CDarksendPool::GetDenominations(const std::vector& vout, bool fRandDenom){ +int CDarksendPool::GetDenominations(const std::vector& vout, bool fSingleRandomDenom){ std::vector > denomUsed; // make a list of denominations, with zero uses @@ -1937,8 +1937,11 @@ int CDarksendPool::GetDenominations(const std::vector& vout, bool fRandD int c = 0; // if the denomination is used, shift the bit on. // then move to the next - BOOST_FOREACH (PAIRTYPE(int64_t, int)& s, denomUsed) - denom |= ((fRandDenom ? rand()%2 : 1) * s.second) << c++; + BOOST_FOREACH (PAIRTYPE(int64_t, int)& s, denomUsed) { + int bit = (fSingleRandomDenom ? rand()%2 : 1) * s.second; + denom |= bit << c++; + if(fSingleRandomDenom && bit) break; // use just one random denomination + } // Function returns as follows: // @@ -1951,20 +1954,17 @@ int CDarksendPool::GetDenominations(const std::vector& vout, bool fRandD } -int CDarksendPool::GetDenominationsByAmounts(std::vector& vecAmount, bool fRandDenom){ +int CDarksendPool::GetDenominationsByAmounts(std::vector& vecAmount){ CScript e = CScript(); std::vector vout1; // Make outputs by looping through denominations, from small to large BOOST_REVERSE_FOREACH(int64_t v, vecAmount){ - int nOutputs = 0; - CTxOut o(v, e); vout1.push_back(o); - nOutputs++; } - return GetDenominations(vout1, fRandDenom); + return GetDenominations(vout1, true); } int CDarksendPool::GetDenominationsByAmount(int64_t nAmount, int nDenomTarget){ diff --git a/src/darksend.h b/src/darksend.h index d8c21ce1a8..570449b677 100644 --- a/src/darksend.h +++ b/src/darksend.h @@ -481,14 +481,14 @@ public: bool CreateDenominated(int64_t nTotalValue); /// Get the denominations for a list of outputs (returns a bitshifted integer) - int GetDenominations(const std::vector& vout, bool fRandDenom = false); + int GetDenominations(const std::vector& vout, bool fSingleRandomDenom = false); int GetDenominations(const std::vector& vout); void GetDenominationsToString(int nDenom, std::string& strDenom); /// Get the denominations for a specific amount of dash. int GetDenominationsByAmount(int64_t nAmount, int nDenomTarget=0); // is not used anymore? - int GetDenominationsByAmounts(std::vector& vecAmount, bool fRandDenom = false); + int GetDenominationsByAmounts(std::vector& vecAmount); std::string GetMessageByID(int messageID);