public static CryptocurrencyApi Get(CryptocurrencyAPIProvider aPIProvider) { var cache = new CryptocurrenciesApiCache(); var dictionary = (Dictionary <CryptocurrencyAPIProvider, CryptocurrencyApi>)cache.Get(); return(dictionary[aPIProvider]); }
public static BitcoinAddress GetAddress(string bitcoinAddress, CryptocurrencyAPIProvider type) { List <BitcoinAddress> addresses = new List <BitcoinAddress>(); switch (type) { case CryptocurrencyAPIProvider.CoinPayments: addresses = TableHelper.SelectRows <BitcoinAddress>(TableHelper.MakeDictionary("CoinPaymentsAddress", bitcoinAddress)); break; case CryptocurrencyAPIProvider.Coinbase: addresses = TableHelper.SelectRows <BitcoinAddress>(TableHelper.MakeDictionary("CoinbaseAddress", bitcoinAddress)); break; case CryptocurrencyAPIProvider.Blocktrail: addresses = TableHelper.SelectRows <BitcoinAddress>(TableHelper.MakeDictionary("BlocktrailAddress", bitcoinAddress)); break; } if (addresses.Count == 0) { return(null); } return(addresses[0]); }
public static bool Contains(CryptocurrencyAPIProvider provider, string id, int userId) { var count = (int)TableHelper.SelectScalar( String.Format("SELECT COUNT(*) FROM BitcoinIPNHistory WHERE UserId = {0} AND BitcoinCryptocurrencyAPIProvider = {1} AND IPNId = '{2}'", userId, (int)provider, id)); return(count > 0); }
public static void Add(CryptocurrencyAPIProvider provider, string id, int userId) { BitcoinIPNHistory history = new BitcoinIPNHistory(); history.UserId = userId; history.IPNId = id; history.CryptocurrencyAPIProvider = provider; history.Save(); }
/// <summary> /// Use if you don't have Member object (need to get it from DB by address) /// </summary> /// <param name="provider"></param> /// <param name="address"></param> /// <param name="amountInCryptocurrency"></param> /// <param name="transactionHash"></param> /// <param name="cryptoCurrencyInfo"></param> /// <param name="confirmations"></param> public void TryDepositCryptocurrency(CryptocurrencyAPIProvider provider, string address, decimal amountInCryptocurrency, string transactionHash, string cryptoCurrencyInfo, int confirmations = 100) { Member User = new Member(BitcoinAddress.GetUserId(address, provider)); TryDepositCryptocurrency(User, amountInCryptocurrency, transactionHash, cryptoCurrencyInfo, confirmations); //Blank the address BitcoinAddress.MakeBlank(User.Id, provider); }
public static bool IsAdministratorAddress(string address, CryptocurrencyAPIProvider cryptocurrencyAPI) { var adminAddresses = BitcoinAddress.GetAddress(address, cryptocurrencyAPI); if (adminAddresses != null) { return(true); } return(false); }
public static void AddPaymentAccount(CryptocurrencyAPIProvider processorName) { var stat = new Statistics { Data1 = processorName.ToString(), data2 = "0.000#0.000#0.000#0.000#0.000#0.000#0.000#0.000#0.000#0.000#0.000#0.000#0.000#0.000", Type = StatisticsType.AvailableFunds, NumberOfDays = 14 }; stat.Save(); }
public static LogType GetTypeFromProcessor(CryptocurrencyAPIProvider CryptocurrencyAPIProvider) { LogType Type = LogType.Other; switch (CryptocurrencyAPIProvider) { case CryptocurrencyAPIProvider.CoinPayments: Type = LogType.CoinPayments; break; case CryptocurrencyAPIProvider.Coinbase: Type = LogType.Coinbase; break; case CryptocurrencyAPIProvider.Blocktrail: Type = LogType.Blocktrail; break; } return(Type); }
public static string GetAddress(int userId, CryptocurrencyAPIProvider type) { var address = TableHelper.SelectRows <BitcoinAddress>(TableHelper.MakeDictionary("UserId", userId)); if (address.Count == 0) { return(String.Empty); } switch (type) { case CryptocurrencyAPIProvider.CoinPayments: return(address[0].CoinPaymentsAddress); case CryptocurrencyAPIProvider.Coinbase: return(address[0].CoinbaseAddress); case CryptocurrencyAPIProvider.Blocktrail: return(address[0].BlocktrailAddress); } return(String.Empty); }
public static void MakeBlank(int userId, CryptocurrencyAPIProvider type) { var addresses = TableHelper.SelectRows <BitcoinAddress>(TableHelper.MakeDictionary("UserId", userId)); if (addresses.Count > 0) { switch (type) { case CryptocurrencyAPIProvider.CoinPayments: addresses[0].CoinPaymentsAddress = String.Empty; break; case CryptocurrencyAPIProvider.Coinbase: addresses[0].CoinbaseAddress = String.Empty; break; case CryptocurrencyAPIProvider.Blocktrail: addresses[0].BlocktrailAddress = String.Empty; break; } addresses[0].Save(); } }
public static void DeletePaymentAccount(CryptocurrencyAPIProvider processorName) { TableHelper.DeleteRows <Statistics>(TableHelper.MakeDictionary("Data1", processorName.ToString())); }
public static CryptocurrencyApi Get(CryptocurrencyAPIProvider cryptocurrencyApiProvider) { return(CryptocurrencyApiFactory.Get(cryptocurrencyApiProvider)); }
public static void AddIPNLog(DateTime operationDate, OperationType operationType, int?confirmations, int userId, string targetAddress, decimal?bitcoinAmount, Money moneyAmount, CryptocurrencyAPIProvider BitcoinAPIProvider, bool isExecuted = false) { if (operationType == OperationType.Deposit) { BlockioIPN ipn = new BlockioIPN(); ipn.OperationDate = operationDate; ipn.OperationType = operationType; if (confirmations.HasValue) { ipn.Confirmations = confirmations.Value; } ipn.UserId = userId; ipn.TargetAddress = targetAddress; if (bitcoinAmount.HasValue) { ipn.BitcoinAmount = bitcoinAmount.Value; } if (moneyAmount != null) { ipn.MoneyAmount = moneyAmount; } ipn.IsExecuted = isExecuted; ipn.BitcoinAPIProvider = (int)BitcoinAPIProvider; ipn.Save(); } }
public static int GetUserId(string bitcoinAddress, CryptocurrencyAPIProvider type) { return(GetAddress(bitcoinAddress, type).UserId); }