Skip to content

Commit

Permalink
Prevent adding duplicated inputs from candidates (#798)
Browse files Browse the repository at this point in the history
  • Loading branch information
alex v committed Feb 20, 2021
1 parent 439dc43 commit 0e69844
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/blsct/aggregationsession.cpp
Expand Up @@ -179,6 +179,8 @@ bool AggregationSession::SelectCandidates(CandidateTransaction &ret)
unsigned int i = 0;
unsigned int nSelected = 0;

std::set<uint256> setSeen;

while (nSelected < nSelect && i < vTransactionCandidates.size())
{
if (!inputs->HaveInputs(vTransactionCandidates[i].tx))
Expand All @@ -203,6 +205,15 @@ bool AggregationSession::SelectCandidates(CandidateTransaction &ret)
{
COutPoint prevOut = vTransactionCandidates[i].tx.vin[j].prevout;

if (setSeen.count(prevOut.GetHash()))
{
i++;
fShouldIContinue = true;
break;
}

setSeen.insert(prevOut.GetHash());

if (pwalletMain->mapWallet.count(prevOut.hash))
{
auto prevTx = pwalletMain->mapWallet[prevOut.hash];
Expand Down
5 changes: 5 additions & 0 deletions src/primitives/transaction.h
Expand Up @@ -62,6 +62,11 @@ class COutPoint
return !(a == b);
}

uint256 GetHash() const
{
return SerializeHash(*this, SER_GETHASH, SERIALIZE_TRANSACTION_NO_WITNESS);
}

std::string ToString() const;
};

Expand Down

0 comments on commit 0e69844

Please sign in to comment.