14 const std::shared_ptr<logging::log>& logger,
15 const std::string& wallet_file,
16 const std::string& client_file)
17 :
client(opts, logger, wallet_file, client_file),
18 m_wc(opts.m_watchtower_client_endpoints[0]),
23 m_atomizer_network.
close();
27 m_atomizer_network.cluster_connect(m_opts.m_atomizer_endpoints);
28 if(!m_atomizer_network.connected_to_one()) {
29 m_logger->warn(
"Failed to connect to any atomizers");
33 m_logger->warn(
"Failed to initialize watchtower client");
41 for(
const auto& [tx_id, tx] : pending_txs()) {
43 auto [it, success] = tus.insert({ctx.m_id, {}});
45 it->second.insert(it->second.end(),
48 it->second.insert(it->second.end(),
49 ctx.m_uhs_outputs.begin(),
50 ctx.m_uhs_outputs.end());
53 for(
const auto& [tx_id, in] : pending_inputs()) {
54 tus.insert({tx_id, {in.hash()}});
59 m_logger->debug(
"Checking watchtower state...");
61 auto res = m_wc.request_status_update(req);
64 for(
const auto& [tx_id, uhs_states] : res->states()) {
65 for(
const auto& s : uhs_states) {
68 m_logger->warn(
"Tx ID:",
73 static_cast<uint32_t
>(s.status()));
82 success = confirm_transaction(tx_id);
92 for(
size_t i = 0; i < m_opts.m_attestation_threshold; i++) {
94 = ctx.sign(m_secp.get(), m_opts.m_sentinel_private_keys[i]);
95 ctx.m_attestations.insert(att);
97 msg.
m_tx = std::move(ctx);
~atomizer_client() override
auto init_derived() -> bool override
Initializes the atomizer client.
auto sync() -> bool override
Update the client with the latest state from the watchtower.
auto send_mint_tx(const transaction::full_tx &mint_tx) -> bool override
Sends the given transaction directly to the atomizer cluster.
External client for sending new transactions to the system.
void close()
Shuts down the network listener and all existing peer connections.
Network request to interact with the Watchtower's status update service.
std::variant< tx_notify_request, prune_request, get_block_request > request
Atomizer RPC request.
@ spent
The STXO set contains the requested UHS ID.
@ unspent
The UTXO set contains the requested UHS ID.
std::unordered_map< hash_t, std::vector< hash_t >, hashing::const_sip_hash< hash_t > > tx_id_uhs_ids
Set of UHS IDs to query, keyed by Tx IDs.
auto to_string(const hash_t &val) -> std::string
Converts a hash to a hexadecimal string.
Transaction notification message.
transaction::compact_tx m_tx
Compact transaction associated with the notification.
uint64_t m_block_height
Block height at which the given input attestations are valid.
Project-wide configuration options.
A condensed, hash-only transaction representation.
Watchtower core functionality.