tnetwork UntrustedServerReturnedError: add "DO NOT TRUST..." tag - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 88650ed8d60acde94d476af5431ee654f09b2b30 DIR parent 55a0043ab77ed6a59d27b675847d9dd5101c9e55 HTML Author: SomberNight <somber.night@protonmail.com> Date: Fri, 28 Feb 2020 18:47:12 +0100 network UntrustedServerReturnedError: add "DO NOT TRUST..." tag Diffstat: M electrum/gui/qt/main_window.py | 11 ++++++++--- M electrum/network.py | 6 +++++- 2 files changed, 13 insertions(+), 4 deletions(-) --- DIR diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py t@@ -69,7 +69,7 @@ from electrum.address_synchronizer import AddTransactionException from electrum.wallet import (Multisig_Wallet, CannotBumpFee, Abstract_Wallet, sweep_preparations, InternalAddressCorruption) from electrum.version import ELECTRUM_VERSION -from electrum.network import Network, TxBroadcastError, BestEffortRequestFailed +from electrum.network import Network, TxBroadcastError, BestEffortRequestFailed, UntrustedServerReturnedError from electrum.exchange_rate import FxThread from electrum.simple_config import SimpleConfig from electrum.logging import Logger t@@ -2542,11 +2542,16 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): try: raw_tx = self.network.run_from_another_thread( self.network.get_transaction(txid, timeout=10)) + except UntrustedServerReturnedError as e: + self.logger.info(f"Error getting transaction from network: {repr(e)}") + self.show_message(_("Error getting transaction from network") + ":\n" + e.get_message_for_gui()) + return except Exception as e: self.show_message(_("Error getting transaction from network") + ":\n" + repr(e)) return - tx = transaction.Transaction(raw_tx) - self.show_transaction(tx) + else: + tx = transaction.Transaction(raw_tx) + self.show_transaction(tx) @protected def export_privkeys_dialog(self, password): DIR diff --git a/electrum/network.py b/electrum/network.py t@@ -219,11 +219,15 @@ class UntrustedServerReturnedError(NetworkException): def __init__(self, *, original_exception): self.original_exception = original_exception + def get_message_for_gui(self) -> str: + return str(self) + def __str__(self): return _("The server returned an error.") def __repr__(self): - return f"<UntrustedServerReturnedError original_exception: {repr(self.original_exception)}>" + return (f"<UntrustedServerReturnedError " + f"[DO NOT TRUST THIS MESSAGE] original_exception: {repr(self.original_exception)}>") _INSTANCE = None