def main(args):
    if len(args) != 3:
        return print_help()
    keys = None
    with open(args[0], 'rb') as fd:
        dec = bencode.BCodec(fd)
        keys = dec.decode()
    runner = AddrGen(int(args[2]), keys, args[1])
    keys[b'x'], addr = runner.runit()
    if addr:
        print("found {}.coinicles".format(addr))
        with open(args[0], 'wb') as fd:
            enc = bencode.BCodec(fd)
            enc.encode(keys)
 def _runner(self):
     while self.sync[2] == 0:
         time.sleep(1)
         self._print_stats()
     self._joinall()
     fd = BytesIO()
     enc = bencode.BCodec(fd)
     hi = self.sync[0]
     lo = self.sync[1]
     si = _gen_si(self._keys)
     si['x'] = struct.pack('>QQ', lo, hi)
     enc.encode(si)
     pub = bytes(fd.getbuffer())
     addr = zb32_encode(libnacl.crypto_generichash(pub))
     return si['x'], addr
 def _gen_addr_tick(self, prefix, lo, hi, si):
     print(prefix)
     fd = BytesIO()
     addr = ''
     enc = bencode.BCodec(fd)
     while self.sync[2] == 0:
         si['x'] = struct.pack('>QQ', lo, hi)
         fd.seek(0, 0)
         enc.encode(si)
         pub = bytes(fd.getbuffer())
         addr = zb32_encode(libnacl.crypto_generichash(pub))
         if addr.startswith(prefix):
             self.sync[2] = 1
             self.sync[0] = hi
             self.sync[1] = lo
             return
         hi += self._inc
         if hi == 0:
             lo += 1
         self._c.value += 1