URI: 
       tinstanciate LNWorker without Network - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit e6d680ec1bec8d6d091403dd48780957cece7987
   DIR parent 7cf4f40dcb328bb95cae460213373401991cb2b8
  HTML Author: ThomasV <thomasv@electrum.org>
       Date:   Sat, 26 Jan 2019 17:57:00 +0100
       
       instanciate LNWorker without Network
       
       Diffstat:
         M electrum/lnworker.py                |      12 +++++++-----
         M electrum/wallet.py                  |       5 +++--
       
       2 files changed, 10 insertions(+), 7 deletions(-)
       ---
   DIR diff --git a/electrum/lnworker.py b/electrum/lnworker.py
       t@@ -64,15 +64,12 @@ encoder = ChannelJsonEncoder()
        
        class LNWorker(PrintError):
        
       -    def __init__(self, wallet: 'Abstract_Wallet', network: 'Network'):
       +    def __init__(self, wallet: 'Abstract_Wallet'):
                self.wallet = wallet
                # invoices we are currently trying to pay (might be pending HTLCs on a commitment transaction)
                self.paying = self.wallet.storage.get('lightning_payments_inflight', {}) # type: Dict[bytes, Tuple[str, Optional[int], str]]
                self.sweep_address = wallet.get_receiving_address()
       -        self.network = network
       -        self.channel_db = self.network.channel_db
                self.lock = threading.RLock()
       -        self.config = network.config
                self.ln_keystore = self._read_ln_keystore()
                self.node_keypair = generate_keypair(self.ln_keystore, LnKeyFamily.NODE_KEY, 0)
                self.peers = {}  # type: Dict[bytes, Peer]  # pubkey -> Peer
       t@@ -80,13 +77,18 @@ class LNWorker(PrintError):
                self.channels = {}  # type: Dict[bytes, Channel]
                for x in wallet.storage.get("channels", []):
                    c = Channel(x, sweep_address=self.sweep_address, payment_completed=self.payment_completed)
       -            c.lnwatcher = network.lnwatcher
                    c.get_preimage_and_invoice = self.get_invoice
                    self.channels[c.channel_id] = c
                    c.set_remote_commitment()
                    c.set_local_commitment(c.current_commitment(LOCAL))
       +
       +    def start_network(self, network: 'Network'):
       +        self.network = network
       +        self.config = network.config
       +        self.channel_db = self.network.channel_db
                for chan_id, chan in self.channels.items():
                    self.network.lnwatcher.watch_channel(chan.get_funding_address(), chan.funding_outpoint.to_str())
       +            chan.lnwatcher = network.lnwatcher
                self._last_tried_peer = {}  # LNPeerAddr -> unix timestamp
                self._add_peers_from_config()
                # wait until we see confirmations
   DIR diff --git a/electrum/wallet.py b/electrum/wallet.py
       t@@ -229,10 +229,11 @@ class Abstract_Wallet(AddressSynchronizer):
                if self.storage.get('wallet_type') is None:
                    self.storage.put('wallet_type', self.wallet_type)
        
       +        # lightning
       +        self.lnworker = LNWorker(self)
                # invoices and contacts
                self.invoices = InvoiceStore(self.storage)
                self.contacts = Contacts(self.storage)
       -
                self._coin_price_cache = {}
        
            def stop_threads(self):
       t@@ -249,7 +250,7 @@ class Abstract_Wallet(AddressSynchronizer):
        
            def start_network(self, network):
                AddressSynchronizer.start_network(self, network)
       -        self.lnworker = LNWorker(self, network)
       +        self.lnworker.start_network(network)
        
            def load_and_cleanup(self):
                self.load_keystore()