Skip to content

Commit

Permalink
fix #4218
Browse files Browse the repository at this point in the history
  • Loading branch information
SomberNight committed Apr 2, 2018
1 parent 4703d93 commit 5a508f7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions lib/keystore.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ def can_sign(self, tx):
return False
return bool(self.get_tx_derivations(tx))

def ready_to_sign(self):
return not self.is_watching_only()


class Software_KeyStore(KeyStore):
Expand Down Expand Up @@ -536,6 +538,17 @@ def get_password_for_storage_encryption(self):
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 '')
Expand Down
4 changes: 2 additions & 2 deletions lib/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1458,8 +1458,8 @@ def sign_transaction(self, tx, password):
# 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)
Expand Down

0 comments on commit 5a508f7

Please sign in to comment.