fee_policy: use FEERATE_PRECISION for .. precision
What changed, and why it matters
This is a tiny code cleanup in Electrum's fee-estimation logic. It replaces a hard-coded number (100) with a named constant (FEERATE_PRECISION) when rounding Bitcoin transaction fee rates. The math stays the same because the constant value is 2, so 10**2 equals 100. There is no obvious security issue here; it is a maintainability/refactoring change.
No security action required. Treat as normal code-quality review.
Security signals we found
No security-relevant behavior change observed in the diff.
Change is a constant-for-literal substitution in a rounding expression.
No input validation, cryptographic, authorization, or network changes present.
Evidence from the diff
In electrum/fee_policy.py, the FeeHistogram class rounds mempool fee-rate histogram entries to two decimal places. The patch changes the literal 100 to 10**FEERATE_PRECISION, where FEERATE_PRECISION is imported from util and equals 2. The computation is functionally identical. A comment was also slightly reworded. No logic, bounds, or behavior change is apparent from the diff.
Changed components
electrum/fee_policy.py:FeeHistogramInspect captured patch +3 / −3
diff --git a/electrum/fee_policy.py b/electrum/fee_policy.py
index 2d76902..28c5db8 100644
--- a/electrum/fee_policy.py
+++ b/electrum/fee_policy.py
@@ -5,7 +5,7 @@ from enum import IntEnum
import math
from .i18n import _
-from .util import NoDynamicFeeEstimates, quantize_feerate, format_fee_satoshis
+from .util import NoDynamicFeeEstimates, quantize_feerate, format_fee_satoshis, FEERATE_PRECISION
from . import util, constants
from .logging import Logger
@@ -363,9 +363,9 @@ class FeeHistogram:
slot = min(item[1], bytes_limit - bytes_current)
bytes_current += slot
# round & limit precision
- value = int(item[0] * 100) / 100
+ value = int(item[0] * 10**FEERATE_PRECISION) / 10**FEERATE_PRECISION
capped_histogram.append([
- max(FEERATE_MIN_RELAY/1000, value), # clamped to [FEERATE_MIN_RELAY/1000,inf]
+ max(FEERATE_MIN_RELAY/1000, value), # clamped to [FEERATE_MIN_RELAY/1000, inf)
slot, # width of bucket
bytes_current, # cumulative depth at far end of bucket
])
Why this scored 17/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.