TransactionInputSet

class cometa.transaction_body.transaction_input_set.TransactionInputSet(ptr=None)[source]

Bases: Set[TransactionInput]

Represents an ordered set of transaction inputs.

Transaction inputs are unique references to UTXOs being spent. The set maintains ordering and prevents duplicates.

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

None

__enter__()[source]
Return type:

TransactionInputSet

__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 TransactionInputSet from CBOR data.

Parameters:

reader (CborReader) – A CborReader positioned at the input set data.

Returns:

A new TransactionInputSet deserialized from the CBOR data.

Raises:

CardanoError – If deserialization fails.

Return type:

TransactionInputSet

classmethod from_list(inputs)[source]

Creates a TransactionInputSet from an iterable of TransactionInput objects.

Parameters:

inputs (Iterable[TransactionInput]) – An iterable of TransactionInput objects.

Returns:

A new TransactionInputSet containing all the inputs.

Raises:

CardanoError – If creation fails.

Return type:

TransactionInputSet

Example

>>> input1 = TransactionInput.from_hex(tx_hash1, 0)
>>> input2 = TransactionInput.from_hex(tx_hash2, 1)
>>> input_set = TransactionInputSet.from_list([input1, input2])
to_cbor(writer)[source]

Serializes the input set to CBOR format.

Parameters:

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

Raises:

CardanoError – If serialization fails.

Return type:

None

add(tx_input)[source]

Adds a transaction input to the set.

Parameters:

tx_input (TransactionInput) – The TransactionInput to add.

Raises:

CardanoError – If addition fails.

Return type:

None

get(index)[source]

Retrieves a transaction input at the specified index.

Parameters:

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

Returns:

The TransactionInput at the specified index.

Raises:
  • CardanoError – If retrieval fails.

  • IndexError – If index is out of bounds.

Return type:

TransactionInput

property is_tagged: bool

Whether this set uses Conway era tagged encoding.

Returns:

True if using tagged encoding, False otherwise.

__len__()[source]

Returns the number of inputs in the set.

Return type:

int

__iter__()[source]

Iterates over all inputs in the set.

Return type:

Iterator[TransactionInput]

__getitem__(index)[source]

Gets an input by index using bracket notation.

Parameters:

index (int)

Return type:

TransactionInput

__bool__()[source]

Returns True if the set 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

__contains__(item)[source]

Checks if an item is in the set.

Parameters:

item (object)

Return type:

bool

isdisjoint(other)[source]

Returns True if the set has no elements in common with other.

Parameters:

other (Iterable[TransactionInput]) – Another iterable to compare with.

Returns:

True if the sets are disjoint.

Return type:

bool