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 theTxHandler
. - [
txhandler.rs
] - Defines theTxHandler
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 theTxHandler
. - [
output.rs
] - Defines types and utilities for transaction outputs used in theTxHandler
. - [
deposit_signature_owner.rs
] - Maps which TxIn signatures are signed by which protocol entities, additionally supporting different Sighash types.
Modules§
- Challenge Transaction Logic
- Deposit Signature Ownership Mapping
- Transaction Input Types and Utilities
- Transaction Output Types and Utilities
- Transaction Signing Utilities
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§
- Creates a P2A (anchor) output for Child Pays For Parent (CPFP) fee bumping.
- Combines multiple emergency stop transactions into a single transaction.
- Creates a
TxHandler
for burning unused kickoff connectors. - Creates a Taproot output for a disprove path, combining a script, an additional disprove script, and a hidden node containing the BitVM disprove scripts.
- Creates a
TxHandler
for theemergency_stop_tx
. - Creates a
TxHandler
for themove_to_vault_tx
. - Creates a
TxHandler
for theoptimistic_payout_tx
. - Creates a
TxHandler
for thepayout_tx
. - Creates a
TxHandler
for thereplacement_deposit_tx
. - Creates the nth (1-indexed)
round_txhandler
andreimburse_generator_txhandler
pair for a specific operator. - 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.
- Helper function to create a Taproot output that combines a single script and a root hash containing any number of scripts. The main use case for this function is to speed up the tx creating during a deposit. We don’t need to create and combine all the scripts in the taproot repeatedly, but cache and combine the common scripts for each kickoff tx to a root hash, and add an additional script that depends on the specific operator or nofn_pk that is signing the deposit.
- Creates all required transaction handlers for a given context and transaction type.
- A non-ephemeral anchor output. It is used in tx’s that should have a non-ephemeral anchor. Because ephemeral anchors force the tx to have 0 fee.
- Creates an OP_RETURN output with the given data slice.
- Removes a
TxHandler
from a map by transaction type, returning an error if not found.