private async Task UpdateTransaction(TransactionRequest item) { try { var result = await wallet.GetTransferByTxId(item.TxId); if (result != null && result.Transfer != null) { switch (result.Transfer.GetTransferType()) { case WalletRpc.TransferType.Pool: case WalletRpc.TransferType.Pending: case WalletRpc.TransferType.In: await databaseWorker.UpdateTransactionStatus(item.Id, TransactionRequestStatus.InProgress); break; case WalletRpc.TransferType.Out: await databaseWorker.UpdateTransactionStatus(item.Id, TransactionRequestStatus.Out); break; case WalletRpc.TransferType.Failed: case WalletRpc.TransferType.Unknown: default: await databaseWorker.UpdateTransactionStatus(item.Id, TransactionRequestStatus.RpcFailed); break; } } } catch (Exception ex) { logger.LogError(ex, $"Failed to check transaction status for {item.TxId}."); } }
private async Task <IEnumerable <TransactionRequest> > ValidateTransactions(IEnumerable <TransactionRequest> transactions) { List <TransactionRequest> validAddress = new List <TransactionRequest>(); foreach (var item in transactions) { bool isValid = false; try { isValid = await wallet.IsAddressValid(new AddressValidRequest() { address = item.Address }); } catch (Exception ex) { logger.LogError(ex, "Failed to check tx status"); } if (isValid) { validAddress.Add(item); } else { try { await databaseWorker.UpdateTransactionStatus(item.Id, TransactionRequestStatus.IncorrectAddress); } catch (Exception ex) { logger.LogError(ex, $"Failed to update incorrect address '{item.Address}' tx '{item.Id}' status"); } } } return(validAddress); }