wallet.get_tx_fee_warning: fix rounding error for sub-1 sat/vbyte fees
What changed, and why it matters
This is a one-line bug fix in Electrum's fee warning logic. The app compares the user's chosen transaction fee rate against the network's minimum relay fee. Previously, because of how Python handles decimal versus floating-point numbers, very low fee rates (below 1 satoshi per virtual byte) could be compared incorrectly, potentially causing the warning not to appear when it should. The fix forces the relay fee to be treated as a precise Decimal so the comparison works correctly. The practical effect is mainly to ensure users get warned about fees that are too low to be relayed.
Apply the patch. It is a safe, minimal correctness fix. No immediate incident response is warranted, but users on unfixed versions may occasionally create transactions with fees too low to propagate without receiving the expected warning.
Security signals we found
Incorrect numeric comparison in fee validation
Potential UI warning bypass for low-fee transactions
User-facing transaction reliability issue
Evidence from the diff
In electrum/wallet.py, get_tx_fee_warning compares feerate (a Decimal) against self.relayfee() / 1000. relayfee() returns an integer (sat/kvByte). Before the patch, 100/1000 in Python 3 evaluates as float division, yielding 0.1 as a binary float, which compares unequally to Decimal(‘0.1’) (Decimal(‘0.1’) < 0.1 is True). This means sub-1 sat/vByte fee rates could fail the intended warning trigger. The patch wraps relayfee() in Decimal(), making the division exact and the comparison semantically correct.
Changed components
electrum/wallet.pyAbstract_Wallet.get_tx_fee_warningInspect captured patch +1 / −1
diff --git a/electrum/wallet.py b/electrum/wallet.py
index 4e0d265..17c8be3 100644
--- a/electrum/wallet.py
+++ b/electrum/wallet.py
@@ -3384,7 +3384,7 @@ class Abstract_Wallet(ABC, Logger, EventListener):
long_warning = None
short_warning = None
allow_send = True
- if feerate < self.relayfee() / 1000 and not is_future_tx:
+ if feerate < Decimal(self.relayfee()) / 1000 and not is_future_tx:
long_warning = ' '.join([
_("This transaction requires a higher fee, or it will not be propagated by your current server."),
_("Try to raise your transaction fee, or use a server with a lower relay fee.")
Why this scored 34/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.