Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/darksend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,6 @@ void CDarksendPool::ProcessMessageDarksend(CNode* pfrom, std::string& strCommand

}

int randomizeList (int i) { return std::rand()%i;}

void CDarksendPool::Reset(){
cachedLastSuccess = 0;
lastNewBlock = 0;
Expand Down Expand Up @@ -533,9 +531,9 @@ void CDarksendPool::Check()
txNew.vin.push_back(s);
}

// shuffle the outputs for improved anonymity
std::random_shuffle ( txNew.vin.begin(), txNew.vin.end(), randomizeList);
std::random_shuffle ( txNew.vout.begin(), txNew.vout.end(), randomizeList);
// BIP69 https://github.com/kristovatlas/bips/blob/master/bip-0069.mediawiki
sort(txNew.vin.begin(), txNew.vin.end());
sort(txNew.vout.begin(), txNew.vout.end());


LogPrint("darksend", "Transaction 1: %s\n", txNew.ToString());
Expand Down
10 changes: 10 additions & 0 deletions src/primitives/transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ class CTxIn
return !(a == b);
}

friend bool operator<(const CTxIn& a, const CTxIn& b)
{
return a.prevout<b.prevout;
}

std::string ToString() const;
};

Expand Down Expand Up @@ -166,6 +171,11 @@ class CTxOut
return !(a == b);
}

friend bool operator<(const CTxOut& a, const CTxOut& b)
{
return a.nValue < b.nValue || (a.nValue == b.nValue && a.scriptPubKey < b.scriptPubKey);
}

std::string ToString() const;
};

Expand Down
11 changes: 6 additions & 5 deletions src/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2234,10 +2234,14 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, CAmount> >& vecSend,
BOOST_FOREACH(const PAIRTYPE(const CWalletTx*,unsigned int)& coin, setCoins)
txNew.vin.push_back(CTxIn(coin.first->GetHash(),coin.second));

// BIP69 https://github.com/kristovatlas/bips/blob/master/bip-0069.mediawiki
sort(txNew.vin.begin(), txNew.vin.end());
sort(txNew.vout.begin(), txNew.vout.end());

// Sign
int nIn = 0;
BOOST_FOREACH(const PAIRTYPE(const CWalletTx*,unsigned int)& coin, setCoins)
if (!SignSignature(*this, *coin.first, txNew, nIn++))
BOOST_FOREACH(const CTxIn& vin, txNew.vin)
if (!SignSignature(*this, mapWallet[vin.prevout.hash], txNew, nIn++))
{
strFailReason = _("Signing transaction failed");
return false;
Expand Down Expand Up @@ -2505,9 +2509,6 @@ string CWallet::PrepareDarksendDenominate(int minRounds, int maxRounds)
return "Error: can't make current denominated outputs";
}

// randomize the output order
std::random_shuffle (vOut.begin(), vOut.end());

// We also do not care about full amount as long as we have right denominations, just pass what we found
darkSendPool.SendDarksendDenominate(vCoinsResult, vOut, nValueIn - nValueLeft);

Expand Down