URI: 
       tfix #4657 - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 69a204d72600d7a2a58917cb4fe705ab438d4437
   DIR parent 44fbd8330bed41fd243b0881aad44e41d3706e66
  HTML Author: SomberNight <somber.night@protonmail.com>
       Date:   Wed,  5 Sep 2018 18:30:53 +0200
       
       fix #4657
       
       Diffstat:
         M electrum/gui/kivy/main_window.py    |      10 +++++++---
         M electrum/gui/qt/main_window.py      |      11 ++++++++---
         M electrum/util.py                    |       9 +++++++--
       
       3 files changed, 22 insertions(+), 8 deletions(-)
       ---
   DIR diff --git a/electrum/gui/kivy/main_window.py b/electrum/gui/kivy/main_window.py
       t@@ -69,7 +69,8 @@ Label.register('Roboto',
        
        
        from electrum.util import (base_units, NoDynamicFeeEstimates, decimal_point_to_base_unit_name,
       -                           base_unit_name_to_decimal_point, NotEnoughFunds)
       +                           base_unit_name_to_decimal_point, NotEnoughFunds, UnknownBaseUnit,
       +                           DECIMAL_POINT_DEFAULT)
        
        
        class ElectrumWindow(App):
       t@@ -163,8 +164,11 @@ class ElectrumWindow(App):
                self._trigger_update_history()
        
            def _get_bu(self):
       -        decimal_point = self.electrum_config.get('decimal_point', 5)
       -        return decimal_point_to_base_unit_name(decimal_point)
       +        decimal_point = self.electrum_config.get('decimal_point', DECIMAL_POINT_DEFAULT)
       +        try:
       +            return decimal_point_to_base_unit_name(decimal_point)
       +        except UnknownBaseUnit:
       +            return decimal_point_to_base_unit_name(DECIMAL_POINT_DEFAULT)
        
            def _set_bu(self, value):
                assert value in base_units.keys()
   DIR diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py
       t@@ -49,7 +49,8 @@ from electrum.util import (format_time, format_satoshis, format_fee_satoshis,
                                   UserCancelled, NoDynamicFeeEstimates, profiler,
                                   export_meta, import_meta, bh2u, bfh, InvalidPassword,
                                   base_units, base_units_list, base_unit_name_to_decimal_point,
       -                           decimal_point_to_base_unit_name, quantize_feerate)
       +                           decimal_point_to_base_unit_name, quantize_feerate,
       +                           UnknownBaseUnit, DECIMAL_POINT_DEFAULT)
        from electrum.transaction import Transaction, TxOutput
        from electrum.address_synchronizer import AddTransactionException
        from electrum.wallet import Multisig_Wallet, CannotBumpFee
       t@@ -126,8 +127,12 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
                self.create_status_bar()
                self.need_update = threading.Event()
        
       -        self.decimal_point = config.get('decimal_point', 5)
       -        self.num_zeros     = int(config.get('num_zeros',0))
       +        self.decimal_point = config.get('decimal_point', DECIMAL_POINT_DEFAULT)
       +        try:
       +            decimal_point_to_base_unit_name(self.decimal_point)
       +        except UnknownBaseUnit:
       +            self.decimal_point = DECIMAL_POINT_DEFAULT
       +        self.num_zeros = int(config.get('num_zeros', 0))
        
                self.completions = QStringListModel()
        
   DIR diff --git a/electrum/util.py b/electrum/util.py
       t@@ -49,13 +49,18 @@ base_units = {'BTC':8, 'mBTC':5, 'bits':2, 'sat':0}
        base_units_inverse = inv_dict(base_units)
        base_units_list = ['BTC', 'mBTC', 'bits', 'sat']  # list(dict) does not guarantee order
        
       +DECIMAL_POINT_DEFAULT = 5  # mBTC
       +
       +
       +class UnknownBaseUnit(Exception): pass
       +
        
        def decimal_point_to_base_unit_name(dp: int) -> str:
            # e.g. 8 -> "BTC"
            try:
                return base_units_inverse[dp]
            except KeyError:
       -        raise Exception('Unknown base unit')
       +        raise UnknownBaseUnit(dp) from None
        
        
        def base_unit_name_to_decimal_point(unit_name: str) -> int:
       t@@ -63,7 +68,7 @@ def base_unit_name_to_decimal_point(unit_name: str) -> int:
            try:
                return base_units[unit_name]
            except KeyError:
       -        raise Exception('Unknown base unit')
       +        raise UnknownBaseUnit(unit_name) from None
        
        
        def normalize_version(v):