| 1574 | } |
| 1575 | |
| 1576 | pub async fn start_time_timeout( |
| 1577 | &mut self, |
| 1578 | client: &AsyncClient, |
| 1579 | output_script_pubkey: ScriptBuf, |
| 1580 | ) -> Result<Transaction, Error> { |
| 1581 | verify_if_not_mined( |
| 1582 | client, |
| 1583 | self.start_time_timeout_transaction.tx().compute_txid(), |
| 1584 | ) |
| 1585 | .await?; |
| 1586 | |
| 1587 | let kick_off_1_txid = self.kick_off_1_transaction.tx().compute_txid(); |
| 1588 | let kick_off_1_status = client.get_tx_status(&kick_off_1_txid).await; |
| 1589 | |
| 1590 | let blockchain_height = client.get_height().await; |
| 1591 | |
| 1592 | match kick_off_1_status { |
| 1593 | Ok(status) => match status.confirmed { |
| 1594 | true => match status.block_height { |
| 1595 | Some(block_height) |
| 1596 | if blockchain_height.is_ok_and(|height| { |
| 1597 | block_height + self.connector_1.num_blocks_timelock_leaf_2 <= height |
| 1598 | }) => |
| 1599 | { |
| 1600 | self.start_time_timeout_transaction |
| 1601 | .add_output(output_script_pubkey); |
| 1602 | Ok(self.start_time_timeout_transaction.finalize()) |
| 1603 | } |
| 1604 | _ => Err(Error::Graph(GraphError::PrecedingTxTimelockNotMet( |
| 1605 | NamedTx::for_tx(&self.kick_off_1_transaction, status.confirmed), |
| 1606 | ))), |
| 1607 | }, |
| 1608 | false => Err(Error::Graph(GraphError::PrecedingTxNotConfirmed(vec![ |
| 1609 | NamedTx::for_tx(&self.kick_off_1_transaction, status.confirmed), |
| 1610 | ]))), |
| 1611 | }, |
| 1612 | Err(e) => Err(Error::Esplora(e)), |
| 1613 | } |
| 1614 | } |
| 1615 | |
| 1616 | pub async fn kick_off_2( |
| 1617 | &mut self, |