public void TestAdd()
        {
            Transaction tx       = TestUtils.GetTransaction(UInt160.Zero);
            var         context1 = new ContractParametersContext(tx);

            context1.Add(contract, 0, new byte[] { 0x01 }).Should().BeFalse();

            tx = TestUtils.GetTransaction(UInt160.Parse("0x282646ee0afa5508bb999318f35074b84a17c9f0"));
            var context2 = new ContractParametersContext(tx);

            context2.Add(contract, 0, new byte[] { 0x01 }).Should().BeTrue();
            //test repeatlly createItem
            context2.Add(contract, 0, new byte[] { 0x01 }).Should().BeTrue();
        }
        public void TestAdd()
        {
            Transaction tx       = TestUtils.GetTransaction();
            var         context1 = new ContractParametersContext(tx);

            context1.Add(contract, 0, new byte[] { 0x01 }).Should().BeFalse();

            tx.Sender = UInt160.Parse("0x1bd5c777ec35768892bd3daab60fb7a1cb905066");
            var context2 = new ContractParametersContext(tx);

            context2.Add(contract, 0, new byte[] { 0x01 }).Should().BeTrue();
            //test repeatlly createItem
            context2.Add(contract, 0, new byte[] { 0x01 }).Should().BeTrue();
        }
Example #3
0
        public void TestAdd()
        {
            Transaction tx       = TestUtils.GetTransaction();
            var         context1 = new ContractParametersContext(tx);

            context1.Add(contract, 0, new byte[] { 0x01 }).Should().BeFalse();

            tx.Sender = UInt160.Parse("0xbecaad15c0ea585211faf99738a4354014f177f2");
            var context2 = new ContractParametersContext(tx);

            context2.Add(contract, 0, new byte[] { 0x01 }).Should().BeTrue();
            //test repeatlly createItem
            context2.Add(contract, 0, new byte[] { 0x01 }).Should().BeTrue();
        }
Example #4
0
        public void TestAdd()
        {
            Transaction tx       = TestUtils.GetTransaction();
            var         context1 = new ContractParametersContext(tx);

            context1.Add(contract, 0, new byte[] { 0x01 }).Should().BeFalse();

            tx.Sender = UInt160.Parse("0x1a2791a63139294337863c7d822d17454876977c");
            var context2 = new ContractParametersContext(tx);

            context2.Add(contract, 0, new byte[] { 0x01 }).Should().BeTrue();
            //test repeatlly createItem
            context2.Add(contract, 0, new byte[] { 0x01 }).Should().BeTrue();
        }
        public void TestAdd()
        {
            Transaction tx       = TestUtils.GetTransaction();
            var         context1 = new ContractParametersContext(tx);

            context1.Add(contract, 0, new byte[] { 0x01 }).Should().BeFalse();

            tx.Sender = UInt160.Parse("0xcd4ced947d791e887559b3829c3bc08fe37b0a64");
            var context2 = new ContractParametersContext(tx);

            context2.Add(contract, 0, new byte[] { 0x01 }).Should().BeTrue();
            //test repeatlly createItem
            context2.Add(contract, 0, new byte[] { 0x01 }).Should().BeTrue();
        }
Example #6
0
        public void TestAdd()
        {
            var         snapshot = TestBlockchain.GetTestSnapshot();
            Transaction tx       = TestUtils.GetTransaction(UInt160.Zero);
            var         context1 = new ContractParametersContext(snapshot, tx);

            context1.Add(contract, 0, new byte[] { 0x01 }).Should().BeFalse();

            tx = TestUtils.GetTransaction(UInt160.Parse("0x902e0d38da5e513b6d07c1c55b85e77d3dce8063"));
            var context2 = new ContractParametersContext(snapshot, tx);

            context2.Add(contract, 0, new byte[] { 0x01 }).Should().BeTrue();
            //test repeatlly createItem
            context2.Add(contract, 0, new byte[] { 0x01 }).Should().BeTrue();
        }
Example #7
0
        public void TestAdd()
        {
            var         snapshot = TestBlockchain.GetTestSnapshot();
            Transaction tx       = TestUtils.GetTransaction(UInt160.Zero);
            var         context1 = new ContractParametersContext(snapshot, tx);

            context1.Add(contract, 0, new byte[] { 0x01 }).Should().BeFalse();

            tx = TestUtils.GetTransaction(UInt160.Parse("0x4bc1b25796f4a13fa3cc7538168d86f7d3bc5356"));
            var context2 = new ContractParametersContext(snapshot, tx);

            context2.Add(contract, 0, new byte[] { 0x01 }).Should().BeTrue();
            //test repeatlly createItem
            context2.Add(contract, 0, new byte[] { 0x01 }).Should().BeTrue();
        }
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listBox1.SelectedIndex < 0)
            {
                return;
            }
            listBox2.Items.Clear();
            if (Service.CurrentWallet == null)
            {
                return;
            }
            UInt160 hash       = ((string)listBox1.SelectedItem).ToScriptHash(Service.NeoSystem.Settings.AddressVersion);
            var     parameters = context.GetParameters(hash);

            if (parameters == null)
            {
                var parameterList = Service.CurrentWallet.GetAccount(hash).Contract.ParameterList;
                if (parameterList != null)
                {
                    var pList = new List <ContractParameter>();
                    for (int i = 0; i < parameterList.Length; i++)
                    {
                        pList.Add(new ContractParameter(parameterList[i]));
                        context.Add(Service.CurrentWallet.GetAccount(hash).Contract, i, null);
                    }
                }
            }
            listBox2.Items.AddRange(context.GetParameters(hash).ToArray());
            button4.Visible = context.Completed;
        }
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listBox1.SelectedIndex < 0)
            {
                return;
            }
            listBox2.Items.Clear();
            if (Program.CurrentWallet == null)
            {
                return;
            }
            UInt160 hash       = ((string)listBox1.SelectedItem).ToScriptHash();
            var     parameters = context.GetParameters(hash);

            if (parameters == null)
            {
                var parameterList = Program.CurrentWallet.GetAccount(hash).Contract.ParameterList ?? Blockchain.Singleton.Store.GetContracts()[hash].ParameterList;
                if (parameterList != null)
                {
                    var pList = new List <ContractParameter>();
                    for (int i = 0; i < parameterList.Length; i++)
                    {
                        pList.Add(new ContractParameter(parameterList[i]));
                        context.Add(Program.CurrentWallet.GetAccount(hash).Contract, i, null);
                    }
                }
            }
            listBox2.Items.AddRange(context.GetParameters(hash).ToArray());
            button4.Visible = context.Completed;
        }
Example #10
0
 /// <summary>
 /// Add Witness with contract
 /// </summary>
 /// <param name="contract">The witness verification contract</param>
 /// <param name="parameters">The witness invocation parameters</param>
 public TransactionManager AddWitness(Contract contract, params object[] parameters)
 {
     if (!context.Add(contract, parameters))
     {
         throw new Exception("AddWitness failed!");
     }
     ;
     return(this);
 }
        public void TestToString()
        {
            Transaction tx      = TestUtils.GetTransaction(UInt160.Parse("0x1bd5c777ec35768892bd3daab60fb7a1cb905066"));
            var         context = new ContractParametersContext(tx);

            context.Add(contract, 0, new byte[] { 0x01 });
            string str = context.ToString();

            str.Should().Be(@"{""type"":""Neo.Network.P2P.Payloads.Transaction"",""hex"":""AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFmUJDLobcPtqo9vZKIdjXsd8fVGwEAAQA="",""items"":{}}");
        }
        public void TestGetWitnesses()
        {
            Transaction tx      = TestUtils.GetTransaction(UInt160.Parse("0x282646ee0afa5508bb999318f35074b84a17c9f0"));
            var         context = new ContractParametersContext(tx);

            context.Add(contract, 0, new byte[] { 0x01 });
            Witness[] witnesses = context.GetWitnesses();
            witnesses.Length.Should().Be(1);
            witnesses[0].InvocationScript.ToHexString().Should().Be(new byte[] { (byte)OpCode.PUSHDATA1, 0x01, 0x01 }.ToHexString());
            witnesses[0].VerificationScript.ToHexString().Should().Be(contract.Script.ToHexString());
        }
Example #13
0
        public void TestToString()
        {
            var         snapshot = TestBlockchain.GetTestSnapshot();
            Transaction tx       = TestUtils.GetTransaction(UInt160.Parse("0x1bd5c777ec35768892bd3daab60fb7a1cb905066"));
            var         context  = new ContractParametersContext(snapshot, tx, ProtocolSettings.Default.Network);

            context.Add(contract, 0, new byte[] { 0x01 });
            string str = context.ToString();

            str.Should().Be(@"{""type"":""Neo.Network.P2P.Payloads.Transaction"",""hash"":""0x602c1fa1c08b041e4e6b87aa9a9f9c643166cd34bdd5215a3dd85778c59cce88"",""data"":""AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFmUJDLobcPtqo9vZKIdjXsd8fVGwEAARI="",""items"":{},""network"":" + ProtocolSettings.Default.Network + "}");
        }
Example #14
0
        public void TestToString()
        {
            Transaction tx = TestUtils.GetTransaction();

            tx.Sender = UInt160.Parse("0xbecaad15c0ea585211faf99738a4354014f177f2");
            var context = new ContractParametersContext(tx);

            context.Add(contract, 0, new byte[] { 0x01 });
            string str = context.ToString();

            str.Should().Be("{\"type\":\"Neo.Network.P2P.Payloads.Transaction\",\"hex\":\"AAAAAADyd\\/EUQDWkOJf5\\u002BhFSWOrAFa3KvgAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAA==\",\"items\":{\"0xbecaad15c0ea585211faf99738a4354014f177f2\":{\"script\":\"IQJv8DuUkkHOHa3UNRnmlg4KhbQaaaBcMoEDqivOFZTKFmh0dHaq\",\"parameters\":[{\"type\":\"Signature\",\"value\":\"AQ==\"}]}}}");
        }
Example #15
0
        public void TestToString()
        {
            Transaction tx = TestUtils.GetTransaction();

            tx.Sender = UInt160.Parse("0x1a2791a63139294337863c7d822d17454876977c");
            var context = new ContractParametersContext(tx);

            context.Add(contract, 0, new byte[] { 0x01 });
            string str = context.ToString();

            str.Should().Be(@"{""type"":""Neo.Network.P2P.Payloads.Transaction"",""hex"":""AAAAAAB8l3ZIRRctgn08hjdDKTkxppEnGgAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAA=="",""items"":{""0x1a2791a63139294337863c7d822d17454876977c"":{""script"":""IQJv8DuUkkHOHa3UNRnmlg4KhbQaaaBcMoEDqivOFZTKFlBoCpBq1A=="",""parameters"":[{""type"":""Signature"",""value"":""AQ==""}]}}}");
        }
        public void TestToString()
        {
            Transaction tx = TestUtils.GetTransaction();

            tx.Sender = UInt160.Parse("0x1bd5c777ec35768892bd3daab60fb7a1cb905066");
            var context = new ContractParametersContext(tx);

            context.Add(contract, 0, new byte[] { 0x01 });
            string str = context.ToString();

            str.Should().Be(@"{""type"":""Neo.Network.P2P.Payloads.Transaction"",""hex"":""AAAAAABmUJDLobcPtqo9vZKIdjXsd8fVGwAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAA=="",""items"":{""0x1bd5c777ec35768892bd3daab60fb7a1cb905066"":{""script"":""DCECb/A7lJJBzh2t1DUZ5pYOCoW0GmmgXDKBA6orzhWUyhYLQQqQatQ="",""parameters"":[{""type"":""Signature"",""value"":""AQ==""}]}}}");
        }
Example #17
0
        public void TestGetWitnesses()
        {
            var         snapshot = TestBlockchain.GetTestSnapshot();
            Transaction tx       = TestUtils.GetTransaction(UInt160.Parse("0x902e0d38da5e513b6d07c1c55b85e77d3dce8063"));
            var         context  = new ContractParametersContext(snapshot, tx);

            context.Add(contract, 0, new byte[] { 0x01 });
            Witness[] witnesses = context.GetWitnesses();
            witnesses.Length.Should().Be(1);
            witnesses[0].InvocationScript.ToHexString().Should().Be(new byte[] { (byte)OpCode.PUSHDATA1, 0x01, 0x01 }.ToHexString());
            witnesses[0].VerificationScript.ToHexString().Should().Be(contract.Script.ToHexString());
        }
        public void TestGetParameter()
        {
            Transaction tx      = TestUtils.GetTransaction(UInt160.Parse("0x282646ee0afa5508bb999318f35074b84a17c9f0"));
            var         context = new ContractParametersContext(tx);

            context.GetParameter(tx.Sender, 0).Should().BeNull();

            context.Add(contract, 0, new byte[] { 0x01 });
            var ret = context.GetParameter(tx.Sender, 0);

            ((byte[])ret.Value).ToHexString().Should().Be(new byte[] { 0x01 }.ToHexString());
        }
Example #19
0
        public void TestToString()
        {
            Transaction tx = TestUtils.GetTransaction();

            tx.Sender = UInt160.Parse("0xbecaad15c0ea585211faf99738a4354014f177f2");
            var context = new ContractParametersContext(tx);

            context.Add(contract, 0, new byte[] { 0x01 });
            string str = context.ToString();

            str.Should().Be("{\"type\":\"Neo.Network.P2P.Payloads.Transaction\",\"hex\":\"0000000000f277f1144035a43897f9fa115258eac015adcabe000000000000000000000000000000000000000000000100\",\"items\":{\"0xbecaad15c0ea585211faf99738a4354014f177f2\":{\"script\":\"21026ff03b949241ce1dadd43519e6960e0a85b41a69a05c328103aa2bce1594ca1668747476aa\",\"parameters\":[{\"type\":\"Signature\",\"value\":\"01\"}]}}}");
        }
Example #20
0
        public void TestGetWitnesses()
        {
            var         snapshot = TestBlockchain.GetTestSnapshot();
            Transaction tx       = TestUtils.GetTransaction(UInt160.Parse("0x4bc1b25796f4a13fa3cc7538168d86f7d3bc5356"));
            var         context  = new ContractParametersContext(snapshot, tx);

            context.Add(contract, 0, new byte[] { 0x01 });
            Witness[] witnesses = context.GetWitnesses();
            witnesses.Length.Should().Be(1);
            witnesses[0].InvocationScript.ToHexString().Should().Be(new byte[] { (byte)OpCode.PUSHDATA1, 0x01, 0x01 }.ToHexString());
            witnesses[0].VerificationScript.ToHexString().Should().Be(contract.Script.ToHexString());
        }
Example #21
0
        public void TestGetWitnesses()
        {
            Transaction tx = TestUtils.GetTransaction();

            tx.Sender = UInt160.Parse("0x1a2791a63139294337863c7d822d17454876977c");
            var context = new ContractParametersContext(tx);

            context.Add(contract, 0, new byte[] { 0x01 });
            Witness[] witnesses = context.GetWitnesses();
            witnesses.Length.Should().Be(1);
            witnesses[0].InvocationScript.ToHexString().Should().Be(new byte[] { 0x01, 0x01 }.ToHexString());
            witnesses[0].VerificationScript.ToHexString().Should().Be(contract.Script.ToHexString());
        }
Example #22
0
        public void TestGetParameter()
        {
            var         snapshot = TestBlockchain.GetTestSnapshot();
            Transaction tx       = TestUtils.GetTransaction(UInt160.Parse("0x4bc1b25796f4a13fa3cc7538168d86f7d3bc5356"));
            var         context  = new ContractParametersContext(snapshot, tx);

            context.GetParameter(tx.Sender, 0).Should().BeNull();

            context.Add(contract, 0, new byte[] { 0x01 });
            var ret = context.GetParameter(tx.Sender, 0);

            ((byte[])ret.Value).ToHexString().Should().Be(new byte[] { 0x01 }.ToHexString());
        }
        public void TestGetWitnesses()
        {
            Transaction tx = TestUtils.GetTransaction();

            tx.Sender = UInt160.Parse("0x1bd5c777ec35768892bd3daab60fb7a1cb905066");
            var context = new ContractParametersContext(tx);

            context.Add(contract, 0, new byte[] { 0x01 });
            Witness[] witnesses = context.GetWitnesses();
            witnesses.Length.Should().Be(1);
            witnesses[0].InvocationScript.ToHexString().Should().Be(new byte[] { (byte)OpCode.PUSHDATA1, 0x01, 0x01 }.ToHexString());
            witnesses[0].VerificationScript.ToHexString().Should().Be(contract.Script.ToHexString());
        }
Example #24
0
        public void TestGetWitnesses()
        {
            Transaction tx = TestUtils.GetTransaction();

            tx.Sender = UInt160.Parse("0xbecaad15c0ea585211faf99738a4354014f177f2");
            var context = new ContractParametersContext(tx);

            context.Add(contract, 0, new byte[] { 0x01 });
            Witness[] witnesses = context.GetWitnesses();
            witnesses.Length.Should().Be(1);
            witnesses[0].InvocationScript.ToHexString().Should().Be(new byte[] { 0x01, 0x01 }.ToHexString());
            witnesses[0].VerificationScript.ToHexString().Should().Be(contract.Script.ToHexString());
        }
        public void TestGetWitnesses()
        {
            Transaction tx = TestUtils.GetTransaction();

            tx.Sender = UInt160.Parse("0xcd4ced947d791e887559b3829c3bc08fe37b0a64");
            var context = new ContractParametersContext(tx);

            context.Add(contract, 0, new byte[] { 0x01 });
            Witness[] witnesses = context.GetWitnesses();
            witnesses.Length.Should().Be(1);
            witnesses[0].InvocationScript.ToHexString().Should().Be(new byte[] { (byte)OpCode.PUSHDATA1, 0x01, 0x01 }.ToHexString());
            witnesses[0].VerificationScript.ToHexString().Should().Be(contract.Script.ToHexString());
        }
Example #26
0
        public void TestGetParameter()
        {
            var         snapshot = TestBlockchain.GetTestSnapshot();
            Transaction tx       = TestUtils.GetTransaction(UInt160.Parse("0x902e0d38da5e513b6d07c1c55b85e77d3dce8063"));
            var         context  = new ContractParametersContext(snapshot, tx);

            context.GetParameter(tx.Sender, 0).Should().BeNull();

            context.Add(contract, 0, new byte[] { 0x01 });
            var ret = context.GetParameter(tx.Sender, 0);

            ((byte[])ret.Value).ToHexString().Should().Be(new byte[] { 0x01 }.ToHexString());
        }
Example #27
0
        public void TestGetParameter()
        {
            Transaction tx = TestUtils.GetTransaction();

            tx.Sender = UInt160.Parse("0x1a2791a63139294337863c7d822d17454876977c");
            var context = new ContractParametersContext(tx);

            context.GetParameter(tx.Sender, 0).Should().BeNull();

            context.Add(contract, 0, new byte[] { 0x01 });
            var ret = context.GetParameter(tx.Sender, 0);

            ((byte[])ret.Value).ToHexString().Should().Be(new byte[] { 0x01 }.ToHexString());
        }
Example #28
0
        public void TestGetParameter()
        {
            Transaction tx = TestUtils.GetTransaction();

            tx.Sender = UInt160.Parse("0xbecaad15c0ea585211faf99738a4354014f177f2");
            var context = new ContractParametersContext(tx);

            context.GetParameter(tx.Sender, 0).Should().BeNull();

            context.Add(contract, 0, new byte[] { 0x01 });
            var ret = context.GetParameter(tx.Sender, 0);

            ((byte[])ret.Value).ToHexString().Should().Be(new byte[] { 0x01 }.ToHexString());
        }
        public void TestGetParameter()
        {
            Transaction tx = TestUtils.GetTransaction();

            tx.Sender = UInt160.Parse("0x1bd5c777ec35768892bd3daab60fb7a1cb905066");
            var context = new ContractParametersContext(tx);

            context.GetParameter(tx.Sender, 0).Should().BeNull();

            context.Add(contract, 0, new byte[] { 0x01 });
            var ret = context.GetParameter(tx.Sender, 0);

            ((byte[])ret.Value).ToHexString().Should().Be(new byte[] { 0x01 }.ToHexString());
        }
        public void TestGetParameter()
        {
            Transaction tx = TestUtils.GetTransaction();

            tx.Sender = UInt160.Parse("0xcd4ced947d791e887559b3829c3bc08fe37b0a64");
            var context = new ContractParametersContext(tx);

            context.GetParameter(tx.Sender, 0).Should().BeNull();

            context.Add(contract, 0, new byte[] { 0x01 });
            var ret = context.GetParameter(tx.Sender, 0);

            ((byte[])ret.Value).ToHexString().Should().Be(new byte[] { 0x01 }.ToHexString());
        }