plugins: hardware: HardwareHandlerBase.show_error() takes str, not exc
What changed, and why it matters
This commit is a minor code clean-up in Electrum's hardware wallet plugins. It changes the type annotations and adds explicit str() conversions when passing error messages to a GUI helper. The commit message explicitly states runtime behavior is unchanged, and the diff confirms the same values are ultimately displayed to the user. There is no security fix here.
No action required. This is a non-security refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch updates give_error() signatures in bitbox02, coldcard, digitalbitbox, and ledger plugins to accept str | BaseException instead of Exception, and wraps exception objects with str() before calling HardwareHandlerBase.show_error(). The commit message and diff confirm this is a conceptual/typing clean-up: downstream GUI code already casts the argument to str, so no observable behavior changes. No vulnerability is patched or introduced.
Changed components
electrum/plugins/bitbox02/bitbox02.pyelectrum/plugins/coldcard/coldcard.pyelectrum/plugins/digitalbitbox/digitalbitbox.pyelectrum/plugins/ledger/ledger.pyInspect captured patch +15 / −15
diff --git a/electrum/plugins/bitbox02/bitbox02.py b/electrum/plugins/bitbox02/bitbox02.py
index ead4d8d..7d694f3 100644
--- a/electrum/plugins/bitbox02/bitbox02.py
+++ b/electrum/plugins/bitbox02/bitbox02.py
@@ -577,10 +577,10 @@ class BitBox02_KeyStore(Hardware_KeyStore):
super().__init__(d)
self.ux_busy = False
- def give_error(self, message: Exception):
+ def give_error(self, message: str | BaseException):
self.logger.info(message)
if not self.ux_busy:
- self.handler.show_error(message)
+ self.handler.show_error(str(message))
else:
self.ux_busy = False
raise UserFacingException(message)
@@ -636,7 +636,7 @@ class BitBox02_KeyStore(Hardware_KeyStore):
self.handler.finished()
except Exception as e:
self.logger.exception("")
- self.handler.show_error(e)
+ self.handler.show_error(str(e))
class BitBox02Plugin(HW_PluginBase):
diff --git a/electrum/plugins/coldcard/coldcard.py b/electrum/plugins/coldcard/coldcard.py
index a9f74ec..e92c6c2 100644
--- a/electrum/plugins/coldcard/coldcard.py
+++ b/electrum/plugins/coldcard/coldcard.py
@@ -301,10 +301,10 @@ class Coldcard_KeyStore(Hardware_KeyStore):
return client
- def give_error(self, message):
+ def give_error(self, message: str | BaseException):
self.logger.info(message)
if not self.ux_busy:
- self.handler.show_error(message)
+ self.handler.show_error(str(message))
else:
self.ux_busy = False
raise UserFacingException(message)
@@ -460,7 +460,7 @@ class Coldcard_KeyStore(Hardware_KeyStore):
_('Error showing address') + ':', str(exc)))
except BaseException as exc:
self.logger.exception('')
- self.handler.show_error(exc)
+ self.handler.show_error(str(exc))
@wrap_busy
def show_p2sh_address(self, M, script, xfp_paths, txin_type):
@@ -482,7 +482,7 @@ class Coldcard_KeyStore(Hardware_KeyStore):
str(exc)))
except BaseException as exc:
self.logger.exception('')
- self.handler.show_error(exc)
+ self.handler.show_error(str(exc))
class ColdcardPlugin(HW_PluginBase):
diff --git a/electrum/plugins/digitalbitbox/digitalbitbox.py b/electrum/plugins/digitalbitbox/digitalbitbox.py
index 00b9030..1ad124d 100644
--- a/electrum/plugins/digitalbitbox/digitalbitbox.py
+++ b/electrum/plugins/digitalbitbox/digitalbitbox.py
@@ -454,7 +454,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):
+ def give_error(self, message: str | BaseException):
raise Exception(message)
def decrypt_message(self, pubkey, message, password):
diff --git a/electrum/plugins/ledger/ledger.py b/electrum/plugins/ledger/ledger.py
index c7099ec..408c82f 100644
--- a/electrum/plugins/ledger/ledger.py
+++ b/electrum/plugins/ledger/ledger.py
@@ -403,10 +403,10 @@ class Ledger_Client_Legacy(Ledger_Client):
self.signing = False
return wrapper
- def give_error(self, message):
+ def give_error(self, message: str | BaseException):
_logger.info(message)
if not self.signing:
- self.handler.show_error(message)
+ self.handler.show_error(str(message))
else:
self.signing = False
raise UserFacingException(message)
@@ -545,10 +545,10 @@ class Ledger_Client_Legacy(Ledger_Client):
_('Your device might not have support for this functionality.')))
else:
_logger.exception('')
- self.handler.show_error(e)
+ self.handler.show_error(str(e))
except BaseException as e:
_logger.exception('')
- self.handler.show_error(e)
+ self.handler.show_error(str(e))
finally:
self.handler.finished()
@@ -959,7 +959,7 @@ class Ledger_Client_New(Ledger_Client):
pass # cancelled by user
except BaseException as e:
_logger.exception('Error while showing an address')
- self.handler.show_error(e)
+ self.handler.show_error(str(e))
finally:
self.handler.finished()
@@ -1139,7 +1139,7 @@ class Ledger_Client_New(Ledger_Client):
pass # cancelled by user
except BaseException as e:
_logger.exception('Error while signing')
- self.handler.show_error(e)
+ self.handler.show_error(str(e))
finally:
self.handler.finished()
@@ -1166,7 +1166,7 @@ class Ledger_Client_New(Ledger_Client):
pass # cancelled by user
except BaseException as e:
_logger.exception('')
- self.handler.show_error(e)
+ self.handler.show_error(str(e))
finally:
self.handler.finished()
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.