Transaction Body¶
-
typedef struct cardano_transaction_body_t cardano_transaction_body_t¶
The transaction body encapsulates the core details of a transaction.
-
cardano_error_t cardano_transaction_body_new(cardano_transaction_input_set_t *inputs, cardano_transaction_output_list_t *outputs, uint64_t fee, const uint64_t *ttl, cardano_transaction_body_t **transaction_body)¶
Creates and initializes a new instance of a Cardano transaction body.
This function allocates and initializes a new cardano_transaction_body_t object.
Usage Example:
cardano_transaction_input_set_t* inputs = ...; // Assume inputs are initialized cardano_transaction_output_list_t* outputs = ...; // Assume outputs are initialized uint64_t fee = 200000; // 0.2 ADA transaction fee uint64_t ttl_value = 100000; // Optional TTL for the transaction cardano_transaction_body_t* transaction_body = NULL; // Pass the TTL as a pointer cardano_error_t result = cardano_transaction_body_new(inputs, outputs, fee, &ttl_value, &transaction_body); if (result == CARDANO_SUCCESS) { // Use the transaction body // Free resources when done cardano_transaction_body_unref(&transaction_body); } else { printf("Failed to create the transaction body: %s\n", cardano_error_to_string(result)); } // If no TTL is required, set the ttl pointer to NULL cardano_error_t no_ttl_result = cardano_transaction_body_new(inputs, outputs, fee, NULL, &transaction_body);- Parameters:¶
- cardano_transaction_input_set_t *inputs¶
[in] A pointer to an initialized cardano_transaction_input_set_t object representing the set of transaction inputs. This parameter must not be NULL.
- cardano_transaction_output_list_t *outputs¶
[in] A pointer to an initialized cardano_transaction_output_list_t object representing the list of transaction outputs. This parameter must not be NULL.
- uint64_t fee¶
[in] The transaction fee, specified in lovelaces (1 ADA = 1,000,000 lovelaces).
- const uint64_t *ttl¶
[in] An optional pointer to a uint64_t representing the time-to-live (TTL) parameter, specified as a slot number. The transaction will be invalid if not included in a block by the time this slot is reached. If no TTL is required, this pointer can be set to NULL.
- cardano_transaction_body_t **transaction_body¶
[out] On successful initialization, this will point to a newly created cardano_transaction_body_t object. This object represents a “strong reference” to the transaction body, meaning that it is fully initialized and ready for use. The caller is responsible for managing the lifecycle of this object. Specifically, once the transaction body is no longer needed, the caller must release it by calling cardano_transaction_body_unref.
- Returns:¶
cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the transaction body was successfully created, or an appropriate error code indicating the failure reason, such as CARDANO_ERROR_POINTER_IS_NULL if any of the required input pointers (inputs, outputs) are NULL.
-
cardano_error_t cardano_transaction_body_from_cbor(cardano_cbor_reader_t *reader, cardano_transaction_body_t **transaction_body)¶
Creates a cardano_transaction_body_t from a CBOR reader.
This function parses CBOR data using a provided cardano_cbor_reader_t and constructs a cardano_transaction_body_t object. It assumes that the CBOR reader is set up correctly and that the CBOR data corresponds to the structure expected for a transaction body.
Usage Example:
cardano_cbor_reader_t* reader = cardano_cbor_reader_new(cbor_data, data_size); cardano_transaction_body_t* transaction_body = NULL; cardano_error_t result = cardano_transaction_body_from_cbor(reader, &transaction_body); if (result == CARDANO_SUCCESS) { // Use the transaction_body // Once done, ensure to clean up and release the transaction_body cardano_transaction_body_unref(&transaction_body); } else { const char* error = cardano_cbor_reader_get_last_error(reader); printf("Failed to decode transaction_body: %s\n", error); } cardano_cbor_reader_unref(&reader); // Cleanup the CBOR readerRemark
In Cardano, transactions are encoded in CBOR, but CBOR allows multiple valid ways to encode the same data. The Cardano blockchain does not enforce a canonical transaction representation, meaning that if you decode a transaction from CBOR and then re-encode it, the resulting encoding could be different. This would change the transaction body hash and invalidate any existing signatures. To prevent this, when a transaction body object is created using cardano_transaction_body_from_cbor, it caches the original CBOR representation internally. When cardano_transaction_body_to_cbor is called, it will output the cached CBOR. If the cached CBOR representation is not needed, the client can call cardano_transaction_body_clear_cbor_cache after the object has been created.
Note
If the function fails, the last error can be retrieved by calling cardano_cbor_reader_get_last_error with the reader. The caller is responsible for freeing the created cardano_transaction_body_t object by calling cardano_transaction_body_unref when it is no longer needed.
- Parameters:¶
- cardano_cbor_reader_t *reader¶
[in] A pointer to an initialized cardano_cbor_reader_t that is ready to read the CBOR-encoded data.
- cardano_transaction_body_t **transaction_body¶
[out] A pointer to a pointer of cardano_transaction_body_t that will be set to the address of the newly created transaction body object upon successful decoding.
- Returns:¶
A cardano_error_t value indicating the outcome of the operation. Returns CARDANO_SUCCESS if the transaction body was successfully created, or an appropriate error code if an error occurred.
-
cardano_error_t cardano_transaction_body_to_cbor(const cardano_transaction_body_t *transaction_body, cardano_cbor_writer_t *writer)¶
Serializes a transaction body into CBOR format using a CBOR writer.
This function serializes the given cardano_transaction_body_t object using a cardano_cbor_writer_t. If the transaction body was created by cardano_transaction_body_from_cbor, the function will use the cached CBOR representation to maintain the original encoding. This avoids potential differences in CBOR encoding which could invalidate signatures. If no cached CBOR is available, the function will serialize the transaction following the Cardano serialization format as outlined in CIP-21.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; cardano_cbor_writer_t* writer = cardano_cbor_writer_new(); if (writer) { cardano_error_t result = cardano_transaction_body_to_cbor(transaction_body, writer); if (result == CARDANO_SUCCESS) { // Use the writer's buffer containing the serialized data } else { const char* error_message = cardano_cbor_writer_get_last_error(writer); printf("Serialization failed: %s\n", error_message); } cardano_cbor_writer_unref(&writer); } cardano_transaction_body_unref(&transaction_body);Remark
If the transaction body object was created by cardano_transaction_body_from_cbor, the original CBOR encoding will be cached and reused by this function to prevent round-trip encoding issues that can change the transaction body hash and invalidate signatures. If the cached CBOR is not available or has been cleared, the function will serialize the transaction body in accordance with CIP-21.
- Parameters:¶
- const cardano_transaction_body_t *transaction_body¶
[in] A constant pointer to the cardano_transaction_body_t object that is to be serialized.
- cardano_cbor_writer_t *writer¶
[out] A pointer to a cardano_cbor_writer_t where the CBOR serialized data will be written. The writer must already be initialized and ready to accept the data.
- Returns:¶
Returns CARDANO_SUCCESS if the serialization is successful. If the
transaction_bodyorwriteris NULL, returns CARDANO_ERROR_POINTER_IS_NULL.
-
cardano_error_t cardano_transaction_body_to_cip116_json(const cardano_transaction_body_t *body, cardano_json_writer_t *writer)¶
Serializes a transaction body to CIP-116 JSON format.
This function takes a Cardano transaction body structure and converts all its components (inputs, outputs, fees, optional fields like collateral, mint, and governance data) into a single JSON object string compliant with the CIP-116 specification.
- Parameters:¶
- const cardano_transaction_body_t *body¶
[in] Pointer to the valid cardano_transaction_body_t object to be serialized.
- cardano_json_writer_t *writer¶
[in] Pointer to the active cardano_json_writer_t instance where the JSON output will be written.
- Returns:¶
CARDANO_SUCCESS On successful serialization.
- Returns:¶
CARDANO_ERROR_POINTER_IS_NULL If
bodyorwriteris NULL.- Returns:¶
CARDANO_ERROR_MEMORY_ALLOCATION_FAILED If memory allocation for internal hex strings fails.
- Returns:¶
Other Any error propagated from recursive serialization calls (e.g., cardano_transaction_input_set_to_cip116_json).
-
cardano_transaction_input_set_t *cardano_transaction_body_get_inputs(cardano_transaction_body_t *transaction_body)¶
Retrieves the set of transaction inputs from a transaction body.
This function returns the set of transaction inputs associated with a given cardano_transaction_body_t object. These inputs represent the UTXOs (Unspent Transaction Outputs) being used as inputs in the transaction.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is already initialized cardano_transaction_input_set_t* inputs = cardano_transaction_body_get_inputs(transaction_body); if (inputs != NULL) { // Process the inputs cardano_transaction_input_set_unref(&inputs); // Ensure to release the inputs when done } else { printf("Failed to retrieve transaction inputs or transaction body is NULL.\n"); }- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[in] A pointer to an initialized cardano_transaction_body_t object.
- Returns:¶
A pointer to a cardano_transaction_input_set_t object representing the set of transaction inputs. The returned object is a new reference, and the caller is responsible for managing its lifecycle. Specifically, the caller must release it by calling cardano_transaction_input_set_unref when it is no longer needed. If the
transaction_bodyis NULL, the function will return NULL.
-
cardano_error_t cardano_transaction_body_set_inputs(cardano_transaction_body_t *transaction_body, cardano_transaction_input_set_t *inputs)¶
Sets the transaction inputs for a transaction body.
This function assigns a set of transaction inputs to a cardano_transaction_body_t object. The inputs represent the UTXOs (Unspent Transaction Outputs) that will be used as inputs for the transaction.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is initialized cardano_transaction_input_set_t* inputs = ...; // Assume inputs is initialized cardano_error_t result = cardano_transaction_body_set_inputs(transaction_body, inputs); if (result == CARDANO_SUCCESS) { printf("Transaction inputs successfully set.\n"); } else { printf("Failed to set transaction inputs: %s\n", cardano_error_to_string(result)); } // Clean up resources when no longer needed cardano_transaction_input_set_unref(&inputs); cardano_transaction_body_unref(&transaction_body);Note
This function increases the reference count of the
inputsobject; the caller retains ownership of the inputs and must release their reference to the inputs when no longer needed by calling cardano_transaction_input_set_unref.- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[inout] A pointer to an initialized cardano_transaction_body_t object.
- cardano_transaction_input_set_t *inputs¶
[in] A pointer to an initialized cardano_transaction_input_set_t object representing the inputs to be set. This parameter must not be NULL.
- Returns:¶
A cardano_error_t value indicating the outcome of the operation. Returns CARDANO_SUCCESS if the inputs were successfully set. Returns CARDANO_ERROR_POINTER_IS_NULL if either the
transaction_bodyorinputsis NULL.
-
cardano_transaction_output_list_t *cardano_transaction_body_get_outputs(cardano_transaction_body_t *transaction_body)¶
Retrieves the list of outputs from a transaction body.
This function returns the list of outputs associated with a given cardano_transaction_body_t object. The outputs represent the recipients and amounts being transferred as part of the transaction.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is initialized cardano_transaction_output_list_t* outputs = cardano_transaction_body_get_outputs(transaction_body); if (outputs != NULL) { // Use the outputs list // Clean up resources when no longer needed cardano_transaction_output_list_unref(&outputs); } else { printf("Failed to retrieve transaction outputs or no outputs exist.\n"); } cardano_transaction_body_unref(&transaction_body);- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[in] A pointer to an initialized cardano_transaction_body_t object.
- Returns:¶
A pointer to a cardano_transaction_output_list_t object representing the list of transaction outputs. If the
transaction_bodyis NULL or there are no outputs, this function returns NULL. The caller is responsible for managing the lifecycle of the returned list by calling cardano_transaction_output_list_unref when it is no longer needed.
-
cardano_error_t cardano_transaction_body_set_outputs(cardano_transaction_body_t *transaction_body, cardano_transaction_output_list_t *outputs)¶
Sets the list of outputs for a transaction body.
This function assigns a new list of outputs to the specified cardano_transaction_body_t object. The outputs represent the recipients and amounts that are being transferred in the transaction.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is already initialized cardano_transaction_output_list_t* outputs = ...; // Assume outputs are initialized cardano_error_t result = cardano_transaction_body_set_outputs(transaction_body, outputs); if (result == CARDANO_SUCCESS) { printf("Transaction outputs successfully set.\n"); } else { printf("Failed to set transaction outputs.\n"); } // Clean up resources when no longer needed cardano_transaction_body_unref(&transaction_body); cardano_transaction_output_list_unref(&outputs);Note
This function increases the reference count of the
outputsobject, so the caller retains ownership of their respective references. It is the caller’s responsibility to release their reference to the outputs when they are no longer needed.- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[inout] A pointer to an initialized cardano_transaction_body_t object where the outputs will be set.
- cardano_transaction_output_list_t *outputs¶
[in] A pointer to an initialized cardano_transaction_output_list_t object representing the list of transaction outputs. This value must not be NULL, and it will replace any existing outputs in the
transaction_body.
- Returns:¶
cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the outputs were successfully set, or an appropriate error code indicating the failure reason, such as CARDANO_ERROR_POINTER_IS_NULL if any of the input pointers are NULL.
-
uint64_t cardano_transaction_body_get_fee(cardano_transaction_body_t *transaction_body)¶
Retrieves the fee associated with the transaction body.
This function returns the fee specified in the cardano_transaction_body_t object. The fee represents the amount of lovelace (Cardano’s native cryptocurrency) required to process the transaction.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is already initialized uint64_t fee = cardano_transaction_body_get_fee(transaction_body); if (fee > 0) { printf("Transaction fee: %llu lovelaces\n", fee); } else { printf("Failed to retrieve transaction fee.\n"); }- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[in] A pointer to an initialized cardano_transaction_body_t object. This value must not be NULL.
- Returns:¶
The fee amount in lovelaces. If the
transaction_bodypointer is NULL, the function will return 0.
-
cardano_error_t cardano_transaction_body_set_fee(cardano_transaction_body_t *transaction_body, uint64_t fee)¶
Sets the fee for the transaction body.
This function assigns a fee to the cardano_transaction_body_t object. The fee represents the amount of lovelace (Cardano’s native cryptocurrency) required to process the transaction.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is already initialized uint64_t fee = 200000; // Setting a fee of 200,000 lovelaces cardano_error_t result = cardano_transaction_body_set_fee(transaction_body, fee); if (result == CARDANO_SUCCESS) { printf("Transaction fee set successfully.\n"); } else { printf("Failed to set transaction fee: %s\n", cardano_error_to_string(result)); }- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[inout] A pointer to an initialized cardano_transaction_body_t object where the fee will be set.
- uint64_t fee¶
[in] The fee amount in lovelaces to be assigned to the transaction.
- Returns:¶
A cardano_error_t value indicating the outcome of the operation. Returns CARDANO_SUCCESS if the fee was successfully set, or an appropriate error code if an error occurred, such as CARDANO_ERROR_POINTER_IS_NULL if the
transaction_bodypointer is NULL.
-
const uint64_t *cardano_transaction_body_get_invalid_after(cardano_transaction_body_t *transaction_body)¶
Retrieves the “invalid after” value from the transaction body.
This function fetches the “invalid after” field from a cardano_transaction_body_t object, representing the slot number after which the transaction is considered invalid. This field is optional, and the function will return a pointer to a
uint64_tif the field is set, orNULLif it is not.Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume initialized const uint64_t* invalid_after = cardano_transaction_body_get_invalid_after(transaction_body); if (invalid_after != NULL) { printf("Transaction is invalid after slot: %llu\n", *invalid_after); } else { printf("No invalid_after field is set for this transaction.\n"); }- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[in] A pointer to an initialized cardano_transaction_body_t object.
- Returns:¶
A pointer to a
uint64_trepresenting the “invalid after” slot number if set. If this field is not set, the function will returnNULL. The returned pointer is managed internally and must not be freed by the caller. The caller can use the pointer to read the value but not modify or free it.
-
cardano_error_t cardano_transaction_body_set_invalid_after(cardano_transaction_body_t *transaction_body, const uint64_t *epoch)¶
Sets the “invalid after” field in the transaction body.
This function assigns a value to the “invalid after” field of a cardano_transaction_body_t object, specifying the slot number after which the transaction becomes invalid. The “invalid after” field is optional, and passing a
NULLpointer will unset the value, effectively removing the “invalid after” field from the transaction.Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume initialized uint64_t epoch = 123456; // Slot number cardano_error_t result = cardano_transaction_body_set_invalid_after(transaction_body, &epoch); if (result == CARDANO_SUCCESS) { printf("Invalid after field set to slot: %llu\n", epoch); } else { printf("Failed to set invalid after: %s\n", cardano_error_to_string(result)); } // To unset the invalid after field: result = cardano_transaction_body_set_invalid_after(transaction_body, NULL);- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[inout] A pointer to an initialized cardano_transaction_body_t object where the field will be set.
- const uint64_t *epoch¶
[in] A constant pointer to a
uint64_trepresenting the “invalid after” slot number. IfNULL, this will unset the field.
- Returns:¶
cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the field was successfully set or unset, or an appropriate error code if an error occurred, such as CARDANO_ERROR_POINTER_IS_NULL if
transaction_bodyis NULL.
-
cardano_certificate_set_t *cardano_transaction_body_get_certificates(cardano_transaction_body_t *transaction_body)¶
Retrieves the set of certificates associated with the transaction body.
This function returns the certificates from a cardano_transaction_body_t object, if they are present. Certificates in Cardano are used for various purposes, such as stake delegation and pool registration.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is initialized cardano_certificate_set_t* certificates = cardano_transaction_body_get_certificates(transaction_body); if (certificates != NULL) { // Process the certificates // Once done, ensure to clean up and release the certificate set cardano_certificate_set_unref(&certificates); } else { printf("No certificates present in the transaction body.\n"); }- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[in] A pointer to an initialized cardano_transaction_body_t object.
- Returns:¶
A pointer to a cardano_certificate_set_t object representing the set of certificates. If the transaction body does not contain any certificates, the function returns
NULL. If a valid certificate set is returned, it is a new reference, and the caller is responsible for managing its lifecycle. The caller must release the certificate set using cardano_certificate_set_unref when it is no longer needed.
-
cardano_error_t cardano_transaction_body_set_certificates(cardano_transaction_body_t *transaction_body, cardano_certificate_set_t *certificates)¶
Sets the certificates for the transaction body.
This function assigns a set of certificates to a cardano_transaction_body_t object. Certificates in Cardano are used for various purposes such as stake delegation, pool registration, and other governance actions.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume initialized cardano_certificate_set_t* certificates = ...; // Assume certificates are initialized cardano_error_t result = cardano_transaction_body_set_certificates(transaction_body, certificates); if (result == CARDANO_SUCCESS) { printf("Certificates were successfully set.\n"); } else { printf("Failed to set certificates: %s\n", cardano_error_to_string(result)); } // Clean up certificates and transaction_body when done cardano_certificate_set_unref(&certificates); cardano_transaction_body_unref(&transaction_body);Note
The function increases the reference count of the
certificatesobject. The caller retains ownership of the certificate set and is responsible for releasing it when it is no longer needed.- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[inout] A pointer to an initialized cardano_transaction_body_t object.
- cardano_certificate_set_t *certificates¶
[in] A pointer to an initialized cardano_certificate_set_t object representing the certificates to be assigned to the transaction body. The certificates must be properly initialized and cannot be NULL.
- Returns:¶
cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the certificates were successfully set, or an appropriate error code such as CARDANO_ERROR_POINTER_IS_NULL if either
transaction_bodyorcertificatesis NULL.
-
cardano_withdrawal_map_t *cardano_transaction_body_get_withdrawals(cardano_transaction_body_t *transaction_body)¶
Retrieves the withdrawals from a transaction body.
This function fetches the withdrawals specified in the given cardano_transaction_body_t object. Withdrawals allow the transaction to withdraw rewards from staking addresses.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is already initialized cardano_withdrawal_map_t* withdrawals = cardano_transaction_body_get_withdrawals(transaction_body); if (withdrawals != NULL) { // Process the withdrawals // Once done, ensure to release the withdrawals cardano_withdrawal_map_unref(&withdrawals); } else { printf("No withdrawals present in the transaction body.\n"); }Note
If the returned value is NULL, it indicates that there are no withdrawals set in the transaction body.
- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[in] A pointer to an initialized cardano_transaction_body_t object.
- Returns:¶
A pointer to a cardano_withdrawal_map_t object representing the withdrawals in the transaction body. If the transaction body does not contain any withdrawals, the function returns NULL. The returned cardano_withdrawal_map_t object is a new reference, and the caller is responsible for managing its lifecycle by calling cardano_withdrawal_map_unref when it is no longer needed.
-
cardano_error_t cardano_transaction_body_set_withdrawals(cardano_transaction_body_t *transaction_body, cardano_withdrawal_map_t *withdrawals)¶
Sets or unsets the withdrawals in the transaction body.
This function assigns a map of withdrawals to a cardano_transaction_body_t object. Withdrawals in Cardano represent the withdrawal of rewards from a stake address.
If
withdrawalsis NULL, this function will unset any previously assigned withdrawals from the transaction body.Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume initialized cardano_withdrawal_map_t* withdrawals = ...; // Assume withdrawals are initialized cardano_error_t result = cardano_transaction_body_set_withdrawals(transaction_body, withdrawals); if (result == CARDANO_SUCCESS) { printf("Withdrawals were successfully set.\n"); } else { printf("Failed to set withdrawals: %s\n", cardano_error_to_string(result)); } // Unset the withdrawals by passing NULL result = cardano_transaction_body_set_withdrawals(transaction_body, NULL); if (result == CARDANO_SUCCESS) { printf("Withdrawals were successfully unset.\n"); } // Clean up withdrawals and transaction_body when done cardano_withdrawal_map_unref(&withdrawals); cardano_transaction_body_unref(&transaction_body);Note
If
withdrawalsis non-NULL, the function increases the reference count of thewithdrawalsobject. The caller retains ownership of the withdrawal map and is responsible for releasing it when it is no longer needed.- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[inout] A pointer to an initialized cardano_transaction_body_t object.
- cardano_withdrawal_map_t *withdrawals¶
[in] A pointer to an initialized cardano_withdrawal_map_t object representing the withdrawals to be assigned to the transaction body, or NULL to unset any previously set withdrawals.
- Returns:¶
cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the withdrawals were successfully set or unset, or an appropriate error code such as CARDANO_ERROR_POINTER_IS_NULL if
transaction_bodyis NULL.
-
cardano_update_t *cardano_transaction_body_get_update(cardano_transaction_body_t *transaction_body)¶
Retrieves the update field from a transaction body.
This function fetches the update information, if any, from a given cardano_transaction_body_t object. Updates are used in Cardano transactions to propose changes to the protocol parameters.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is already initialized cardano_update_t* update = cardano_transaction_body_get_update(transaction_body); if (update != NULL) { // Use the update object // Clean up when done cardano_update_unref(&update); } else { printf("No update is set in this transaction body.\n"); }Note
The returned pointer may be NULL if no update is set in the transaction body.
- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[in] A pointer to an initialized cardano_transaction_body_t object.
- Returns:¶
A pointer to a cardano_update_t object representing the update field of the transaction body. If the update field is not set, the function returns NULL. If a valid cardano_update_t object is returned, it is a new reference, and the caller is responsible for managing its lifecycle. The returned cardano_update_t object must be released by calling cardano_update_unref when it is no longer needed.
-
cardano_error_t cardano_transaction_body_set_update(cardano_transaction_body_t *transaction_body, cardano_update_t *update)¶
Sets the update field in a transaction body.
This function assigns an update to a cardano_transaction_body_t object. Updates in a Cardano transaction can include protocol parameter changes.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is already initialized cardano_update_t* update = cardano_update_new(...); // Assume update is already initialized cardano_error_t result = cardano_transaction_body_set_update(transaction_body, update); if (result == CARDANO_SUCCESS) { printf("Update successfully set.\n"); } else { printf("Failed to set the update: %s\n", cardano_error_to_string(result)); } // Clean up when done cardano_update_unref(&update);Note
If a valid update object is provided, its reference count will be incremented. The caller retains ownership of their reference to the update object and is responsible for managing its lifecycle (e.g., by calling cardano_update_unref when the update is no longer needed).
Note
If
updateis NULL, the current update field in the transaction body will be removed.- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[inout] A pointer to an initialized cardano_transaction_body_t object where the update will be set.
- cardano_update_t *update¶
[in] A pointer to an initialized cardano_update_t object representing the update to be added to the transaction body. This parameter can be NULL, in which case the update field will be unset (cleared).
- Returns:¶
cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the update was successfully set, or an appropriate error code if an error occurred (e.g., CARDANO_ERROR_POINTER_IS_NULL if the transaction body pointer is NULL).
-
cardano_blake2b_hash_t *cardano_transaction_body_get_aux_data_hash(cardano_transaction_body_t *transaction_body)¶
Retrieves the auxiliary data hash from a transaction body.
This function fetches the auxiliary data hash associated with the given cardano_transaction_body_t object. The auxiliary data hash represents the hash of additional metadata included with the transaction.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is already initialized cardano_blake2b_hash_t* aux_data_hash = cardano_transaction_body_get_aux_data_hash(transaction_body); if (aux_data_hash != NULL) { // Process the auxiliary data hash cardano_blake2b_hash_unref(&aux_data_hash); // Clean up when done } else { printf("No auxiliary data hash found or transaction_body is NULL.\n"); }- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[in] A pointer to an initialized cardano_transaction_body_t object from which the auxiliary data hash will be retrieved.
- Returns:¶
A pointer to the cardano_blake2b_hash_t object representing the auxiliary data hash. If the auxiliary data hash is not set, or if the input is NULL, this function returns NULL. The returned object is a new reference, and the caller is responsible for releasing it by calling cardano_blake2b_hash_unref when it is no longer needed.
-
cardano_error_t cardano_transaction_body_set_aux_data_hash(cardano_transaction_body_t *transaction_body, cardano_blake2b_hash_t *aux_data_hash)¶
Sets the auxiliary data hash for a transaction body.
This function assigns a new auxiliary data hash to the given cardano_transaction_body_t object. The auxiliary data hash is used to reference additional metadata that may be included with the transaction.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is already initialized cardano_blake2b_hash_t* aux_data_hash = cardano_blake2b_hash_new(...); // Assume aux_data_hash is initialized cardano_error_t result = cardano_transaction_body_set_aux_data_hash(transaction_body, aux_data_hash); if (result == CARDANO_SUCCESS) { printf("Auxiliary data hash successfully set.\n"); } else { printf("Failed to set auxiliary data hash.\n"); } // Optionally clean up the aux_data_hash when no longer needed cardano_blake2b_hash_unref(&aux_data_hash);Note
If a valid auxiliary data hash object is provided, its reference count will be incremented. The caller retains ownership of their reference to the update object and is responsible for managing its lifecycle (e.g., by calling cardano_blake2b_hash_unref when the auxiliary data hash is no longer needed).
Note
If
aux_data_hashis set to NULL, it will clear the current auxiliary data hash in the transaction body, if any.- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[inout] A pointer to an initialized cardano_transaction_body_t object to which the auxiliary data hash will be set.
- cardano_blake2b_hash_t *aux_data_hash¶
[in] A pointer to an initialized cardano_blake2b_hash_t object representing the auxiliary data hash to set. This parameter can be NULL to unset or clear the auxiliary data hash.
- Returns:¶
cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the auxiliary data hash was successfully set, or an appropriate error code, such as CARDANO_ERROR_POINTER_IS_NULL if the
transaction_bodypointer is NULL.
-
const uint64_t *cardano_transaction_body_get_invalid_before(cardano_transaction_body_t *transaction_body)¶
Retrieves the “invalid before” field from a transaction body.
This function retrieves the “invalid before” field from a given cardano_transaction_body_t object. The “invalid before” field specifies the earliest slot in which the transaction is valid. If this field is not set, the function will return NULL.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is already initialized const uint64_t* invalid_before = cardano_transaction_body_get_invalid_before(transaction_body); if (invalid_before != NULL) { printf("Transaction invalid before slot: %llu\n", *invalid_before); } else { printf("Invalid before field not set.\n"); }- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[in] A pointer to an initialized cardano_transaction_body_t object.
- Returns:¶
A pointer to a
uint64_trepresenting the “invalid before” field. If the field is set, it returns a pointer to the value. If the field is not set, the function returns NULL. The returned pointer points to internally managed memory and must not be freed or modified by the caller.
-
cardano_error_t cardano_transaction_body_set_invalid_before(cardano_transaction_body_t *transaction_body, const uint64_t *epoch)¶
Sets the “invalid before” field in a transaction body.
This function sets the “invalid before” field in a given cardano_transaction_body_t object. The “invalid before” field specifies the earliest slot in which the transaction is valid.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is already initialized uint64_t invalid_before_slot = 500000; // Set the transaction to be valid after slot 500000 cardano_error_t result = cardano_transaction_body_set_invalid_before(transaction_body, &invalid_before_slot); if (result == CARDANO_SUCCESS) { printf("Successfully set the invalid before field.\n"); } else { printf("Failed to set the invalid before field.\n"); }// Unsetting the invalid before field:
result = cardano_transaction_body_set_invalid_before(transaction_body, NULL); if (result == CARDANO_SUCCESS) { printf("Successfully unset the invalid before field.\n"); } else { printf("Failed to unset the invalid before field.\n"); }- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[inout] A pointer to an initialized cardano_transaction_body_t object.
- const uint64_t *epoch¶
[in] A pointer to a
uint64_trepresenting the “invalid before” field. This specifies the earliest slot at which the transaction is valid. If this parameter is NULL, the “invalid before” field will be unset (i.e., removed from the transaction body).
- Returns:¶
A cardano_error_t value indicating the outcome of the operation. Returns CARDANO_SUCCESS if the “invalid before” field was successfully set or unset, or an appropriate error code indicating the failure reason, such as CARDANO_ERROR_POINTER_IS_NULL if the transaction body pointer is NULL.
-
cardano_multi_asset_t *cardano_transaction_body_get_mint(cardano_transaction_body_t *transaction_body)¶
Retrieves the mint field from a transaction body.
This function retrieves the minting assets contained in the mint field of the given cardano_transaction_body_t object. The mint field specifies the assets to be minted or burned in the transaction.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is already initialized cardano_multi_asset_t* mint_assets = cardano_transaction_body_get_mint(transaction_body); if (mint_assets != NULL) { // Use the mint assets // Once done, release the mint assets cardano_multi_asset_unref(&mint_assets); } else { printf("No mint field set in this transaction body.\n"); }- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[in] A pointer to an initialized cardano_transaction_body_t object.
- Returns:¶
A pointer to a newly created cardano_multi_asset_t object representing the minting/burning assets. If the mint field is not set, this function will return NULL. The caller is responsible for managing the lifecycle of the returned object, and must release it by calling cardano_multi_asset_unref when it is no longer needed.
-
cardano_error_t cardano_transaction_body_set_mint(cardano_transaction_body_t *transaction_body, cardano_multi_asset_t *mint)¶
Sets the mint field for a transaction body.
This function assigns the minting assets to the mint field of the specified cardano_transaction_body_t object. The mint field specifies the assets to be minted or burned in the transaction.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is already initialized cardano_multi_asset_t* mint_assets = ...; // Assume mint_assets is initialized cardano_error_t result = cardano_transaction_body_set_mint(transaction_body, mint_assets); if (result == CARDANO_SUCCESS) { printf("Mint field set successfully.\n"); } else { printf("Failed to set mint field: %s\n", cardano_error_to_string(result)); } // Clean up resources when no longer needed cardano_multi_asset_unref(&mint_assets);Note
This function increases the reference count of the mint object, if provided. The caller retains ownership of the provided mint object and must release it when it is no longer needed.
- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[inout] A pointer to an initialized cardano_transaction_body_t object to which the mint field will be set.
- cardano_multi_asset_t *mint¶
[in] A pointer to an initialized cardano_multi_asset_t object representing the assets to be minted or burned. This parameter can be NULL if the mint field should be unset (i.e., no assets to mint or burn).
- Returns:¶
cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the mint field was successfully set, or an appropriate error code indicating the failure reason, such as CARDANO_ERROR_POINTER_IS_NULL if the transaction_body pointer is NULL.
-
cardano_blake2b_hash_t *cardano_transaction_body_get_script_data_hash(cardano_transaction_body_t *transaction_body)¶
Retrieves the script data hash from a transaction body.
This function extracts the script data hash from a given cardano_transaction_body_t object. The script data hash is used in Cardano’s Plutus transactions to ensure the integrity of script data (datums and redeemers).
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is already initialized cardano_blake2b_hash_t* script_data_hash = cardano_transaction_body_get_script_data_hash(transaction_body); if (script_data_hash != NULL) { // Process the script data hash cardano_blake2b_hash_unref(&script_data_hash); } else { printf("No script data hash set for this transaction body.\n"); }Note
It is important to call cardano_transaction_body_get_script_data_hash only after ensuring the transaction body contains a script data hash. If the transaction body does not have this field set, the function will return NULL.
- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[in] A pointer to an initialized cardano_transaction_body_t object. This pointer must not be NULL.
- Returns:¶
A pointer to a cardano_blake2b_hash_t object representing the script data hash. If the script data hash is not set for the transaction body, the function returns NULL. The returned script data hash is a new reference, and the caller is responsible for releasing it with cardano_blake2b_hash_unref when it is no longer needed.
-
cardano_error_t cardano_transaction_body_set_script_data_hash(cardano_transaction_body_t *transaction_body, cardano_blake2b_hash_t *script_data_hash)¶
Sets the script data hash for a transaction body.
This function assigns a script data hash to a given cardano_transaction_body_t object. The script data hash is used in Cardano’s Plutus transactions to ensure the integrity of the script data (datums and redeemers).
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is already initialized cardano_blake2b_hash_t* script_data_hash = ...; // Assume script_data_hash is initialized cardano_error_t result = cardano_transaction_body_set_script_data_hash(transaction_body, script_data_hash); if (result == CARDANO_SUCCESS) { // The script data hash was successfully set for the transaction body } else { printf("Failed to set the script data hash.\n"); } // Cleanup resources if necessary cardano_blake2b_hash_unref(&script_data_hash);Note
If a script data hash was previously set, this function will replace it with the new value. If the script data hash is no longer needed, passing a NULL pointer will unset it.
- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[inout] A pointer to an initialized cardano_transaction_body_t object to which the script data hash will be set.
- cardano_blake2b_hash_t *script_data_hash¶
[in] A pointer to an initialized cardano_blake2b_hash_t object representing the new script data hash. This parameter can be NULL if the script data hash is to be unset.
- Returns:¶
cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the script data hash was successfully set, or an appropriate error code indicating the failure reason, such as CARDANO_ERROR_POINTER_IS_NULL if the transaction_body pointer is NULL.
-
cardano_transaction_input_set_t *cardano_transaction_body_get_collateral(cardano_transaction_body_t *transaction_body)¶
Retrieves the collateral inputs from a transaction body.
This function extracts the set of collateral inputs from a given cardano_transaction_body_t object. Collateral inputs are used in Plutus transactions to cover the fees if script execution fails.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is already initialized cardano_transaction_input_set_t* collateral_inputs = cardano_transaction_body_get_collateral(transaction_body); if (collateral_inputs != NULL) { // Use the collateral inputs cardano_transaction_input_set_unref(&collateral_inputs); } else { printf("No collateral inputs set for this transaction.\n"); }- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[in] A pointer to an initialized cardano_transaction_body_t object.
- Returns:¶
A pointer to a cardano_transaction_input_set_t object representing the collateral inputs of the transaction. If the collateral inputs are not set, this function returns NULL. The returned set is a new reference, and the caller is responsible for releasing it with cardano_transaction_input_set_unref when it is no longer needed.
-
cardano_error_t cardano_transaction_body_set_collateral(cardano_transaction_body_t *transaction_body, cardano_transaction_input_set_t *collateral)¶
Sets the collateral inputs for a transaction body.
This function assigns a set of collateral inputs to a cardano_transaction_body_t object. Collateral inputs are used in Plutus transactions to cover fees in case script execution fails.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is already initialized cardano_transaction_input_set_t* collateral_inputs = ...; // Assume collateral_inputs is initialized cardano_error_t result = cardano_transaction_body_set_collateral(transaction_body, collateral_inputs); if (result == CARDANO_SUCCESS) { printf("Collateral inputs successfully set.\n"); } else { printf("Failed to set collateral inputs: %s\n", cardano_error_to_string(result)); } // Clean up collateral_inputs if needed cardano_transaction_input_set_unref(&collateral_inputs);Note
If the collateral is set, the reference count of the
collateralobject will be incremented. The caller retains ownership of their references and is responsible for releasing their reference when it is no longer needed.- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[inout] A pointer to an initialized cardano_transaction_body_t object to which the collateral inputs will be set.
- cardano_transaction_input_set_t *collateral¶
[in] A pointer to an initialized cardano_transaction_input_set_t object representing the collateral inputs. This parameter can be NULL to unset the collateral inputs.
- Returns:¶
cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the collateral inputs were successfully set, or an appropriate error code such as CARDANO_ERROR_POINTER_IS_NULL if the transaction_body pointer is NULL.
-
cardano_blake2b_hash_set_t *cardano_transaction_body_get_required_signers(cardano_transaction_body_t *transaction_body)¶
Retrieves the set of required signers for a transaction body.
This function fetches the set of required signers from the given cardano_transaction_body_t object. Required signers are represented as hashes of public keys and are needed to authorize the transaction.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is already initialized cardano_blake2b_hash_set_t* required_signers = cardano_transaction_body_get_required_signers(transaction_body); if (required_signers != NULL) { // Use the required_signers set // Ensure to release the required_signers set once done cardano_blake2b_hash_set_unref(&required_signers); } else { printf("No required signers are set for this transaction body.\n"); }Note
If the returned value is NULL, it means there are no required signers for this transaction body.
- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[in] A pointer to an initialized cardano_transaction_body_t object.
- Returns:¶
A pointer to a cardano_blake2b_hash_set_t object representing the set of required signers. If no required signers are set, this function returns NULL. If a set of required signers is returned, it is a new reference, and the caller is responsible for releasing it by calling cardano_blake2b_hash_set_unref when no longer needed.
-
cardano_error_t cardano_transaction_body_set_required_signers(cardano_transaction_body_t *transaction_body, cardano_blake2b_hash_set_t *required_signers)¶
Sets the required signers for a transaction body.
This function assigns a set of required signers to the given cardano_transaction_body_t object. Required signers are represented as hashes of public keys and are necessary to authorize the transaction.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is already initialized cardano_blake2b_hash_set_t* required_signers = ...; // Assume required_signers is initialized cardano_error_t result = cardano_transaction_body_set_required_signers(transaction_body, required_signers); if (result == CARDANO_SUCCESS) { // Required signers successfully set for the transaction body } else { printf("Failed to set required signers.\n"); } // Clean up the required signers if necessary cardano_blake2b_hash_set_unref(&required_signers);Note
If the required signers are no longer needed or need to be cleared, passing a NULL value for the
required_signersparameter will unset the field.- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[inout] A pointer to an initialized cardano_transaction_body_t object to which the required signers will be set.
- cardano_blake2b_hash_set_t *required_signers¶
[in] A pointer to a cardano_blake2b_hash_set_t object representing the set of required signers. This parameter can be NULL to unset the required signers.
- Returns:¶
cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the required signers were successfully set, or an appropriate error code indicating the failure reason, such as CARDANO_ERROR_POINTER_IS_NULL if the transaction_body pointer is NULL.
-
const cardano_network_id_t *cardano_transaction_body_get_network_id(cardano_transaction_body_t *transaction_body)¶
Retrieves the network ID from a transaction body.
This function extracts the network ID from a given cardano_transaction_body_t object, which identifies the Cardano network (mainnet or testnet) where the transaction will be valid. The network ID is optional and may not always be present in the transaction.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is initialized const cardano_network_id_t* network_id = cardano_transaction_body_get_network_id(transaction_body); if (network_id != NULL) { // Process the network ID printf("Transaction network ID: %u\n", *network_id); } else { printf("No network ID is set for this transaction.\n"); }Note
If the network ID is present, it is internally managed by the transaction body object and does not need to be explicitly released by the caller.
- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[in] A pointer to an initialized cardano_transaction_body_t object.
- Returns:¶
A constant pointer to a cardano_network_id_t object representing the network ID, or NULL if the network ID is not set in the transaction body. The returned pointer must not be modified or freed by the caller. If the input is NULL, the function returns NULL.
-
cardano_error_t cardano_transaction_body_set_network_id(cardano_transaction_body_t *transaction_body, const cardano_network_id_t *network_id)¶
Sets the network ID for a transaction body.
This function assigns a network ID to a given cardano_transaction_body_t object. The network ID specifies which Cardano network (mainnet or testnet) the transaction is intended for. The network ID is optional and can be set to NULL if the network ID is to be unset.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is initialized cardano_network_id_t network_id = CARDANO_NETWORK_ID_MAIN_NET; // Example network ID for mainnet cardano_error_t result = cardano_transaction_body_set_network_id(transaction_body, &network_id); if (result == CARDANO_SUCCESS) { printf("Network ID set successfully.\n"); } else { printf("Failed to set network ID: %s\n", cardano_error_to_string(result)); }Note
If
network_idis set to NULL, it will unset any previously set network ID in the transaction body.- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[inout] A pointer to an initialized cardano_transaction_body_t object to which the network ID will be set.
- const cardano_network_id_t *network_id¶
[in] A constant pointer to a cardano_network_id_t object representing the network ID. This parameter can be NULL if the network ID is to be unset.
- Returns:¶
cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the network ID was successfully set, or an appropriate error code indicating the failure reason, such as CARDANO_ERROR_POINTER_IS_NULL if the transaction_body pointer is NULL.
-
cardano_transaction_output_t *cardano_transaction_body_get_collateral_return(cardano_transaction_body_t *transaction_body)¶
Retrieves the collateral return output from a transaction body.
This function fetches the collateral return output from a given cardano_transaction_body_t object. The collateral return is an optional field that specifies the output to which excess collateral is returned in case the collateral provided in the transaction exceeds what is needed.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is initialized cardano_transaction_output_t* collateral_return = cardano_transaction_body_get_collateral_return(transaction_body); if (collateral_return != NULL) { // Use the collateral return output cardano_transaction_output_unref(&collateral_return); } else { printf("No collateral return output is set.\n"); }- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[in] A pointer to an initialized cardano_transaction_body_t object.
- Returns:¶
A pointer to a cardano_transaction_output_t object representing the collateral return output. If the collateral return output is not set, this function will return NULL. If a valid output is returned, the caller is responsible for managing the returned object and must release it using cardano_transaction_output_unref when it is no longer needed.
-
cardano_error_t cardano_transaction_body_set_collateral_return(cardano_transaction_body_t *transaction_body, cardano_transaction_output_t *output)¶
Sets the collateral return output in the transaction body.
This function assigns a new collateral return output to a cardano_transaction_body_t object. The collateral return output specifies where any excess collateral provided by the transaction will be returned, if the collateral exceeds what is needed.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is already initialized cardano_transaction_output_t* collateral_return_output = ...; // Assume collateral_return_output is initialized cardano_error_t result = cardano_transaction_body_set_collateral_return(transaction_body, collateral_return_output); if (result == CARDANO_SUCCESS) { printf("Collateral return output successfully set.\n"); } else { printf("Failed to set collateral return output.\n"); } // Clean up references cardano_transaction_output_unref(&collateral_return_output);Note
This function increases the reference count of the output object. It is the caller’s responsibility to manage the lifetime of their references, including calling cardano_transaction_output_unref when the output is no longer needed.
- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[inout] A pointer to an initialized cardano_transaction_body_t object to which the collateral return output will be set.
- cardano_transaction_output_t *output¶
[in] A pointer to an initialized cardano_transaction_output_t object representing the collateral return output. This parameter can be NULL to unset the collateral return.
- Returns:¶
cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the collateral return output was successfully set, or an appropriate error code indicating the failure reason, such as CARDANO_ERROR_POINTER_IS_NULL if the
transaction_bodypointer is NULL.
-
const uint64_t *cardano_transaction_body_get_total_collateral(cardano_transaction_body_t *transaction_body)¶
Retrieves the total collateral from the transaction body.
This function fetches the total collateral value specified in the transaction body. The total collateral represents the amount of ADA (in lovelaces) that the transaction is providing as collateral.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is initialized const uint64_t* total_collateral = cardano_transaction_body_get_total_collateral(transaction_body); if (total_collateral != NULL) { printf("Total collateral: %llu lovelaces\n", *total_collateral); } else { printf("Total collateral is not set for this transaction.\n"); }Note
This function follows the same convention as other getters of this type—returning
NULLif the field is not set.- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[in] A pointer to an initialized cardano_transaction_body_t object.
- Returns:¶
A constant pointer to a
uint64_tthat contains the total collateral in lovelaces. If the total collateral is not set, the function will return NULL. The memory of the returneduint64_tis managed internally and must not be freed by the caller.
-
cardano_error_t cardano_transaction_body_set_total_collateral(cardano_transaction_body_t *transaction_body, const uint64_t *total_collateral)¶
Sets the total collateral for a transaction body.
This function sets the total collateral amount (in lovelaces) for the transaction body.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is initialized uint64_t total_collateral_value = 5000000; // 5 ADA in lovelaces cardano_error_t result = cardano_transaction_body_set_total_collateral(transaction_body, &total_collateral_value); if (result == CARDANO_SUCCESS) { printf("Total collateral set successfully.\n"); } else { printf("Failed to set total collateral.\n"); } // Unset the total collateral result = cardano_transaction_body_set_total_collateral(transaction_body, NULL); if (result == CARDANO_SUCCESS) { printf("Total collateral unset successfully.\n"); }Note
If the
total_collateralisNULL, this will unset the total collateral in the transaction body.- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[inout] A pointer to an initialized cardano_transaction_body_t object to which the total collateral will be set.
- const uint64_t *total_collateral¶
[in] A constant pointer to a
uint64_trepresenting the total collateral value in lovelaces. If set toNULL, the total collateral will be unset.
- Returns:¶
A cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the total collateral was successfully set, or an appropriate error code if the input pointers are NULL or if another failure occurs.
-
cardano_transaction_input_set_t *cardano_transaction_body_get_reference_inputs(cardano_transaction_body_t *transaction_body)¶
Retrieves the reference inputs from a transaction body.
This function fetches the reference inputs from a given cardano_transaction_body_t object. Reference inputs allow scripts to use outputs without consuming them, enabling transaction builders to reference the necessary data (e.g., Plutus scripts) without spending the UTxO.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is already initialized cardano_transaction_input_set_t* reference_inputs = cardano_transaction_body_get_reference_inputs(transaction_body); if (reference_inputs != NULL) { // Process the reference inputs cardano_transaction_input_set_unref(&reference_inputs); // Free the reference inputs after use } else { printf("No reference inputs found or transaction body is invalid.\n"); }- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[in] A pointer to an initialized cardano_transaction_body_t object.
- Returns:¶
A pointer to a cardano_transaction_input_set_t object representing the set of reference inputs. The returned reference input set is a new reference, and the caller is responsible for releasing it with cardano_transaction_input_set_unref when it is no longer needed. If there are no reference inputs or if the transaction body does not contain reference inputs, the function returns
NULL.
-
cardano_error_t cardano_transaction_body_set_reference_inputs(cardano_transaction_body_t *transaction_body, cardano_transaction_input_set_t *reference_inputs)¶
Sets the reference inputs in a transaction body.
This function assigns a set of reference inputs to a given cardano_transaction_body_t object. Reference inputs allow scripts to access outputs without consuming them, enabling transaction builders to use specific UTxOs for reference purposes, such as providing Plutus scripts access to necessary data.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is already initialized cardano_transaction_input_set_t* reference_inputs = ...; // Assume reference_inputs is initialized cardano_error_t result = cardano_transaction_body_set_reference_inputs(transaction_body, reference_inputs); if (result == CARDANO_SUCCESS) { printf("Reference inputs set successfully.\n"); } else { printf("Failed to set reference inputs.\n"); } // Cleanup if necessary (only if reference_inputs was dynamically allocated elsewhere) cardano_transaction_input_set_unref(&reference_inputs);Note
If
reference_inputsis NULL, any previously set reference inputs in the transaction body will be cleared.- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[inout] A pointer to an initialized cardano_transaction_body_t object where the reference inputs will be set.
- cardano_transaction_input_set_t *reference_inputs¶
[in] A pointer to an initialized cardano_transaction_input_set_t object representing the set of reference inputs to assign to the transaction body. This parameter can be NULL if no reference inputs are to be set, effectively clearing the reference inputs from the transaction body.
- Returns:¶
cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the reference inputs were successfully set, or an appropriate error code indicating the failure reason, such as CARDANO_ERROR_POINTER_IS_NULL if the
transaction_bodypointer is NULL.
-
cardano_voting_procedures_t *cardano_transaction_body_get_voting_procedures(cardano_transaction_body_t *transaction_body)¶
Retrieves the voting procedures associated with a transaction body.
This function fetches the voting procedures from a given cardano_transaction_body_t object. Voting procedures represent governance-related actions that may be included in the transaction, such as votes on proposals or governance actions.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is already initialized cardano_voting_procedures_t* voting_procedures = cardano_transaction_body_get_voting_procedures(transaction_body); if (voting_procedures != NULL) { // Process the voting procedures // Ensure to clean up and release the voting_procedures when done cardano_voting_procedures_unref(&voting_procedures); } else { printf("No voting procedures found in this transaction body.\n"); }- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[in] A pointer to an initialized cardano_transaction_body_t object from which the voting procedures will be retrieved.
- Returns:¶
A pointer to a cardano_voting_procedures_t object representing the voting procedures included in the transaction body. If the transaction body does not have voting procedures set, this function returns NULL. The returned object is a new reference, and the caller is responsible for releasing it with cardano_voting_procedures_unref when it is no longer needed.
-
cardano_error_t cardano_transaction_body_set_voting_procedures(cardano_transaction_body_t *transaction_body, cardano_voting_procedures_t *voting_procedures)¶
Sets the voting procedures for a transaction body.
This function assigns a cardano_voting_procedures_t object to a given cardano_transaction_body_t object. Voting procedures represent governance-related actions, such as votes on proposals or governance actions, that may be included in the transaction body.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is already initialized cardano_voting_procedures_t* voting_procedures = ...; // Assume voting_procedures is already initialized cardano_error_t result = cardano_transaction_body_set_voting_procedures(transaction_body, voting_procedures); if (result == CARDANO_SUCCESS) { // The voting procedures have been successfully set for the transaction body } else { printf("Failed to set the voting procedures.\n"); } // Clean up if necessary cardano_voting_procedures_unref(&voting_procedures);Note
The function increases the reference count of the
voting_proceduresobject, and the caller retains ownership of their references. It is the caller’s responsibility to release their reference tovoting_procedureswhen it is no longer needed.- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[inout] A pointer to an initialized cardano_transaction_body_t object to which the voting procedures will be set.
- cardano_voting_procedures_t *voting_procedures¶
[in] A pointer to an initialized cardano_voting_procedures_t object representing the voting procedures. This parameter can be set to NULL to remove the voting procedures from the transaction body.
- Returns:¶
cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the voting procedures were successfully set, or an appropriate error code indicating the failure reason, such as CARDANO_ERROR_POINTER_IS_NULL if the transaction body pointer is NULL.
-
cardano_proposal_procedure_set_t *cardano_transaction_body_get_proposal_procedures(cardano_transaction_body_t *transaction_body)¶
Retrieves the proposal procedure set from a transaction body.
This function extracts the cardano_proposal_procedure_set_t object from the given cardano_transaction_body_t object. The proposal procedure set represents the set of governance proposals or actions included in the transaction body.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is already initialized cardano_proposal_procedure_set_t* proposal_procedure_set = cardano_transaction_body_get_proposal_procedures(transaction_body); if (proposal_procedure_set != NULL) { // Use the proposal procedure set // Once done, ensure to clean up and release the proposal_procedure_set cardano_proposal_procedure_set_unref(&proposal_procedure_set); } else { printf("No proposal procedure set present in the transaction body.\n"); }- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[in] A pointer to an initialized cardano_transaction_body_t object from which the proposal procedure set is retrieved.
- Returns:¶
A pointer to the retrieved cardano_proposal_procedure_set_t object, or NULL if no proposal procedure set is present. The caller is responsible for managing the returned object, and must call cardano_proposal_procedure_set_unref to release it when it is no longer needed.
-
cardano_error_t cardano_transaction_body_set_proposal_procedure(cardano_transaction_body_t *transaction_body, cardano_proposal_procedure_set_t *proposal_procedures)¶
Sets the proposal procedure set for a transaction body.
This function assigns a cardano_proposal_procedure_set_t object to the given cardano_transaction_body_t object. The proposal procedure set represents a collection of governance proposals or actions that are to be included in the transaction body.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is already initialized cardano_proposal_procedure_set_t* proposal_procedures = ...; // Assume proposal_procedures is initialized cardano_error_t result = cardano_transaction_body_set_proposal_procedure(transaction_body, proposal_procedures); if (result == CARDANO_SUCCESS) { // The proposal procedures have been set for the transaction body } else { printf("Failed to set the proposal procedures: %s\n", cardano_error_to_string(result)); } // Clean up proposal_procedures if it's no longer needed cardano_proposal_procedure_set_unref(&proposal_procedures);Note
The function increases the reference count of the
proposal_proceduresobject, so the caller retains ownership and is still responsible for managing its lifecycle. To remove the proposal procedures, passproposal_proceduresas NULL.- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[inout] A pointer to an initialized cardano_transaction_body_t object to which the proposal procedure set will be assigned.
- cardano_proposal_procedure_set_t *proposal_procedures¶
[in] A pointer to a cardano_proposal_procedure_set_t object representing the new proposal procedure set. This parameter can be NULL to unset the proposal procedures from the transaction body.
- Returns:¶
cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the proposal procedure set was successfully set, or an appropriate error code indicating the failure reason, such as CARDANO_ERROR_POINTER_IS_NULL if the
transaction_bodypointer is NULL.
-
const uint64_t *cardano_transaction_body_get_treasury_value(cardano_transaction_body_t *transaction_body)¶
Retrieves the treasury value from a transaction body.
This function returns a pointer to the treasury value (in ADA, represented in lovelaces) associated with a cardano_transaction_body_t object.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is already initialized const uint64_t* treasury_value = cardano_transaction_body_get_treasury_value(transaction_body); if (treasury_value != NULL) { printf("Treasury Value: %llu lovelaces\n", *treasury_value); } else { printf("No treasury value set for this transaction.\n"); }Note
Since the returned pointer can be NULL if the treasury value is not set, callers should always check for NULL before dereferencing it.
- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[in] A pointer to an initialized cardano_transaction_body_t object.
- Returns:¶
A pointer to a
uint64_trepresenting the treasury value in lovelaces. The pointer will be NULL if the treasury value is not set in this transaction. The memory of the returned value is managed internally by the cardano_transaction_body_t object and must not be freed by the caller.
-
cardano_error_t cardano_transaction_body_set_treasury_value(cardano_transaction_body_t *transaction_body, const uint64_t *treasury_value)¶
Sets the treasury value in a transaction body.
This function sets the treasury value (in ADA, represented in lovelaces) in a cardano_transaction_body_t object.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is already initialized uint64_t treasury_value = 1000000; // 1 ADA in lovelaces cardano_error_t result = cardano_transaction_body_set_treasury_value(transaction_body, &treasury_value); if (result == CARDANO_SUCCESS) { printf("Treasury value set successfully.\n"); } else { printf("Failed to set treasury value: %s\n", cardano_error_to_string(result)); }Note
Passing NULL for
treasury_valuewill unset the treasury value in the transaction body.- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[inout] A pointer to an initialized cardano_transaction_body_t object in which to set the treasury value.
- const uint64_t *treasury_value¶
[in] A pointer to a
uint64_trepresenting the treasury value in lovelaces. This parameter can be NULL to unset the treasury value.
- Returns:¶
cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the treasury value was successfully set, or an appropriate error code if the operation failed, such as CARDANO_ERROR_POINTER_IS_NULL if the
transaction_bodypointer is NULL.
-
const uint64_t *cardano_transaction_body_get_donation(cardano_transaction_body_t *transaction_body)¶
Retrieves the donation value from a transaction body.
This function returns the donation value (in ADA, represented in lovelaces) from a cardano_transaction_body_t object.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is already initialized const uint64_t* donation_value = cardano_transaction_body_get_donation(transaction_body); if (donation_value != NULL) { printf("Donation value: %llu lovelaces\n", *donation_value); } else { printf("No donation value set.\n"); }Note
The returned pointer must not be freed by the caller. If no donation value is set, this function returns NULL.
- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[in] A pointer to an initialized cardano_transaction_body_t object from which to retrieve the donation value.
- Returns:¶
A pointer to a
uint64_trepresenting the donation value in lovelaces. If the donation value is not set, this function returns NULL. The memory for the returneduint64_tis managed internally by the transaction body object and must not be freed by the caller.
-
cardano_error_t cardano_transaction_body_set_donation(cardano_transaction_body_t *transaction_body, const uint64_t *donation)¶
Sets the donation value in a transaction body.
This function assigns a donation value to a cardano_transaction_body_t object.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is already initialized uint64_t donation_value = 5000000; // 5 ADA in lovelaces cardano_error_t result = cardano_transaction_body_set_donation(transaction_body, &donation_value); if (result == CARDANO_SUCCESS) { printf("Donation value set successfully.\n"); } else { printf("Failed to set the donation value: %s\n", cardano_error_to_string(result)); }Note
If the
donationparameter is set to NULL, it will unset any previously set donation value in the transaction body.- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[inout] A pointer to an initialized cardano_transaction_body_t object to which the donation value will be set.
- const uint64_t *donation¶
[in] A pointer to a
uint64_trepresenting the donation value in lovelaces. This parameter can be NULL to unset the donation value.
- Returns:¶
cardano_error_t indicating the outcome of the operation. Returns CARDANO_SUCCESS if the donation value was successfully set, or an appropriate error code indicating the failure reason, such as CARDANO_ERROR_POINTER_IS_NULL if the transaction_body pointer is NULL.
-
cardano_blake2b_hash_t *cardano_transaction_body_get_hash(cardano_transaction_body_t *transaction_body)¶
Retrieves the hash of a transaction body.
This function computes and returns the hash of the given cardano_transaction_body_t object. The hash is a unique identifier for the transaction body, which can be used to reference the transaction in other parts of the blockchain.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is already initialized cardano_blake2b_hash_t* tx_body_hash = cardano_transaction_body_get_hash(transaction_body); if (tx_body_hash != NULL) { // Use the transaction body hash for signing or verification // Clean up when done cardano_blake2b_hash_unref(&tx_body_hash); } else { printf("Failed to retrieve the transaction body hash.\n"); }- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[in] A pointer to an initialized cardano_transaction_body_t object. The object must be valid and not NULL.
- Returns:¶
A pointer to a cardano_blake2b_hash_t object representing the transaction body hash. The returned object is a new reference, and the caller is responsible for releasing it by calling cardano_blake2b_hash_unref when it is no longer needed. If the input is NULL, the function will return NULL.
-
bool cardano_transaction_body_has_tagged_sets(cardano_transaction_body_t *transaction_body)¶
Determines if the transaction body uses tagged sets in its encoding.
This function checks whether the given cardano_transaction_body_t object uses the new Conway era encoding for sets, which are collections identified by a tag. In the Conway era, certain collections within the transaction body are encoded as tagged sets, whereas in previous eras, these collections were encoded as arrays without the tag.
Usage Example:
cardano_transaction_body_t* transaction_body = ...; // Assume transaction_body is already initialized bool has_tagged_sets = cardano_transaction_body_has_tagged_sets(transaction_body); if (has_tagged_sets) { printf("The transaction body uses Conway era tagged sets.\n"); } else { printf("The transaction body uses pre-Conway era encoding.\n"); }Note
This function helps in determining the serialization format of the transaction body, which may be necessary for compatibility with other transaction encoders/decoders.
- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[in] A pointer to an initialized cardano_transaction_body_t object.
- Returns:¶
A boolean value:
trueif the transaction body uses the Conway era encoding for sets (tagged sets).falseif the transaction body uses the older encoding (arrays without tags).
-
void cardano_transaction_body_clear_cbor_cache(cardano_transaction_body_t *transaction_body)¶
Clears the cached CBOR representation from a transaction body.
This function removes the internally cached CBOR data from a cardano_transaction_body_t object. It is useful when you have modified the transaction body after it was created from CBOR using cardano_transaction_body_from_cbor and you want to ensure that the next serialization reflects the current state of the transaction body, rather than using the original cached CBOR.
Usage Example:
// Assume transaction_body was created using cardano_transaction_body_from_cbor cardano_transaction_body_t* transaction_body = ...; // Modify the transaction body as needed // For example, change the fee uint64_t new_fee = 500000; cardano_error_t result = cardano_transaction_body_set_fee(transaction_body, new_fee); if (result != CARDANO_SUCCESS) { printf("Failed to set new fee: %s\n", cardano_error_to_string(result)); } // Clear the CBOR cache to ensure serialization uses the updated transaction body cardano_transaction_body_clear_cbor_cache(transaction_body); // Serialize the transaction body to CBOR cardano_cbor_writer_t* writer = cardano_cbor_writer_new(); result = cardano_transaction_body_to_cbor(transaction_body, writer); if (result == CARDANO_SUCCESS) { // Process the CBOR data as needed } else { const char* error_message = cardano_cbor_writer_get_last_error(writer); printf("Serialization failed: %s\n", error_message); } // Clean up resources cardano_cbor_writer_unref(&writer); cardano_transaction_body_unref(&transaction_body);Note
After calling this function, subsequent calls to cardano_transaction_body_to_cbor will serialize the transaction body using the standard encoding as defined in CIP-21, rather than reusing the original cached CBOR.
Warning
Clearing the CBOR cache may change the binary representation of the transaction body when serialized, which can alter the transaction body hash and invalidate any existing signatures. Use this function with caution, especially if the transaction has already been signed or if preserving the exact CBOR encoding is important for your application.
- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[inout] A pointer to an initialized cardano_transaction_body_t object from which the CBOR cache will be cleared.
-
void cardano_transaction_body_unref(cardano_transaction_body_t **transaction_body)¶
Decrements the reference count of a cardano_transaction_body_t object.
This function is responsible for managing the lifecycle of a cardano_transaction_body_t object by decreasing its reference count. When the reference count reaches zero, the transaction_body is finalized; its associated resources are released, and its memory is deallocated.
Usage Example:
cardano_transaction_body_t* transaction_body = cardano_transaction_body_new(major, minor); // Perform operations with the transaction_body... cardano_transaction_body_unref(&transaction_body); // At this point, transaction_body is NULL and cannot be used.Note
After calling cardano_transaction_body_unref, the pointer to the cardano_transaction_body_t object will be set to NULL to prevent its reuse.
- Parameters:¶
- cardano_transaction_body_t **transaction_body¶
[inout] A pointer to the pointer of the transaction_body object. This double indirection allows the function to set the caller’s pointer to NULL, avoiding dangling pointer issues after the object has been freed.
-
void cardano_transaction_body_ref(cardano_transaction_body_t *transaction_body)¶
Increases the reference count of the cardano_transaction_body_t object.
This function is used to manually increment the reference count of an cardano_transaction_body_t object, indicating that another part of the code has taken ownership of it. This ensures the object remains allocated and valid until all owners have released their reference by calling cardano_transaction_body_unref.
Usage Example:
// Assuming transaction_body is a previously created transaction_body object cardano_transaction_body_ref(transaction_body); // Now transaction_body can be safely used elsewhere without worrying about premature deallocationNote
Always ensure that for every call to cardano_transaction_body_ref there is a corresponding call to cardano_transaction_body_unref to prevent memory leaks.
- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
A pointer to the cardano_transaction_body_t object whose reference count is to be incremented.
-
size_t cardano_transaction_body_refcount(const cardano_transaction_body_t *transaction_body)¶
Retrieves the current reference count of the cardano_transaction_body_t object.
This function returns the number of active references to an cardano_transaction_body_t object. It’s useful for debugging purposes or managing the lifecycle of the object in complex scenarios.
Usage Example:
// Assuming transaction_body is a previously created transaction_body object size_t ref_count = cardano_transaction_body_refcount(transaction_body); printf("Reference count: %zu\n", ref_count);Warning
This function does not account for transitive references. A transitive reference occurs when an object holds a reference to another object, rather than directly to the cardano_transaction_body_t. As such, the reported count may not fully represent the total number of conceptual references in cases where such transitive relationships exist.
- Parameters:¶
- const cardano_transaction_body_t *transaction_body¶
A pointer to the cardano_transaction_body_t object whose reference count is queried. The object must not be NULL.
- Returns:¶
The number of active references to the specified cardano_transaction_body_t object. If the object is properly managed (i.e., every cardano_transaction_body_ref call is matched with a cardano_transaction_body_unref call), this count should reach zero right before the object is deallocated.
-
void cardano_transaction_body_set_last_error(cardano_transaction_body_t *transaction_body, const char *message)¶
Sets the last error message for a given cardano_transaction_body_t object.
Records an error message in the transaction_body’s last_error buffer, overwriting any existing message. This is useful for storing descriptive error information that can be later retrieved. The message is truncated if it exceeds the buffer’s capacity.
Note
The error message is limited to 1023 characters, including the null terminator, due to the fixed size of the last_error buffer.
- Parameters:¶
- cardano_transaction_body_t *transaction_body¶
[in] A pointer to the cardano_transaction_body_t instance whose last error message is to be set. If
NULL, the function does nothing.- const char *message¶
[in] A null-terminated string containing the error message. If
NULL, the transaction_body’s last_error is set to an empty string, indicating no error.
-
const char *cardano_transaction_body_get_last_error(const cardano_transaction_body_t *transaction_body)¶
Retrieves the last error message recorded for a specific transaction_body.
This function returns a pointer to the null-terminated string containing the last error message set by cardano_transaction_body_set_last_error for the given transaction_body. If no error message has been set, or if the last_error buffer was explicitly cleared, an empty string is returned, indicating no error.
Note
The returned string points to internal storage within the object and must not be modified by the caller. The string remains valid until the next call to cardano_transaction_body_set_last_error for the same transaction_body, or until the transaction_body is deallocated.
- Parameters:¶
- const cardano_transaction_body_t *transaction_body¶
[in] A pointer to the cardano_transaction_body_t instance whose last error message is to be retrieved. If the transaction_body is NULL, the function returns a generic error message indicating the null transaction_body.
- Returns:¶
A pointer to a null-terminated string containing the last error message for the specified transaction_body. If the transaction_body is NULL, “Object is NULL.” is returned to indicate the error.