OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
cbdc::atomizer_client Class Reference

Client for interacting with the atomizer architecture. More...

#include <atomizer_client.hpp>

Inheritance diagram for cbdc::atomizer_client:
Collaboration diagram for cbdc::atomizer_client:

Public Member Functions

 atomizer_client (const cbdc::config::options &opts, const std::shared_ptr< logging::log > &logger, const std::string &wallet_file, const std::string &client_file)
 Constructor.
 
 ~atomizer_client () override
 
 atomizer_client ()=delete
 
 atomizer_client (const atomizer_client &)=delete
 
auto operator= (const atomizer_client &) -> atomizer_client &=delete
 
 atomizer_client (atomizer_client &&)=delete
 
auto operator= (atomizer_client &&) -> atomizer_client &=delete
 
auto sync () -> bool override
 Update the client with the latest state from the watchtower.
 
- Public Member Functions inherited from cbdc::client
 client (cbdc::config::options opts, std::shared_ptr< logging::log > logger, std::string wallet_file, std::string client_file)
 Constructor.
 
virtual ~client ()=default
 
 client (const client &)=delete
 
auto operator= (const client &) -> client &=delete
 
 client (client &&)=delete
 
auto operator= (client &&) -> client &=delete
 
auto init () -> bool
 Initializes the client.
 
auto mint (size_t n_outputs, uint32_t output_val) -> transaction::full_tx
 Creates the specified number spendable outputs each with the specified value.
 
auto send (uint32_t value, const pubkey_t &payee) -> std::pair< std::optional< transaction::full_tx >, std::optional< cbdc::sentinel::execute_response > >
 Send a specified amount from this client's wallet to a target address.
 
auto fan (uint32_t count, uint32_t value, const pubkey_t &payee) -> std::pair< std::optional< transaction::full_tx >, std::optional< cbdc::sentinel::execute_response > >
 Send a specified number of fixed-value outputs from this client's wallet to a target address.
 
void import_send_input (const transaction::input &in)
 Imports transaction data from a sender.
 
auto new_address () -> pubkey_t
 Generates a new wallet address that other clients can use to send money to this client using send.
 
auto balance () -> uint64_t
 Returns the balance in this client's wallet.
 
auto utxo_count () -> size_t
 Returns the number of UTXOs in this client's wallet.
 
auto pending_tx_count () -> size_t
 Returns the number of unconfirmed transactions.
 
auto pending_input_count () -> size_t
 Returns the number of pending received inputs.
 
auto confirm_transaction (const hash_t &tx_id) -> bool
 Confirms the transaction with the given ID.
 
auto create_transaction (uint32_t value, const pubkey_t &payee) -> std::optional< transaction::full_tx >
 Create a new transaction.
 
auto send_transaction (const transaction::full_tx &tx) -> std::optional< cbdc::sentinel::execute_response >
 Send the given transaction to the sentinel.
 
auto abandon_transaction (const hash_t &tx_id) -> bool
 Abandons a transaction currently awaiting confirmation.
 
auto check_pending (const transaction::input &inp) -> bool
 Checks the client's pending transaction set for the specified transaction.
 
void sign_transaction (transaction::full_tx &tx)
 Signs the given transaction for as far as client's wallet contains the transaction's keys.
 

Protected Member Functions

auto init_derived () -> bool override
 Initializes the atomizer client.
 
auto send_mint_tx (const transaction::full_tx &mint_tx) -> bool override
 Sends the given transaction directly to the atomizer cluster.
 
- Protected Member Functions inherited from cbdc::client
auto pending_txs () const -> std::unordered_map< hash_t, transaction::full_tx, hashing::null >
 Returns the set of transactions pending confirmation.
 
auto pending_inputs () const -> std::unordered_map< hash_t, transaction::input, hashing::null >
 Returns the set of imported inputs from senders.
 

Additional Inherited Members

- Public Types inherited from cbdc::client
enum class  address_type : uint8_t { public_key = 0 }
 Client address type signifier. More...
 
- Static Public Member Functions inherited from cbdc::client
static auto print_amount (uint64_t val) -> std::string
 Format a value given in currency base units as USD.
 
static auto export_send_inputs (const transaction::full_tx &send_tx, const pubkey_t &payee) -> std::vector< transaction::input >
 Extracts the transaction data that recipients need from senders to confirm pending transfers.
 

Detailed Description

Client for interacting with the atomizer architecture.

Definition at line 14 of file atomizer_client.hpp.

Constructor & Destructor Documentation

◆ atomizer_client() [1/4]

cbdc::atomizer_client::atomizer_client ( const cbdc::config::options & opts,
const std::shared_ptr< logging::log > & logger,
const std::string & wallet_file,
const std::string & client_file )

Constructor.

Parameters
optsconfiguration options.
loggerpointer shared logger.
wallet_filename of .dat file in which to store the wallet data.
client_filename of .dat file in which to store the internal state data.

Definition at line 12 of file atomizer_client.cpp.

◆ ~atomizer_client()

cbdc::atomizer_client::~atomizer_client ( )
override

Definition at line 22 of file atomizer_client.cpp.

References cbdc::network::connection_manager::close().

Here is the call graph for this function:

◆ atomizer_client() [2/4]

cbdc::atomizer_client::atomizer_client ( )
delete

◆ atomizer_client() [3/4]

cbdc::atomizer_client::atomizer_client ( const atomizer_client & )
delete

◆ atomizer_client() [4/4]

cbdc::atomizer_client::atomizer_client ( atomizer_client && )
delete

Member Function Documentation

◆ init_derived()

auto cbdc::atomizer_client::init_derived ( ) -> bool
overrideprotectedvirtual

Initializes the atomizer client.

Connects to the network of atomizers to allow this client to directly submit mint transactions. Initializes the watchtower client to allow this client to confirm pending transactions and imported inputs.

Returns
true if the initialization succeeded.

Implements cbdc::client.

Definition at line 26 of file atomizer_client.cpp.

◆ operator=() [1/2]

auto cbdc::atomizer_client::operator= ( atomizer_client && ) -> atomizer_client &=delete
delete

◆ operator=() [2/2]

auto cbdc::atomizer_client::operator= ( const atomizer_client & ) -> atomizer_client &=delete
delete

◆ send_mint_tx()

auto cbdc::atomizer_client::send_mint_tx ( const transaction::full_tx & mint_tx) -> bool
overrideprotectedvirtual

Sends the given transaction directly to the atomizer cluster.

Parameters
mint_txtransaction to send.
Returns
true if sending the transaction was successful.

Implements cbdc::client.

Definition at line 88 of file atomizer_client.cpp.

References cbdc::atomizer::tx_notify_request::m_block_height, and cbdc::atomizer::tx_notify_request::m_tx.

◆ sync()

auto cbdc::atomizer_client::sync ( ) -> bool
overridevirtual

Update the client with the latest state from the watchtower.

Queries the watchtower's client endpoint to determine whether any pending transactions or inputs have confirmed or been rejected by the system.

Returns
false if any pending transactions have failed according to the watchtower.

Implements cbdc::client.

Definition at line 39 of file atomizer_client.cpp.

References cbdc::watchtower::spent, cbdc::to_string(), and cbdc::watchtower::unspent.

Here is the call graph for this function:

The documentation for this class was generated from the following files: