Skip to content
Draft
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
9 changes: 7 additions & 2 deletions src/confidential_validation.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

#include <chainparams.h>
#include <confidential_validation.h>
#include <issuance.h>
#include <pegins.h>
Expand Down Expand Up @@ -28,14 +29,18 @@ bool HasValidFee(const CTransaction& tx) {
CAmountMap totalFee;
for (unsigned int i = 0; i < tx.vout.size(); i++) {
CAmount fee = 0;
if (tx.vout[i].IsFee()) {
if (tx.vout[i].IsFee() && tx.vout[i].nAsset.GetAsset() == Params().GetConsensus().pegged_asset) {
fee = tx.vout[i].nValue.GetAmount();
if (fee == 0 || !MoneyRange(fee))
if (fee == 0 || !MoneyRange(fee)) {
return false;
}
totalFee[tx.vout[i].nAsset.GetAsset()] += fee;
if (!MoneyRange(totalFee)) {
return false;
}
if(fee < 0) {
return false;
}
Comment on lines +41 to +43
Copy link
Member

Choose a reason for hiding this comment

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

Is this to check for overflow?

Suggested change
if(fee < 0) {
return false;
}
if (fee < 0) {
return false;
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually was from a previous version. I have updated it now so that for policyAsset the check is MoneyRange, but if not policy asset check that fee < 0.

}
}
return true;
Expand Down
3 changes: 2 additions & 1 deletion src/consensus/tx_verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <script/interpreter.h>
#include <script/pegins.h>
#include <util/moneystr.h>
#include <chainparams.h>

bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime)
{
Expand Down Expand Up @@ -254,7 +255,7 @@ bool Consensus::CheckTxInputs(const CTransaction& tx, TxValidationState& state,
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-txns-in-ne-out", "value in != value out");
}
fee_map += GetFeeMap(tx);
if (!MoneyRange(fee_map)) {
if (!MoneyRange(fee_map[::Params().GetConsensus().pegged_asset])) {
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-block-total-fee-outofrange");
}
} else {
Expand Down