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}"); } }
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; }
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."); } }
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); } }
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}"); } }
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.EmitSysCall("Neo.Contract.Create", script, parameter_list, return_type, need_storage, name, version, author, email, description); return(new InvocationTransaction { Script = sb.ToArray() }); } }
private void button3_Click(object sender, EventArgs e) { ContractParametersContext context; JObject json1 = JObject.Parse(textBox2.Text); if (json1.ContainsProperty("hex")) { context = ContractParametersContext.FromJson(json1); } else { ContractTransaction tx1 = JsonToRequest(json1); ContractTransaction tx2 = JsonToRequest(JObject.Parse(textBox3.Text)); context = new ContractParametersContext(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.Witnesses = context.GetWitnesses(); ContractTransaction tx = (ContractTransaction)context.Verifiable; Program.CurrentWallet.ApplyTransaction(tx); Program.NeoSystem.LocalNode.Tell(new LocalNode.Relay { Inventory = tx }); InformationBox.Show(tx.Hash.ToString(), Strings.TradeSuccessMessage, Strings.TradeSuccessCaption); } else { InformationBox.Show(context.ToString(), Strings.TradeNeedSignatureMessage, Strings.TradeNeedSignatureCaption); } }
private void button2_Click(object sender, EventArgs e) { InformationBox.Show(context.ToString(), "SignatureContext", "SignatureContext"); }