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

Fixed the unspent index for remints of 50 XZC #714

Merged
merged 3 commits into from
Oct 8, 2019
Merged
Changes from 1 commit
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
30 changes: 18 additions & 12 deletions src/txdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,13 +559,16 @@ void CDbIndexHelper::ConnectTransaction(CTransaction const & tx, int height, int
}
}

no = 0;
if(tx.IsZerocoinRemint()) {
for (std::vector<CTxIn>::const_iterator iter = tx.vin.begin(); iter != tx.vin.end(); ++iter) {
CTxIn const & input = *iter;
handleRemint(input, no, tx.GetHash(), height, txNumber, tx.vout[no].nValue, addressIndex, addressUnspentIndex, spentIndex);
++no;
CAmount remintValue = 0;
for (std::vector<CTxOut>::const_iterator iter_out = tx.vout.begin(); iter_out != tx.vout.end(); ++iter_out) {
a-bezrukov marked this conversation as resolved.
Show resolved Hide resolved
remintValue += iter_out->nValue;
}
if (tx.vin.size() != 1) {
error("A Zerocoin to Sigma remint tx shoud have just 1 input");
return;
}
handleRemint(tx.vin[0], 0, tx.GetHash(), height, txNumber, remintValue, addressIndex, addressUnspentIndex, spentIndex);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second parameter inputNo to handleRemint is no longer necessary and should be removed. This will also imply by the code that a remint can only have one input.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

}

if(tx.IsZerocoinSpend() || tx.IsSigmaSpend())
Expand All @@ -592,17 +595,20 @@ void CDbIndexHelper::DisconnectTransactionInputs(CTransaction const & tx, int he
if(spentIndex)
pSpentBegin = spentIndex->size();

size_t no = 0;

if(tx.IsZerocoinRemint()) {
for (std::vector<CTxIn>::const_iterator iter = tx.vin.begin(); iter != tx.vin.end(); ++iter) {
CTxIn const & input = *iter;
handleRemint(input, no, tx.GetHash(), height, txNumber, tx.vout[no].nValue, addressIndex, addressUnspentIndex, spentIndex);
++no;
CAmount remintValue = 0;
for (std::vector<CTxOut>::const_iterator iter_out = tx.vout.begin(); iter_out != tx.vout.end(); ++iter_out) {
remintValue += iter_out->nValue;
}
if (tx.vin.size() != 1) {
error("A Zerocoin to Sigma remint tx shoud have just 1 input");
return;
}
handleRemint(tx.vin[0], 0, tx.GetHash(), height, txNumber, remintValue, addressIndex, addressUnspentIndex, spentIndex);
}

no = 0;
size_t no = 0;

if(!tx.IsCoinBase() && !tx.IsZerocoinSpend() && !tx.IsSigmaSpend() && !tx.IsZerocoinRemint())
for (std::vector<CTxIn>::const_iterator iter = tx.vin.begin(); iter != tx.vin.end(); ++iter) {
CTxIn const & input = *iter;
Expand Down