From 662433e59ed73f6ecf74354e3529dd71c7735d73 Mon Sep 17 00:00:00 2001 From: timemarkovqtum Date: Wed, 30 Aug 2023 14:46:53 +0200 Subject: [PATCH] Exclude coinstake from the fee calculation --- src/core_write.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/core_write.cpp b/src/core_write.cpp index 54ffcf2772..4b151c086e 100644 --- a/src/core_write.cpp +++ b/src/core_write.cpp @@ -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]; @@ -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); @@ -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));