| 1614 | } |
| 1615 | |
| 1616 | pub async fn kick_off_2( |
| 1617 | &mut self, |
| 1618 | client: &AsyncClient, |
| 1619 | context: &OperatorContext, |
| 1620 | superblock_commitment_secret: &WinternitzSecret, |
| 1621 | superblock_hash_commitment_secret: &WinternitzSecret, |
| 1622 | ) -> Result<Transaction, Error> { |
| 1623 | verify_if_not_mined(client, self.kick_off_2_transaction.tx().compute_txid()).await?; |
| 1624 | |
| 1625 | let kick_off_1_txid = self.kick_off_1_transaction.tx().compute_txid(); |
| 1626 | let kick_off_1_status = client.get_tx_status(&kick_off_1_txid).await; |
| 1627 | |
| 1628 | let blockchain_height = client.get_height().await; |
| 1629 | |
| 1630 | match kick_off_1_status { |
| 1631 | Ok(status) => match status.confirmed { |
| 1632 | true => match status.block_height { |
| 1633 | Some(block_height) |
| 1634 | if blockchain_height.is_ok_and(|height| { |
| 1635 | block_height + self.connector_1.num_blocks_timelock_leaf_0 <= height |
| 1636 | }) => |
| 1637 | { |
| 1638 | let superblock_header = find_superblock(); |
| 1639 | self.kick_off_2_transaction.sign( |
| 1640 | context, |
| 1641 | &self.connector_1, |
| 1642 | &WinternitzSigningInputs { |
| 1643 | message: &get_superblock_message(&superblock_header), |
| 1644 | signing_key: superblock_commitment_secret, |
| 1645 | }, |
| 1646 | &WinternitzSigningInputs { |
| 1647 | message: &get_superblock_hash_message(&superblock_header), |
| 1648 | signing_key: superblock_hash_commitment_secret, |
| 1649 | }, |
| 1650 | ); |
| 1651 | Ok(self.kick_off_2_transaction.finalize()) |
| 1652 | } |
| 1653 | _ => Err(Error::Graph(GraphError::PrecedingTxTimelockNotMet( |
| 1654 | NamedTx::for_tx(&self.kick_off_1_transaction, status.confirmed), |
| 1655 | ))), |
| 1656 | }, |
| 1657 | false => Err(Error::Graph(GraphError::PrecedingTxNotConfirmed(vec![ |
| 1658 | NamedTx::for_tx(&self.kick_off_1_transaction, status.confirmed), |
| 1659 | ]))), |
| 1660 | }, |
| 1661 | Err(e) => Err(Error::Esplora(e)), |
| 1662 | } |
| 1663 | } |
| 1664 | |
| 1665 | pub async fn kick_off_timeout( |
| 1666 | &mut self, |