|
OpenCBDC Transaction Processor
|
Client for interacting with the 2PC architecture. More...
#include <twophase_client.hpp>


Public Member Functions | |
| twophase_client (const cbdc::config::options &opts, const std::shared_ptr< logging::log > &logger, const std::string &wallet_file, const std::string &client_file) | |
| Constructor. | |
| ~twophase_client () override=default | |
| twophase_client ()=delete | |
| twophase_client (const twophase_client &)=delete | |
| auto | operator= (const twophase_client &) -> twophase_client &=delete |
| twophase_client (twophase_client &&)=delete | |
| auto | operator= (twophase_client &&) -> twophase_client &=delete |
| auto | sync () -> bool override |
| Update the client with the latest state from the shard network. | |
| auto | check_tx_id (const hash_t &tx_id) -> std::optional< bool > |
| Checks the shard network for the status of a specific transaction. | |
| auto | check_unspent (const hash_t &uhs_id) -> std::optional< bool > |
| Checks the shard network for the status of a specific UHS ID. | |
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 2PC architecture client. | |
| auto | send_mint_tx (const transaction::full_tx &mint_tx) -> bool override |
| Sends the given mint transaction directly to a coordinator 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. | |
Client for interacting with the 2PC architecture.
Definition at line 15 of file twophase_client.hpp.
| cbdc::twophase_client::twophase_client | ( | const cbdc::config::options & | opts, |
| const std::shared_ptr< logging::log > & | logger, | ||
| const std::string & | wallet_file, | ||
| const std::string & | client_file ) |
Constructor.
| opts | configuration options. |
| logger | pointer to shared logger. |
| wallet_file | name of .dat file in which to store the wallet data. |
| client_file | name of .dat file in which to store the internal state data. |
Definition at line 11 of file twophase_client.cpp.
|
overridedefault |
|
delete |
|
delete |
|
delete |
| auto cbdc::twophase_client::check_tx_id | ( | const hash_t & | tx_id | ) | -> std::optional<bool> |
Checks the shard network for the status of a specific transaction.
Queries the shards' read-only endpoints to determine whether the transaction processing system has confirmed a specific transaction.
Definition at line 66 of file twophase_client.cpp.
| auto cbdc::twophase_client::check_unspent | ( | const hash_t & | uhs_id | ) | -> std::optional<bool> |
Checks the shard network for the status of a specific UHS ID.
Queries the shards' read-only endpoints to determine whether a specific UHS ID is unspent.
Definition at line 71 of file twophase_client.cpp.
|
overrideprotectedvirtual |
Initializes the 2PC architecture client.
Connects to the coordinator network to allow this client to directly submit minting transactions. Initializes the locking shard read-only client to allow this client to confirm transactions and imported inputs.
Implements cbdc::client.
Definition at line 24 of file twophase_client.cpp.
|
delete |
|
delete |
|
overrideprotectedvirtual |
Sends the given mint transaction directly to a coordinator cluster.
| mint_tx | transaction to send. |
Implements cbdc::client.
Definition at line 76 of file twophase_client.cpp.
|
overridevirtual |
Update the client with the latest state from the shard network.
Queries the shards' read-only endpoints to determine whether the transaction processing system has confirmed any of this client's pending transactions or inputs.
Implements cbdc::client.
Definition at line 36 of file twophase_client.cpp.
References cbdc::to_string().
