diff --git a/electrum/network.py b/electrum/network.py index 0ea79d3c8..e59e17aca 100644 --- a/electrum/network.py +++ b/electrum/network.py @@ -238,13 +238,20 @@ class UntrustedServerReturnedError(NetworkException): def get_message_for_gui(self) -> str: return str(self) + def get_untrusted_message(self) -> str: + e = self.original_exception + return (f"") + def __str__(self): + # We should not show the untrusted text from self.original_exception, + # to avoid accidentally showing it in the GUI. return _("The server returned an error.") def __repr__(self): - e = self.original_exception - return (f"") + # We should not show the untrusted text from self.original_exception, + # to avoid accidentally showing it in the GUI. + return f"" _INSTANCE = None @@ -899,7 +906,7 @@ class Network(Logger, NetworkRetryManager[ServerAddr]): except aiorpcx.jsonrpc.CodeMessageError as e: wrapped_exc = UntrustedServerReturnedError(original_exception=e) # log (sanitized) untrusted error text now, to ease debugging - self.logger.debug(f"got error from server for {func.__qualname__}: {wrapped_exc!r}") + self.logger.debug(f"got error from server for {func.__qualname__}: {wrapped_exc.get_untrusted_message()!r}") raise wrapped_exc from e return wrapper