예제 #1
0
        public string SendBitcoins(String FromCardId, String FromCardPublicAddress, String encryptedPrivateKey, String DestinationCardId, Decimal BitcoinAmount, Decimal FiatAmount, String Currency)
        {
            // For the FromCardId, Obtain the password.
            String Password = "******";

            // Check that the FromCardPublicAddress = what is in the cards table for this cardID
            String DBCardPublicAddress = FromCardPublicAddress;

            Boolean AutoTopUp = true;

            // For the DesintationCardId, obtain the DestinationAddress from the Cards Table
            String DestinationAddress = "1QJQMFhgyoiLLUZXpr913T2TaEaX7pNFaF";

            if (DBCardPublicAddress == DestinationAddress)
            {
                Card.CardClient card        = new Card.CardClient();
                ATM.AtmClient   atm         = new ATM.AtmClient();
                Decimal         CardBalance = atm.GetBalance(FromCardPublicAddress, 1);
                Decimal         MinersFee   = 0.0001M;
                if (CardBalance >= (BitcoinAmount + MinersFee))
                {
                    String result = atm.SendBitcoins(encryptedPrivateKey, Password, DestinationAddress, BitcoinAmount);
                    return(result);
                }
                else
                {
                    if (AutoTopUp)
                    {
                        // Purchase more coins to cover the difference



                        DCExchange.ExchangeClient ExchangeClient = new DCExchange.ExchangeClient();
                        DCExchange.Margin         margin         = ExchangeClient.GetMargin(Currency, 0);
                        Decimal PurchaseBitcoinsAmount           = FiatAmount * margin.Buy;

                        // PurchaseFiatAmount = PurchaseBitcoinsAmount;

                        PurchaseBitcoins(FromCardId, DestinationAddress, FiatAmount, Currency);


                        //  Empty the wallet
                        String result = atm.SendBitcoins(encryptedPrivateKey, Password, DestinationAddress, CardBalance);

                        return("");
                    }
                    else
                    {
                        return("Refer to DD/CC Issuer");
                    }
                }
            }
            else
            {
                return("Invalid Card - Public Address does not match entry in Database.  Card may have been tampered with");
            }
        }
예제 #2
0
        private void getquote()
        {
            if (txtAmount.Text != "" && Convert.ToInt32(txtAmount.Text) > 0)
            {
                Card.CardClient card = new Card.CardClient();

                decimal amount   = Convert.ToInt32(txtAmount.Text);
                Decimal bitcoins = GetSpotPrice(cboCurrency.SelectedItem.ToString(), amount);

                txtBitcoins.Text = bitcoins.ToString("0.000000");
            }
            else
            {
                txtBitcoins.Text = "0";
            }
        }
예제 #3
0
        private void btnActivate_Click(object sender, EventArgs e)
        {
            try
            {
                if (validate())
                {
                    String CardId = "";
                    String body   = "";
                    nfc = DCPOS.Factory.GetNFC();
                    Card.CardClient card = new Card.CardClient();
                    ATM.AtmClient   atm  = new ATM.AtmClient();
                    if (nfc.InitReader())
                    {
                        if (nfc.ConnectReader() && nfc.ReadTagID(ref CardId))
                        {
                            if (!card.IsCardOnFile(CardId))
                            {
                                ATM.Keys key               = atm.CreatePublicEncryptedPrivateKey();
                                String   Password          = key.Password.ToString();
                                String   PrivateKey        = key.PrivateKey;
                                String   PublicKey         = key.PublicKey;
                                String   modifiedpublicuri = String.Format("bitcoin:{0}", PublicKey);
                                if (nfc.WriteNFCTag(modifiedpublicuri, PrivateKey))
                                {
                                    body += Environment.NewLine;
                                    body += "Dear " + txtFirstName.Text + "," + Environment.NewLine;
                                    body += Environment.NewLine;
                                    body += Environment.NewLine;
                                    body += "Your Purchase" + Environment.NewLine;
                                    body += "From PC POS" + Environment.NewLine;
                                    body += Environment.NewLine;
                                    body += "Your Public Bitcoin Address is: https://blockchain.info/address/" + PublicKey + Environment.NewLine;
                                    body += Environment.NewLine;
                                    body += "LOSE THE FOLLOWING INFORMATION AND YOUR BITCOINS ARE LOST" + Environment.NewLine;
                                    body += "Your Private Key is: " + PrivateKey + Environment.NewLine;
                                    body += Environment.NewLine;
                                    body += Environment.NewLine;
                                    body += "Thank you" + Environment.NewLine;
                                    body += Environment.NewLine;
                                    body += "Diamond Circle Team" + Environment.NewLine;
                                    body += Environment.NewLine;
                                    body += "Allow for 6 Confirmations before balance appears." + Environment.NewLine;
                                    body += "See Terms and Conditions " + Environment.NewLine;
                                    atm.SendEmailAsync(txtEmail.Text, "Diamond Circle Private Key. CardId:" + CardId, body);
                                    // Write TagID to Database.
                                    Password = Convert.ToBase64String(key.Password);
                                    // card.AddCardWithPinLimit(CardId, PublicKey, Password, txtFirstName.Text, txtLastName.Text, txtAddress.Text, txtCity.Text, txtZip.Text, txtState.Text, cboCountry.SelectedItem, txtTelephone.Text, txtDOB.Text, txtEmail.Text, txtFirstName.Text + " " + txtLastName.Text, txtCCNumber.Text, txtExpiryDateMM.Text, txtExpiryDateYY.Text, txtCCNumber.Text, txtPIN.Text, cboCurrency.SelectedItem, Convert.ToInt32(txtLimit.Text), chkTopup);
                                }
                                else
                                {
                                    // Cannot write card.
                                }
                            }
                            else
                            {
                                // Card on file
                            }
                        }
                        else
                        {
                            lblStatusMessage.Text = "Hold Card on Reader";
                            this.Refresh();
                        }
                    }
                    else
                    {
                        lblStatusMessage.Text = "Cannot Initialse Reader";
                        this.Refresh();
                    }
                }
                else
                {
                    lblStatusMessage.Text = "Complete all Fields";
                }
            }

            catch (Exception ex)
            {
                // GeneralExceptions("Encode Tag", System.Diagnostics.TraceEventType.Critical, ex);
            }
        }