public InvocationTransaction GetTransaction()
        {
            byte[] script                     = textBox8.Text.HexToBytes();
            byte[] parameter_list             = textBox6.Text.HexToBytes();
            ContractParameterType return_type = textBox7.Text.HexToBytes().Select(p => (ContractParameterType?)p).FirstOrDefault() ?? ContractParameterType.Void;
            bool   need_storage               = checkBox1.Checked;
            string name        = textBox1.Text;
            string version     = textBox2.Text;
            string author      = textBox3.Text;
            string email       = textBox4.Text;
            string description = textBox5.Text;

            InformationBox.Show(script.ToScriptHash().ToString(), "This is the Script Hash for your Smart Contract:", "Script Hash");

            using (ScriptBuilder sb = new ScriptBuilder())
            {
                sb.EmitPush(Encoding.UTF8.GetBytes(description));
                sb.EmitPush(Encoding.UTF8.GetBytes(email));
                sb.EmitPush(Encoding.UTF8.GetBytes(author));
                sb.EmitPush(Encoding.UTF8.GetBytes(version));
                sb.EmitPush(Encoding.UTF8.GetBytes(name));
                sb.EmitPush(need_storage);
                sb.EmitPush((byte)return_type);
                sb.EmitPush(parameter_list);
                sb.EmitPush(script);
                sb.EmitSysCall("Neo.Contract.Create");
                return(new InvocationTransaction
                {
                    Script = sb.ToArray()
                });
            }
        }
Exemplo n.º 2
0
        private void button8_Click(object sender, EventArgs e)
        {
            TransactionWrapper        wrapper = (TransactionWrapper)propertyGrid1.SelectedObject;
            ContractParametersContext context = new ContractParametersContext(wrapper.Unwrap());

            InformationBox.Show(context.ToString(), "ParametersContext", "ParametersContext");
        }
Exemplo n.º 3
0
        public static void SignAndShowInformation(Transaction tx)
        {
            if (tx == null)
            {
                MessageBox.Show(Strings.InsufficientFunds);
                return;
            }
            SignatureContext context;

            try
            {
                context = new SignatureContext(tx);
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show(Strings.UnsynchronizedBlock);
                return;
            }
            Program.CurrentWallet.Sign(context);
            if (context.Completed)
            {
                context.Verifiable.Scripts = context.GetScripts();
                Program.CurrentWallet.SaveTransaction(tx);
                Program.LocalNode.Relay(tx);
                InformationBox.Show(tx.Hash.ToString(), Strings.SendTxSucceedMessage, Strings.SendTxSucceedTitle);
            }
            else
            {
                InformationBox.Show(context.ToString(), Strings.IncompletedSignatureMessage, Strings.IncompletedSignatureTitle);
            }
        }
        public InvocationTransaction GetTransaction()
        {
            byte[] script                     = textBox8.Text.HexToBytes();
            byte[] parameter_list             = textBox6.Text.HexToBytes();
            ContractParameterType return_type = textBox7.Text.HexToBytes().Select(p => (ContractParameterType?)p).FirstOrDefault() ?? ContractParameterType.Void;
            ContractPropertyState properties  = ContractPropertyState.NoProperty;

            if (checkBox1.Checked)
            {
                properties |= ContractPropertyState.HasStorage;
            }
            if (checkBox2.Checked)
            {
                properties |= ContractPropertyState.HasDynamicInvoke;
            }
            string name        = textBox1.Text;
            string version     = textBox2.Text;
            string author      = textBox3.Text;
            string email       = textBox4.Text;
            string description = textBox5.Text;

            InformationBox.Show(script.ToScriptHash().ToString(), "This is the Script Hash for your Smart Contract:", "Script Hash");

            using (ScriptBuilder sb = new ScriptBuilder())
            {
                sb.EmitSysCall("Neo.Contract.Create", script, parameter_list, return_type, properties, name, version, author, email, description);
                return(new InvocationTransaction
                {
                    Script = sb.ToArray()
                });
            }
        }
