SomberNight 7 years ago
parent
commit
5a508f7b8d
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 13
      lib/keystore.py
  2. 4
      lib/wallet.py

13
lib/keystore.py

@ -76,6 +76,8 @@ class KeyStore(PrintError):
return False return False
return bool(self.get_tx_derivations(tx)) return bool(self.get_tx_derivations(tx))
def ready_to_sign(self):
return not self.is_watching_only()
class Software_KeyStore(KeyStore): class Software_KeyStore(KeyStore):
@ -536,6 +538,17 @@ class Hardware_KeyStore(KeyStore, Xpub):
password = self.get_pubkey_from_xpub(xpub, ()) password = self.get_pubkey_from_xpub(xpub, ())
return password 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): def bip39_normalize_passphrase(passphrase):
return normalize('NFKD', passphrase or '') return normalize('NFKD', passphrase or '')

4
lib/wallet.py

@ -1458,8 +1458,8 @@ class Abstract_Wallet(PrintError):
# hardware wallets require extra info # hardware wallets require extra info
if any([(isinstance(k, Hardware_KeyStore) and k.can_sign(tx)) for k in self.get_keystores()]): if any([(isinstance(k, Hardware_KeyStore) and k.can_sign(tx)) for k in self.get_keystores()]):
self.add_hw_info(tx) self.add_hw_info(tx)
# sign # sign. start with ready keystores.
for k in self.get_keystores(): for k in sorted(self.get_keystores(), key=lambda ks: ks.ready_to_sign(), reverse=True):
try: try:
if k.can_sign(tx): if k.can_sign(tx):
k.sign_transaction(tx, password) k.sign_transaction(tx, password)

Loading…
Cancel
Save