URI: 
       texchange_rate: minor clean-up - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 5cbf54d23a5e98f0b81b39de707433699fb0264f
   DIR parent 95a122596e0451bd8f4d6d963b1f1e72d8ec8cef
  HTML Author: SomberNight <somber.night@protonmail.com>
       Date:   Fri, 22 Mar 2019 16:48:47 +0100
       
       exchange_rate: minor clean-up
       
       based on mhsmith/electrum@7ed3f032dd90210638a6efa4b513350d2824037a
       
       Diffstat:
         M electrum/exchange_rate.py           |      16 ++++++++++++----
       
       1 file changed, 12 insertions(+), 4 deletions(-)
       ---
   DIR diff --git a/electrum/exchange_rate.py b/electrum/exchange_rate.py
       t@@ -21,6 +21,11 @@ from .network import Network
        from .simple_config import SimpleConfig
        
        
       +DEFAULT_ENABLED = False
       +DEFAULT_CURRENCY = "EUR"
       +DEFAULT_EXCHANGE = "BitcoinAverage"  # default exchange should ideally provide historical rates
       +
       +
        # See https://en.wikipedia.org/wiki/ISO_4217
        CCY_PRECISIONS = {'BHD': 3, 'BIF': 0, 'BYR': 0, 'CLF': 4, 'CLP': 0,
                          'CVE': 0, 'DJF': 0, 'GNF': 0, 'IQD': 3, 'ISK': 0,
       t@@ -509,7 +514,7 @@ class FxThread(ThreadJob):
                        await self.exchange.update_safe(self.ccy)
        
            def is_enabled(self):
       -        return bool(self.config.get('use_exchange_rate'))
       +        return bool(self.config.get('use_exchange_rate', DEFAULT_ENABLED))
        
            def set_enabled(self, b):
                self.config.set_key('use_exchange_rate', bool(b))
       t@@ -535,10 +540,10 @@ class FxThread(ThreadJob):
        
            def get_currency(self):
                '''Use when dynamic fetching is needed'''
       -        return self.config.get("currency", "EUR")
       +        return self.config.get("currency", DEFAULT_CURRENCY)
        
            def config_exchange(self):
       -        return self.config.get('use_exchange', 'BitcoinAverage')
       +        return self.config.get('use_exchange', DEFAULT_EXCHANGE)
        
            def show_history(self):
                return self.is_enabled() and self.get_history_config() and self.ccy in self.exchange.history_ccys()
       t@@ -554,7 +559,7 @@ class FxThread(ThreadJob):
                    self.network.asyncio_loop.call_soon_threadsafe(self._trigger.set)
        
            def set_exchange(self, name):
       -        class_ = globals().get(name, BitcoinAverage)
       +        class_ = globals().get(name) or globals().get(DEFAULT_EXCHANGE)
                self.print_error("using exchange", name)
                if self.config_exchange() != name:
                    self.config.set_key('use_exchange', name, True)
       t@@ -624,3 +629,6 @@ class FxThread(ThreadJob):
                from .util import timestamp_to_datetime
                date = timestamp_to_datetime(timestamp)
                return self.history_rate(date)
       +
       +
       +assert globals().get(DEFAULT_EXCHANGE), f"default exchange {DEFAULT_EXCHANGE} does not exist"