qml: (trivial) QEConfig.formatMilliSats: conv unused fallback to assert
What changed, and why it matters
This is a tiny code cleanup in Electrum's QML (mobile-style) user interface. A function that formats tiny Bitcoin amounts used to silently return '---' if it received an unexpected input type. The change removes that fallback and instead adds an assertion that will crash the program if the wrong type is ever passed. This is a defensive coding change, not a security fix, and it does not introduce a vulnerability.
No action required. This is a trivial defensive refactor with no security relevance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
In electrum/gui/qml/qeconfig.py, formatMilliSats() previously checked isinstance(amount, QEAmount) and returned ‘—’ on mismatch. The patch replaces the conditional with an assert and directly uses amount.msatsInt. The only behavioral difference is that an unexpected type now raises AssertionError instead of returning a placeholder string. The commit message labels this as ‘trivial’ and explicitly notes the fallback was unused.
Changed components
electrum/gui/qml/qeconfig.pyQEConfig.formatMilliSatsInspect captured patch +2 / −4
diff --git a/electrum/gui/qml/qeconfig.py b/electrum/gui/qml/qeconfig.py
index 349f873..38cd806 100644
--- a/electrum/gui/qml/qeconfig.py
+++ b/electrum/gui/qml/qeconfig.py
@@ -356,10 +356,8 @@ class QEConfig(AuthMixin, QObject):
@pyqtSlot(QEAmount, result=str)
@pyqtSlot(QEAmount, bool, result=str)
def formatMilliSats(self, amount, with_unit=False):
- if isinstance(amount, QEAmount):
- msats = amount.msatsInt
- else:
- return '---'
+ assert isinstance(amount, QEAmount), f"unexpected type for amount: {type(amount)}"
+ msats = amount.msatsInt
precision = 3 # config.amt_precision_post_satoshi is not exposed in preferences
if with_unit:
return self.config.format_amount_and_units(msats/1000, precision=precision)
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.