Exemplo n.º 5
0
        private void button3_Click(object sender, EventArgs e)
        {
            SignatureContext context;
            JObject          json1 = JObject.Parse(textBox2.Text);

            if (json1.ContainsProperty("hex"))
            {
                context = SignatureContext.FromJson(json1);
            }
            else
            {
                ContractTransaction tx1 = JsonToRequest(json1);
                ContractTransaction tx2 = JsonToRequest(JObject.Parse(textBox3.Text));
                context = new SignatureContext(new ContractTransaction
                {
                    Attributes = new TransactionAttribute[0],
                    Inputs     = tx1.Inputs.Concat(tx2.Inputs).ToArray(),
                    Outputs    = tx1.Outputs.Concat(tx2.Outputs).ToArray()
                });
            }
            Program.CurrentWallet.Sign(context);
            if (context.Completed)
            {
                context.Verifiable.Scripts = context.GetScripts();
                ContractTransaction tx = (ContractTransaction)context.Verifiable;
                Program.CurrentWallet.SaveTransaction(tx);
                Program.LocalNode.Relay(tx);
                InformationBox.Show(tx.Hash.ToString(), Strings.TradeSuccessMessage, Strings.TradeSuccessCaption);
            }
            else
            {
                InformationBox.Show(context.ToString(), Strings.TradeNeedSignatureMessage, Strings.TradeNeedSignatureCaption);
            }
        }
Exemplo n.º 6
0
        public static void SignAndShowInformation(Transaction tx)
        {
            if (tx == null)
            {
                MessageBox.Show(Strings.InsufficientFunds);
                return;
            }
            ContractParametersContext context;

            try
            {
                context = new ContractParametersContext(tx);
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show(Strings.UnsynchronizedBlock);
                return;
            }
            Program.CurrentWallet.Sign(context);
            if (context.Completed)
            {
                context.Verifiable.Witnesses = context.GetWitnesses();
                Program.CurrentWallet.ApplyTransaction(tx);
                Program.NeoSystem.LocalNode.Tell(new LocalNode.Relay {
                    Inventory = tx
                });
                InformationBox.Show(tx.Hash.ToString(), Strings.SendTxSucceedMessage, Strings.SendTxSucceedTitle);
            }
            else
            {
                InformationBox.Show(context.ToString(), Strings.IncompletedSignatureMessage, Strings.IncompletedSignatureTitle);
            }
        }
        private void button4_Click(object sender, EventArgs e)
        {
            context.Verifiable.Scripts = context.GetScripts();
            IInventory inventory = (IInventory)context.Verifiable;

            Program.LocalNode.Relay(inventory);
            InformationBox.Show(inventory.Hash.ToString(), Strings.RelaySuccessText, Strings.RelaySuccessTitle);
        }
Exemplo n.º 8
0
        private void button1_Click(object sender, EventArgs e)
        {
            ContractTransaction tx = Program.CurrentWallet.MakeTransaction(new ContractTransaction {
                Outputs = txOutListBox1.Items.Select(p => p.Output).ToArray()
            }, fee: Fixed8.Zero);

            textBox3.Text = RequestToJson(tx).ToString();
            InformationBox.Show(textBox3.Text, Strings.TradeRequestCreatedMessage, Strings.TradeRequestCreatedCaption);
            tabControl1.SelectedTab = tabPage2;
        }
Exemplo n.º 9
0
        private void button4_Click(object sender, EventArgs e)
        {
            ContractParametersContext context = ContractParametersContext.Parse(textBox2.Text);

            context.Verifiable.Scripts = context.GetScripts();
            IInventory inventory = (IInventory)context.Verifiable;

            Program.LocalNode.Relay(inventory);
            InformationBox.Show(inventory.Hash.ToString(), Strings.RelaySuccessText, Strings.RelaySuccessTitle);
            button4.Visible = false;
        }
        private void button4_Click(object sender, EventArgs e)
        {
            context.Verifiable.Witnesses = context.GetWitnesses();
            IInventory        inventory = (IInventory)context.Verifiable;
            RelayResultReason reason    = Program.NeoSystem.Blockchain.Ask <RelayResultReason>(inventory).Result;

            if (reason == RelayResultReason.Succeed)
            {
                InformationBox.Show(inventory.Hash.ToString(), Strings.RelaySuccessText, Strings.RelaySuccessTitle);
            }
            else
            {
                MessageBox.Show($"Transaction cannot be broadcast: {reason}");
            }
        }
