URI: 
       tqt main_window: add error handling to show_bitcoin_paper - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit d13995309a35e246a2c5ccb8d16ecbca40812a1b
   DIR parent 338adf05bad3f39b16d9e1d9f531c4e05b965756
  HTML Author: SomberNight <somber.night@protonmail.com>
       Date:   Wed, 27 Jan 2021 20:38:23 +0100
       
       qt main_window: add error handling to show_bitcoin_paper
       
       related: #6970
       
       Diffstat:
         M electrum/gui/qt/main_window.py      |      37 +++++++++++++++++++------------
       
       1 file changed, 23 insertions(+), 14 deletions(-)
       ---
   DIR diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py
       t@@ -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:
       t@@ -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())
       -                return
       -            except Exception as e:
       -                self.show_message(_("Error getting transaction from network") + ":\n" + repr(e))
       +            raw_tx = self._fetch_tx_from_network(txid)
       +            if not raw_tx:
                        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):