Example #1
0
        public void GetBalanceTest()
        {
            var atmsvc = new Node.atm();
            var result = atmsvc.GetBalance("1D45JxNkyhCyxC7LFwA6hwH2ssLkZhExij");

            Assert.AreEqual(result, 0.001M);
        }
Example #2
0
        /// <summary>
        /// Charges the FiatAmount to the customer's credit card,
        /// then buys the Bitcoin amount,
        /// the records the transaction.
        /// //TODO: Store a log of the transaction steps so that refunds or rollback can occur since proper transactions are impossible here
        /// </summary>
        /// <param name="CardId"></param>
        /// <param name="BitcoinAmount"></param>
        /// <param name="Currency"></param>
        /// <param name="Amount"></param>
        /// <param name="TerminalId"></param>
        /// <returns></returns>
        public bool PayForAndBuyBitcoin(string CardId, string ToCardPublicAddress, decimal BitcoinAmount, string Currency, decimal FiatAmount, int TerminalId)
        {
            if (MakeFiatPayment(CardId, Currency, FiatAmount, TerminalId))
            {
                if (ToCardPublicAddress != "")
                {
                    DC.Data.Card card;
                    using (var db = new DiamondCircle_dbEntities())
                    {
                        card = db.Cards.Where(c => c.CardId == CardId).ToList().First();
                        ToCardPublicAddress = card.PublicKey;
                    }
                }

                DC.Node.atm atmsvc = new Node.atm();

                var order = atmsvc.CreateOrder(ToCardPublicAddress, BitcoinAmount);

                WriteTransaction(CardId, "BUY", TerminalId, Currency, "Bitcoin", BitcoinAmount, FiatAmount, order.Txn.ToString(), 1);

                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #3
0
        public void SendBitcoinsCoinTest()
        {
            var atmsvc = new Node.atm();
            //var atmsvc = new dcweb.Tests.NodeTest.AtmClient();
            var result = atmsvc.SendBitcoins("xe6LdFKXUaZpOy3cbX8Bh8gFMwWQSTMKhoO9mcFdcBz2CA4Wy2I2Y3uEJ480Onwed5uTUZJBibzOvrVEvPkFJw==", "hh67+bZBgWY/4MFEBGgs9Q==", "1DA8Jp3GmdmEJirRQoCu28wMMpEHk9cmbr", 0.0001M);

            Assert.IsTrue(result.Length > 0);
        }
Example #4
0
        public void SendCoinTest()
        {
            var atmsvc = new Node.atm();
            // This code passed.
            var order = atmsvc.CreateOrder("1MR8RpE2v2yq6ZS6s9x79HTrxdzZZumt3B", 0.01M);



            Assert.IsNotNull(order);
        }
Example #5
0
        public void ResolvePrivateKeyTest()
        {
            var atmsvc = new Node.atm();

            var result = atmsvc.ResolvePrivateKey("xe6LdFKXUaZpOy3cbX8Bh8gFMwWQSTMKhoO9mcFdcBz2CA4Wy2I2Y3uEJ480Onwed5uTUZJBibzOvrVEvPkFJw==", "hh67+bZBgWY/4MFEBGgs9Q==");

            //var result = atmsvc.ResolvePrivateKey("DoYNH6IrB72s5fJqNM280mQ4zs2HNQkz5vMk9tTIo40hLpCYhXucRfovAQbDEmmMs+XhZRsmkzCyyxFUzeszXg==", "hh67+bZBgWY/4MFEBGgs9Q==");

            Assert.AreEqual("1MR8RpE2v2yq6ZS6s9x79HTrxdzZZumt3B", result);
        }
Example #6
0
        public void GetConfirmationsTest()
        {
            var  atmsvc = new Node.atm();
            bool result = false;

            if (atmsvc.GetConfirmations("1MR8RpE2v2yq6ZS6s9x79HTrxdzZZumt3B") > 0)
            {
                result = true;
            }

            Assert.IsTrue(result);
        }
Example #7
0
        public void SendCoinTest()
        {
            var atmsvc = new Node.atm();
            // This code passed.
            Decimal btcAmount = 0.5M;

            var order = atmsvc.CreateOrder("1EckcwV6Szv4UndFq4PkNHBrZaMnnJXGgj", btcAmount);



            Assert.IsNotNull(order);
        }