Exemple #1
0
        public async Task <Transaction> GetTransaction(string id)
        {
            Transaction transaction;

            try
            {
                transaction = await TransactionRepository.GetById(id);

                if (transaction == null)
                {
                    transaction = await BlockchainDataProvider.GetTransaction(id);

                    if (transaction == null)
                    {
                        return(null);
                    }

                    transaction.Block = await BlockService.GetBlock(transaction.Blockhash);

                    await TransactionRepository.Save(transaction);

                    foreach (var @in in transaction.TransactionIn)
                    {
                        if (@in.PrevTxIdPointer == null)
                        {
                            continue;
                        }
                        var inputTransaction = await BlockchainDataProvider.GetTransaction(@in.PrevTxIdPointer);

                        @in.PrevVOutFetchedValue = inputTransaction.TransactionsOut[@in.PrevVOutPointer].Value;
                    }
                }
            }
            catch (Exception ex)
            {
                _log.LogError(ex.Message);
                return(null);
            }

            return(transaction);
        }
Exemple #2
0
        public async Task <Transaction> GetTransaction(string id)
        {
            Transaction transaction;

            try
            {
                transaction = await TransactionRepository.GetById(id);

                if (transaction == null)
                {
                    transaction = await BlockchainDataProvider.GetTransaction(id);

                    if (transaction != null)
                    {
                        await BlockService.GetBlock(transaction.Blockhash);

                        foreach (var asset in transaction.Assets)
                        {
                            var assetExists = await AssetRepository.Exists(asset.Id);

                            if (!assetExists && !String.IsNullOrWhiteSpace(asset.MetadataUrl))
                            {
                                var assetData = await BlockchainDataProvider.GetMetadataContent(new Uri(asset.MetadataUrl));

                                await AssetRepository.Save(assetData);
                            }
                        }

                        await TransactionRepository.Save(transaction);
                    }
                }
            }
            catch (Exception ex)
            {
                await Log.WriteError(this.GetType().ToString(), "GetTransaction", $"transaction_id:{id}", ex, DateTime.Now);

                return(null);
            }

            return(transaction);
        }