Skip to content

Commit e16deba

Browse files
committed
qt: fix AmountEdit zero precision significance stripping
1 parent 3e56aad commit e16deba

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

electrum/gui/qt/amountedit.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,12 @@ def get_amount(self) -> Union[None, Decimal, int]:
115115
def _get_text_from_amount(self, amount) -> str:
116116
x = to_decimal(amount)
117117
scale_factor = pow(10, self.decimal_point())
118-
nfmt = "{:." + str(self.decimal_point() + self.extra_precision()) + "f}"
119-
text = nfmt.format(x / scale_factor).rstrip('0').rstrip('.')
120-
text = text.replace('.', DECIMAL_POINT)
118+
total_precision = self.decimal_point() + self.extra_precision()
119+
nfmt = "{:." + str(total_precision) + "f}"
120+
text = nfmt.format(x / scale_factor)
121+
if total_precision > 0:
122+
text = text.rstrip('0').rstrip('.')
123+
text = text.replace('.', DECIMAL_POINT)
121124
return text
122125

123126
def setAmount(self, amount):

0 commit comments

Comments
 (0)