public DateTime?GetTransactionInMemory(Transaction tx) { DateTime?res = null; Currency ccy = tx.Received.Ccy; foreach (var item in FeesMemory[ccy]) { if (item.Value.Item1 == tx.ID) { res = item.Key; } } return(res); }
public BitcoinValue GetTransactionFees(Transaction tx, List <string> depositAddresses) { Currency ccy = tx.Received.Ccy; DateTime?timeKey = GetTransactionInMemory(tx); if (timeKey.HasValue) { return(FeesMemory[ccy][timeKey.Value].Item2); } UpdateMemory[ccy] = true; decimal res = 0; long tx_date_ref = StaticLibrary.DateTimeToUnixTimeStamp(tx.Date); DateTime?tx_date = null; foreach (string address in depositAddresses) { List <ApiTx> tx_add = GetAddressTransactions(address); foreach (ApiTx item in tx_add) { if (item.GetAmountFromAddress(address).GetBtc() == (decimal)tx.Received.Amount) { if (StaticLibrary.DateTimeDistTest(tx.Date, item.Time, 4)) { res = item.GetFees().GetBtc(); tx_date = item.Time; } } } } BitcoinValue bv = new BitcoinValue(res); if (tx_date.HasValue) { FeesMemory[ccy][tx_date.Value] = new Tuple <string, BitcoinValue>(tx.ID, bv); } return(bv); }