qt main_window: add error handling to show_bitcoin_paper
related: #6970
This commit is contained in:
@@ -795,8 +795,9 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
||||
def show_bitcoin_paper(self):
|
||||
filename = os.path.join(self.config.path, 'bitcoin.pdf')
|
||||
if not os.path.exists(filename):
|
||||
s = self.network.run_from_another_thread(
|
||||
self.network.get_transaction("54e48e5f5c656b26c3bca14a8c95aa583d07ebe84dde3b7dd4a78f4e4186e713"))
|
||||
s = self._fetch_tx_from_network("54e48e5f5c656b26c3bca14a8c95aa583d07ebe84dde3b7dd4a78f4e4186e713")
|
||||
if not s:
|
||||
return
|
||||
s = s.split("0100000000000000")[1:-1]
|
||||
out = ''.join(x[6:136] + x[138:268] + x[270:400] if len(x) > 136 else x[6:] for x in s)[16:-20]
|
||||
with open(filename, 'wb') as f:
|
||||
@@ -2772,19 +2773,27 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
||||
txid, ok = QInputDialog.getText(self, _('Lookup transaction'), _('Transaction ID') + ':')
|
||||
if ok and txid:
|
||||
txid = str(txid).strip()
|
||||
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())
|
||||
raw_tx = self._fetch_tx_from_network(txid)
|
||||
if not raw_tx:
|
||||
return
|
||||
except Exception as e:
|
||||
self.show_message(_("Error getting transaction from network") + ":\n" + repr(e))
|
||||
return
|
||||
else:
|
||||
tx = transaction.Transaction(raw_tx)
|
||||
self.show_transaction(tx)
|
||||
tx = transaction.Transaction(raw_tx)
|
||||
self.show_transaction(tx)
|
||||
|
||||
def _fetch_tx_from_network(self, txid: str) -> Optional[str]:
|
||||
if not self.network:
|
||||
self.show_message(_("You are offline."))
|
||||
return
|
||||
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
|
||||
return raw_tx
|
||||
|
||||
@protected
|
||||
def export_privkeys_dialog(self, password):
|
||||
|
||||
Reference in New Issue
Block a user