pub async fn create_txhandlers(
transaction_type: TransactionType,
context: ContractContext,
txhandler_cache: &mut TxHandlerCache,
db_cache: &mut ReimburseDbCache,
) -> Result<BTreeMap<TransactionType, TxHandler>, BridgeError>
Expand description
Creates all required transaction handlers for a given context and transaction type.
This function builds and caches all necessary transaction handlers for the specified transaction type, operator, round, and deposit context. It handles the full flow of collateral, kickoff, challenge, reimbursement, and assertion transactions, including round management and challenge handling. Function returns early if the needed txhandler is already created. Currently there are 3 kinds of specific transaction types that can be given as parameter that change the logic flow
- AllNeededForDeposit: Creates all transactions, including the round tx’s and deposit related tx’s.
- Round related tx’s (Round, ReadyToReimburse, UnspentKickoff): Creates only round related tx’s and returns early.
- MiniAssert and LatestBlockhash: These tx’s are created to commit data in their witness using winternitz signatures. To enable signing these transactions, the kickoff transaction (where the input of MiniAssert and LatestBlockhash resides) needs to be created with the full list of scripts in its TxHandler data. This may take some time especially for a deposit where thousands of kickoff tx’s are created. That’s why if MiniAssert or LatestBlockhash is not requested, these scripts are not created and just the merkle root hash of these scripts is used to create the kickoff tx. But if these tx’s are requested, the full list of scripts is needed to create the kickoff tx, to enable signing these transactions with winternitz signatures.
§Arguments
transaction_type
- The type of transaction(s) to create.context
- The contract context (operator, round, deposit, etc).txhandler_cache
- Cache for storing/retrieving intermediate txhandlers.db_cache
- Database-backed cache for retrieving protocol data.
§Returns
A map of TransactionType
to TxHandler
for all constructed transactions, or a BridgeError
if construction fails.