Skip to content

Commit

Permalink
core_write: Rename calculate_fee to have_undo for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
fyquah authored and kiminuo committed Oct 4, 2021
1 parent dcd7124 commit b0f7af3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/core_write.cpp
Expand Up @@ -178,7 +178,7 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry,

// If available, use Undo data to calculate the fee. Note that txundo == nullptr
// for coinbase transactions and for transactions where undo data is unavailable.
const bool calculate_fee = txundo != nullptr;
const bool have_undo = txundo != nullptr;
CAmount amt_total_in = 0;
CAmount amt_total_out = 0;

Expand All @@ -202,7 +202,7 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry,
}
in.pushKV("txinwitness", txinwitness);
}
if (calculate_fee) {
if (have_undo) {
const Coin& prev_coin = txundo->vprevout[i];
const CTxOut& prev_txout = prev_coin.out;

Expand Down Expand Up @@ -244,13 +244,13 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry,
out.pushKV("scriptPubKey", o);
vout.push_back(out);

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

if (calculate_fee) {
if (have_undo) {
const CAmount fee = amt_total_in - amt_total_out;
CHECK_NONFATAL(MoneyRange(fee));
entry.pushKV("fee", ValueFromAmount(fee));
Expand Down

0 comments on commit b0f7af3

Please sign in to comment.