Example #1
0
        public async Task <IEnumerable <Transaction> > PullTransactionsAsync(int maxGetTransactions = 20, int updateTransactionsWithConfirmationLessThan = 6)
        {
            var newTransactions = new List <Transaction>();
            var wallets         = await _bitcoindClient.GetListWalletsAsync();

            foreach (var wallet in wallets)
            {
                var transactionsDto = await _bitcoindClient.GetListTransactionsAsync(wallet, maxGetTransactions);

                var transactionsDb = Mapper.Map <List <Transaction> >(transactionsDto);

                foreach (var transaction in transactionsDb)
                {
                    if (transaction.Category == Category.Unknown)
                    {
                        continue;
                    }

                    var tran = await _dataContext.Transactions
                               .FirstOrDefaultAsync(x => x.Txid == transaction.Txid && x.Category == transaction.Category);

                    if (tran == null)
                    {
                        transaction.Wallet = wallet;
                        _dataContext.Transactions.Add(transaction);
                        newTransactions.Add(transaction);
                    }
                    else if (tran.Confirmations <= updateTransactionsWithConfirmationLessThan)
                    {
                        tran.Confirmations = transaction.Confirmations;
                    }
                }
            }

            await _dataContext.SaveChangesAsync();

            return(newTransactions);
        }
Example #2
0
 public void CanGetListTransactions(string wallet)
 {
     var transactions = _bitcoindClient.GetListTransactionsAsync(wallet).Result;
 }