1
0

hw plugins: (cleanup) rm no-op clear_client argument from keystore.give_error

The keystore does not have a "client" field.
One is supposed to use the "get_client" method instead (the generic API is `plugin.get_client(keystore)`)
Remnants of old code.
This commit is contained in:
SomberNight
2022-05-11 19:30:14 +02:00
parent aab8e664ed
commit 6c50d3b0a3
4 changed files with 15 additions and 21 deletions

View File

@@ -564,14 +564,12 @@ class BitBox02_KeyStore(Hardware_KeyStore):
def get_client(self) -> Optional['BitBox02Client']:
return self.plugin.get_client(self)
def give_error(self, message: Exception, clear_client: bool = False):
def give_error(self, message: Exception):
self.logger.info(message)
if not self.ux_busy:
self.handler.show_error(message)
else:
self.ux_busy = False
if clear_client:
self.client = None
raise UserFacingException(message)
def decrypt_message(self, pubkey, message, password):
@@ -606,7 +604,7 @@ class BitBox02_KeyStore(Hardware_KeyStore):
except Exception as e:
self.logger.exception("")
self.give_error(e, True)
self.give_error(e)
return
@runs_in_hwd_thread

View File

@@ -280,14 +280,12 @@ class Coldcard_KeyStore(Hardware_KeyStore):
return rv
def give_error(self, message, clear_client=False):
def give_error(self, message):
self.logger.info(message)
if not self.ux_busy:
self.handler.show_error(message)
else:
self.ux_busy = False
if clear_client:
self.client = None
raise UserFacingException(message)
def wrap_busy(func):
@@ -351,7 +349,7 @@ class Coldcard_KeyStore(Hardware_KeyStore):
self.handler.show_error('{}\n\n{}'.format(
_('Error showing address') + ':', str(exc)))
except Exception as e:
self.give_error(e, True)
self.give_error(e)
# give empty bytes for error cases; it seems to clear the old signature box
return b''
@@ -397,7 +395,7 @@ class Coldcard_KeyStore(Hardware_KeyStore):
return
except BaseException as e:
self.logger.exception('')
self.give_error(e, True)
self.give_error(e)
return
tx2 = PartialTransaction.from_raw_psbt(raw_resp)

View File

@@ -444,9 +444,7 @@ class DigitalBitbox_KeyStore(Hardware_KeyStore):
Hardware_KeyStore.__init__(self, d)
self.maxInputs = 14 # maximum inputs per single sign command
def give_error(self, message, clear_client = False):
if clear_client:
self.client = None
def give_error(self, message):
raise Exception(message)
@@ -652,7 +650,7 @@ class DigitalBitbox_KeyStore(Hardware_KeyStore):
except UserCancelled:
raise
except BaseException as e:
self.give_error(e, True)
self.give_error(e)
else:
_logger.info(f"Transaction is_complete {tx.is_complete()}")

View File

@@ -260,14 +260,12 @@ class Ledger_KeyStore(Hardware_KeyStore):
def get_client_electrum(self) -> Optional[Ledger_Client]:
return self.plugin.get_client(self)
def give_error(self, message, clear_client = False):
def give_error(self, message):
_logger.info(message)
if not self.signing:
self.handler.show_error(message)
else:
self.signing = False
if clear_client:
self.client = None
raise UserFacingException(message)
def set_and_unset_signing(func):
@@ -306,18 +304,20 @@ class Ledger_KeyStore(Hardware_KeyStore):
signature = client_ledger.signMessageSign(pin)
except BTChipException as e:
if e.sw == 0x6a80:
self.give_error("Unfortunately, this message cannot be signed by the Ledger wallet. Only alphanumerical messages shorter than 140 characters are supported. Please remove any extra characters (tab, carriage return) and retry.")
self.give_error("Unfortunately, this message cannot be signed by the Ledger wallet. "
"Only alphanumerical messages shorter than 140 characters are supported. "
"Please remove any extra characters (tab, carriage return) and retry.")
elif e.sw == 0x6985: # cancelled by user
return b''
elif e.sw == 0x6982:
raise # pin lock. decorator will catch it
else:
self.give_error(e, True)
self.give_error(e)
except UserWarning:
self.handler.show_error(_('Cancelled by user'))
return b''
except Exception as e:
self.give_error(e, True)
self.give_error(e)
finally:
self.handler.finished()
# Parse the ASN.1 signature
@@ -541,10 +541,10 @@ class Ledger_KeyStore(Hardware_KeyStore):
raise # pin lock. decorator will catch it
else:
self.logger.exception('')
self.give_error(e, True)
self.give_error(e)
except BaseException as e:
self.logger.exception('')
self.give_error(e, True)
self.give_error(e)
finally:
self.handler.finished()