URI: 
       tMerge pull request #1027 from m0mchil/check_trezor_ver - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 65a8521d35d8e23f9bd9e95e09b30ec26d0ed166
   DIR parent 3ae3faf96bb19db89cae969a6de01126ddb7350d
  HTML Author: ThomasV <electrumdev@gmail.com>
       Date:   Sun, 15 Feb 2015 13:28:14 +0100
       
       Merge pull request #1027 from m0mchil/check_trezor_ver
       
       better trezor version checks
       Diffstat:
         M plugins/trezor.py                   |      13 ++++++++++---
       
       1 file changed, 10 insertions(+), 3 deletions(-)
       ---
   DIR diff --git a/plugins/trezor.py b/plugins/trezor.py
       t@@ -133,7 +133,7 @@ class Plugin(BasePlugin):
                    tx.error = str(e)
            @hook
            def receive_menu(self, menu, addrs):
       -        if not self.wallet.is_watching_only() and len(addrs) == 1:
       +        if not self.wallet.is_watching_only() and self.wallet.atleast_version(1, 3) and len(addrs) == 1:
                    menu.addAction(_("Show on TREZOR"), lambda: self.wallet.show_address(addrs[0]))
        
            def settings_widget(self, window):
       t@@ -216,15 +216,22 @@ class TrezorWallet(BIP32_HD_Wallet):
                    except:
                        give_error('Could not connect to your Trezor. Please verify the cable is connected and that no other app is using it.')
                    self.client = QtGuiTrezorClient(self.transport)
       -            if (self.client.features.major_version == 1 and self.client.features.minor_version < 2) or (self.client.features.major_version == 1 and self.client.features.minor_version == 2 and self.client.features.patch_version < 1):
       -                give_error('Outdated Trezor firmware. Please update the firmware from https://www.mytrezor.com') 
                    self.client.set_tx_api(self)
                    #self.client.clear_session()# TODO Doesn't work with firmware 1.1, returns proto.Failure
                    self.client.bad = False
                    self.device_checked = False
                    self.proper_device = False
       +            if not self.atleast_version(1, 2, 1):
       +                give_error('Outdated Trezor firmware. Please update the firmware from https://www.mytrezor.com')
                return self.client
        
       +    def compare_version(self, major, minor=0, patch=0):
       +        features = self.get_client().features
       +        return cmp([features.major_version, features.minor_version, features.patch_version], [major, minor, patch])
       +
       +    def atleast_version(self, major, minor=0, patch=0):
       +        return self.compare_version(major, minor, patch) >= 0
       +
            def address_id(self, address):
                account_id, (change, address_index) = self.get_address_index(address)
                return "44'/0'/%s'/%d/%d" % (account_id, change, address_index)