Skip to content

Commit

Permalink
Add double checks that WriteSerial and WriteMint succeed when process…
Browse files Browse the repository at this point in the history
…ing an Elysium tx.
  • Loading branch information
sproxet committed Jun 17, 2021
1 parent e61403f commit bbd92d8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/elysium/txprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,17 @@ int TxProcessor::ProcessLelantusJoinSplit(const CMPTransaction& tx)

// record serial and change
for (auto const &s : serials) {
lelantusDb->WriteSerial(property, s, block, tx.getHash());
if (!lelantusDb->WriteSerial(property, s, block, tx.getHash())) {
PrintToLog("%s(): rejected: serial is duplicated\n", __func__);
return PKT_ERROR_LELANTUS - 907;
}
}

if (joinSplitMint.get_ptr() != nullptr) {
lelantusDb->WriteMint(property, joinSplitMint.get(), block);
if (!lelantusDb->WriteMint(property, joinSplitMint.get(), block)) {
PrintToLog("%s(): error writing mint\n", __func__);
// Accept the spend even if the mint is invalid. The mint will be unusable though.
}
}

assert(update_tally_map(tx.getReceiver(), property, spendAmount, BALANCE));
Expand Down

0 comments on commit bbd92d8

Please sign in to comment.