clementine_core::builder

Module transaction

Source
Expand description

§builder::transaction

This module provides the core logic for constructing, handling, and signing the various Bitcoin transactions required by the Clementine bridge protocol. It defines the creation, and validation of transaction flows involving operators, verifiers, watchtowers, and the security council, aimed to make it easy to create transactions and sign them properly.

§Overview

The transaction builder is responsible for:

  • Defining all transaction types and their flows in the protocol (see TransactionType).
  • Building and signing transactions for deposit, withdrawal, challenge, reimbursement, and related operations.
  • Storing transaction inputs/outputs, scripts, and Taproot spend information.
  • Providing utilities to speed up transaction creating during a deposit using caching tx and db data.

§Main Components

  • [mod.rs] - The main entry point, re-exporting key types and functions. Defines some helper functions for creating taproot outputs.
  • [creator.rs] - Contains the functions to create multiple TxHandler’s for a deposit and related structs for caching. In particular, it contains the functions to create TxHandler’s for all transactions generated during a deposit from a single kickoff.
  • [operator_collateral.rs] - Handles the creation of operator-specific collateral-related transactions, such as round, ready-to-reimburse, and unspent kickoff transactions.
  • [operator_reimburse.rs] - Implements the creation of reimbursement and payout transactions, including logic for operator compensation and optimistic payouts.
  • [operator_assert.rs] - Provides functions for creating BitVM assertion and timeout transactions.
  • [challenge.rs] - Handles the creation of challenge, disprove, and watchtower challenge transactions, supporting protocol dispute resolution and fraud proofs.
  • [sign.rs] - Contains logic for signing transactions using data in the TxHandler.
  • [txhandler.rs] - Defines the TxHandler abstraction, which wraps a transaction and its metadata, and provides methods for signing, finalizing, and extracting transaction data.
  • [input.rs] - Defines types and utilities for transaction inputs used in the TxHandler.
  • [output.rs] - Defines types and utilities for transaction outputs used in the TxHandler.
  • [deposit_signature_owner.rs] - Maps which TxIn signatures are signed by which protocol entities, additionally supporting different Sighash types.

Modules§

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.
  • Marker type for signed transactions.
  • Handler for protocol transactions, wrapping inputs, outputs, and cached transaction data.
  • Builder for TxHandler, allowing stepwise construction of inputs and outputs.
  • Stores and manages cached transaction handlers for efficient flow construction.
  • Marker type for unsigned transactions.

Enums§

  • Types of all transactions that can be created. Some transactions have an (usize) as they are created multiple times per kickoff.

Constants§

Traits§

Functions§

Type Aliases§