tkivy amount_dialog: truncate btc amounts to max precision - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit b1dc281cbac03417383114746627128283810828 DIR parent d5d9f5b46cf9cea6e4770d22396c28e82ebb3b2b HTML Author: SomberNight <somber.night@protonmail.com> Date: Sun, 8 Sep 2019 15:41:10 +0200 kivy amount_dialog: truncate btc amounts to max precision closes #5624 Diffstat: M electrum/gui/kivy/uix/dialogs/amou… | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) --- DIR diff --git a/electrum/gui/kivy/uix/dialogs/amount_dialog.py b/electrum/gui/kivy/uix/dialogs/amount_dialog.py t@@ -120,6 +120,8 @@ from kivy.properties import BooleanProperty class AmountDialog(Factory.Popup): show_max = BooleanProperty(False) + app = App.get_running_app() + def __init__(self, show_max, amount, cb): Factory.Popup.__init__(self) self.show_max = show_max t@@ -129,8 +131,8 @@ class AmountDialog(Factory.Popup): def update_amount(self, c): kb = self.ids.kb - amount = kb.fiat_amount if kb.is_fiat else kb.amount - if c == '<': + amount = kb.fiat_amount if kb.is_fiat else kb.amount # type: str + if c == '<': # delete amount = amount[:-1] elif c == '.' and amount in ['0', '']: amount = '0.' t@@ -142,6 +144,11 @@ class AmountDialog(Factory.Popup): amount += c except: pass + # truncate btc amounts to max precision: + if not kb.is_fiat and '.' in amount: + p = amount.find('.') + amount = amount.replace('.', '') + amount = amount[:p] + '.' + amount[p:p + self.app.decimal_point()] if kb.is_fiat: kb.fiat_amount = amount else: