public void TestFromJson() { var snapshot = TestBlockchain.GetTestSnapshot(); Action action = () => ContractParametersContext.Parse("{\"type\":\"wrongType\",\"data\":\"00000000007c97764845172d827d3c863743293931a691271a0000000000000000000000000000000000000000000100\",\"items\":{\"0x1bd5c777ec35768892bd3daab60fb7a1cb905066\":{\"script\":\"21026ff03b949241ce1dadd43519e6960e0a85b41a69a05c328103aa2bce1594ca1650680a906ad4\",\"parameters\":[{\"type\":\"Signature\",\"value\":\"01\"}]}}}", snapshot); action.Should().Throw <FormatException>(); }
private bool OnRelayCommand(string[] args) { if (args.Length < 2) { Console.WriteLine("You must input JSON object to relay."); return(true); } var jsonObjectToRelay = string.Join(string.Empty, args.Skip(1)); if (string.IsNullOrWhiteSpace(jsonObjectToRelay)) { Console.WriteLine("You must input JSON object to relay."); return(true); } try { ContractParametersContext context = ContractParametersContext.Parse(jsonObjectToRelay); if (!context.Completed) { Console.WriteLine("The signature is incomplete."); return(true); } context.Verifiable.Witnesses = context.GetWitnesses(); IInventory inventory = (IInventory)context.Verifiable; system.LocalNode.Tell(new LocalNode.Relay { Inventory = inventory }); Console.WriteLine($"Data relay success, the hash is shown as follows:\r\n{inventory.Hash}"); } catch (Exception e) { Console.WriteLine($"One or more errors occurred:\r\n{e.Message}"); } return(true); }
private bool OnSignCommand(string[] args) { if (NoWallet()) { return(true); } if (args.Length < 2) { Console.WriteLine("You must input JSON object pending signature data."); return(true); } var jsonObjectToSign = string.Join(string.Empty, args.Skip(1)); if (string.IsNullOrWhiteSpace(jsonObjectToSign)) { Console.WriteLine("You must input JSON object pending signature data."); return(true); } try { ContractParametersContext context = ContractParametersContext.Parse(jsonObjectToSign); if (!Program.Wallet.Sign(context)) { Console.WriteLine("The private key that can sign the data is not found."); return(true); } Console.WriteLine($"Signed Output:\r\n{context}"); } catch (Exception e) { Console.WriteLine($"One or more errors occurred:\r\n{e.Message}"); } return(true); }
public void TestParse() { var ret = ContractParametersContext.Parse("{\"type\":\"Neo.Network.P2P.Payloads.Transaction\",\"hex\":\"AAAAAADyd\\/EUQDWkOJf5\\u002BhFSWOrAFa3KvgAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAA==\",\"items\":{\"0xbecaad15c0ea585211faf99738a4354014f177f2\":{\"script\":\"IQJv8DuUkkHOHa3UNRnmlg4KhbQaaaBcMoEDqivOFZTKFmh0dHaq\",\"parameters\":[{\"type\":\"Signature\",\"value\":\"AQ==\"}]}}}"); ret.ScriptHashes[0].ToString().Should().Be("0xbecaad15c0ea585211faf99738a4354014f177f2"); ((Transaction)ret.Verifiable).Script.ToHexString().Should().Be(new byte[1].ToHexString()); }
private void button1_Click(object sender, EventArgs e) { string input = InputBox.Show("ParametersContext", "ParametersContext"); if (string.IsNullOrEmpty(input)) { return; } try { context = ContractParametersContext.Parse(input); } catch (FormatException ex) { MessageBox.Show(ex.Message); return; } listBox1.Items.Clear(); listBox2.Items.Clear(); textBox1.Clear(); textBox2.Clear(); listBox1.Items.AddRange(context.ScriptHashes.Select(p => p.ToAddress()).ToArray()); button2.Enabled = true; button4.Visible = context.Completed; }
private void OnSignCommand(JObject jsonObjectToSign) { if (NoWallet()) { return; } if (jsonObjectToSign == null) { Console.WriteLine("You must input JSON object pending signature data."); return; } try { var snapshot = NeoSystem.StoreView; ContractParametersContext context = ContractParametersContext.Parse(jsonObjectToSign.ToString(), snapshot); if (!CurrentWallet.Sign(context)) { Console.WriteLine("The private key that can sign the data is not found."); return; } Console.WriteLine($"Signed Output:{Environment.NewLine}{context}"); } catch (Exception e) { Console.WriteLine("Error: " + GetExceptionMessage(e)); } }
public void TestParse() { var ret = ContractParametersContext.Parse("{\"type\":\"Neo.Network.P2P.Payloads.Transaction\",\"hex\":\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFmUJDLobcPtqo9vZKIdjXsd8fVGwEAARI=\",\"items\":{\"0xbecaad15c0ea585211faf99738a4354014f177f2\":{\"script\":\"IQJv8DuUkkHOHa3UNRnmlg4KhbQaaaBcMoEDqivOFZTKFmh0dHaq\",\"parameters\":[{\"type\":\"Signature\",\"value\":\"AQ==\"}]}}}"); ret.ScriptHashes[0].ToString().Should().Be("0x1bd5c777ec35768892bd3daab60fb7a1cb905066"); ((Transaction)ret.Verifiable).Script.ToHexString().Should().Be(new byte[] { 18 }.ToHexString()); }
private void OnRelayCommand(JObject jsonObjectToRelay) { if (jsonObjectToRelay == null) { Console.WriteLine("You must input JSON object to relay."); return; } try { ContractParametersContext context = ContractParametersContext.Parse(jsonObjectToRelay.ToString()); if (!context.Completed) { Console.WriteLine("The signature is incomplete."); return; } if (!(context.Verifiable is Transaction tx)) { Console.WriteLine($"Only support to relay transaction."); return; } tx.Witnesses = context.GetWitnesses(); NeoSystem.Blockchain.Tell(tx); Console.WriteLine($"Data relay success, the hash is shown as follows:{Environment.NewLine}{tx.Hash}"); } catch (Exception e) { Console.WriteLine("Error: " + GetExceptionMessage(e)); } }
public void TestParse() { var snapshot = TestBlockchain.GetTestSnapshot(); var ret = ContractParametersContext.Parse("{\"type\":\"Neo.Network.P2P.Payloads.Transaction\",\"data\":\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFmUJDLobcPtqo9vZKIdjXsd8fVGwEAARI=\",\"items\":{\"0xbecaad15c0ea585211faf99738a4354014f177f2\":{\"script\":\"IQJv8DuUkkHOHa3UNRnmlg4KhbQaaaBcMoEDqivOFZTKFmh0dHaq\",\"parameters\":[{\"type\":\"Signature\",\"value\":\"AQ==\"}],\"signatures\":{\"03b209fd4f53a7170ea4444e0cb0a6bb6a53c2bd016926989cf85f9b0fba17a70c\":\"AQ==\"}}}}", snapshot); ret.ScriptHashes[0].ToString().Should().Be("0x1bd5c777ec35768892bd3daab60fb7a1cb905066"); ((Transaction)ret.Verifiable).Script.ToHexString().Should().Be(new byte[] { 18 }.ToHexString()); }
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) { ContractParametersContext context = ContractParametersContext.Parse(textBox2.Text, Service.NeoSystem.StoreView); if (!(context.Verifiable is Transaction tx)) { MessageBox.Show("Only support to broadcast transaction."); return; } tx.Witnesses = context.GetWitnesses(); Service.NeoSystem.Blockchain.Tell(tx); InformationBox.Show(tx.Hash.ToString(), Strings.RelaySuccessText, Strings.RelaySuccessTitle); button4.Visible = false; }
private bool OnRelayCommand(string[] args) { if (args.Length < 3) { Console.WriteLine("You must input JSON object to relay."); return(true); } string hashString = args[1]; ZoroSystem zoroSystem = system.GetZoroSystem(hashString); if (zoroSystem == null) { Console.WriteLine($"Unknown blockchain hash {hashString}."); return(true); } var jsonObjectToRelay = string.Join(string.Empty, args.Skip(2)); if (string.IsNullOrWhiteSpace(jsonObjectToRelay)) { Console.WriteLine("You must input JSON object to relay."); return(true); } try { ContractParametersContext context = ContractParametersContext.Parse(jsonObjectToRelay); if (!context.Completed) { Console.WriteLine("The signature is incomplete."); return(true); } if (!(context.Verifiable is Transaction tx)) { Console.WriteLine($"Only support to relay transaction."); return(true); } tx.Witnesses = context.GetWitnesses(); zoroSystem.LocalNode.Tell(new LocalNode.Relay { Inventory = tx }); Console.WriteLine($"Data relay success, the hash is shown as follows:\r\n{tx.Hash}"); } catch (Exception e) { Console.WriteLine($"One or more errors occurred:\r\n{e.Message}"); } return(true); }
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.OXSystem.LocalNode.Tell(new LocalNode.Relay { Inventory = tx }); InformationBox.Show(tx.Hash.ToString(), LanHelper.LocalLanguage("Data broadcast success, the hash is shown as follows:"), LanHelper.LocalLanguage("Broadcast Success")); button4.Visible = false; }
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.CronSystem.LocalNode.Tell(new LocalNode.Relay { Inventory = tx }); InformationBox.Show(tx.Hash.ToString(), Strings.RelaySuccessText, Strings.RelaySuccessTitle); button4.Visible = false; }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "") { MessageBox.Show(LanHelper.LocalLanguage("You must input JSON object pending signature data.")); return; } ContractParametersContext context = ContractParametersContext.Parse(textBox1.Text); if (!Program.CurrentWallet.Sign(context)) { MessageBox.Show(LanHelper.LocalLanguage("The private key that can sign the data is not found.")); return; } textBox2.Text = context.ToString(); if (context.Completed) { button4.Visible = true; } }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "") { MessageBox.Show(Strings.SigningFailedNoDataMessage); return; } ContractParametersContext context = ContractParametersContext.Parse(textBox1.Text); if (!Program.CurrentWallet.Sign(context)) { MessageBox.Show(Strings.SigningFailedKeyNotFoundMessage); return; } textBox2.Text = context.ToString(); if (context.Completed) { button4.Visible = true; } }
public void TestFromJson() { Action action = () => ContractParametersContext.Parse("{\"type\":\"wrongType\",\"hex\":\"0000000000f277f1144035a43897f9fa115258eac015adcabe0000000000000000000000000000000000000000000100\",\"items\":{\"0xbecaad15c0ea585211faf99738a4354014f177f2\":{\"script\":\"21026ff03b949241ce1dadd43519e6960e0a85b41a69a05c328103aa2bce1594ca1668747476aa\",\"parameters\":[{\"type\":\"Signature\",\"value\":\"01\"}]}}}"); action.Should().Throw <FormatException>(); }
public void TestFromJson() { Action action = () => ContractParametersContext.Parse("{\"type\":\"wrongType\",\"hex\":\"00000000007c97764845172d827d3c863743293931a691271a0000000000000000000000000000000000000000000100\",\"items\":{\"0x1a2791a63139294337863c7d822d17454876977c\":{\"script\":\"21026ff03b949241ce1dadd43519e6960e0a85b41a69a05c328103aa2bce1594ca1650680a906ad4\",\"parameters\":[{\"type\":\"Signature\",\"value\":\"01\"}]}}}"); action.Should().Throw <FormatException>(); }