Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            var key = GetScriptHashFromAddress(textBox1.Text);

            label1.Text = key.ToHexString();

            var skey = new Neo.Core.StorageKey();

            skey.Key        = key;
            skey.ScriptHash = UInt160.Parse(plugin_whoami.whoami_scripthash);

            var item = Neo.Core.Blockchain.Default.GetStorageItem(skey);

            this.listBox1.Items.Clear();
            if (item == null)
            {
                this.listBox1.Items.Add("<nothing>");
            }
            else
            {
                this.listBox1.Items.Add("hexstr:" + item.Value.ToHexString());
                var text = "";
                try
                {
                    text = System.Text.Encoding.UTF8.GetString(item.Value);
                }
                catch
                {
                }
                this.listBox1.Items.Add("as str:" + text);
            }
        }
Exemplo n.º 2
0
        private void button6_Click(object sender, EventArgs e)
        {
            var script_hash = UInt160.Parse(textBox1.Text);
            var key         = System.Text.Encoding.ASCII.GetBytes("!pool");
            var bchain      = Neo.Core.Blockchain.Default;

            var skey = new Neo.Core.StorageKey();

            skey.Key        = key;
            skey.ScriptHash = script_hash;

            listBox2.Items.Clear();

            var item = bchain.GetStorageItem(skey);

            if (item == null)
            {
                listBox2.Items.Add("pool empty");
            }
            else
            {
                listBox2.Items.Add("pool balance=" + (decimal) new System.Numerics.BigInteger(item.Value) / (decimal)amount);
            }

            var scripthash     = textBox1.Text;
            var addrscripthash = GetScriptHashFromAddress(textBox5.Text);
            {
                var p1 = new Neo.SmartContract.ContractParameter(Neo.SmartContract.ContractParameterType.String)
                {
                    Value = "checkBonus"
                };
                var p2 = new ContractParameter(Neo.SmartContract.ContractParameterType.Array)
                {
                };
                var script = MakeAppCallScript(scripthash, p1, p2);
                var ts     = TestCallScript(script);
                if (ts == null)
                {
                    listBox2.Items.Add("no Bonus.");
                }
                else
                {
                    try
                    {
                        var tss = ts as Neo.VM.Types.Array;
                        for (var i = 0; i < tss.Count; i++)
                        {
                            var titme = tss[i];
                            if (titme is  Neo.VM.Types.Array)
                            {
                                var arr = titme as Neo.VM.Types.Array;

                                listBox2.Items.Add(i + "领奖block=" + arr[0].GetBigInteger());
                                listBox2.Items.Add(i + "奖池总数=" + (decimal)arr[1].GetBigInteger() / (decimal)amount);
                                listBox2.Items.Add(i + "领奖比例=" + (decimal)arr[2].GetBigInteger() / (decimal)amount);
                            }
                        }
                    }
                    catch
                    {
                        listBox2.Items.Add("no bonus");
                    }
                }
            }
        }
Exemplo n.º 3
0
 public abstract StorageItem GetStorageItem(StorageKey key);
Exemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            var key = GetScriptHashFromAddress(textBox1.Text);

            label1.Text = key.ToHexString();
            var keylast = key.Concat(new byte[] { 0x02 }).ToArray();
            var keynow  = key.Concat(new byte[] { 0x01 }).ToArray();
            var keyname = key.Concat(new byte[] { 0x20, 0x01 }).ToArray();
            var keypic  = key.Concat(new byte[] { 0x20, 0x02 }).ToArray();
            var hash    = UInt160.Parse(plugin_whoami.microblog_scripthash);

            var skeyLast = new Neo.Core.StorageKey();

            skeyLast.Key        = keylast;
            skeyLast.ScriptHash = hash;
            var itemLast = Neo.Core.Blockchain.Default.GetStorageItem(skeyLast);

            var skeyNow = new Neo.Core.StorageKey();

            skeyNow.Key        = keynow;
            skeyNow.ScriptHash = hash;
            var itemNow = Neo.Core.Blockchain.Default.GetStorageItem(skeyNow);

            var skeyName = new Neo.Core.StorageKey();

            skeyName.Key        = keyname;
            skeyName.ScriptHash = hash;
            var itemName = Neo.Core.Blockchain.Default.GetStorageItem(skeyName);

            var skeyPic = new Neo.Core.StorageKey();

            skeyPic.Key        = keypic;
            skeyPic.ScriptHash = hash;
            var itemPic = Neo.Core.Blockchain.Default.GetStorageItem(skeyPic);

            this.listBox1.Items.Clear();
            if (itemLast != null)
            {
                this.listBox1.Items.Add("lastblock:" + itemLast.Value.ToHexString());
            }
            else
            {
                this.listBox1.Items.Add("lastblock:<nothing>");
            }
            if (itemNow != null)
            {
                this.listBox1.Items.Add("nowblock:" + itemNow.Value.ToHexString());
            }
            else
            {
                this.listBox1.Items.Add("nowblock:<nothing>");
            }

            if (itemName == null)
            {
                this.listBox1.Items.Add("name:<nothing>");
            }
            else
            {
                var text = "";
                try
                {
                    text = System.Text.Encoding.UTF8.GetString(itemName.Value);
                }
                catch
                {
                }
                this.listBox1.Items.Add("name:" + text);
            }

            if (itemPic == null)
            {
                this.pictureBox1.Image = null;
            }
            else
            {
                using (var ms = new System.IO.MemoryStream(itemPic.Value))
                {
                    this.pictureBox1.Image = Bitmap.FromStream(ms);
                }
            }
        }