private void sendto_textchange(object sender, EventArgs e)
        {
            bool bValid = false;
            if (GetInfoFromAddressBook(true,m_SendTo.Text) != null) bValid = true;

            if (bValid == false)
            {
                MicroCashAddress address = new MicroCashAddress(m_SendTo.Text);
                if (address.IsPaymentCode())
                {
                    m_SendToAmount.ReadOnly = true;
                    m_TXInfo.ReadOnly = true;
                    m_CreatePaymentCodeButton.Enabled = false;
                    m_TXInfo.Text = address.GetPaymentAmountInfoString();
                    m_SendToAmount.Text = DoBalanceString(address.GetPaymentAmount());
                }
                else if (address.IsLongAddress())
                {
                    m_TXInfo.ReadOnly = true;
                    m_CreatePaymentCodeButton.Enabled = false;
                    m_TXInfo.Text = address.GetPaymentAmountInfoString();

                    m_SendToAmount.ReadOnly = false;
                }
                else
                {
                    m_CreatePaymentCodeButton.Enabled = true;
                    m_SendToAmount.ReadOnly = false;
                    m_TXInfo.ReadOnly = false;
                    m_TXInfo.Text = "";
                    m_SendToAmount.Text = "";
                }
                bValid = address.IsValid();
            }

            if(bValid)  m_SendTo.ForeColor = Color.FromArgb(0,0,0);
            else        m_SendTo.ForeColor = Color.FromArgb(255,0,0);
        }
        private void sendFunds(object sender, EventArgs e)
        {
            if (m_SendToAmount.Text.Length <= 0) { MessageBox.Show("Please enter an amount to send","Error Creating Payment"); return; }

            string addrstr = m_SendTo.Text;
            if (m_SendTo.Items.IndexOf(addrstr) >= 0)
            {
                addrstr = GetInfoFromAddressBook(true,addrstr);
            }

            MicroCashAddress address = new MicroCashAddress(addrstr);
            if (address.IsValid() == false) { MessageBox.Show("Please enter a valid address to send to", "Error Creating Payment"); return; }

            try
            {
                SC_Transaction tx = new SC_Transaction();

                int nAccount = m_SendFrom.SelectedIndex;
                AccountItem account = m_ThinUser.m_Accounts[nAccount];

                Array.Copy(account.GetPubKeyBytes(), 1, tx.m_Extra1, 0, 64);    //this isnt always sent, but may as well just copy it
                tx.m_dwAddressID = account.m_addressid;
                if (tx.m_dwAddressID == 0)
                {
                    tx.m_dwType = 1;
                }
                tx.m_FromAddress = account.GetAddressBytes();
                tx.m_RecvAddress = address.GetAddressBytes();
                if (address.IsPaymentCode())
                {
                    tx.m_qAmount = address.GetPaymentAmount();
                    Array.Copy(address.GetInfoBytes(), tx.m_Info, 8);
                }
                else
                {
                    tx.m_qAmount = (Int64)(Convert.ToDouble(m_SendToAmount.Text) * 10000);
                    System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
                    byte[] info = encoding.GetBytes(m_TXInfo.Text);
                    int nLen = info.Length;
                    if (nLen > 8) nLen = 8;
                    for (int x = 0; x < 8; x++) tx.m_Info[x] = 0;
                    Array.Copy(info, tx.m_Info, nLen);
                }

                byte[] hash = tx.GetHash(false);
                string s = MicroCashFunctions.ToHex(hash);
                tx.m_Signature = account.Sign(hash);

                MicroCashRPC mcrpc = CreateMCRPC();
                SendTransaction sendtx = mcrpc.SendTransaction(MicroCashFunctions.ToHex(tx.GetByteBuffer(true)));
                if (sendtx != null && sendtx.sent == true)
                {
                    m_SendToAmount.Text = "";
                    m_SendTo.Text = "";
                    m_TXInfo.Text = "";
                    m_bUpdateNow = true;
                    MessageBox.Show("Transaction sent!");
                }
                else
                {
                    MessageBox.Show(mcrpc.m_ErrorMessage,"Error sending transaction");
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }