public async Task EthereumTransactionServiceTest_CheckTransactionIsPending() { string trHash = "0xa91534ba74bd42f9971fa2b54344bc043eb2e7b51e7017b90757ee042caaacc0"; bool result = await _transactionService.IsTransactionInPool(trHash); Assert.IsFalse(result); }
public async Task ThrowOnExistingHashAsync(string trHash) { bool transactionInPool = await _ethereumTransactionService.IsTransactionInPool(trHash); TransactionReceipt reciept = await _ethereumTransactionService.GetTransactionReceipt(trHash); if (transactionInPool || reciept != null) { throw new ClientSideException(ExceptionType.TransactionExists, $"Transaction with hash {trHash} already exists"); } }
public async Task Execute(CoinTransactionMessage transaction, QueueTriggeringContext context) { ICoinTransaction coinTransaction = null; try { bool isTransactionInMemoryPool = await _ethereumTransactionService.IsTransactionInPool(transaction.TransactionHash); if (isTransactionInMemoryPool) { SendMessageToTheQueueEnd(context, transaction, 100, "Transaction is in memory pool"); return; } coinTransaction = await _coinTransactionService.ProcessTransaction(transaction); } catch (Exception ex) { if (ex.Message != transaction.LastError) { await _log.WriteWarningAsync(nameof(AirlinesHotWalletMonitoringTransactionJob), "Execute", $"TrHash: [{transaction.TransactionHash}]", ""); } SendMessageToTheQueueEnd(context, transaction, 200, ex.Message); await _log.WriteErrorAsync(nameof(AirlinesHotWalletMonitoringTransactionJob), "Execute", "", ex); return; } if (coinTransaction == null) { await RepeatOperationTillWin(transaction); await _slackNotifier.ErrorAsync($"Airlines: Transaction with hash {transaction.TransactionHash} has ERROR. RETRY. Address is yet blocked"); } else { if (coinTransaction.ConfirmationLevel >= CoinTransactionService.Level2Confirm) { bool sentToRabbit = await SendCompleteEvent(transaction.TransactionHash, transaction.OperationId, !coinTransaction.Error, context, transaction); if (sentToRabbit) { await _log.WriteInfoAsync(nameof(AirlinesHotWalletMonitoringTransactionJob), "Execute", "", $"Put coin transaction {transaction.TransactionHash} to rabbit queue with confimation level {coinTransaction?.ConfirmationLevel ?? 0}"); } else { await _log.WriteInfoAsync(nameof(AirlinesHotWalletMonitoringTransactionJob), "Execute", "", $"Put coin transaction {transaction.TransactionHash} to monitoring queue with confimation level {coinTransaction?.ConfirmationLevel ?? 0}"); } if (coinTransaction.Error) { await _slackNotifier.ErrorAsync($"EthereumCoreService: HOTWALLET - Transaction with hash {transaction.TransactionHash} has an Error. Notify Caller about fail!"); } } else { SendMessageToTheQueueEnd(context, transaction, 100); await _log.WriteInfoAsync(nameof(AirlinesHotWalletMonitoringTransactionJob), "Execute", "", $"Put coin transaction {transaction.TransactionHash} to monitoring queue with confimation level {coinTransaction?.ConfirmationLevel ?? 0}"); } } }
public async Task Execute(CoinTransactionMessage transaction, QueueTriggeringContext context) { ICoinTransaction coinTransaction = null; try { bool isTransactionInMemoryPool = await _ethereumTransactionService.IsTransactionInPool(transaction.TransactionHash); if (isTransactionInMemoryPool) { SendMessageToTheQueueEnd(context, transaction, 100, "Transaction is in memory pool"); return; } coinTransaction = await _coinTransactionService.ProcessTransaction(transaction); } catch (Exception ex) { if (ex.Message != transaction.LastError) { await _log.WriteWarningAsync("MonitoringCoinTransactionJob", "Execute", $"TrHash: [{transaction.TransactionHash}]", ""); } SendMessageToTheQueueEnd(context, transaction, 200, ex.Message); await _log.WriteErrorAsync("MonitoringCoinTransactionJob", "Execute", "", ex); return; } if ((coinTransaction == null) && (DateTime.UtcNow - transaction.PutDateTime > _broadcastMonitoringPeriodSeconds)) { await RepeatOperationTillWin(transaction); await _slackNotifier.ErrorAsync($"EthereumCoreService: Transaction with hash {transaction.TransactionHash} has no confirmations." + $" Reason - unable to find transaction in txPool and in blockchain within {_broadcastMonitoringPeriodSeconds} seconds"); } else { if (coinTransaction != null && coinTransaction.ConfirmationLevel >= CoinTransactionService.Level2Confirm) { if (!coinTransaction.Error) { bool sentToRabbit = await SendCompletedCoinEvent( transaction.TransactionHash, transaction.OperationId, true, context, transaction); if (sentToRabbit) { await _log.WriteInfoAsync("CoinTransactionService", "Execute", "", $"Put coin transaction {transaction.TransactionHash} to rabbit queue with confimation level {coinTransaction?.ConfirmationLevel ?? 0}"); } else { await _log.WriteInfoAsync("CoinTransactionService", "Execute", "", $"Put coin transaction {transaction.TransactionHash} to monitoring queue with confimation level {coinTransaction?.ConfirmationLevel ?? 0}"); } } else { ICoinEvent coinEvent = await GetCoinEvent(transaction.TransactionHash, transaction.OperationId, true); await _slackNotifier.ErrorAsync($"EthereumCoreService: Transaction with hash {transaction.TransactionHash} has an Error!({coinEvent.CoinEventType})"); if (coinEvent.CoinEventType == CoinEventType.CashoutStarted || coinEvent.CoinEventType == CoinEventType.CashoutFailed) { if (coinTransaction.ConfirmationLevel >= 2) { //SEND FAILED CASHOUTS EVENTS HERE AND FILL Black LIST await _blackListAddressesRepository.SaveAsync(new BlackListAddress() { Address = coinEvent.ToAddress }); await SendCompletedCoinEvent(transaction.TransactionHash, transaction.OperationId, false, context, transaction); } else { SendMessageToTheQueueEnd(context, transaction, 200, "Did not recieve confirmation level 3 yet"); } return; } else { await RepeatOperationTillWin(transaction); await _slackNotifier.ErrorAsync($"EthereumCoreService: Transaction with hash {transaction.TransactionHash} has an Error. RETRY!({coinEvent.CoinEventType})"); } } } else { SendMessageToTheQueueEnd(context, transaction, 100); await _log.WriteInfoAsync("CoinTransactionService", "Execute", "", $"Put coin transaction {transaction.TransactionHash} to monitoring queue with confimation level {coinTransaction?.ConfirmationLevel ?? 0}"); } } }
public async Task Execute(CoinTransactionMessage transaction, QueueTriggeringContext context) { ICoinTransaction coinTransaction = null; try { bool isTransactionInMemoryPool = await _ethereumTransactionService.IsTransactionInPool(transaction.TransactionHash); if (isTransactionInMemoryPool) { SendMessageToTheQueueEnd(context, transaction, 100, "Transaction is in memory pool"); return; } coinTransaction = await _coinTransactionService.ProcessTransaction(transaction); } catch (Exception ex) { if (ex.Message != transaction.LastError) { await _log.WriteWarningAsync(nameof(HotWalletMonitoringTransactionJob), "Execute", $"TrHash: [{transaction.TransactionHash}]", ""); } SendMessageToTheQueueEnd(context, transaction, 200, ex.Message); await _log.WriteErrorAsync(nameof(HotWalletMonitoringTransactionJob), "Execute", "", ex); return; } if (coinTransaction == null || coinTransaction.Error) { await RepeatOperationTillWin(transaction); //await _slackNotifier.ErrorAsync($"EthereumCoreService: Transaction with hash {transaction.TransactionHash} has no confirmations." + // $" Reason - unable to find transaction in txPool and in blockchain within {_broadcastMonitoringPeriodSeconds} seconds"); } else { if (coinTransaction.ConfirmationLevel >= CoinTransactionService.Level2Confirm) { if (!coinTransaction.Error) { bool sentToRabbit = await SendCompleteEvent(transaction.TransactionHash, transaction.OperationId, true, context, transaction); if (sentToRabbit) { await _log.WriteInfoAsync(nameof(HotWalletMonitoringTransactionJob), "Execute", "", $"Put coin transaction {transaction.TransactionHash} to rabbit queue with confimation level {coinTransaction?.ConfirmationLevel ?? 0}"); } else { await _log.WriteInfoAsync(nameof(HotWalletMonitoringTransactionJob), "Execute", "", $"Put coin transaction {transaction.TransactionHash} to monitoring queue with confimation level {coinTransaction?.ConfirmationLevel ?? 0}"); } } else { await _slackNotifier.ErrorAsync($"EthereumCoreService: HOTWALLET - Transaction with hash {transaction.TransactionHash} has an Error!"); await RepeatOperationTillWin(transaction); await _slackNotifier.ErrorAsync($"EthereumCoreService: HOTWALLET - Transaction with hash {transaction.TransactionHash} has an Error. RETRY!"); } } else { SendMessageToTheQueueEnd(context, transaction, 100); await _log.WriteInfoAsync(nameof(HotWalletMonitoringTransactionJob), "Execute", "", $"Put coin transaction {transaction.TransactionHash} to monitoring queue with confimation level {coinTransaction?.ConfirmationLevel ?? 0}"); } } }