def generate_key_address_pair(): private_key = generate_private_key() public_key = point_to_public_key(private_key.public_key().public_numbers(), compressed=True) address = public_key_to_address(public_key) return int_to_hex(private_key.private_numbers().private_value), address
def generate_key_address_pair(): private_key = gen_privkey(SECP256K1, DEFAULT_BACKEND) public_key = point_to_public_key(private_key.public_key().public_numbers(), compressed=True) bitcoin_address = public_key_to_address(public_key) return int_to_hex( private_key.private_numbers().private_value), bitcoin_address
def stream_key_address_pairs(queue, event): # pragma: no cover while True: private_key = generate_private_key() public_key = point_to_public_key( private_key.public_key().public_numbers(), compressed=True) address = public_key_to_address(public_key) queue.put_nowait( (private_key.private_numbers().private_value, address)) if event.is_set(): return
def address(self): """The public address you share with others to receive funds.""" if self._address is None: self._address = public_key_to_address(self._public_key, version='test') return self._address
def test_public_key_to_address_test_uncompressed(self): assert public_key_to_address(PUBLIC_KEY_UNCOMPRESSED, version='test') == BITCOIN_ADDRESS_TEST
def test_public_key_to_address_incorrect_length(self): with pytest.raises(ValueError): public_key_to_address(PUBLIC_KEY_COMPRESSED[:-1])
def test_public_key_to_address_uncompressed(self): assert public_key_to_address(PUBLIC_KEY_UNCOMPRESSED) == BITCOIN_ADDRESS
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