| 1406 | } |
| 1407 | |
| 1408 | pub async fn peg_out( |
| 1409 | &mut self, |
| 1410 | client: &AsyncClient, |
| 1411 | context: &OperatorContext, |
| 1412 | input: Input, |
| 1413 | ) -> Result<Transaction, Error> { |
| 1414 | if !self.is_peg_out_initiated() { |
| 1415 | return Err(Error::L2(L2Error::PegOutNotInitiated)); |
| 1416 | } |
| 1417 | |
| 1418 | if self.peg_out_transaction.is_some() { |
| 1419 | let txid = self |
| 1420 | .peg_out_transaction |
| 1421 | .as_ref() |
| 1422 | .unwrap() |
| 1423 | .tx() |
| 1424 | .compute_txid(); |
| 1425 | verify_if_not_mined(client, txid).await?; |
| 1426 | } else { |
| 1427 | let event = self.peg_out_chain_event.as_ref().unwrap(); |
| 1428 | let tx = PegOutTransaction::new(context, event, input); |
| 1429 | self.peg_out_transaction = Some(tx); |
| 1430 | } |
| 1431 | |
| 1432 | Ok(self.peg_out_transaction.as_mut().unwrap().finalize()) |
| 1433 | } |
| 1434 | |
| 1435 | pub async fn peg_out_confirm(&mut self, client: &AsyncClient) -> Result<Transaction, Error> { |
| 1436 | verify_if_not_mined(client, self.peg_out_confirm_transaction.tx().compute_txid()).await?; |