Browse Source

network UntrustedServerReturnedError: add "DO NOT TRUST..." tag

hard-fail-on-bad-server-string
SomberNight 5 years ago
parent
commit
88650ed8d6
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 11
      electrum/gui/qt/main_window.py
  2. 6
      electrum/network.py

11
electrum/gui/qt/main_window.py

@ -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
@ -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):

6
electrum/network.py

@ -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

Loading…
Cancel
Save