Ipv6
- class cometa.pool_params.ipv6.IPv6(ptr)[source]
Bases:
objectRepresents 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
- 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:
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:
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:
- 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