All pastes #2098039 Raw Edit

Someone

public text v1 · immutable
#2098039 ·published 2012-01-02 03:15 UTC
rendered paste body
        public static void ProcessProfit(bool isTestAccount)
        {
            EscrowOperations escrow = new EscrowOperations(isTestAccount);
            
            //Get total amount in escrow account.
            decimal totalMoneyInEscrowBitCoinAcount = escrow.GetAmountInEscrowAccount();

            //minimum buffer to hold above the escrow's debt
            decimal minDebtBuffer = Decimal.Parse(ConfigurationManager.AppSettings["minDebtBuffer"]);
            //minimum profit to take
            decimal minProfitTransaction = Decimal.Parse(ConfigurationManager.AppSettings["minProfitTransaction"]);

            
            var openAccounts = escrow.GetOpenAccounts();
            Console.WriteLine("{0} open accounts", openAccounts);
            
            //Sum up all money owed.
            decimal amountHeldInEscrow = openAccounts.Sum(account => escrow.GetAccountBalance(account.EscrowAccountAddress));

            //Total profit
            decimal totalProfit = totalMoneyInEscrowBitCoinAcount - amountHeldInEscrow - minDebtBuffer;

            var logMessage = String.Format("Finished processing accounts the account: IsTestAccount: {0} has total balance {1} owed {2} profit {3}", isTestAccount,
                               totalMoneyInEscrowBitCoinAcount, amountHeldInEscrow, totalProfit);
            
            Logger log = LogManager.GetCurrentClassLogger();
            log.Info(logMessage);
            
            if (totalProfit > minProfitTransaction)
            {
                escrow.SendBitCoinsToAddress(escrow.HouseAddress, totalProfit);
            }
        }