OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
cbdc::transaction::compact_tx Struct Reference

A condensed, hash-only transaction representation. More...

#include <transaction.hpp>

Public Member Functions

auto operator== (const compact_tx &tx) const noexcept -> bool
 Equality of two compact transactions.
 
 compact_tx ()=default
 
 compact_tx (const full_tx &tx)
 
auto sign (secp256k1_context *ctx, const privkey_t &key) const -> sentinel_attestation
 Sign the compact transaction and return the signature.
 
auto verify (secp256k1_context *ctx, const sentinel_attestation &att) const -> bool
 Verify the given attestation contains a valid signature that matches the compact transaction.
 
auto hash () const -> hash_t
 Return the hash of the compact transaction, without the sentinel attestations included.
 

Data Fields

hash_t m_id {}
 The hash of the full transaction returned by tx_id.
 
std::vector< hash_tm_inputs
 The set of hashes of the transaction's inputs.
 
std::vector< hash_tm_uhs_outputs
 The set of hashes of the new outputs created in the transaction.
 
std::unordered_map< pubkey_t, signature_t, hashing::nullm_attestations
 Signatures from sentinels attesting the compact TX is valid.
 

Detailed Description

A condensed, hash-only transaction representation.

The minimum amount of data necessary for the transaction processor to update the UHS with the changes from a full_tx.

See also
cbdc::operator<<(serializer&, const transaction::compact_tx&)

Definition at line 119 of file transaction.hpp.

Constructor & Destructor Documentation

◆ compact_tx() [1/2]

cbdc::transaction::compact_tx::compact_tx ( )
default

◆ compact_tx() [2/2]

cbdc::transaction::compact_tx::compact_tx ( const full_tx & tx)
explicit

Member Function Documentation

◆ hash()

auto cbdc::transaction::compact_tx::hash ( ) const -> hash_t
nodiscard

Return the hash of the compact transaction, without the sentinel attestations included.

Used as the message which is signed in sentinel attestations.

Returns

Definition at line 158 of file transaction.cpp.

References cbdc::make_buffer().

Here is the call graph for this function:

◆ operator==()

auto cbdc::transaction::compact_tx::operator== ( const compact_tx & tx) const -> bool
noexcept

Equality of two compact transactions.

Only compares the transaction IDs.

Definition at line 122 of file transaction.cpp.

◆ sign()

auto cbdc::transaction::compact_tx::sign ( secp256k1_context * ctx,
const privkey_t & key ) const -> sentinel_attestation
nodiscard

Sign the compact transaction and return the signature.

Parameters
ctxsecp256k1 context with which to sign the transaction.
keyprivate key with which to sign the transaction.
Returns
sentinel attestation containing the signature and associated public key.

Definition at line 137 of file transaction.cpp.

References cbdc::pubkey_from_privkey().

Here is the call graph for this function:

◆ verify()

auto cbdc::transaction::compact_tx::verify ( secp256k1_context * ctx,
const sentinel_attestation & att ) const -> bool
nodiscard

Verify the given attestation contains a valid signature that matches the compact transaction.

Parameters
ctxsecp256k1 contact with which to validate the signature.
attsentinel attestation containing a public key and signature.
Returns
true if the given attestation is valid for this compact transaction.

Definition at line 170 of file transaction.cpp.

Field Documentation

◆ m_attestations

std::unordered_map<pubkey_t, signature_t, hashing::null> cbdc::transaction::compact_tx::m_attestations

Signatures from sentinels attesting the compact TX is valid.

Definition at line 131 of file transaction.hpp.

◆ m_id

hash_t cbdc::transaction::compact_tx::m_id {}

The hash of the full transaction returned by tx_id.

Definition at line 121 of file transaction.hpp.

Referenced by cbdc::locking_shard::locking_shard::apply_outputs(), and compact_tx().

◆ m_inputs

std::vector<hash_t> cbdc::transaction::compact_tx::m_inputs

The set of hashes of the transaction's inputs.

Definition at line 124 of file transaction.hpp.

Referenced by cbdc::locking_shard::locking_shard::apply_outputs(), and compact_tx().

◆ m_uhs_outputs

std::vector<hash_t> cbdc::transaction::compact_tx::m_uhs_outputs

The set of hashes of the new outputs created in the transaction.

Definition at line 127 of file transaction.hpp.

Referenced by cbdc::locking_shard::locking_shard::apply_outputs(), and compact_tx().


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