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;
LogManager.GetCurrentClassLogger().Info("Finished processing accounts the account: IsTestAccount: {0} has total balance {1} owed {2} profit {3}", isTestAccount,
totalMoneyInEscrowBitCoinAcount, amountHeldInEscrow, totalProfit);
if (totalProfit > minProfitTransaction)
{
escrow.SendBitCoinsToAddress(escrow.HouseAddress, totalProfit);
}
}