TransactionInput
- class cometa.transaction_body.transaction_input.TransactionInput(ptr)[source]
Bases:
objectRepresents a reference to an unspent transaction output (UTXO) being spent.
A transaction input consists of: - Transaction ID: The hash of the transaction containing the UTXO - Index: The index of the output within that transaction
- classmethod new(transaction_id, index)[source]
Creates a new TransactionInput.
- Parameters:
transaction_id (bytes) – The 32-byte transaction hash.
index (int) – The output index within the transaction.
- Returns:
A new TransactionInput instance.
- Raises:
CardanoError – If creation fails.
- Return type:
- classmethod from_hex(transaction_id_hex, index)[source]
Creates a new TransactionInput from a hex-encoded transaction ID.
- Parameters:
transaction_id_hex (str) – The transaction hash as a hex string.
index (int) – The output index within the transaction.
- Returns:
A new TransactionInput instance.
- Raises:
CardanoError – If creation fails.
- Return type:
- classmethod from_cbor(reader)[source]
Deserializes a TransactionInput from CBOR data.
- Parameters:
reader (CborReader) – A CborReader positioned at the input data.
- Returns:
A new TransactionInput deserialized from the CBOR data.
- Raises:
CardanoError – If deserialization fails.
- Return type:
- to_cbor(writer)[source]
Serializes the transaction input to CBOR format.
- Parameters:
writer (CborWriter) – A CborWriter to write the serialized data to.
- Raises:
CardanoError – If serialization fails.
- Return type:
None
- to_cip116_json(writer)[source]
Serializes this transaction input to CIP-116 JSON format.
CIP-116 defines a standard JSON representation for Cardano transactions.
- Parameters:
writer – A JsonWriter to write the serialized data to.
- Raises:
CardanoError – If serialization fails.
- Return type:
None
Example
>>> from cometa.json import JsonWriter >>> input = TransactionInput.from_hex(tx_hash, 0) >>> writer = JsonWriter() >>> input.to_cip116_json(writer) >>> json_str = writer.encode()
- property transaction_id: bytes
The transaction ID (hash of the transaction containing the UTXO).
- Returns:
The 32-byte transaction hash.
- property index: int
The output index within the transaction.
- Returns:
The output index.
- __eq__(other)[source]
Checks equality with another TransactionInput.
- Parameters:
other (object)
- Return type:
bool
- __lt__(other)[source]
Compares this input with another for ordering.
- Parameters:
other (TransactionInput)
- Return type:
bool