示例#1
0
        public System.IO.Stream Check(string hash)
        {
            try
            {
                if (!App.credentials.IsAllow("check"))
                {
                    return(null);
                }

                BtcAddressEntity model = new BtcAddressModel(App.db).getByHash(hash);
                if (model == null)
                {
                    return(null);
                }

                string result = new CheckResponse(model, App.settings).toJson();

                byte[] resultBytes = Encoding.UTF8.GetBytes(result);
                WebOperationContext.Current.OutgoingResponse.ContentType = "application/json";
                return(new MemoryStream(resultBytes));
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
示例#2
0
        static void BalancesChecker()
        {
            while (true)
            {
                try
                {
                    App.btc.WalletPassphrase(App.settings.data.btc_wallet_password);

                    long timeFrom = ((DateTimeOffset)DateTime.UtcNow).ToUnixTimeSeconds() - (App.settings.data.canceled_min * 60);

                    BtcAddressModel        targetModel  = new BtcAddressModel(App.db);
                    BtcAddressForwardModel forwardModel = new BtcAddressForwardModel(App.db);

                    List <string> addresses = targetModel.GetEmptyBtcAddresses(timeFrom);

                    foreach (string address in addresses)
                    {
                        double balance = App.btc.GetBalance(address);
                        if (balance <= 0)
                        {
                            continue;
                        }

                        targetModel.UpdateIncomeBalance(address, balance);
                        CheckResponse incomeChecker = new CheckResponse(targetModel.getByHash(address), App.settings);

                        try
                        {
                            if (incomeChecker.status == CheckResponse.PAID)
                            {
                                SendToForwardAndUpdateStatus(address, balance, forwardModel);
                            }
                        }
                        catch (Exception) { }
                    }
                }
                catch (Exception ex) { }
                Thread.Sleep(1000);
            }
        }