wallet.get_full_history: rm "include_fiat" arg, infer it from fx
What changed, and why it matters
This is a small code cleanup in Electrum's wallet history display. It removes a redundant 'include_fiat' setting and instead decides whether to show fiat currency values based on whether a working exchange-rate object is provided. The change also fixes a minor consistency issue where a placeholder 'parent' grouping entry could previously contain a fiat currency code even when fiat values were not supposed to be included. There is no direct security vulnerability here.
No security action required. Treat as normal code-quality/maintenance update.
Security signals we found
No security-relevant signals in commit message or diff
Refactoring/cleanup only
Minor data-consistency improvement for grouped history entries
Evidence from the diff
The commit refactors Abstract_Wallet.get_full_history() to drop the explicit include_fiat boolean parameter and derive it internally as fx is not None and fx.has_history(). Callers in the Qt and QML history models now pass fx only when fiat display is desired. Additionally, the synthetic parent dict used for grouped transactions no longer unconditionally sets a fiat_value field; it only does so when include_fiat is true. This prevents a mismatched fiat currency code from appearing in non-fiat history output.
Changed components
electrum/wallet.pyelectrum/gui/qt/history_list.pyelectrum/gui/qml/qetransactionlistmodel.pyInspect captured patch +6 / −7
diff --git a/electrum/gui/qml/qetransactionlistmodel.py b/electrum/gui/qml/qetransactionlistmodel.py
index 20d5029..c693ec4 100644
--- a/electrum/gui/qml/qetransactionlistmodel.py
+++ b/electrum/gui/qml/qetransactionlistmodel.py
@@ -214,7 +214,6 @@ class QETransactionListModel(QAbstractListModel, QtEventListener):
history = self.wallet.get_full_history(
onchain_domain=self.onchain_domain,
include_lightning=self.include_lightning,
- include_fiat=False,
)
txs = []
for key, tx in history.items():
diff --git a/electrum/gui/qt/history_list.py b/electrum/gui/qt/history_list.py
index d041c99..ee8474e 100644
--- a/electrum/gui/qt/history_list.py
+++ b/electrum/gui/qt/history_list.py
@@ -298,10 +298,9 @@ class HistoryModel(CustomModel, Logger):
wallet = self.window.wallet
self.set_visibility_of_columns()
transactions = wallet.get_full_history(
- self.window.fx,
+ fx=self.window.fx if self.should_show_fiat() else None,
onchain_domain=self.get_domain(),
include_lightning=self.should_include_lightning_payments(),
- include_fiat=self.should_show_fiat(),
)
old_length = self._root.childCount()
if old_length != 0:
@@ -853,7 +852,7 @@ 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, include_fiat=self.main_window.fx.is_enabled())
+ txns = self.wallet.get_full_history(fx=self.main_window.fx if self.hm.should_show_fiat() else None)
lines = []
def get_all_fees_paid_by_item(h_item: dict) -> Tuple[int, Fiat]:
diff --git a/electrum/wallet.py b/electrum/wallet.py
index 9c21594..e997e9b 100644
--- a/electrum/wallet.py
+++ b/electrum/wallet.py
@@ -1427,16 +1427,16 @@ class Abstract_Wallet(ABC, Logger, EventListener):
@profiler
def get_full_history(
self,
- fx=None,
*,
+ fx: 'FxThread' = None, # used for fiat values if set
onchain_domain=None,
include_lightning=True,
- include_fiat=False
) -> OrderedDictWithIndex:
"""
includes both onchain and lightning
includes grouping information
"""
+ include_fiat = fx is not None and fx.has_history()
transactions_tmp = OrderedDictWithIndex()
# add on-chain txns
onchain_history = self.get_onchain_history(domain=onchain_domain)
@@ -1476,7 +1476,6 @@ class Abstract_Wallet(ABC, Logger, EventListener):
if parent is None:
parent = {
'label': group_label,
- 'fiat_value': Fiat(Decimal(0), fx.ccy) if fx else None,
'bc_value': Satoshis(0),
'ln_value': Satoshis(0),
'value': Satoshis(0),
@@ -1489,6 +1488,8 @@ class Abstract_Wallet(ABC, Logger, EventListener):
'confirmations': 0,
'txid': '----',
}
+ if include_fiat:
+ parent['fiat_value'] = Fiat(Decimal(0), fx.ccy)
transactions[key] = parent
parent['bc_value'] += tx_item['bc_value']
parent['ln_value'] += tx_item['ln_value']
Why this scored 18/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.