URI: 
       tfix #4218 - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 5a508f7b8d07835d54aec8b9c22a9b2c25609357
   DIR parent 4703d93b0f04a472ba9388da2f1e5eec5f3dc112
  HTML Author: SomberNight <somber.night@protonmail.com>
       Date:   Tue,  3 Apr 2018 01:50:37 +0200
       
       fix #4218
       
       Diffstat:
         M lib/keystore.py                     |      13 +++++++++++++
         M lib/wallet.py                       |       4 ++--
       
       2 files changed, 15 insertions(+), 2 deletions(-)
       ---
   DIR diff --git a/lib/keystore.py b/lib/keystore.py
       t@@ -76,6 +76,8 @@ class KeyStore(PrintError):
                    return False
                return bool(self.get_tx_derivations(tx))
        
       +    def ready_to_sign(self):
       +        return not self.is_watching_only()
        
        
        class Software_KeyStore(KeyStore):
       t@@ -536,6 +538,17 @@ class Hardware_KeyStore(KeyStore, Xpub):
                password = self.get_pubkey_from_xpub(xpub, ())
                return password
        
       +    def has_usable_connection_with_device(self):
       +        if not hasattr(self, 'plugin'):
       +            return False
       +        client = self.plugin.get_client(self, force_pair=False)
       +        if client is None:
       +            return False
       +        return client.has_usable_connection_with_device()
       +
       +    def ready_to_sign(self):
       +        return super().ready_to_sign() and self.has_usable_connection_with_device()
       +
        
        def bip39_normalize_passphrase(passphrase):
            return normalize('NFKD', passphrase or '')
   DIR diff --git a/lib/wallet.py b/lib/wallet.py
       t@@ -1458,8 +1458,8 @@ class Abstract_Wallet(PrintError):
                # hardware wallets require extra info
                if any([(isinstance(k, Hardware_KeyStore) and k.can_sign(tx)) for k in self.get_keystores()]):
                    self.add_hw_info(tx)
       -        # sign
       -        for k in self.get_keystores():
       +        # sign. start with ready keystores.
       +        for k in sorted(self.get_keystores(), key=lambda ks: ks.ready_to_sign(), reverse=True):
                    try:
                        if k.can_sign(tx):
                            k.sign_transaction(tx, password)