sgns::GeniusTransaction¶
Base class of the GeniusTransaction.
#include <GeniusTransaction.hpp>
Inherited by sgns::EscrowTransaction, sgns::MigrationTransaction, sgns::MintTransaction, sgns::MintTransactionV2, sgns::ProcessingTransaction, sgns::TransferTransaction
Public Types¶
| Name | |
|---|---|
| using std::function< std::shared_ptr< GeniusTransaction >(const std::vector< uint8_t > &)> | TransactionDeserializeFn Alias for the de-serializer method type to be implemented in derived classes. |
Public Functions¶
| Name | |
|---|---|
| GeniusTransaction(std::string type, SGTransaction::DAGStruct dag) Constructs a GeniusTransaction with the specified type and DAG metadata. |
|
| virtual | ~GeniusTransaction() =default Virtual destructor to avoid leakage when deleting derived classes through a base pointer. |
| std::string | GetType() const Returns the transaction type. |
| virtual std::vector< uint8_t > | SerializeByteVector(const SGTransaction::DAGStruct & dag) const =0 Serializes the transaction into a byte vector, including the DAG metadata. |
| virtual EmbeddedTransaction | SerializeToEmbeddedTransaction(const SGTransaction::DAGStruct & dag) const =0 Serializes the transaction into an EmbeddedTransaction proto with the appropriate oneof field set. |
| EmbeddedTransaction | SerializeToEmbeddedTransaction() const Serializes using internal DAG metadata. |
| std::vector< uint8_t > | SerializeByteVector() const Serializes the transaction using the internal DAG metadata. |
| virtual bool | HasUTXOParameters() const Returns if transaction supports UTXOs. |
| virtual std::optional< UTXOTxParameters > | GetUTXOParametersOpt() const Returns the UTXOs. |
| virtual std::string | GetChainId() const Returns the source chain id for input validation routing. |
| virtual std::string | GetTransactionSpecificPath() const =0 Returns the transaction-specific path component for storage and retrieval. |
| std::string | GetTransactionFullPath() const Returns the full storage path for the transaction based on its hash. |
| std::string | GetProofFullPath() const Returns the full storage path for the proof based on the transaction hash. |
| std::string | GetSrcAddress() const Returns the source address for the transaction. |
| std::string | GetHash() const Returns the hash of the transaction. |
| std::string | GetPreviousHash() const Returns the hash of the previous transaction. |
| std::string | GetUncleHash() const Returns the hash of the uncle transaction. |
| uint64_t | GetTimestamp() const Returns the timestamp of the transaction. |
| uint64_t | GetNonce() const Returns the nonce of the transaction. |
| virtual std::unordered_set< std::string > | GetTopics() const Returns the destination topics associated with the transaction. |
| void | FillHash() Fills the data hash field in the DAG metadata based on the transaction content. |
| bool | CheckHash() const Checks the integrity of the transaction by verifying that the hash field matches the calculated hash. |
| std::vector< uint8_t > | MakeSignature(GeniusAccount & account) Creates a signature for the transaction using the provided GeniusAccount. |
| bool | CheckSignature() const Verifies the transaction signature using the source address and the serialized transaction content. |
| bool | CheckDAGSignatureLegacy() const Legacy method to verify the transaction signature using the DAG metadata. This method may be used for backward compatibility with older transaction formats. |
| virtual std::string | GetSlotID() const Generates a slot ID used by consensus to identify competing transactions. |
| outcome::result< SGTransaction::DAGStruct > | DeSerializeDAGStruct(const std::vector< uint8_t > & data) Deserializes the DAG metadata from a byte vector. |
| outcome::result< SGTransaction::DAGStruct > | DeSerializeDAGStruct(const std::string & data) Deserializes the DAG metadata from a string. |
| SGTransaction::DAGStruct | SetDAGWithType(SGTransaction::DAGStruct dag, const std::string & type) Sets the transaction type in the DAG metadata and returns the modified DAGStruct. |
| std::string | GetTransactionFullPath(const std::string & tx_hash) Returns the full storage path for the transaction based on its hash. |
| void | RegisterDeserializer(const std::string & transaction_type, TransactionDeserializeFn fn) Registers a deserializer function for a specific transaction type. |
| std::unordered_map< std::string, TransactionDeserializeFn > & | GetDeSerializers() Returns the map of registered deserializer functions for transaction types. |
Public Attributes¶
| Name | |
|---|---|
| std::string_view | GENIUS_CHAIN_ID The chain ID used for transactions that are not associated with a specific external chain. |
| SGTransaction::DAGStruct | dag_st The DAG metadata struct that is included in all transactions, containing common fields such as source address, hashes, timestamp, nonce, and signature. |
Public Types Documentation¶
using TransactionDeserializeFn¶
using sgns::GeniusTransaction::TransactionDeserializeFn =
std::function<std::shared_ptr<GeniusTransaction>( const std::vector<uint8_t> & )>;
Alias for the de-serializer method type to be implemented in derived classes.
Public Functions Documentation¶
function GeniusTransaction¶
Constructs a GeniusTransaction with the specified type and DAG metadata.
Parameters:
- type The transaction type (e.g., "transfer", "mint", "escrow-hold").
- dag The DAG metadata for the transaction.
function ~GeniusTransaction¶
Virtual destructor to avoid leakage when deleting derived classes through a base pointer.
function GetType¶
Returns the transaction type.
Return: The transaction type string.
function SerializeByteVector¶
Serializes the transaction into a byte vector, including the DAG metadata.
Parameters:
- dag The DAG metadata to be included in the serialization.
Return: The serialized byte vector representing the transaction.
Note: This should be defined in the derived class, but the version without parameters is to used
Reimplemented by: sgns::EscrowTransaction::SerializeByteVector, sgns::MigrationTransaction::SerializeByteVector, sgns::MintTransaction::SerializeByteVector, sgns::MintTransactionV2::SerializeByteVector, sgns::ProcessingTransaction::SerializeByteVector, sgns::TransferTransaction::SerializeByteVector
function SerializeToEmbeddedTransaction¶
virtual EmbeddedTransaction SerializeToEmbeddedTransaction(
const SGTransaction::DAGStruct & dag
) const =0
Serializes the transaction into an EmbeddedTransaction proto with the appropriate oneof field set.
Parameters:
- dag The DAG metadata to be included in the serialization.
Return: EmbeddedTransaction proto with the typed transaction field set.
Reimplemented by: sgns::EscrowTransaction::SerializeToEmbeddedTransaction, sgns::MigrationTransaction::SerializeToEmbeddedTransaction, sgns::MintTransaction::SerializeToEmbeddedTransaction, sgns::MintTransactionV2::SerializeToEmbeddedTransaction, sgns::ProcessingTransaction::SerializeToEmbeddedTransaction, sgns::TransferTransaction::SerializeToEmbeddedTransaction
function SerializeToEmbeddedTransaction¶
Serializes using internal DAG metadata.
function SerializeByteVector¶
Serializes the transaction using the internal DAG metadata.
Return: The serialized byte vector representing the transaction.
function HasUTXOParameters¶
Returns if transaction supports UTXOs.
Return: true if supported, false otherwise
Reimplemented by: sgns::EscrowTransaction::HasUTXOParameters, sgns::MigrationTransaction::HasUTXOParameters, sgns::MintTransactionV2::HasUTXOParameters, sgns::TransferTransaction::HasUTXOParameters
function GetUTXOParametersOpt¶
Returns the UTXOs.
Return: If exists, returns the UTXOs of the transaction
Reimplemented by: sgns::EscrowTransaction::GetUTXOParametersOpt, sgns::MigrationTransaction::GetUTXOParametersOpt, sgns::MintTransactionV2::GetUTXOParametersOpt, sgns::TransferTransaction::GetUTXOParametersOpt
function GetChainId¶
Returns the source chain id for input validation routing.
Return: The source chain id
Reimplemented by: sgns::MigrationTransaction::GetChainId, sgns::MintTransaction::GetChainId, sgns::MintTransactionV2::GetChainId
function GetTransactionSpecificPath¶
Returns the transaction-specific path component for storage and retrieval.
Return: The transaction-specific path component, typically derived from the transaction type or other unique attributes.
Reimplemented by: sgns::EscrowTransaction::GetTransactionSpecificPath, sgns::MigrationTransaction::GetTransactionSpecificPath, sgns::MintTransaction::GetTransactionSpecificPath, sgns::MintTransactionV2::GetTransactionSpecificPath, sgns::ProcessingTransaction::GetTransactionSpecificPath, sgns::TransferTransaction::GetTransactionSpecificPath
function GetTransactionFullPath¶
Returns the full storage path for the transaction based on its hash.
Return: The full storage path for the transaction.
function GetProofFullPath¶
Returns the full storage path for the proof based on the transaction hash.
Return: The full storage path for the proof.
function GetSrcAddress¶
Returns the source address for the transaction.
Return: The source address.
function GetHash¶
Returns the hash of the transaction.
Return: The hash of the transaction.
function GetPreviousHash¶
Returns the hash of the previous transaction.
Return: The hash of the previous transaction.
function GetUncleHash¶
Returns the hash of the uncle transaction.
Return: The hash of the uncle transaction.
function GetTimestamp¶
Returns the timestamp of the transaction.
Return: The timestamp of the transaction.
function GetNonce¶
Returns the nonce of the transaction.
Return: The nonce of the transaction.
function GetTopics¶
Returns the destination topics associated with the transaction.
Return: The set of destination topics associated with the transaction.
Reimplemented by: sgns::MigrationTransaction::GetTopics, sgns::MintTransactionV2::GetTopics, sgns::TransferTransaction::GetTopics
function FillHash¶
Fills the data hash field in the DAG metadata based on the transaction content.
Note: This should be called after all transaction fields are set and before signing.
function CheckHash¶
Checks the integrity of the transaction by verifying that the hash field matches the calculated hash.
Return: true if the hash is valid, false otherwise.
function MakeSignature¶
Creates a signature for the transaction using the provided GeniusAccount.
Parameters:
- account The GeniusAccount used to sign the transaction.
Return: The signature as a byte vector.
function CheckSignature¶
Verifies the transaction signature using the source address and the serialized transaction content.
Return: true if the signature is valid, false otherwise.
function CheckDAGSignatureLegacy¶
Legacy method to verify the transaction signature using the DAG metadata. This method may be used for backward compatibility with older transaction formats.
Return: true if the signature is valid and the hash matches, false otherwise.
function GetSlotID¶
Generates a slot ID used by consensus to identify competing transactions.
Return: The unique slot ID, typically derived from the source address
Reimplemented by: sgns::MintTransactionV2::GetSlotID
function DeSerializeDAGStruct¶
static outcome::result< SGTransaction::DAGStruct > DeSerializeDAGStruct(
const std::vector< uint8_t > & data
)
Deserializes the DAG metadata from a byte vector.
Parameters:
- data The byte vector containing the serialized DAG metadata.
Return: DAGStruct wrapped in an outcome::result, containing an error if deserialization fails.
function DeSerializeDAGStruct¶
Deserializes the DAG metadata from a string.
Parameters:
- data The string containing the serialized DAG metadata.
Return: DAGStruct wrapped in an outcome::result, containing an error if deserialization fails.
function SetDAGWithType¶
static inline SGTransaction::DAGStruct SetDAGWithType(
SGTransaction::DAGStruct dag,
const std::string & type
)
Sets the transaction type in the DAG metadata and returns the modified DAGStruct.
Parameters:
- dag The original DAGStruct to be modified.
- type The transaction type to set in the DAG metadata.
Return: The modified DAGStruct with the transaction type set.
function GetTransactionFullPath¶
Returns the full storage path for the transaction based on its hash.
Parameters:
- tx_hash Hash of the transaction to be included in the path.
Return: The full storage path for the transaction.
function RegisterDeserializer¶
static inline void RegisterDeserializer(
const std::string & transaction_type,
TransactionDeserializeFn fn
)
Registers a deserializer function for a specific transaction type.
Parameters:
- transaction_type The transaction type for which the deserializer is registered.
- fn The deserializer function to be registered.
function GetDeSerializers¶
Returns the map of registered deserializer functions for transaction types.
Return: The map of transaction types to their corresponding deserializer functions.
Public Attributes Documentation¶
variable GENIUS_CHAIN_ID¶
The chain ID used for transactions that are not associated with a specific external chain.
variable dag_st¶
The DAG metadata struct that is included in all transactions, containing common fields such as source address, hashes, timestamp, nonce, and signature.
Updated on 2026-06-05 at 17:22:18 -0700