def generate_matching_address(prefix, cores='all'): # pragma: no cover for char in prefix: if char not in BASE58_ALPHABET: raise ValueError('{} is an invalid base58 encoded ' 'character.'.format(char)) if not prefix: return generate_key_address_pair() elif not prefix.startswith('1'): prefix = '1' + prefix available_cores = cpu_count() if cores == 'all': cores = available_cores elif 0 < int(cores) <= available_cores: cores = int(cores) else: cores = 1 counter = Value('i') match = Event() queue = Queue() workers = [] for _ in range(cores): workers.append( Process(target=generate_key_address_pairs, args=(prefix, counter, match, queue))) for worker in workers: worker.start() keys_generated = 0 while True: time.sleep(1) current = counter.value if current == keys_generated: if current == 0: continue break keys_generated = current s = 'Keys generated: {}\r'.format(keys_generated) sys.stdout.write(s) sys.stdout.flush() private_key, address = queue.get() print('\n\n' 'WIF: {}\n' 'Address: {}'.format(bytes_to_wif(private_key), address))
def to_wif(self): return bytes_to_wif(self._pk.secret, version='test', compressed=self.is_compressed())
def to_wif(self): return bytes_to_wif(self._pk.secret, prefix=self.prefix, compressed=self.is_compressed())
def generate_key_address_pair(): # pragma: no cover private_key = ECPrivateKey() address = public_key_to_address(private_key.public_key.format()) return bytes_to_wif(private_key.secret), address
def test_compressed_testnet(self): assert bytes_to_wif(PRIVATE_KEY_BYTES, version='test', compressed=True) == WALLET_FORMAT_COMPRESSED_TEST
def test_compressed(self): assert bytes_to_wif(PRIVATE_KEY_BYTES, compressed=True) == WALLET_FORMAT_COMPRESSED_MAIN
def test_testnet(self): assert bytes_to_wif(PRIVATE_KEY_BYTES, version='test') == WALLET_FORMAT_TEST
def test_mainnet(self): assert bytes_to_wif(PRIVATE_KEY_BYTES) == WALLET_FORMAT_MAIN