URI: 
       tfix bug if headers file is empty - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit feb0f483f5e070a678bdb10a713bfad4cb144b2e
   DIR parent 97343d95e57d2045144f5404683ef6aeafcaa8f3
  HTML Author: ThomasV <thomasv@electrum.org>
       Date:   Wed, 19 Jul 2017 17:23:46 +0200
       
       fix bug if headers file is empty
       
       Diffstat:
         M lib/blockchain.py                   |       2 ++
         M lib/network.py                      |      16 ++++++++++++----
       
       2 files changed, 14 insertions(+), 4 deletions(-)
       ---
   DIR diff --git a/lib/blockchain.py b/lib/blockchain.py
       t@@ -286,6 +286,8 @@ class Blockchain(util.PrintError):
                height = header['block_height']
                if self.height() != height - 1:
                    return False
       +        if height == 0:
       +            return hash_header(header) == bitcoin.GENESIS
                previous_header = self.read_header(height -1)
                if not previous_header:
                    return False
   DIR diff --git a/lib/network.py b/lib/network.py
       t@@ -990,11 +990,19 @@ class Network(util.DaemonThread):
                    self.notify('interfaces')
                    self.switch_lagging_interface()
                    return
       -        interface.mode = 'backward'
       -        interface.bad = height
       -        interface.bad_header = header
                tip = max([x.height() for x in self.blockchains.values()])
       -        self.request_header(interface, tip)
       +        if tip >=0:
       +            interface.mode = 'backward'
       +            interface.bad = height
       +            interface.bad_header = header
       +            self.request_header(interface, tip)
       +        else:
       +            chain = self.blockchains[0]
       +            if chain.catch_up is None:
       +                chain.catch_up = interface
       +                interface.mode = 'catch_up'
       +                interface.blockchain = chain
       +                self.request_header(interface, 0)
        
            def blockchain(self):
                if self.interface and self.interface.blockchain is not None: