sgns::UTXOManager¶
#include <UTXOManager.hpp>
Public Types¶
| Name | |
|---|---|
| enum class uint8_t | UTXOState |
| using std::pair< UTXOState, GeniusUTXO > | UTXOData |
| using std::function< std::vector< uint8_t >(const std::vector< uint8_t > &data)> | SignFunc |
| using std::function< bool(const std::string &address, const std::vector< uint8_t > &signature, const std::vector< uint8_t > &data)> | VerifySignatureFunc |
Public Functions¶
| Name | |
|---|---|
| UTXOManager(const bool is_full_node, std::string address, SignFunc sign, VerifySignatureFunc verify_signature) | |
| uint64_t | GetBalance() const Get the account's balance. |
| uint64_t | GetBalance(const std::string & address) const |
| uint64_t | GetBalance(const TokenID & token_id) const Get the accounts balance for a specific token. |
| uint64_t | GetBalance(const TokenID & token_id, const std::string & address) const |
| bool | PutUTXO(GeniusUTXO new_utxo, const std::string & address) Add a new UTXO to the account. |
| bool | PutUTXO(const GeniusUTXO & new_utxo) |
| void | DeleteUTXO(const base::Hash256 & utxo_id, const std::string & address) Delete a UTXO from the account. |
| bool | ConsumeUTXOs(const std::vector< InputUTXOInfo > & infos, const std::string & address) Consume UTXOs from the account. |
| bool | ConsumeUTXOs(const std::vector< InputUTXOInfo > & infos) |
| std::vector< GeniusUTXO > | GetUTXOs(const std::string & address) const Get UTXOs for a specific address. |
| std::vector< GeniusUTXO > | GetUTXOs() const |
| std::unordered_map< std::string, std::vector< UTXOData > > | GetAllUTXOs() const |
| outcome::result< void > | SetUTXOs(const std::vector< GeniusUTXO > & utxos, const std::string & address) Set UTXOs for a specific address (replaces existing UTXOs). |
| outcome::result< void > | SetUTXOs(const std::vector< GeniusUTXO > & utxos) |
| outcome::result< UTXOTxParameters > | CreateTxParameter(uint64_t amount, const std::string & dest_address, const TokenID & token_id) |
| outcome::result< UTXOTxParameters > | CreateTxParameter(const std::vector< OutputDestInfo > & destinations, const TokenID & token_id) |
| void | ReserveUTXOs(const std::vector< InputUTXOInfo > & inputs) |
| void | RollbackUTXOs(const std::vector< InputUTXOInfo > & inputs) |
| bool | VerifyParameters(const UTXOTxParameters & params) const |
| bool | VerifyParameters(const UTXOTxParameters & params, const std::string & address) const |
| outcome::result< bool > | LoadUTXOs(std::shared_ptr< storage::rocksdb > db) |
| outcome::result< void > | StoreUTXOs(const std::string & address) |
Public Types Documentation¶
enum UTXOState¶
| Enumerator | Value | Description |
|---|---|---|
| UTXO_READY | ||
| UTXO_RESERVED | ||
| UTXO_CONSUMED |
using UTXOData¶
using SignFunc¶
using sgns::UTXOManager::SignFunc = std::function<std::vector<uint8_t>( const std::vector<uint8_t> &data )>;
using VerifySignatureFunc¶
using sgns::UTXOManager::VerifySignatureFunc = std::function<bool( const std::string &address,
const std::vector<uint8_t> &signature,
const std::vector<uint8_t> &data )>;
Public Functions Documentation¶
function UTXOManager¶
inline UTXOManager(
const bool is_full_node,
std::string address,
SignFunc sign,
VerifySignatureFunc verify_signature
)
function GetBalance¶
Get the account's balance.
Return: The total balance of the account
function GetBalance¶
function GetBalance¶
Get the accounts balance for a specific token.
Parameters:
- token_id Token ID to get the balance
Return: The balance of the account for the specific token
function GetBalance¶
function PutUTXO¶
Add a new UTXO to the account.
Parameters:
- new_utxo The new UTXO to be added
- address Address to add the UTXO to
Return: true if the UTXO was added, false otherwise
function PutUTXO¶
function DeleteUTXO¶
Delete a UTXO from the account.
Parameters:
- utxo_id The ID of the UTXO to be deleted
- address Address to remove the UTXO from
function ConsumeUTXOs¶
Consume UTXOs from the account.
Parameters:
- infos Vector of UTXO information to be consumed
- address Address to consume UTXOs from
Return: true if all UTXOs were consumed, false otherwise
function ConsumeUTXOs¶
function GetUTXOs¶
Get UTXOs for a specific address.
Parameters:
- address The address to get UTXOs for
Return: Vector of UTXOs for the address
function GetUTXOs¶
function GetAllUTXOs¶
function SetUTXOs¶
outcome::result< void > SetUTXOs(
const std::vector< GeniusUTXO > & utxos,
const std::string & address
)
Set UTXOs for a specific address (replaces existing UTXOs).
Parameters:
- utxos Vector of UTXOs to set for the address
- address The address to set UTXOs for
function SetUTXOs¶
function CreateTxParameter¶
outcome::result< UTXOTxParameters > CreateTxParameter(
uint64_t amount,
const std::string & dest_address,
const TokenID & token_id
)
function CreateTxParameter¶
outcome::result< UTXOTxParameters > CreateTxParameter(
const std::vector< OutputDestInfo > & destinations,
const TokenID & token_id
)
function ReserveUTXOs¶
function RollbackUTXOs¶
function VerifyParameters¶
function VerifyParameters¶
function LoadUTXOs¶
function StoreUTXOs¶
Return: True if loaded any UTXOs, false if loaded 0 UTXOs and error if one occurred
Updated on 2026-03-04 at 13:10:43 -0800