Exemple #1
0
        private void UpdateTemps()
        {
            if (AmountBtc.Equals("0") || AmountCurr.Equals("0") || String.IsNullOrEmpty(AmountBtc) || String.IsNullOrEmpty(AmountCurr))
            {
                TempBalance = Balance;
                TempBalanceCurr = Math.Round(BalanceCurr,2);
                return;
            }

            decimal remainBtc = Balance.ToDecimal(MoneyUnit.BTC) - decimal.Parse(AmountBtc) - AmountFee.ToDecimal(MoneyUnit.BTC);
            if (remainBtc >= 0)
            {
                TempBalance = Money.FromUnit(remainBtc, MoneyUnit.BTC);
            }
            else
            {                
                TempBalance = 0;
            }

            decimal remainCurr = BalanceCurr - decimal.Parse(AmountCurr) - AmountFeeCurr;
            if (remainCurr >= 0)
            {
                TempBalanceCurr = Math.Round(remainCurr,2);
            }
            else
            {
                
                TempBalanceCurr = 0;
            }
        }
Exemple #2
0
        private void UpdateFee()
        {
            if (EnoughFunds(false) && !AmountBtc.Equals("0"))
            {
                var txBuilder = new TransactionBuilder();
                Money amountToSend = Money.Parse(AmountBtc);
                var fee = _wallet.CalculateFee(amountToSend);
                AmountFee = fee;
                AmountFeeCurr = Converters.Btc2Currency(fee);
            }
            else
            {
                AmountFee = Money.Zero;
            }

        }
Exemple #3
0
 /// <summary>
 /// checks to see if the user entered a valid bitcoin amount
 /// ie) only 8 decimal places
 /// </summary>
 /// <returns>return true if the bitcoin amount is valid</returns>
 private bool AmountBtcOK()
 {
     // disallow negative values
     if (AmountBtc.Contains("-"))
     {
         AmountBtcError = true;
         return false;
     }
     // ie) "2.21" => ["2","21"]
     string[] seperate = AmountBtc.Split('.');
     
     if (seperate.Length == 2 && IsNumeric(seperate[0]) && IsNumeric(seperate[1]))
     {
         string postDecimal = seperate[1];
         if (postDecimal.Length <= 8)
         {
             AmountBtcError = false;
             return true;
         }
         else
         {
             AmountBtcError = true;
             return false;
         }
     }
     // no decimal entered, just integer
     else if (seperate.Length == 1 && IsNumeric(seperate[0]))
     {
         AmountBtcError = false;
         return true;
     }
     else
     {
         AmountBtcError = true;
         return false;
     }
 }