Skip to content

Commit

Permalink
Exclude coinstake from the fee calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
timemarkovqtum committed Aug 30, 2023
1 parent 7dc943c commit 662433e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/core_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry
const bool have_undo = txundo != nullptr;
CAmount amt_total_in = 0;
CAmount amt_total_out = 0;
bool isCoinStake = tx.IsCoinStake();

for (unsigned int i = 0; i < tx.vin.size(); i++) {
const CTxIn& txin = tx.vin[i];
Expand All @@ -212,7 +213,10 @@ void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry
const Coin& prev_coin = txundo->vprevout[i];
const CTxOut& prev_txout = prev_coin.out;

amt_total_in += prev_txout.nValue;
if(!isCoinStake)
{
amt_total_in += prev_txout.nValue;
}

if (verbosity == TxVerbosity::SHOW_DETAILS_AND_PREVOUT) {
UniValue o_script_pub_key(UniValue::VOBJ);
Expand Down Expand Up @@ -245,13 +249,13 @@ void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry
out.pushKV("scriptPubKey", o);
vout.push_back(out);

if (have_undo) {
if (have_undo && !isCoinStake) {
amt_total_out += txout.nValue;
}
}
entry.pushKV("vout", vout);

if (have_undo && !tx.IsCoinStake()) {
if (have_undo && !isCoinStake) {
const CAmount fee = amt_total_in - amt_total_out;
CHECK_NONFATAL(MoneyRange(fee));
entry.pushKV("fee", ValueFromAmount(fee));
Expand Down

0 comments on commit 662433e

Please sign in to comment.