clementine_core::builder::transaction

Module creator

Source
Expand description

§Transaction Handler Creation Logic

This module provides the logic for constructing, caching, and managing transaction handlers (TxHandler) for all transaction types in the Clementine bridge.

It is responsible for orchestrating the creation of all transaction flows for a given operator, round, and deposit, including collateral, kickoff, challenge, reimbursement, and assertion transactions. It also manages context and database-backed caching to support efficient and correct transaction construction.

§Key Types

  • KickoffWinternitzKeys - Helper for managing Winternitz keys for kickoff transactions, to retrieve the correct keys for a given round.
  • ReimburseDbCache - Retrieves and caches relevant data from the database for transaction handler creation.
  • ContractContext - Holds context for a specific operator, round, and optionally deposit, in short all the information needed to create the relevant transactions.
  • TxHandlerCache - Stores and manages cached transaction handlers for efficient flow construction. This is important during the deposit, as the functions create all transactions for a single operator, kickoff utxo, and deposit tuple, which has common transactions between them. (Mainly round tx and move to vault tx)

§Main Functions

  • create_txhandlers - Orchestrates the creation of all required transaction handlers for a given context and transaction type.
  • create_round_txhandlers - Creates round and ready-to-reimburse transaction handlers for a specific operator and round.

Structs§

  • Context for a single operator and round, and optionally a single deposit. Data about deposit and kickoff idx is needed to create the deposit-related transactions. For non deposit related transactions, like the round tx and ready to reimburse tx, the round idx is enough.
  • Helper struct to get specific kickoff winternitz keys for a sequential collateral tx
  • Struct to retrieve and cache data from DB for creating TxHandlers on demand It can only store information for one deposit and operator pair. It has two context modes, for rounds or for deposits. Deposit context needs additional information, like the deposit outpoint, which is not needed for rounds. Round context can only create transactions that do not depend on the deposit, like the round tx and ready to reimburse tx. Deposit context can create all transactions. Note: This cache is specific to a single operator, for each operator a new cache is needed.
  • Stores and manages cached transaction handlers for efficient flow construction.

Functions§

  • Creates the round and ready-to-reimburse txhandlers for a specific operator and round index. These transactions currently include round tx, ready to reimburse tx, and unspent kickoff txs.
  • Creates all required transaction handlers for a given context and transaction type.