Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing anonymity set construction for new sets. #1189

Merged
merged 3 commits into from
Jul 20, 2022
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
1 change: 1 addition & 0 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ void Shutdown()
llmq::StopLLMQSystem();

BatchProofContainer::get_instance()->finalize();
BatchProofContainer::get_instance()->verify();

#ifdef ENABLE_WALLET
if (pwalletMain)
Expand Down
41 changes: 24 additions & 17 deletions src/lelantus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ static bool CheckLelantusSpendSerial(
return true;
}

/*
* Util funtions
*/
size_t CountCoinInBlock(CBlockIndex *index, int id) {
return index->lelantusMintedPubCoins.count(id) > 0
? index->lelantusMintedPubCoins[id].size() : 0;
}

std::vector<unsigned char> GetAnonymitySetHash(CBlockIndex *index, int group_id, bool generation = false) {
std::vector<unsigned char> out_hash;
Expand Down Expand Up @@ -501,17 +508,25 @@ bool CheckLelantusJoinSplitTransaction(
// This list of public coins is required by function "Verify" of JoinSplit.

while (true) {
if(index->lelantusMintedPubCoins.count(idAndHash.first) > 0) {
BOOST_FOREACH(
const auto& pubCoinValue,
index->lelantusMintedPubCoins[idAndHash.first]) {
// skip mints from blacklist if nLelantusFixesStartBlock is passed
if (chainActive.Height() >= ::Params().GetConsensus().nLelantusFixesStartBlock) {
if (::Params().GetConsensus().lelantusBlacklist.count(pubCoinValue.first.getValue()) > 0) {
continue;
int id = 0;
if (CountCoinInBlock(index, idAndHash.first)) {
id = idAndHash.first;
} else if (CountCoinInBlock(index, idAndHash.first - 1)) {
id = idAndHash.first - 1;
}
if (id) {
if(index->lelantusMintedPubCoins.count(id) > 0) {
BOOST_FOREACH(
const auto& pubCoinValue,
index->lelantusMintedPubCoins[id]) {
// skip mints from blacklist if nLelantusFixesStartBlock is passed
if (chainActive.Height() >= ::Params().GetConsensus().nLelantusFixesStartBlock) {
if (::Params().GetConsensus().lelantusBlacklist.count(pubCoinValue.first.getValue()) > 0) {
continue;
}
}
anonymity_set.push_back(pubCoinValue.first);
}
anonymity_set.push_back(pubCoinValue.first);
}
}
if (index == coinGroup.firstBlock)
Expand Down Expand Up @@ -1046,14 +1061,6 @@ void CLelantusTxInfo::Complete() {
fInfoIsComplete = true;
}

/*
* Util funtions
*/
size_t CountCoinInBlock(CBlockIndex *index, int id) {
return index->lelantusMintedPubCoins.count(id) > 0
? index->lelantusMintedPubCoins[id].size() : 0;
}

/******************************************************************************/
// CLelantusState::Containers
/******************************************************************************/
Expand Down
32 changes: 16 additions & 16 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3015,6 +3015,22 @@ std::list<CLelantusEntry> CWallet::GetAvailableLelantusCoins(const CCoinControl
if (coin.IsUsed)
return true;

COutPoint outPoint;
lelantus::PublicCoin pubCoin(coin.value);
lelantus::GetOutPoint(outPoint, pubCoin);

if(lockedCoins.count(outPoint) > 0){
return true;
}

if(coinControl != NULL){
if(coinControl->HasSelected()){
if(!coinControl->IsSelected(outPoint)){
return true;
}
}
}

int coinHeight, coinId;
std::tie(coinHeight, coinId) = state->GetMintedCoinHeightAndId(lelantus::PublicCoin(coin.value));

Expand Down Expand Up @@ -3046,22 +3062,6 @@ std::list<CLelantusEntry> CWallet::GetAvailableLelantusCoins(const CCoinControl
return true;
}

COutPoint outPoint;
lelantus::PublicCoin pubCoin(coin.value);
lelantus::GetOutPoint(outPoint, pubCoin);

if(lockedCoins.count(outPoint) > 0){
return true;
}

if(coinControl != NULL){
if(coinControl->HasSelected()){
if(!coinControl->IsSelected(outPoint)){
return true;
}
}
}

return false;
});

Expand Down