private void createPaymentCode(object sender, EventArgs e) { bool bAmount=true; if (m_SendToAmount.Text.Length <= 0) bAmount = false; 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 Code"); return; } System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); address.SetInfo(encoding.GetBytes(m_TXInfo.Text)); if (bAmount) { address.SetAmount((Int64)(Convert.ToDouble(m_SendToAmount.Text) * 10000)); m_SendTo.Text = address.GetPaymentCodeString(); } else { m_SendTo.Text = address.GetAddressInfoString(); } }
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) { try { 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; } int nAccount = m_SendFrom.SelectedIndex; Account account = m_ThinUser.m_Accounts[nAccount]; SendTxResult result = null; if (address.IsPaymentCode) { //send a payment code style transaction result = account.SendTx(address); } else { //attempt to parse the send amount text box double amount = 0; if (!Double.TryParse(m_SendToAmount.Text, out amount)) MessageBox.Show(String.Format("Could not convert {0} to a number!", m_SendToAmount.Text), "Unable to Parse!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); //convert the tx info text box, if populated byte[] info = null; if (!string.IsNullOrEmpty(m_TXInfo.Text)) info = UTF8Encoding.Default.GetBytes(m_TXInfo.Text); //send custom transaction result = account.SendTx(address, amount, info); } if (result != null && result.IsSent == true) { m_SendToAmount.Text = ""; m_SendTo.Text = ""; m_TXInfo.Text = ""; m_bUpdateNow = true; MessageBox.Show("Transaction sent!"); } else { MessageBox.Show(result.ErrorMessage, "Error sending transaction"); } } catch (Exception exception) { MessageBox.Show(exception.Message); } }