def _read_wallet(self): self.address_bundle = [] if not os.path.isfile(self.wallet_dat_filename): upgraded = self._upgrade_old_wallet() if not upgraded: return try: logger.info('Retrieving wallet file') with open(self.wallet_dat_filename, "rb") as infile: wallet_store = qrl_pb2.WalletStore() wallet_store.ParseFromString(bytes(infile.read())) self.address_bundle = [] for a in wallet_store.wallets: tmpxmss = XMSS(config.dev.xmss_tree_height, mnemonic2bin(a.mnemonic.strip())) tmpxmss.set_index(a.xmss_index) if a.address != tmpxmss.get_address(): logger.fatal("Mnemonic and address do not match.") exit(1) self.address_bundle.append( AddressBundle(tmpxmss.get_address().encode(), tmpxmss)) except Exception as e: logger.warning("It was not possible to open the wallet: %s", e)
def get_ntp_response(): for retry in range(NTP_RETRIES): ntp_server = ntp_servers[retry % len(ntp_servers)] try: ntp_client = NTPClient() response = ntp_client.request(ntp_server, version=NTP_VERSION) except Exception as e: logger.warning(e) continue return response # FIXME: Provide some proper clean before exiting logger.fatal("Could not contact NTP servers after %d retries", NTP_RETRIES) sys.exit(-1)