Ejemplo n.º 1
0
        private void SendCoidAddressChanged(object sender, EventArgs e)
        {
            abContoller.ValueChanged -= SendCoidAddressChanged;
            var address = abContoller.selectedAccount;

            if (address == null || address.Length < 10)
            {
                showAlert("Error", "Please select address to send coins to");
            }
            else
            {
                var alert = new UIAlertView();
                alert.Title = address;
                alert.AddButton("Send");
                alert.AddButton("Cancel");
                alert.Message        = "Please Enter amount.";
                alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput;
                alert.Clicked       += (object s, UIButtonEventArgs ev) =>
                {
                    if (ev.ButtonIndex == 0)
                    {
                        long amount = long.Parse(alert.GetTextField(0).Text);
                        if (amount > 0 && amount <= balance)
                        {
                            var c = new SJCoinContract(
                                Settings.ServiceEndpoint,
                                Settings.MyAddress,
                                Settings.MyPubKey,
                                Settings.MyPrivKey);
                            string txId = c.Send(address, amount);
                            if (string.IsNullOrEmpty(txId))
                            {
                                showAlert("Error", "Transaction failed");
                            }
                            else
                            {
                                showAlert("Transaction Posted", txId);
                            }
                        }
                        else
                        {
                            showAlert("Error", "Invalid amount");
                        }
                    }
                };
                alert.Show();
            }
        }