async fn confirm_transaction(
        &mut self,
        tx_id: u64,
        inputs: &[TransactionInput],
        outputs: &[TransactionOutput],
    ) -> Result<(), OutputManagerError>
    {
        let pending_transaction = self.resources.db.fetch_pending_transaction_outputs(tx_id).await?;

        // Check that outputs to be spent can all be found in the provided transaction inputs
        let mut inputs_confirmed = true;
        for output_to_spend in pending_transaction.outputs_to_be_spent.iter() {
            let input_to_check = output_to_spend
                .unblinded_output
                .clone()
                .as_transaction_input(&self.resources.factories.commitment, OutputFeatures::default());
            inputs_confirmed =
                inputs_confirmed && inputs.iter().any(|input| input.commitment == input_to_check.commitment);
        }

        // Check that outputs to be received can all be found in the provided transaction outputs
        let mut outputs_confirmed = true;
        for output_to_receive in pending_transaction.outputs_to_be_received.iter() {
            let output_to_check = output_to_receive
                .unblinded_output
                .clone()
                .as_transaction_input(&self.resources.factories.commitment, OutputFeatures::default());
            outputs_confirmed = outputs_confirmed &&
                outputs
                    .iter()
                    .any(|output| output.commitment == output_to_check.commitment);
        }

        if !inputs_confirmed || !outputs_confirmed {
            return Err(OutputManagerError::IncompleteTransaction);
        }

        self.resources
            .db
            .confirm_pending_transaction_outputs(pending_transaction.tx_id)
            .await?;

        trace!(target: LOG_TARGET, "Confirm transaction (TxId: {})", tx_id);

        Ok(())
    }
/// Confirm that a received or sent transaction and its outputs have been detected on the base chain. The inputs and
/// outputs are checked to see that they match what the stored PendingTransaction contains. This will
/// be called by the Transaction Service which monitors the base chain.
Confirm that a received or sent transaction and its outputs have been detected on the base chain. The inputs and
outputs are checked to see that they match what the stored PendingTransaction contains. This will
be called by the Transaction Service which monitors the base chain.
Confirm that a received or sent transaction and its outputs have been detected on the base chain . The inputs and outputs are checked to see that they match what the stored PendingTransaction contains . This will be called by the Transaction Service which monitors the base chain .
async fn confirm_transaction(
        &mut self,
        tx_id: u64,
        inputs: &[TransactionInput],
        outputs: &[TransactionOutput],
    ) -> Result<(), OutputManagerError>
    {
        let pending_transaction = self.resources.db.fetch_pending_transaction_outputs(tx_id).await?;
        // Check that outputs to be spent can all be found in the provided transaction inputs
        let mut inputs_confirmed = true;
        for output_to_spend in pending_transaction.outputs_to_be_spent.iter() {
            let input_to_check = output_to_spend
                .unblinded_output
                .clone()
                .as_transaction_input(&self.resources.factories.commitment, OutputFeatures::default());
            inputs_confirmed =
                inputs_confirmed && inputs.iter().any(|input| input.commitment == input_to_check.commitment);
        }
        // Check that outputs to be received can all be found in the provided transaction outputs
        let mut outputs_confirmed = true;
        for output_to_receive in pending_transaction.outputs_to_be_received.iter() {
            let output_to_check = output_to_receive
                .unblinded_output
                .clone()
                .as_transaction_input(&self.resources.factories.commitment, OutputFeatures::default());
            outputs_confirmed = outputs_confirmed &&
                outputs
                    .iter()
                    .any(|output| output.commitment == output_to_check.commitment);
        }
        if !inputs_confirmed || !outputs_confirmed {
            return Err(OutputManagerError::IncompleteTransaction);
        }
        self.resources
            .db
            .confirm_pending_transaction_outputs(pending_transaction.tx_id)
            .await?;
        trace!(target: LOG_TARGET, "Confirm transaction (TxId: {})", tx_id);
        Ok(())
    }
async fn confirm_transaction ( & mut self , tx_id : u64 , inputs : & [ TransactionInput ] , outputs : & [ TransactionOutput ] , ) -> Result < ( ) , OutputManagerError > { let pending_transaction = self . resources . db . fetch_pending_transaction_outputs ( tx_id ) . await ? ; // Check that outputs to be spent can all be found in the provided transaction inputs let mut inputs_confirmed = true ; for output_to_spend in pending_transaction . outputs_to_be_spent . iter ( ) { let input_to_check = output_to_spend . unblinded_output . clone ( ) . as_transaction_input ( & self . resources . factories . commitment , OutputFeatures :: default ( ) ) ; inputs_confirmed = inputs_confirmed && inputs . iter ( ) . any ( | input | input . commitment == input_to_check . commitment ) ; } // Check that outputs to be received can all be found in the provided transaction outputs let mut outputs_confirmed = true ; for output_to_receive in pending_transaction . outputs_to_be_received . iter ( ) { let output_to_check = output_to_receive . unblinded_output . clone ( ) . as_transaction_input ( & self . resources . factories . commitment , OutputFeatures :: default ( ) ) ; outputs_confirmed = outputs_confirmed && outputs . iter ( ) . any ( | output | output . commitment == output_to_check . commitment ) ; } if ! inputs_confirmed || ! outputs_confirmed { return Err ( OutputManagerError :: IncompleteTransaction ) ; } self . resources . db . confirm_pending_transaction_outputs ( pending_transaction . tx_id ) . await ? ; trace ! ( target LOG_TARGET " " tx_id ) ; Ok ( ( ) ) }
Confirm that a received or sent transaction and its outputs have been detected on the base chain.
Confirm that a received or sent transaction and its outputs have been detected on the base chain .
&mut self
tx_id
u64
inputs
&[TransactionInput]
outputs
&[TransactionOutput]
&mut self
tx_id
u64
inputs
&[TransactionInput]
outputs
&[TransactionOutput]