public async Task BroadcastTransaction(NeoModules.NEP6.Transactions.Transaction signedTransaction,
                                               OperationAggregate aggregate)
        {
            var txHash = signedTransaction.Hash.ToString().Substring(2);

            var lastBlockHeight = await _blockchainProvider.GetHeightAsync();

            try
            {
                var isSuccess = await _neoRawTransactionSender.SendRequestAsync(signedTransaction.ToHexString());

                if (!isSuccess)
                {
                    throw new Exception("Unknown error while broadcasting the tx");
                }
            }
            catch (RpcResponseException e) when(e.RpcError.Code == -501)
            {
                throw new TransactionAlreadyBroadcastedException(e);
            }

            await _observableOperationRepository.InsertOrReplace(ObervableOperation.Create(aggregate,
                                                                                           BroadcastStatus.InProgress,
                                                                                           txHash,
                                                                                           (int)lastBlockHeight));

            await _unconfirmedTransactionRepository.InsertOrReplace(
                UnconfirmedTransaction.Create(aggregate.OperationId, txHash));

            await _transactionOutputsService.CompleteTxOutputs(aggregate.OperationId, signedTransaction);
        }
Esempio n. 2
0
 public static string ToHexString(this NeoModules.NEP6.Transactions.Transaction transaction)
 {
     return(transaction.ToArray().ToHexString());
 }