| 1514 | } |
| 1515 | |
| 1516 | pub async fn challenge( |
| 1517 | &mut self, |
| 1518 | client: &AsyncClient, |
| 1519 | crowdfundng_inputs: &Vec<InputWithScript<'_>>, |
| 1520 | keypair: &Keypair, |
| 1521 | output_script_pubkey: ScriptBuf, |
| 1522 | ) -> Result<Transaction, Error> { |
| 1523 | verify_if_not_mined(client, self.challenge_transaction.tx().compute_txid()).await?; |
| 1524 | |
| 1525 | let kick_off_1_txid = self.kick_off_1_transaction.tx().compute_txid(); |
| 1526 | let kick_off_1_status = client.get_tx_status(&kick_off_1_txid).await; |
| 1527 | |
| 1528 | match kick_off_1_status { |
| 1529 | Ok(status) => match status.confirmed { |
| 1530 | true => { |
| 1531 | self.challenge_transaction.add_inputs_and_output( |
| 1532 | crowdfundng_inputs, |
| 1533 | keypair, |
| 1534 | output_script_pubkey, |
| 1535 | ); |
| 1536 | Ok(self.challenge_transaction.finalize()) |
| 1537 | } |
| 1538 | false => Err(Error::Graph(GraphError::PrecedingTxNotConfirmed(vec![ |
| 1539 | NamedTx::for_tx(&self.kick_off_1_transaction, status.confirmed), |
| 1540 | ]))), |
| 1541 | }, |
| 1542 | Err(e) => Err(Error::Esplora(e)), |
| 1543 | } |
| 1544 | } |
| 1545 | |
| 1546 | pub async fn start_time( |
| 1547 | &mut self, |