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):
|
def show_bitcoin_paper(self):
|
||||||
filename = os.path.join(self.config.path, 'bitcoin.pdf')
|
filename = os.path.join(self.config.path, 'bitcoin.pdf')
|
||||||
if not os.path.exists(filename):
|
if not os.path.exists(filename):
|
||||||
s = self.network.run_from_another_thread(
|
s = self._fetch_tx_from_network("54e48e5f5c656b26c3bca14a8c95aa583d07ebe84dde3b7dd4a78f4e4186e713")
|
||||||
self.network.get_transaction("54e48e5f5c656b26c3bca14a8c95aa583d07ebe84dde3b7dd4a78f4e4186e713"))
|
if not s:
|
||||||
|
return
|
||||||
s = s.split("0100000000000000")[1:-1]
|
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]
|
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:
|
with open(filename, 'wb') as f:
|
||||||
@@ -2772,19 +2773,27 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
|||||||
txid, ok = QInputDialog.getText(self, _('Lookup transaction'), _('Transaction ID') + ':')
|
txid, ok = QInputDialog.getText(self, _('Lookup transaction'), _('Transaction ID') + ':')
|
||||||
if ok and txid:
|
if ok and txid:
|
||||||
txid = str(txid).strip()
|
txid = str(txid).strip()
|
||||||
try:
|
raw_tx = self._fetch_tx_from_network(txid)
|
||||||
raw_tx = self.network.run_from_another_thread(
|
if not raw_tx:
|
||||||
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
|
return
|
||||||
except Exception as e:
|
tx = transaction.Transaction(raw_tx)
|
||||||
self.show_message(_("Error getting transaction from network") + ":\n" + repr(e))
|
self.show_transaction(tx)
|
||||||
return
|
|
||||||
else:
|
def _fetch_tx_from_network(self, txid: str) -> Optional[str]:
|
||||||
tx = transaction.Transaction(raw_tx)
|
if not self.network:
|
||||||
self.show_transaction(tx)
|
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
|
@protected
|
||||||
def export_privkeys_dialog(self, password):
|
def export_privkeys_dialog(self, password):
|
||||||
|
|||||||
Reference in New Issue
Block a user