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

ExchangeRate: return NaN if rate is 0

Public commit record

What the developer wrote

Authored by f321x

76/100 · Adequate
ExchangeRate: return NaN if rate is 0

Prevent DivisionByZero exceptions by returning `Decimal('NaN')
instead of `Decimal(0)` if the exchange rate is 0.

Fixes https://github.com/spesmilo/electrum/issues/10403

```
>>> bool(Decimal(0))
False
```
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This is a small defensive fix in Electrum's currency-conversion code. Previously, if an exchange rate was reported as zero, the code treated it the same as a missing rate and returned zero. Other parts of the program could then crash with a 'division by zero' error when converting amounts. The change makes zero rates return a special 'not a number' value instead, so callers can handle it safely. It is a robustness improvement rather than a clear-cut security vulnerability.

Recommended action

No urgent action beyond applying the patch. If maintaining a fork, review other callers of quotes() to ensure they handle Decimal('NaN') gracefully rather than propagating NaN into user-facing totals.

Security signals we found

01

DivisionByZero crash path removed in exchange-rate conversion

02

Zero quote now handled identically to missing quote

03

Fixes public issue #10403

Risk score

Why this scored 25/100

Our methodology →
Potential impact 4/30
Exploitability 3/25
Stealth signal 3/15
Affected reach 5/15
Confidence 7/10
Evidence quality 3/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.