URI: 
       twallet: don't try to get_input_tx from network when offline - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit bde415cae781f12a96d7d971ecfd641d76c20bfb
   DIR parent 292016d28375c8412c790ee77efd34f7c38b1c33
  HTML Author: SomberNight <somber.night@protonmail.com>
       Date:   Wed, 14 Oct 2020 19:30:10 +0200
       
       wallet: don't try to get_input_tx from network when offline
       
       related: https://github.com/spesmilo/electrum/issues/6648#issuecomment-708499893
       
       Trying to fetch the prev tx from the network is a blocking operation with
       a 10 sec timeout - we should not hang for 10 seconds if there is no network connection.
       
       Diffstat:
         M electrum/network.py                 |       6 ++++++
         M electrum/wallet.py                  |       2 +-
       
       2 files changed, 7 insertions(+), 1 deletion(-)
       ---
   DIR diff --git a/electrum/network.py b/electrum/network.py
       t@@ -328,6 +328,7 @@ class Network(Logger, NetworkRetryManager[ServerAddr]):
                self.debug = False
        
                self._set_status('disconnected')
       +        self._has_ever_managed_to_connect_to_server = False
        
                # lightning network
                self.channel_db = None  # type: Optional[ChannelDB]
       t@@ -339,6 +340,10 @@ class Network(Logger, NetworkRetryManager[ServerAddr]):
                    self.local_watchtower.start_network(self)
                    asyncio.ensure_future(self.local_watchtower.start_watching())
        
       +    def has_internet_connection(self) -> bool:
       +        """Our guess whether the device has Internet-connectivity."""
       +        return self._has_ever_managed_to_connect_to_server
       +
            def is_lightning_running(self):
                return self.channel_db is not None
        
       t@@ -768,6 +773,7 @@ class Network(Logger, NetworkRetryManager[ServerAddr]):
                if server == self.default_server:
                    await self.switch_to_interface(server)
        
       +        self._has_ever_managed_to_connect_to_server = True
                self._add_recent_server(server)
                util.trigger_callback('network_updated')
        
   DIR diff --git a/electrum/wallet.py b/electrum/wallet.py
       t@@ -1613,7 +1613,7 @@ class Abstract_Wallet(AddressSynchronizer, ABC):
                # will likely be.  If co-signing a transaction it may not have
                # all the input txs, in which case we ask the network.
                tx = self.db.get_transaction(tx_hash)
       -        if not tx and self.network:
       +        if not tx and self.network and self.network.has_internet_connection():
                    try:
                        raw_tx = self.network.run_from_another_thread(
                            self.network.get_transaction(tx_hash, timeout=10))