diff --git a/electrum/network.py b/electrum/network.py index d8ae2d105..87c477b4c 100644 --- a/electrum/network.py +++ b/electrum/network.py @@ -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] @@ -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 @@ -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') diff --git a/electrum/wallet.py b/electrum/wallet.py index 7480b95a3..45ac00f02 100644 --- a/electrum/wallet.py +++ b/electrum/wallet.py @@ -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))