Exemplo n.º 11
0
        private void button4_Click(object sender, EventArgs e)
        {
            ContractParametersContext context = ContractParametersContext.Parse(textBox2.Text);

            if (!(context.Verifiable is Transaction tx))
            {
                MessageBox.Show("Only support to broadcast transaction.");
                return;
            }
            tx.Witnesses = context.GetWitnesses();
            Program.NeoSystem.LocalNode.Tell(new LocalNode.Relay {
                Inventory = tx
            });
            InformationBox.Show(tx.Hash.ToString(), Strings.RelaySuccessText, Strings.RelaySuccessTitle);
            button4.Visible = false;
        }
Exemplo n.º 12
0
 public static DialogResult Show(string text, string message = null, string title = null)
 {
     using (InformationBox box = new InformationBox())
     {
         box.textBox1.Text = text;
         if (message != null)
         {
             box.label1.Text = message;
         }
         if (title != null)
         {
             box.Text = title;
         }
         return(box.ShowDialog());
     }
 }
Exemplo n.º 13
0
        public static void SendRaw(Transaction tx)
        {
            if (tx == null)
            {
                MessageBox.Show(Strings.InsufficientFunds);
                return;
            }
            bool b = Program.LocalNode.Relay(tx);

            if (b)
            {
                Program.CurrentWallet.ApplyTransaction(tx);
                InformationBox.Show(tx.Hash.ToString(), Strings.SendTxSucceedMessage, Strings.SendTxSucceedTitle);
                return;
            }
            InformationBox.Show("sendRawError");
        }
        private void button4_Click(object sender, EventArgs e)
        {
            context.Verifiable.Scripts = context.GetScripts();
            IInventory inventory = (IInventory)context.Verifiable;
            var        tx        = inventory as Transaction;

            if (tx.Verify(new List <Transaction> {
                tx
            }))
            {
                Program.LocalNode.Relay(inventory);
                InformationBox.Show(inventory.Hash.ToString(), Strings.RelaySuccessText, Strings.RelaySuccessTitle);
            }
            else
            {
                MessageBox.Show("Transaction validation failed and cannot be broadcast.");
            }
        }
Exemplo n.º 15
0
        public static void SignAndShowInformation(Transaction tx)
        {
            if (tx == null)
            {
                MessageBox.Show(Strings.InsufficientFunds);
                return;
            }
            ContractParametersContext context;

            try
            {
                context = new ContractParametersContext(tx);
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show(Strings.UnsynchronizedBlock);
                return;
            }
            Program.CurrentWallet.Sign(context);
            if (context.Completed)
            {
                context.Verifiable.Scripts = context.GetScripts();
                using (var ms = new System.IO.MemoryStream())
                {
                    using (var br = new System.IO.BinaryWriter(ms))
                    {
                        //tx.SerializeUnsigned(br);
                        IO.ISerializable s = tx;
                        s.Serialize(br);
                    }
                    var hex = ms.ToArray().ToHexString();
                    System.IO.File.WriteAllText("d:\\0x00.transhex.txt", hex);
                }

                Program.CurrentWallet.ApplyTransaction(tx);

                Program.LocalNode.Relay(tx);
                InformationBox.Show(tx.Hash.ToString(), Strings.SendTxSucceedMessage, Strings.SendTxSucceedTitle);
            }
            else
            {
                InformationBox.Show(context.ToString(), Strings.IncompletedSignatureMessage, Strings.IncompletedSignatureTitle);
            }
        }
Exemplo n.º 16
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (!(context.Verifiable is Transaction tx))
            {
                MessageBox.Show("Only support to broadcast transaction.");
                return;
            }
            tx.Witnesses = context.GetWitnesses();
            RelayResultReason reason = Program.NeoSystem.Blockchain.Ask <RelayResultReason>(tx).Result;

            if (reason == RelayResultReason.Succeed)
            {
                InformationBox.Show(tx.Hash.ToString(), Strings.RelaySuccessText, Strings.RelaySuccessTitle);
            }
            else
            {
                MessageBox.Show($"Transaction cannot be broadcast: {reason}");
            }
        }
 private void button2_Click(object sender, EventArgs e)
 {
     InformationBox.Show(context.ToString(), "SignatureContext", "SignatureContext");
 }