TransactionOutputList

class cometa.transaction_body.transaction_output_list.TransactionOutputList(ptr=None)[source]

Bases: Sequence[TransactionOutput]

Represents an ordered list of transaction outputs.

Transaction outputs specify where funds are sent in a transaction, including the recipient address and the value being transferred.

__init__(ptr=None)[source]
Return type:

None

__enter__()[source]
Return type:

TransactionOutputList

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

None

__repr__()[source]

Return repr(self).

Return type:

str

classmethod from_cbor(reader)[source]

Deserializes a TransactionOutputList from CBOR data.

Parameters:

reader (CborReader) – A CborReader positioned at the output list data.

Returns:

A new TransactionOutputList deserialized from the CBOR data.

Raises:

CardanoError – If deserialization fails.

Return type:

TransactionOutputList

classmethod from_list(outputs)[source]

Creates a TransactionOutputList from an iterable of TransactionOutput objects.

Parameters:

outputs (Iterable[TransactionOutput]) – An iterable of TransactionOutput objects.

Returns:

A new TransactionOutputList containing all the outputs.

Raises:

CardanoError – If creation fails.

Return type:

TransactionOutputList

Example

>>> output1 = TransactionOutput.new(address1, 1000000)
>>> output2 = TransactionOutput.new(address2, 2000000)
>>> output_list = TransactionOutputList.from_list([output1, output2])
to_cbor(writer)[source]

Serializes the output list to CBOR format.

Parameters:

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

Raises:

CardanoError – If serialization fails.

Return type:

None

add(output)[source]

Adds a transaction output to the list.

Parameters:

output (TransactionOutput) – The TransactionOutput to add.

Raises:

CardanoError – If addition fails.

Return type:

None

get(index)[source]

Retrieves a transaction output at the specified index.

Parameters:

index (int) – The index of the output to retrieve.

Returns:

The TransactionOutput at the specified index.

Raises:
  • CardanoError – If retrieval fails.

  • IndexError – If index is out of bounds.

Return type:

TransactionOutput

__len__()[source]

Returns the number of outputs in the list.

Return type:

int

__iter__()[source]

Iterates over all outputs in the list.

Return type:

Iterator[TransactionOutput]

__getitem__(index)[source]

Gets an output by index using bracket notation.

Parameters:

index (int)

Return type:

TransactionOutput

__bool__()[source]

Returns True if the list is not empty.

Return type:

bool

to_cip116_json(writer)[source]

Serializes this object to CIP-116 compliant JSON.

Parameters:

writer (JsonWriter) – The JsonWriter to write the JSON to.

Raises:

CardanoError – If serialization fails.

Return type:

None

index(value, start=0, stop=None)[source]

Returns the index of the first occurrence of value.

Parameters:
  • value (TransactionOutput) – The value to search for.

  • start (int) – Start searching from this index.

  • stop (int | None) – Stop searching at this index.

Returns:

The index of the first occurrence.

Raises:

ValueError – If the value is not found.

Return type:

int

count(value)[source]

Returns the number of occurrences of value.

Parameters:

value (TransactionOutput) – The value to count.

Returns:

The number of occurrences.

Return type:

int