use this when possible return both commit1 and commit2, will save time for verifying groth16
(
&mut self,
client: &AsyncClient,
commitment_secrets: &HashMap<CommitmentMessageId, WinternitzSecret>,
proof: &RawProof,
)
| 1791 | // use this when possible |
| 1792 | // return both commit1 and commit2, will save time for verifying groth16 |
| 1793 | pub async fn assert_commits( |
| 1794 | &mut self, |
| 1795 | client: &AsyncClient, |
| 1796 | commitment_secrets: &HashMap<CommitmentMessageId, WinternitzSecret>, |
| 1797 | proof: &RawProof, |
| 1798 | ) -> Result<(Transaction, Transaction), Error> { |
| 1799 | verify_if_not_mined(client, self.assert_commit_1_transaction.tx().compute_txid()).await?; |
| 1800 | verify_if_not_mined(client, self.assert_commit_2_transaction.tx().compute_txid()).await?; |
| 1801 | |
| 1802 | let assert_initial_txid = self.assert_initial_transaction.tx().compute_txid(); |
| 1803 | let assert_initial_status = client.get_tx_status(&assert_initial_txid).await; |
| 1804 | |
| 1805 | match assert_initial_status { |
| 1806 | Ok(status) => match status.confirmed { |
| 1807 | true => { |
| 1808 | let (witness_for_commit1, witness_for_commit2) = |
| 1809 | sign_assert_tx_with_groth16_proof(commitment_secrets, proof); |
| 1810 | self.assert_commit_1_transaction |
| 1811 | .sign(&self.connector_e_1, witness_for_commit1); |
| 1812 | self.assert_commit_2_transaction |
| 1813 | .sign(&self.connector_e_2, witness_for_commit2); |
| 1814 | Ok(( |
| 1815 | self.assert_commit_1_transaction.finalize(), |
| 1816 | self.assert_commit_2_transaction.finalize(), |
| 1817 | )) |
| 1818 | } |
| 1819 | false => Err(Error::Graph(GraphError::PrecedingTxNotConfirmed(vec![ |
| 1820 | NamedTx::for_tx(&self.assert_initial_transaction, status.confirmed), |
| 1821 | ]))), |
| 1822 | }, |
| 1823 | Err(e) => Err(Error::Esplora(e)), |
| 1824 | } |
| 1825 | } |
| 1826 | |
| 1827 | pub async fn assert_final(&mut self, client: &AsyncClient) -> Result<Transaction, Error> { |
| 1828 | verify_if_not_mined(client, self.assert_final_transaction.tx().compute_txid()).await?; |