sgns::GeniusAccount¶
#include <GeniusAccount.hpp>
Inherits from std::enable_shared_from_this< GeniusAccount >
Public Classes¶
| Name | |
|---|---|
| struct | Credentials |
Public Types¶
| Name | |
|---|---|
| using std::pair< std::shared_ptr< ISecureStorage >, std::pair< KeyGenerator::ElGamal, ethereum::EthereumKeyGenerator > > | StorageWithAddress |
Public Functions¶
| Name | |
|---|---|
| std::shared_ptr< GeniusAccount > | New(TokenID token_id, const char * eth_private_key, const boost::filesystem::path & base_path, bool full_node =false) Factory constructor of new GeniusAccount. |
| std::shared_ptr< GeniusAccount > | New(TokenID token_id, const Credentials & credentials, const boost::filesystem::path & base_path, bool full_node =false) Factory constructor of new GeniusAccount. |
| std::shared_ptr< GeniusAccount > | New(TokenID token_id, const boost::filesystem::path & base_path, bool full_node =false) Factory constructor of new GeniusAccount. |
| bool | VerifySignature(const std::string & address, std::string_view sig, const std::vector< uint8_t > & data) Verify a signature using the Genius account's public key. |
| outcome::result< StorageWithAddress > | GenerateGeniusAddress(const char * eth_private_key, const boost::filesystem::path & base_path) |
| outcome::result< StorageWithAddress > | GenerateGeniusAddress(const Credentials & credentials, const boost::filesystem::path & base_path) |
| bool | InitMessenger(std::shared_ptr< ipfs_pubsub::GossipPubSub > pubsub) Initialize the messenger for the account. |
| bool | ConfigureMessengerHandlers(std::shared_ptr< crdt::GlobalDB > global_db) Configures the block response handler. |
| ~GeniusAccount() Destroy the Genius Account object. |
|
| std::string | GetAddress() const Get the Address object. |
| TokenID | GetToken() const Get the account's token. |
| std::string | GetNonce() const Get the confirmed nonce as a string. |
| std::vector< uint8_t > | Sign(const std::vector< uint8_t > & data) const Sign data using the Genius account's private key. |
| void | SetLocalConfirmedNonce(uint64_t nonce) Set the local confirmed nonce. |
| void | SetPeerConfirmedNonce(uint64_t nonce, const std::string & address) Set the local confirmed nonce for a peer. |
| void | RollBackPeerConfirmedNonce(uint64_t nonce, const std::string & address) Rollback the local confirmed nonce for a peer. |
| outcome::result< uint64_t > | GetPeerNonce(const std::string & address) const Get the confirmed nonce for a peer. |
| outcome::result< uint64_t > | GetLocalConfirmedNonce() const Get the local confirmed nonce. |
| outcome::result< uint64_t > | GetConfirmedNonce(uint64_t timeout_ms) const Get confirmed nonce from the network. |
| uint64_t | GetProposedNonce() const Get the next available nonce without reserving it. |
| uint64_t | ReserveNextNonce() Reserve the next available nonce. |
| void | ReleaseNonce(uint64_t nonce) Release a previously reserved nonce. |
| outcome::result< void > | RequestGenesis(uint64_t timeout_ms =8000, std::function< void(outcome::result< std::string >)> callback =nullptr) const |
| outcome::result< void > | RequestAccountCreation(uint64_t timeout_ms, std::function< void(outcome::result< std::string >)> callback) const |
| outcome::result< void > | RequestRegularBlock(uint64_t timeout_ms, const std::string & cid, std::function< void(outcome::result< std::string >)> callback =nullptr) const |
| outcome::result< void > | RequestHeads(const std::unordered_set< std::string > & topics) const Request heads broadcast for specific topics. |
Protected Functions¶
| Name | |
|---|---|
| void | SetGetBlockChainCIDMethod(std::function< outcome::result< std::string >(uint8_t, const std::string &)> method) |
| void | ClearGetBlockChainCIDMethod() |
| void | SetHasBlockCidMethod(std::function< outcome::result< bool >(const std::string &)> method) |
| void | ClearHasBlockCidMethod() |
Public Attributes¶
| Name | |
|---|---|
| const std::array< uint8_t, 32 > | ELGAMAL_PUBKEY_PREDEFINED Predefined ElGamal public key. |
| uint64_t | NONCE_CACHE_DURATION_MS Cache nonce results for 5 seconds. |
Friends¶
| Name | |
|---|---|
| class | Blockchain |
Public Types Documentation¶
using StorageWithAddress¶
using sgns::GeniusAccount::StorageWithAddress = std::pair<std::shared_ptr<ISecureStorage>,
std::pair<KeyGenerator::ElGamal, ethereum::EthereumKeyGenerator>>;
Public Functions Documentation¶
function New¶
static std::shared_ptr< GeniusAccount > New(
TokenID token_id,
const char * eth_private_key,
const boost::filesystem::path & base_path,
bool full_node =false
)
Factory constructor of new GeniusAccount.
Parameters:
- token_id Token ID of the account.
- eth_private_key Ethereum private key in hex format (0x...).
- base_path Base path to store/retrieve keys.
- full_node Whether to initialize as a full node.
Return: Valid pointer if succeeds, nullptr otherwise.
function New¶
static std::shared_ptr< GeniusAccount > New(
TokenID token_id,
const Credentials & credentials,
const boost::filesystem::path & base_path,
bool full_node =false
)
Factory constructor of new GeniusAccount.
Parameters:
- token_id Token ID of the account
function New¶
static std::shared_ptr< GeniusAccount > New(
TokenID token_id,
const boost::filesystem::path & base_path,
bool full_node =false
)
Factory constructor of new GeniusAccount.
Parameters:
- token_id Token ID of the account
function VerifySignature¶
static bool VerifySignature(
const std::string & address,
std::string_view sig,
const std::vector< uint8_t > & data
)
Verify a signature using the Genius account's public key.
Parameters:
- address public address to verify the signature
- sig signature to be verified
- data data to be verified
Return: true if the signature is valid, false otherwise
function GenerateGeniusAddress¶
static outcome::result< StorageWithAddress > GenerateGeniusAddress(
const char * eth_private_key,
const boost::filesystem::path & base_path
)
function GenerateGeniusAddress¶
static outcome::result< StorageWithAddress > GenerateGeniusAddress(
const Credentials & credentials,
const boost::filesystem::path & base_path
)
function InitMessenger¶
Initialize the messenger for the account.
Parameters:
- pubsub pubsub instance
Return: true if succeeds, false otherwise
function ConfigureMessengerHandlers¶
Configures the block response handler.
Parameters:
- global_db GlobalDB instance used to store fetched block CIDs.
Return: true if successfully configured, false otherwise.
function ~GeniusAccount¶
Destroy the Genius Account object.
function GetAddress¶
Get the Address object.
Return: String representation of the address
function GetToken¶
Get the account's token.
Return: The token of the account
function GetNonce¶
Get the confirmed nonce as a string.
Return: The confirmed nonce in string format
function Sign¶
Sign data using the Genius account's private key.
Parameters:
- data data to be signed
Return: the signature as a vector of bytes
function SetLocalConfirmedNonce¶
Set the local confirmed nonce.
Parameters:
- nonce The nonce value to be set
function SetPeerConfirmedNonce¶
Set the local confirmed nonce for a peer.
Parameters:
- nonce The nonce value to be set
- address The address of the peer
function RollBackPeerConfirmedNonce¶
Rollback the local confirmed nonce for a peer.
Parameters:
- nonce The nonce value to be rolled back to
- address The address of the peer
function GetPeerNonce¶
Get the confirmed nonce for a peer.
Parameters:
- address The address of the peer
Return: The confirmed nonce of the peer if exists, error otherwise
function GetLocalConfirmedNonce¶
Get the local confirmed nonce.
Return: The local confirmed nonce if exists, error otherwise
function GetConfirmedNonce¶
Get confirmed nonce from the network.
Parameters:
- timeout_ms Timeout in miliseconds to get the confirmed nonce
Return: The confirmed nonce if success, error otherwise
function GetProposedNonce¶
Get the next available nonce without reserving it.
Return: The nonce that would be assigned to the next transaction
function ReserveNextNonce¶
Reserve the next available nonce.
Return: The reserved nonce value
function ReleaseNonce¶
Release a previously reserved nonce.
Parameters:
- nonce The nonce to release
function RequestGenesis¶
outcome::result< void > RequestGenesis(
uint64_t timeout_ms =8000,
std::function< void(outcome::result< std::string >)> callback =nullptr
) const
function RequestAccountCreation¶
outcome::result< void > RequestAccountCreation(
uint64_t timeout_ms,
std::function< void(outcome::result< std::string >)> callback
) const
function RequestRegularBlock¶
outcome::result< void > RequestRegularBlock(
uint64_t timeout_ms,
const std::string & cid,
std::function< void(outcome::result< std::string >)> callback =nullptr
) const
function RequestHeads¶
Request heads broadcast for specific topics.
Parameters:
- topics Vector of topic names to request heads for
Return: outcome::success if request was sent, error otherwise
Protected Functions Documentation¶
function SetGetBlockChainCIDMethod¶
void SetGetBlockChainCIDMethod(
std::function< outcome::result< std::string >(uint8_t, const std::string &)> method
)
function ClearGetBlockChainCIDMethod¶
function SetHasBlockCidMethod¶
function ClearHasBlockCidMethod¶
Public Attributes Documentation¶
variable ELGAMAL_PUBKEY_PREDEFINED¶
Predefined ElGamal public key.
variable NONCE_CACHE_DURATION_MS¶
Cache nonce results for 5 seconds.
Friends¶
friend Blockchain¶
Updated on 2026-03-04 at 13:10:43 -0800