Browse Source

hww ledger: call scan_devices fewer times

master
SomberNight 4 years ago
parent
commit
574243b897
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
  1. 12
      electrum/plugins/ledger/ledger.py

12
electrum/plugins/ledger/ledger.py

@ -254,9 +254,10 @@ class Ledger_KeyStore(Hardware_KeyStore):
obj['cfg'] = self.cfg obj['cfg'] = self.cfg
return obj return obj
def get_client_dongle_object(self) -> 'btchip': def get_client_dongle_object(self, *, client: Optional['Ledger_Client'] = None) -> 'btchip':
client_electrum = self.get_client() if client is None:
return client_electrum.dongleObject client = self.get_client()
return client.dongleObject
def give_error(self, message): def give_error(self, message):
_logger.info(message) _logger.info(message)
@ -286,8 +287,8 @@ class Ledger_KeyStore(Hardware_KeyStore):
message = message.encode('utf8') message = message.encode('utf8')
message_hash = hashlib.sha256(message).hexdigest().upper() message_hash = hashlib.sha256(message).hexdigest().upper()
# prompt for the PIN before displaying the dialog if necessary # prompt for the PIN before displaying the dialog if necessary
client_ledger = self.get_client_dongle_object()
client_electrum = self.get_client() client_electrum = self.get_client()
client_ledger = self.get_client_dongle_object(client=client_electrum)
address_path = self.get_derivation_prefix()[2:] + "/%d/%d"%sequence address_path = self.get_derivation_prefix()[2:] + "/%d/%d"%sequence
self.handler.show_message("Signing message ...\r\nMessage hash: "+message_hash) self.handler.show_message("Signing message ...\r\nMessage hash: "+message_hash)
try: try:
@ -350,9 +351,10 @@ class Ledger_KeyStore(Hardware_KeyStore):
p2shTransaction = False p2shTransaction = False
segwitTransaction = False segwitTransaction = False
pin = "" pin = ""
client_ledger = self.get_client_dongle_object() # prompt for the PIN before displaying the dialog if necessary # prompt for the PIN before displaying the dialog if necessary
client_electrum = self.get_client() client_electrum = self.get_client()
assert client_electrum assert client_electrum
client_ledger = self.get_client_dongle_object(client=client_electrum)
# Fetch inputs of the transaction to sign # Fetch inputs of the transaction to sign
for txin in tx.inputs(): for txin in tx.inputs():

Loading…
Cancel
Save