Ipv6

class cometa.pool_params.ipv6.IPv6(ptr)[source]

Bases: object

Represents an IPv6 address used in Cardano stake pool relay configuration.

IPv6 addresses are 16 bytes (128 bits) and are used to identify single-host address relays in stake pool registration certificates.

IP_SIZE = 16
__init__(ptr)[source]
Return type:

None

__enter__()[source]
Return type:

IPv6

__exit__(exc_type, exc_val, exc_tb)[source]
Return type:

None

__repr__()[source]

Return repr(self).

Return type:

str

__str__()[source]

Return str(self).

Return type:

str

__eq__(other)[source]

Return self==value.

Parameters:

other (object)

Return type:

bool

__hash__()[source]

Return hash(self).

Return type:

int

classmethod from_bytes(data)[source]

Creates an IPv6 address from raw bytes.

Parameters:

data (bytes | bytearray) – The raw IPv6 bytes (must be exactly 16 bytes).

Returns:

A new IPv6 address.

Raises:

CardanoError – If the bytes are invalid.

Return type:

IPv6

Example

>>> ipv6 = IPv6.from_bytes(bytes([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]))
>>> str(ipv6)
'::1'
classmethod from_string(ip_string)[source]

Creates an IPv6 address from a string.

Parameters:

ip_string (str) – The IPv6 address in standard notation (e.g., “::1” or “2001:db8::1”).

Returns:

A new IPv6 address.

Raises:

CardanoError – If the string is not a valid IPv6 address.

Return type:

IPv6

Example

>>> ipv6 = IPv6.from_string("::1")
>>> ipv6.to_bytes()[-1]
1
classmethod from_cbor(reader)[source]

Deserializes an IPv6 address from CBOR data.

Parameters:

reader (CborReader) – A CborReader positioned at the IPv6 data.

Returns:

A new IPv6 address deserialized from the CBOR data.

Raises:

CardanoError – If deserialization fails.

Return type:

IPv6

to_bytes()[source]

Returns the raw IPv6 bytes.

Returns:

The IPv6 address as a 16-byte bytes object.

Return type:

bytes

Example

>>> ipv6 = IPv6.from_string("::1")
>>> len(ipv6.to_bytes())
16
to_string()[source]

Returns the IPv6 address in standard notation.

Returns:

db8::1”).

Return type:

The IPv6 address as a string (e.g., “::1” or “2001

Example

>>> ipv6 = IPv6.from_bytes(bytes([0]*15 + [1]))
>>> ipv6.to_string()
'::1'
to_cbor(writer)[source]

Serializes the IPv6 address to CBOR format.

Parameters:

writer (CborWriter) – A CborWriter to write the serialized data to.

Raises:

CardanoError – If serialization fails.

Return type:

None