AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Low 32 Bitcoin

swaps: make SwapManager.percentage Decimal

Public commit record

What the developer wrote

Authored by f321x

68/100 · Adequate
swaps: make SwapManager.percentage Decimal

If SwapManager.percentage was a 0.2 float, rounding differences would
cause an exception in the fee calculation inverse sanity check when entering 20
000 sats into the SwapDialog. By making self.percentage a decimal we can
prevent this kind of issue.

```
File "/home/user/code/vibecoding_vm/electrum/electrum/gui/qt/swap_dialog.py", line 294, in on_send_edited
recv_amount = self.swap_manager.get_recv_amount(send_amount, is_reverse=self.is_reverse)
File "/home/user/code/vibecoding_vm/electrum/electrum/submarine_swaps.py", line 1320, in get_recv_amount
if abs(send_amount - inverted_send_amount) > 1:
~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
TypeError: unsupported operand type(s) for -: 'int' and 'NoneType'
```
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This commit fixes a crash in Electrum's submarine-swap feature. When a user typed certain amounts (like 20,000 sats) into the swap dialog, a tiny floating-point rounding mismatch made the fee-calculation sanity check fail, returning None where a number was expected and causing a TypeError. The fix changes the fee percentage from a float to a Decimal, which avoids floating-point rounding errors. It is a reliability/bug-fix patch, not a security vulnerability that an attacker can exploit remotely.

Recommended action

Treat as a normal bug-fix commit. No urgent security response is required. If reviewing, verify that all external serialization points cast Decimal to float/string as intended and that no remaining float percentage values enter the swap arithmetic path.

Security signals we found

01

Floating-point rounding causing a sanity check to fail and raise TypeError

02

Type confusion between int and NoneType in swap amount calculation

03

Fix uses Decimal for precise arithmetic on fee percentages

04

Backwards-compatibility float casts added at network/JSON boundaries

Risk score

Why this scored 32/100

Our methodology →
Potential impact 8/30
Exploitability 3/25
Stealth signal 4/15
Affected reach 5/15
Confidence 8/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.