Beispiel #1
0
        public IEnumerable <GetTransactionApiModel> GetTransactions(string address, int count)
        {
            IEnumerable <GetTransactionApiModel> txs = Node.GetTransactions(address, true)
                                                       .OrderByDescending(tx => tx.DateCreated)
                                                       .Take(count)
                                                       .Select(tx => GetTransactionApiModel.FromTransaction(tx))
                                                       .ToList();

            return(txs);
        }
Beispiel #2
0
        public IEnumerable <GetTransactionApiModel> GetBlcokTransactions(int index)
        {
            bool success = Node.BlockChain.TryGetValue(index, out Block block);

            List <GetTransactionApiModel> txs = new List <GetTransactionApiModel>();

            if (success)
            {
                txs = block.Transactions.Select(tx => GetTransactionApiModel.FromTransaction(tx)).ToList();
                return(txs);
            }

            return(null);
        }
Beispiel #3
0
        public GetTransactionApiModel Get(string txHash)
        {
            GetTransactionApiModel result = Node.PendingTransactions
                                            .Where(t => t.TransactionHash == txHash)
                                            .Select(t => GetTransactionApiModel.FromTransaction(t))
                                            .FirstOrDefault();

            if (result == null)
            {
                result = Node.BlockChain
                         .SelectMany(b => b.Value.Transactions.Select(t => new { BlockIndex = b.Key, Transaction = t }))
                         .Where(t => t.Transaction.TransactionHash == txHash)
                         .Select(x => GetTransactionApiModel.FromTransaction(x.Transaction, x.BlockIndex))
                         .FirstOrDefault();
            }

            return(result);
        }
Beispiel #4
0
 public IEnumerable <GetTransactionApiModel> GetPending()
 {
     return(Node.PendingTransactions.Select(p => GetTransactionApiModel.FromTransaction(p)));
 }