diff --git a/mobilecoind/src/service.rs b/mobilecoind/src/service.rs index fcfd0d011c..1ef9778055 100644 --- a/mobilecoind/src/service.rs +++ b/mobilecoind/src/service.rs @@ -591,12 +591,15 @@ impl { + RpcStatus::with_message(RpcStatusCode::NOT_FOUND, "tx_out not found".into()) + } + _ => rpc_internal_error( "ledger_db.get_tx_out_index_by_public_key", err, &self.logger, - ) + ), })?; let tx_out = self.ledger_db.get_tx_out_by_index(index).map_err(|err| { @@ -793,9 +796,19 @@ impl, LedgerError>>() - .map_err(|e| rpc_internal_error("ledger_error", e, &self.logger))?; // TODO better error handling + .enumerate() + .map(|(idx, tx_out)| { + self.ledger_db + .get_tx_out_index_by_hash(&tx_out.hash()) + .map_err(|err| match err { + LedgerError::NotFound => RpcStatus::with_message( + RpcStatusCode::NOT_FOUND, + format!("tx_out {idx} not found"), + ), + _ => rpc_internal_error("get_tx_out_index_by_hash", err, &self.logger), + }) + }) + .collect::, RpcStatus>>()?; let mixins_with_proofs: Vec<(TxOut, TxOutMembershipProof)> = self .transactions_manager @@ -830,9 +843,15 @@ impl RpcStatus::with_message( + RpcStatusCode::NOT_FOUND, + format!("tx_out {idx} not found"), + ), + _ => rpc_invalid_arg_error("get_tx_out_by_index", err, &self.logger), + }) }) .collect::, RpcStatus>>()?,