Skip to content

Commit

Permalink
Merge branch 'master' into addressbook
Browse files Browse the repository at this point in the history
  • Loading branch information
levonpetrosyan93 committed Nov 24, 2023
2 parents 3db825e + 9b4e7ef commit 5882d6c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 19 deletions.
20 changes: 14 additions & 6 deletions src/lelantus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,13 @@ bool CheckLelantusJoinSplitTransaction(
anonymity_sets[idAndHash.first] = anonymity_set;
}

const std::vector<uint32_t>& ids = joinsplit->getCoinGroupIds();
for (const auto& id: ids) {
if (!anonymity_sets.count(id))
return state.DoS(100,
error("CheckLelantusJoinSplitTransaction: No anonymity set found."));
}

BatchProofContainer* batchProofContainer = BatchProofContainer::get_instance();
bool useBatching = batchProofContainer->fCollectProofs && !isVerifyDB && !isCheckWallet && lelantusTxInfo && !lelantusTxInfo->fInfoIsComplete;

Expand Down Expand Up @@ -941,15 +948,17 @@ bool ConnectBlockLelantus(
)) {
return false;
}
}

if (!fJustCheck) {
if (!fJustCheck) {
BOOST_FOREACH(auto& serial, pblock->lelantusTxInfo->spentSerials) {
pindexNew->lelantusSpentSerials.insert(serial);
lelantusState.AddSpend(serial.first, serial.second);
}
}

if (fJustCheck)
else {
return true;
}

const auto& params = ::Params().GetConsensus();
CHash256 hash;
Expand Down Expand Up @@ -1359,9 +1368,8 @@ void CLelantusState::RemoveBlock(CBlockIndex *index) {
// roll back coin group updates
for (auto &coins : index->lelantusMintedPubCoins)
{
if (coinGroups.count(coins.first) == 0) {
throw std::invalid_argument("Group Id does not exist");
}
if (coinGroups.count(coins.first) == 0)
continue;

LelantusCoinGroupInfo& coinGroup = coinGroups[coins.first];
auto nMintsToForget = coins.second.size();
Expand Down
25 changes: 16 additions & 9 deletions src/qt/sendcoinsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ void SendCoinsDialog::on_sendButton_clicked()
CAmount mintSparkAmount = 0;
CAmount txFee = 0;
CAmount totalAmount = 0;
if (model->getLelantusModel()->getPrivateBalance().first > 0 && chainActive.Height() < ::Params().GetConsensus().nLelantusGracefulPeriod) {
if (model->getLelantusModel()->getPrivateBalance().first > 0 && spark::IsSparkAllowed() && chainActive.Height() < ::Params().GetConsensus().nLelantusGracefulPeriod) {
MigrateLelantusToSparkDialog migrateLelantusToSpark(model);
bool clickedButton = migrateLelantusToSpark.getClickedButton();
if(clickedButton) {
Expand All @@ -332,16 +332,23 @@ void SendCoinsDialog::on_sendButton_clicked()
prepareStatus = model->prepareJoinSplitTransaction(currentTransaction, &ctrl);
} else if ((fAnonymousMode == true) && spark::IsSparkAllowed()) {
prepareStatus = model->prepareSpendSparkTransaction(currentTransaction, &ctrl);
} else if ((fAnonymousMode == false) && (recipients.size() == sparkAddressCount) && spark::IsSparkAllowed()) {
prepareStatus = model->prepareMintSparkTransaction(transactions, recipients, wtxAndFees, reservekeys, &ctrl);
} else if ((fAnonymousMode == false) && (sparkAddressCount == 0)){
SendGoPrivateDialog goPrivateDialog;
bool clickedButton = goPrivateDialog.getClickedButton();
if(clickedButton) {
setAnonymizeMode(true);
fNewRecipientAllowed = true;
} else if ((fAnonymousMode == false) && (recipients.size() == sparkAddressCount)) {
if (spark::IsSparkAllowed())
prepareStatus = model->prepareMintSparkTransaction(transactions, recipients, wtxAndFees, reservekeys, &ctrl);
else {
processSendCoinsReturn(WalletModel::InvalidAddress);
return;
}
} else if ((fAnonymousMode == false) && (sparkAddressCount == 0)) {
if (spark::IsSparkAllowed()) {
SendGoPrivateDialog goPrivateDialog;
bool clickedButton = goPrivateDialog.getClickedButton();
if (clickedButton) {
setAnonymizeMode(true);
fNewRecipientAllowed = true;
return;
}
}
prepareStatus = model->prepareTransaction(currentTransaction, &ctrl);
} else {
fNewRecipientAllowed = true;
Expand Down
8 changes: 5 additions & 3 deletions src/sigma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -643,15 +643,17 @@ bool ConnectBlockSigma(
)) {
return false;
}
}

if (!fJustCheck) {
if (!fJustCheck) {
BOOST_FOREACH(auto& serial, pblock->sigmaTxInfo->spentSerials) {
pindexNew->sigmaSpentSerials.insert(serial);
sigmaState.AddSpend(serial.first, serial.second.denomination, serial.second.coinGroupId);
}
}

if (fJustCheck)
else {
return true;
}

sigmaState.AddMintsToStateAndBlockIndex(pindexNew, pblock);
}
Expand Down
2 changes: 1 addition & 1 deletion src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ bool CheckTransaction(const CTransaction &tx, CValidationState &state, bool fChe
LOCK(cs_main);
nTxHeight = chainActive.Height();
}
if (hasExchangeUTXOs && !isCheckWallet && !isVerifyDB && nTxHeight < ::Params().GetConsensus().nExchangeAddressStartBlock)
if (hasExchangeUTXOs && !isVerifyDB && nTxHeight < ::Params().GetConsensus().nExchangeAddressStartBlock)
return state.DoS(100, false, REJECT_INVALID, "bad-exchange-address");

if (tx.IsCoinBase())
Expand Down

0 comments on commit 5882d6c

Please sign in to comment.