Bitcoin_WPF.MainWindow.btnSendBitcoin_Click C# (CSharp) Method

btnSendBitcoin_Click() private method

private btnSendBitcoin_Click ( object sender, RoutedEventArgs e ) : void
sender object
e System.Windows.RoutedEventArgs
return void
        private void btnSendBitcoin_Click(object sender, RoutedEventArgs e)
        {
            long amount = 0;
            long? fee = null;
            string fromAdr = null, msg = null;

            try
            {
                amount = BitcoinLib.Bitcoin.DecimalToBTC(Convert.ToDouble(tbAmount.Text));

                if (tbSendAdr.Text.Trim().Length <= 0)
                    WriteText("Set address to send !");

                if (amount <= 0)
                    WriteText("Set amount more than 0.00000100 !");

                if (tbFromAdr.Text.Trim() != "(optional)")
                    fromAdr = tbFromAdr.Text;

                if (tbMessage.Text != "(optional)")
                    msg = tbMessage.Text;

                try
                {
                    if (tbFee.Text != "(optional)")
                        fee = BitcoinLib.Bitcoin.DecimalToBTC(Convert.ToDouble(tbFee.Text));
                }
                catch
                {
                    WriteText($"ERROR: Fee value ({tbFee.Text}) is incorrect. Set the minimum to 0.0001");
                    tbFee.Text = "0.0001";
                    return;
                }

                // Send Bitcoins.
                var x = WL.Send(tbSendAdr.Text, amount, fromAdr, fee, msg);

                // If Ok, log transaction hash.
                WriteText($"Your Transaction\r\nHash: {x.TxHash} - Message: {x.Message} - Notice: {x.Notice}");
            }
            catch (Exception ex)
            {
                WriteText($"ERROR: {ex.Message}");
            }
        }