def convert_private_key_to_wif_format(private_key, secret_prefix_bytes, compressed=True): bin_private_key = private_key.to_bytes(32, byteorder='big') input_data = secret_prefix_bytes + bin_private_key if compressed: input_data += b'\x01' check_sum = double_sha256(input_data).digest()[:4] return bytes_to_base58(input_data + check_sum)
def test_bytes_to_base58(bytes_input, result_b58): assert bytes_to_base58(bytes_input) == result_b58
def calculate_address(digest, address_prefix_bytes): input_data = address_prefix_bytes + digest check_sum = double_sha256(input_data).digest()[:4] address = bytes_to_base58(input_data + check_sum) return address
def get_address_range(address_prefix_bytes): low_threshold = address_prefix_bytes + b'\x00' * 24 high_threshold = address_prefix_bytes + b'\xff' * 24 start_address = bytes_to_base58(low_threshold) end_address = bytes_to_base58(high_threshold) return start_address, end_address