URI: 
       tfix some network.get_transaction calls - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 5b4fada2a03f1ebfb156d7c4c7e5d468669ae8d6
   DIR parent f53b480f1cd1b572e4c39b249b5c1ff2a0737466
  HTML Author: SomberNight <somber.night@protonmail.com>
       Date:   Tue, 30 Oct 2018 19:07:37 +0100
       
       fix some network.get_transaction calls
       
       see #4814 (issuecomment-434392195)
       
       Diffstat:
         M electrum/gui/qt/main_window.py      |       9 +++++----
         M electrum/interface.py               |      12 +++++++++---
         M electrum/network.py                 |       7 ++++---
         M electrum/util.py                    |      10 ----------
         M electrum/wallet.py                  |      12 ++++++++----
       
       5 files changed, 26 insertions(+), 24 deletions(-)
       ---
   DIR diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py
       t@@ -2427,11 +2427,12 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
                if ok and txid:
                    txid = str(txid).strip()
                    try:
       -                r = self.network.get_transaction(txid)
       -            except BaseException as e:
       -                self.show_message(str(e))
       +                raw_tx = self.network.run_from_another_thread(
       +                    self.network.get_transaction(txid, timeout=10))
       +            except Exception as e:
       +                self.show_message(_("Error getting transaction from network") + ":\n" + str(e))
                        return
       -            tx = transaction.Transaction(r)
       +            tx = transaction.Transaction(raw_tx)
                    self.show_transaction(tx)
        
            @protected
   DIR diff --git a/electrum/interface.py b/electrum/interface.py
       t@@ -68,9 +68,9 @@ class NotificationSession(RPCSession):
                    else:
                        raise Exception('unexpected request: {}'.format(repr(request)))
        
       -    async def send_request(self, *args, timeout=-1, **kwargs):
       +    async def send_request(self, *args, timeout=None, **kwargs):
                # note: the timeout starts after the request touches the wire!
       -        if timeout == -1:
       +        if timeout is None:
                    timeout = 30
                # note: the semaphore implementation guarantees no starvation
                async with self.in_flight_requests_semaphore:
       t@@ -108,7 +108,13 @@ class NotificationSession(RPCSession):
        
        
        class GracefulDisconnect(Exception): pass
       -class RequestTimedOut(GracefulDisconnect): pass
       +
       +
       +class RequestTimedOut(GracefulDisconnect):
       +    def __str__(self):
       +        return _("Network request timed out.")
       +
       +
        class ErrorParsingSSLCert(Exception): pass
        class ErrorGettingSSLCertFromServer(Exception): pass
        
   DIR diff --git a/electrum/network.py b/electrum/network.py
       t@@ -706,7 +706,7 @@ class Network(PrintError):
                return await self.interface.session.send_request('blockchain.transaction.get_merkle', [tx_hash, tx_height])
        
            @best_effort_reliable
       -    async def broadcast_transaction(self, tx, timeout=10):
       +    async def broadcast_transaction(self, tx, *, timeout=10):
                out = await self.interface.session.send_request('blockchain.transaction.broadcast', [str(tx)], timeout=timeout)
                if out != tx.txid():
                    raise Exception(out)
       t@@ -717,8 +717,9 @@ class Network(PrintError):
                return await self.interface.request_chunk(height, tip=tip, can_return_early=can_return_early)
        
            @best_effort_reliable
       -    async def get_transaction(self, tx_hash: str) -> str:
       -        return await self.interface.session.send_request('blockchain.transaction.get', [tx_hash])
       +    async def get_transaction(self, tx_hash: str, *, timeout=None) -> str:
       +        return await self.interface.session.send_request('blockchain.transaction.get', [tx_hash],
       +                                                         timeout=timeout)
        
            @best_effort_reliable
            async def get_history_for_scripthash(self, sh: str) -> List[dict]:
   DIR diff --git a/electrum/util.py b/electrum/util.py
       t@@ -113,16 +113,6 @@ class FileExportFailed(Exception):
                return _("Failed to export to file.") + "\n" + self.message
        
        
       -class TimeoutException(Exception):
       -    def __init__(self, message=''):
       -        self.message = str(message)
       -
       -    def __str__(self):
       -        if not self.message:
       -            return _("Operation timed out.")
       -        return self.message
       -
       -
        class WalletFileException(Exception): pass
        
        
   DIR diff --git a/electrum/wallet.py b/electrum/wallet.py
       t@@ -43,7 +43,7 @@ from typing import TYPE_CHECKING, List, Optional, Tuple
        from .i18n import _
        from .util import (NotEnoughFunds, PrintError, UserCancelled, profiler,
                           format_satoshis, format_fee_satoshis, NoDynamicFeeEstimates,
       -                   TimeoutException, WalletFileException, BitcoinException,
       +                   WalletFileException, BitcoinException,
                           InvalidPassword, format_time, timestamp_to_datetime, Satoshis,
                           Fiat, bfh, bh2u)
        from .bitcoin import (COIN, TYPE_ADDRESS, is_address, address_to_script,
       t@@ -60,6 +60,7 @@ from .address_synchronizer import (AddressSynchronizer, TX_HEIGHT_LOCAL,
        from .paymentrequest import (PR_PAID, PR_UNPAID, PR_UNKNOWN, PR_EXPIRED,
                                     InvoiceStore)
        from .contacts import Contacts
       +from .interface import RequestTimedOut
        
        if TYPE_CHECKING:
            from .network import Network
       t@@ -768,11 +769,14 @@ class Abstract_Wallet(AddressSynchronizer):
                tx = self.transactions.get(tx_hash, None)
                if not tx and self.network:
                    try:
       -                tx = Transaction(self.network.get_transaction(tx_hash))
       -            except TimeoutException as e:
       -                self.print_error('getting input txn from network timed out for {}'.format(tx_hash))
       +                raw_tx = self.network.run_from_another_thread(
       +                    self.network.get_transaction(tx_hash, timeout=10))
       +            except RequestTimedOut as e:
       +                self.print_error(f'getting input txn from network timed out for {tx_hash}')
                        if not ignore_timeout:
                            raise e
       +            else:
       +                tx = Transaction(raw_tx)
                return tx
        
            def add_hw_info(self, tx):