fix: Re-add fiat values to csv history export
What changed, and why it matters
This commit fixes a bug in Electrum's Qt wallet history export where fiat (local currency) values and fees were missing from CSV exports. The change re-adds those columns by asking the wallet to include fiat data and summing up fiat fees across grouped transactions. There is no security issue here—it's a straightforward data-export bug fix.
No security action needed. Treat as a normal functional bug fix.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch modifies electrum/gui/qt/history_list.py. It imports Fiat, passes include_fiat based on whether the FX plugin is enabled, and updates get_all_fees_paid_by_item to return both satoshi and fiat fee totals, aggregating child fiat fees. The CSV line now uses the aggregated fiat fee string instead of the top-level fiat_fee field. No input validation, cryptographic, or privilege changes are present.
Changed components
electrum/gui/qt/history_list.pyInspect captured patch +12 / −6
diff --git a/electrum/gui/qt/history_list.py b/electrum/gui/qt/history_list.py
index 390a78d..d041c99 100644
--- a/electrum/gui/qt/history_list.py
+++ b/electrum/gui/qt/history_list.py
@@ -43,7 +43,7 @@ from electrum.address_synchronizer import TX_HEIGHT_LOCAL
from electrum.i18n import _
from electrum.util import (block_explorer_URL, profiler, TxMinedInfo,
OrderedDictWithIndex, timestamp_to_datetime,
- Satoshis, format_time)
+ Satoshis, format_time, Fiat)
from electrum.logging import get_logger, Logger
from electrum.simple_config import SimpleConfig
@@ -853,26 +853,32 @@ class HistoryList(MyTreeView, AcceptFileDragDrop):
self.main_window.show_message(_("Your wallet history has been successfully exported."))
def do_export_history(self, file_name, is_csv):
- txns = self.wallet.get_full_history(fx=self.main_window.fx)
+ txns = self.wallet.get_full_history(fx=self.main_window.fx, include_fiat=self.main_window.fx.is_enabled())
lines = []
- def get_all_fees_paid_sat(h_item: dict) -> int:
+ def get_all_fees_paid_by_item(h_item: dict) -> Tuple[int, Fiat]:
# gets all fees paid in an item (or group), as the outer group doesn't contain the
# transaction fees paid by the children
fees_sat = 0
+ fees_fiat = Fiat(ccy=self.main_window.fx.ccy, value=Decimal())
for child in h_item.get('children', []):
fees_sat += child['fee_sat'] or 0 if 'fee_sat' in child \
else (child.get('fee_msat', 0) or 0) // 1000
+ if child_fiat_fee := child.get('fiat_fee'):
+ fees_fiat += child_fiat_fee
fees_sat += h_item['fee_sat'] or 0 if 'fee_sat' in h_item \
else (h_item.get('fee_msat', 0) or 0) // 1000
- return fees_sat
+ if h_item_fiat_fee := h_item.get('fiat_fee'):
+ fees_fiat += h_item_fiat_fee
+ return fees_sat, fees_fiat
if is_csv:
# sort by timestamp so the generated csv is more understandable on first sight
txns = dict(sorted(txns.items(), key=lambda h_item: h_item[1]['timestamp'] or 0))
for item in txns.values():
# tx groups will are shown as single element
+ fees_sat, fees_fiat = get_all_fees_paid_by_item(item)
line = [
item.get('txid', ''),
item.get('payment_hash', ''),
@@ -881,8 +887,8 @@ class HistoryList(MyTreeView, AcceptFileDragDrop):
item['bc_value'],
item['ln_value'],
item.get('fiat_value', ''),
- get_all_fees_paid_sat(item),
- item.get('fiat_fee', ''),
+ fees_sat,
+ str(fees_fiat),
item['date']
]
lines.append(line)
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.