예제 #1
0
#pragma warning disable CS0612 // Type or member is obsolete
        public void SerializeDeserialize_RegisterTransaction()
        {
            var original = new RegisterTransaction()
            {
                Version   = 0x00,
                Name      = RandomString(byte.MaxValue),
                Admin     = RandomUInt60(1).FirstOrDefault(),
                Amount    = RandomFixed8(true, 1).FirstOrDefault(),
                AssetType = RandomEnum <AssetType>(),
                Owner     = ECPoint.Infinity,
                Precision = (byte)_random.Next(byte.MinValue, byte.MaxValue),
            };

            FillRandomTx(original);

            var ret   = _serializer.Serialize(original);
            var copy  = _deserializer.Deserialize <Transaction>(ret);
            var copy2 = _deserializer.Deserialize <RegisterTransaction>(ret);

            // Check exclusive data

            foreach (var check in new RegisterTransaction[] { (RegisterTransaction)copy, copy2 })
            {
                Assert.AreEqual(original.Name, check.Name);
                Assert.AreEqual(original.Amount, check.Amount);
                Assert.AreEqual(original.AssetType, check.AssetType);
                Assert.AreEqual(original.Precision, check.Precision);
                Assert.AreEqual(original.Owner, check.Owner);
                Assert.AreEqual(original.Admin, check.Admin);
            }

            // Check base data

            EqualTx(original, copy, copy2);
        }
예제 #2
0
 private bool TestFilter(BloomFilter filter, Transaction tx)
 {
     if (filter.Check(tx.Hash.ToArray()))
     {
         return(true);
     }
     if (tx.Outputs.Any(p => filter.Check(p.ScriptHash.ToArray())))
     {
         return(true);
     }
     if (tx.Inputs.Any(p => filter.Check(p.ToArray())))
     {
         return(true);
     }
     if (tx.Scripts.Any(p => filter.Check(p.RedeemScript.ToScriptHash().ToArray())))
     {
         return(true);
     }
     if (tx.Type == TransactionType.RegisterTransaction)
     {
         RegisterTransaction asset = (RegisterTransaction)tx;
         if (filter.Check(asset.Admin.ToArray()))
         {
             return(true);
         }
     }
     return(false);
 }
        public async Task Process_AddsContract()
        {
            var pubKey = new byte[33];

            pubKey[0] = 0x02;
            var input = new RegisterTransaction
            {
                Hash      = UInt256.Parse(RandomInt().ToString("X64")),
                AssetType = (AssetType)RandomInt(16),
                Name      = RandomString(10),
                Amount    = new Fixed8(RandomInt()),
                Precision = (byte)RandomInt(8),
                Owner     = new ECPoint(pubKey),
                Admin     = UInt160.Parse(RandomInt().ToString("X40"))
            };
            var repositoryMock = AutoMockContainer.GetMock <IRepository>();
            var testee         = AutoMockContainer.Create <RegisterTransactionProcessor>();

            await testee.Process(input);

            repositoryMock.Verify(m => m.AddAsset(It.Is <Asset>(a =>
                                                                a.Id.Equals(input.Hash) &&
                                                                a.AssetType.Equals(input.AssetType) &&
                                                                a.Name == input.Name &&
                                                                a.Amount.Equals(input.Amount) &&
                                                                a.Precision == input.Precision &&
                                                                a.Owner.CompareTo(input.Owner) == 0 &&
                                                                a.Admin.Equals(input.Admin))));
        }
예제 #4
0
파일: RemoteNode.cs 프로젝트: ys8090/NEU
        private bool TestFilter(BloomFilter filter, Transaction tx)
        {
            if (filter.Check(tx.Hash.ToArray()))
            {
                return(true);
            }
            if (tx.Outputs.Any(p => filter.Check(p.ScriptHash.ToArray())))
            {
                return(true);
            }
            if (tx.Inputs.Any(p => filter.Check(p.ToArray())))
            {
                return(true);
            }
            if (tx.Scripts.Any(p => filter.Check(p.VerificationScript.ToScriptHash().ToArray())))
            {
                return(true);
            }
            if (tx.Type == TransactionType.RegisterTransaction)
            {
#pragma warning disable CS0612
                RegisterTransaction asset = (RegisterTransaction)tx;
                if (filter.Check(asset.Admin.ToArray()))
                {
                    return(true);
                }
#pragma warning restore CS0612
            }
            return(false);
        }
예제 #5
0
        private void viewCertificateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RegisterTransaction asset = (RegisterTransaction)listView2.SelectedItems[0].Tag;
            UInt160             hash  = Contract.CreateSignatureRedeemScript(asset.Issuer).ToScriptHash();
            string address            = Wallet.ToAddress(hash);
            string path = Path.Combine(Settings.Default.CertCachePath, $"{address}.cer");

            Process.Start(path);
        }
예제 #6
0
        public async Task Persist_RegisterTx_CallsRegisterTxPersister()
        {
            var input = new RegisterTransaction();
            var registerTxPersisterMock = AutoMockContainer.GetMock <ITransactionPersister <RegisterTransaction> >();
            var testee = AutoMockContainer.Create <TransactionPersister>();

            await testee.Persist(input);

            registerTxPersisterMock.Verify(m => m.Persist(input));
        }
예제 #7
0
        public async Task Process_RegisterTx_CallsRegisterTxProcessor()
        {
            var input = new RegisterTransaction();
            var registerTxProcessorMock = AutoMockContainer.GetMock <IProcessor <RegisterTransaction> >();
            var testee = AutoMockContainer.Create <TransactionProcessor>();

            await testee.Process(input);

            registerTxProcessorMock.Verify(m => m.Process(input));
        }
예제 #8
0
        private static bool Asset_GetAmount(ExecutionEngine engine)
        {
            RegisterTransaction asset = engine.EvaluationStack.Pop().GetInterface <RegisterTransaction>();

            if (asset == null)
            {
                return(false);
            }
            engine.EvaluationStack.Push(asset.Amount.GetData());
            return(true);
        }
예제 #9
0
        private static bool Asset_GetIssuer(ScriptEngine engine)
        {
            RegisterTransaction asset = engine.EvaluationStack.Pop().GetInterface <RegisterTransaction>();

            if (asset == null)
            {
                return(false);
            }
            engine.EvaluationStack.Push(asset.Issuer.EncodePoint(true));
            return(true);
        }
예제 #10
0
        private static bool Asset_GetAdmin(ScriptEngine engine)
        {
            RegisterTransaction asset = engine.EvaluationStack.Pop().GetInterface <RegisterTransaction>();

            if (asset == null)
            {
                return(false);
            }
            engine.EvaluationStack.Push(asset.Admin.ToArray());
            return(true);
        }
예제 #11
0
 public IssueDialog(RegisterTransaction asset = null)
 {
     InitializeComponent();
     if (asset == null)
     {
         comboBox1.Items.AddRange(Blockchain.Default.GetAssets().Where(p => Program.CurrentWallet.ContainsAddress(p.Admin)).ToArray());
     }
     else
     {
         comboBox1.Items.Add(asset);
     }
 }
예제 #12
0
 public void SetItems(IEnumerable <TransactionOutput> outputs)
 {
     listBox1.Items.Clear();
     foreach (TransactionOutput output in outputs)
     {
         RegisterTransaction asset = (RegisterTransaction)Blockchain.Default.GetTransaction(output.AssetId);
         listBox1.Items.Add(new TxOutListBoxItem
         {
             Output    = output,
             AssetName = $"{asset.GetName()} ({asset.Issuer})"
         });
     }
     ItemsChanged?.Invoke(this, EventArgs.Empty);
 }
예제 #13
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            RegisterTransaction tx = comboBox1.SelectedItem as RegisterTransaction;

            if (tx == null)
            {
                textBox3.Text = "";
            }
            else
            {
                textBox3.Text = Program.CurrentWallet.GetAvailable(tx.Hash).ToString();
            }
            textBox_TextChanged(this, EventArgs.Empty);
        }
예제 #14
0
        public RegisterTransaction GetTransaction()
        {
            RegisterTransaction tx = Program.CurrentWallet.MakeTransaction <RegisterTransaction>(new TransactionOutput[0], Fixed8.Zero);

            if (tx == null)
            {
                return(null);
            }
            tx.AssetType = (AssetType)comboBox1.SelectedItem;
            tx.Name      = tx.AssetType == AssetType.Share ? string.Empty : $"[{{'lang':'zh-CN','name':'{textBox1.Text}'}}]";
            tx.Amount    = checkBox1.Checked ? Fixed8.Parse(textBox2.Text) : -Fixed8.Satoshi;
            tx.Issuer    = (ECPoint)comboBox2.SelectedItem;
            tx.Admin     = Wallet.ToScriptHash(comboBox3.Text);
            return(tx);
        }
예제 #15
0
        public ContractTransaction GetTransaction()
        {
            RegisterTransaction tx = comboBox1.SelectedItem as RegisterTransaction;

            if (tx == null)
            {
                return(null);
            }
            return(Program.CurrentWallet.MakeTransaction <ContractTransaction>(listBox1.Items.OfType <TxOutListBoxItem>().GroupBy(p => p.Account).Select(g => new TransactionOutput
            {
                AssetId = tx.Hash,
                Value = g.Sum(p => p.Amount),
                ScriptHash = g.Key
            }).ToArray(), Fixed8.Zero));
        }
예제 #16
0
        public static IssueTransaction CreateIssueTx(RegisterTransaction governingTx, IEnumerable <ECPoint> validators)
        {
            var governingTxHash = governingTx.CalculateHash();

            var validatorCount      = (validators.Count() / 2) + 1;
            var validatorScript     = Contract.CreateMultiSigRedeemScript(validators, validatorCount);
            var validatorScriptHash = validatorScript.Span.CalculateScriptHash();
            var verificationScript  = ImmutableArray.Create <byte>(OpCode.PUSHT);

            return(new IssueTransaction(
                       version: 0,
                       outputs: new[]
            {
                new TransactionOutput(governingTxHash, governingTx.Amount, validatorScriptHash)
            },
                       witnesses: new[] { new Witness(default, verificationScript) }));
예제 #17
0
        private void button1_Click(object sender, EventArgs e)
        {
            RegisterTransaction antshare = new RegisterTransaction
            {
                AssetType = AssetType.AntShare,
                Name      = "[{'lang':'zh-CN','name':'小蚁股'},{'lang':'en','name':'AntShare'}]",
                Amount    = Fixed8.FromDecimal(numericUpDown1.Value),
                Issuer    = Wallet.ToScriptHash(textBox1.Text),
                Admin     = Wallet.ToScriptHash(textBox2.Text),
                Inputs    = new TransactionInput[0],
                Outputs   = new TransactionOutput[0]
            };
            SignatureContext context = new SignatureContext(antshare);

            InformationBox.Show(context.ToString(), "小蚁股签名上下文");
        }
예제 #18
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            RegisterTransaction tx = comboBox1.SelectedItem as RegisterTransaction;

            if (tx == null)
            {
                textBox1.Text     = "";
                groupBox3.Enabled = false;
            }
            else
            {
                textBox1.Text     = Program.CurrentWallet.GetAvailable(tx.Hash).ToString();
                groupBox3.Enabled = true;
            }
            txOutListBox1.Clear();
        }
예제 #19
0
        static GenesisAssets()
        {
            // NEO Token is represented as a RegisterTransaction of type GoverningToken
            GoverningTokenRegisterTransaction = new RegisterTransaction
            {
                AssetType = AssetType.GoverningToken,
                Name      = "[{\"lang\":\"zh-CN\",\"name\":\"小蚁股\"},{\"lang\":\"en\",\"name\":\"AntShare\"}]",
                Amount    = Fixed8.FromDecimal(100000000),
                Precision = 0,
                Owner     = ECPoint.Infinity,
                //Why this? Check with people
                Admin      = (new[] { (byte)EVMOpCode.PUSH1 }).ToScriptHash(),
                Attributes = new TransactionAttribute[0],
                Inputs     = new CoinReference[0],
                Outputs    = new TransactionOutput[0],
                Witness    = new Witness[0]
            };

            GoverningTokenRegisterTransaction.UpdateHash();

            // GAS Token is represented as a RegisterTransaction of type UtilityToken
            UtilityTokenRegisterTransaction = new RegisterTransaction
            {
                AssetType = AssetType.UtilityToken,
                Name      = "[{\"lang\":\"zh-CN\",\"name\":\"小蚁币\"},{\"lang\":\"en\",\"name\":\"AntCoin\"}]",
                Amount    = Fixed8.FromDecimal(GasGenerationPerBlock.Sum(p => p) * DecrementInterval),
                Precision = 8,
                Owner     = ECPoint.Infinity,
                //Why this? Check with people
                Admin      = (new[] { (byte)EVMOpCode.PUSH0 }).ToScriptHash(),
                Attributes = new TransactionAttribute[0],
                Inputs     = new CoinReference[0],
                Outputs    = new TransactionOutput[0],
                Witness    = new Witness[0]
            };

            UtilityTokenRegisterTransaction.UpdateHash();

            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json", false, true);

            var configuration = builder.Build();

            _networkConfig = new NetworkConfig(configuration);
        }
예제 #20
0
        public ContractTransaction GetTransaction()
        {
            RegisterTransaction asset = comboBox1.SelectedItem as RegisterTransaction;

            if (asset == null)
            {
                return(null);
            }
            return(Program.CurrentWallet.MakeTransaction(new ContractTransaction
            {
                Outputs = txOutListBox1.Items.GroupBy(p => p.Account).Select(g => new TransactionOutput
                {
                    AssetId = asset.Hash,
                    Value = g.Sum(p => p.Amount),
                    ScriptHash = g.Key
                }).ToArray()
            }, Fixed8.Zero));
        }
예제 #21
0
        public IssueTransaction GetTransaction()
        {
            RegisterTransaction tx = comboBox1.SelectedItem as RegisterTransaction;

            if (tx == null)
            {
                return(null);
            }
            return(new IssueTransaction
            {
                Inputs = new TransactionInput[0], //TODO: 从区块链或钱包中找出负资产,并合并到交易中
                Outputs = listBox1.Items.OfType <IssueListBoxItem>().GroupBy(p => p.Account).Select(g => new TransactionOutput
                {
                    AssetId = tx.Hash,
                    ScriptHash = g.Key,
                    Value = g.Sum(p => p.Amount)
                }).ToArray()
            });
        }
예제 #22
0
        private void button2_Click(object sender, EventArgs e)
        {
            RegisterTransaction antshare = textBox3.Text.HexToBytes().AsSerializable <RegisterTransaction>();

            using (IssueDialog dialog = new IssueDialog(antshare))
            {
                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                IssueTransaction tx = dialog.GetTransaction();
                if (tx.Outputs.Sum(p => p.Value) != antshare.Amount)
                {
                    MessageBox.Show("发行量不等于总量!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                SignatureContext context = new SignatureContext(tx);
                InformationBox.Show(context.ToString(), "小蚁股发行签名上下文:");
            }
        }
예제 #23
0
        /// <inheritdoc />
        public RegisterTransaction BuildGoverningTokenRegisterTransaction()
        {
            // NEO Token is represented as a RegisterTransaction of type GoverningToken
            this._governingTokenRegisterTransaction = new RegisterTransaction
            {
                AssetType = AssetType.GoverningToken,
                Name      = "[{\"lang\":\"zh-CN\",\"name\":\"小蚁股\"},{\"lang\":\"en\",\"name\":\"AntShare\"}]",
                Amount    = Fixed8.FromDecimal(100000000),
                Precision = 0,
                Owner     = ECPoint.Infinity,
                //Why this? Check with people
                Admin      = (new[] { (byte)EVMOpCode.PUSH1 }).ToScriptHash(),
                Attributes = new TransactionAttribute[0],
                Inputs     = new CoinReference[0],
                Outputs    = new TransactionOutput[0],
                Witness    = new Witness[0]
            };

            this._transactionSigner.Sign(this._governingTokenRegisterTransaction);
            return(this._governingTokenRegisterTransaction);
        }
예제 #24
0
        /// <inheritdoc />
        public RegisterTransaction BuildUtilityTokenRegisterTransaction()
        {
            // GAS Token is represented as a RegisterTransaction of type UtilityToken
            this._utilityTokenRegisterTransaction = new RegisterTransaction
            {
                AssetType = AssetType.UtilityToken,
                Name      = "[{\"lang\":\"zh-CN\",\"name\":\"小蚁币\"},{\"lang\":\"en\",\"name\":\"AntCoin\"}]",
                Amount    = Fixed8.FromDecimal(_gasGenerationPerBlock.Sum(p => p) * DecrementInterval),
                Precision = 8,
                Owner     = ECPoint.Infinity,
                //Why this? Check with people
                Admin      = (new[] { (byte)EVMOpCode.PUSH0 }).ToScriptHash(),
                Attributes = new TransactionAttribute[0],
                Inputs     = new CoinReference[0],
                Outputs    = new TransactionOutput[0],
                Witness    = new Witness[0]
            };

            this._transactionSigner.Sign(this._utilityTokenRegisterTransaction);
            return(this._utilityTokenRegisterTransaction);
        }
예제 #25
0
        private void button1_Click(object sender, EventArgs e)
        {
            RegisterTransaction antshare = new RegisterTransaction
            {
                AssetType = AssetType.AntShare,
#if TESTNET
                Name = "[{'lang':'zh-CN','name':'小蚁股(测试)'},{'lang':'en','name':'AntShare(TestNet)'}]",
#else
                Name = "[{'lang':'zh-CN','name':'小蚁股'},{'lang':'en','name':'AntShare'}]",
#endif
                Amount     = Fixed8.FromDecimal(numericUpDown1.Value),
                Issuer     = ECPoint.Parse(textBox1.Text, ECCurve.Secp256r1),
                Admin      = Wallet.ToScriptHash(textBox2.Text),
                Attributes = new TransactionAttribute[0],
                Inputs     = new TransactionInput[0],
                Outputs    = new TransactionOutput[0]
            };
            SignatureContext context = new SignatureContext(antshare);

            InformationBox.Show(context.ToString(), "小蚁股签名上下文:");
        }
예제 #26
0
        public IssueTransaction GetTransaction()
        {
            RegisterTransaction asset = comboBox1.SelectedItem as RegisterTransaction;

            if (asset == null)
            {
                return(null);
            }
            Random rand = new Random();

            return(Program.CurrentWallet.MakeTransaction(new IssueTransaction
            {
                Nonce = (uint)rand.Next(),
                Outputs = txOutListBox1.Items.GroupBy(p => p.Account).Select(g => new TransactionOutput
                {
                    AssetId = asset.Hash,
                    Value = g.Sum(p => p.Amount),
                    ScriptHash = g.Key
                }).ToArray()
            }, Fixed8.Zero));
        }
예제 #27
0
 public PayToDialog(RegisterTransaction asset = null, UInt160 scriptHash = null)
 {
     InitializeComponent();
     if (asset == null)
     {
         foreach (UInt256 asset_id in Program.CurrentWallet.FindUnspentCoins().Select(p => p.Output.AssetId).Distinct())
         {
             comboBox1.Items.Add(Blockchain.Default.GetTransaction(asset_id));
         }
     }
     else
     {
         comboBox1.Items.Add(asset);
         comboBox1.SelectedIndex = 0;
         comboBox1.Enabled       = false;
     }
     if (scriptHash != null)
     {
         textBox1.Text     = Wallet.ToAddress(scriptHash);
         textBox1.ReadOnly = true;
     }
 }
예제 #28
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            RegisterTransaction asset = comboBox1.SelectedItem as RegisterTransaction;

            if (asset == null)
            {
                textBox1.Text     = "";
                textBox2.Text     = "";
                textBox3.Text     = "";
                textBox4.Text     = "";
                groupBox3.Enabled = false;
            }
            else
            {
                textBox1.Text     = asset.Issuer.ToString();
                textBox2.Text     = Wallet.ToAddress(asset.Admin);
                textBox3.Text     = asset.Amount == -Fixed8.Satoshi ? "+\u221e" : asset.Amount.ToString();
                textBox4.Text     = Blockchain.Default.GetQuantityIssued(asset.Hash).ToString();
                groupBox3.Enabled = true;
            }
            txOutListBox1.Clear();
        }
예제 #29
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            RegisterTransaction tx = comboBox1.SelectedItem as RegisterTransaction;

            listBox1.Items.Clear();
            if (tx == null)
            {
                textBox1.Text     = "";
                textBox2.Text     = "";
                textBox3.Text     = "";
                textBox4.Text     = "";
                groupBox3.Enabled = false;
                button2.Enabled   = false;
            }
            else
            {
                textBox1.Text     = Wallet.ToAddress(tx.Issuer);
                textBox2.Text     = Wallet.ToAddress(tx.Admin);
                textBox3.Text     = tx.Amount.ToString();
                textBox4.Text     = Blockchain.Default.GetQuantityIssued(tx.Hash).ToString();
                groupBox3.Enabled = true;
            }
        }
예제 #30
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            lbl_height.Text     = $"{Blockchain.Default.Height}/{Blockchain.Default.HeaderHeight}";
            lbl_count_node.Text = Program.LocalNode.RemoteNodeCount.ToString();
            TimeSpan persistence_span = DateTime.Now - persistence_time;

            if (persistence_span > Blockchain.TimePerBlock)
            {
                toolStripProgressBar1.Style = ProgressBarStyle.Marquee;
            }
            else
            {
                toolStripProgressBar1.Value = persistence_span.Seconds;
                toolStripProgressBar1.Style = ProgressBarStyle.Blocks;
            }
            if (balance_changed)
            {
                IEnumerable <Coin> coins = Program.CurrentWallet?.FindCoins() ?? Enumerable.Empty <Coin>();
                var assets = coins.GroupBy(p => p.AssetId, (k, g) => new
                {
                    Asset     = (RegisterTransaction)Blockchain.Default.GetTransaction(k),
                    Value     = g.Sum(p => p.Value),
                    Available = g.Where(p => p.State == CoinState.Unspent).Sum(p => p.Value)
                }).ToDictionary(p => p.Asset.Hash);
                foreach (RegisterTransaction tx in listView2.Items.OfType <ListViewItem>().Select(p => (RegisterTransaction)p.Tag).ToArray())
                {
                    if (!assets.ContainsKey(tx.Hash))
                    {
                        listView2.Items.RemoveByKey(tx.Hash.ToString());
                    }
                }
                foreach (var asset in assets.Values)
                {
                    if (listView2.Items.ContainsKey(asset.Asset.Hash.ToString()))
                    {
                        listView2.Items[asset.Asset.Hash.ToString()].SubItems["value"].Text = asset.Value.ToString();
                    }
                    else
                    {
                        listView2.Items.Add(new ListViewItem(new[]
                        {
                            new ListViewItem.ListViewSubItem
                            {
                                Name = "name",
                                Text = asset.Asset.GetName()
                            },
                            new ListViewItem.ListViewSubItem
                            {
                                Name = "type",
                                Text = asset.Asset.AssetType.ToString()
                            },
                            new ListViewItem.ListViewSubItem
                            {
                                Name = "value",
                                Text = asset.Value.ToString()
                            },
                            new ListViewItem.ListViewSubItem
                            {
                                ForeColor = Color.Gray,
                                Name      = "issuer",
                                Text      = $"未知发行者[{asset.Asset.Issuer}]"
                            }
                        }, -1, listView2.Groups["unchecked"])
                        {
                            Name = asset.Asset.Hash.ToString(),
                            Tag  = asset.Asset,
                            UseItemStyleForSubItems = false
                        });
                    }
                }
                balance_changed = false;
            }
            foreach (ListViewItem item in listView2.Groups["unchecked"].Items.OfType <ListViewItem>().ToArray())
            {
                ListViewItem.ListViewSubItem subitem = item.SubItems["issuer"];
                RegisterTransaction          asset   = (RegisterTransaction)item.Tag;
                byte[] cert_url_data = asset.Attributes.FirstOrDefault(p => p.Usage == TransactionAttributeUsage.CertUrl)?.Data;
                string cert_url      = cert_url_data == null ? null : Encoding.UTF8.GetString(cert_url_data);
                using (CertificateQueryResult result = CertificateQueryService.Query(asset.Issuer, cert_url))
                {
                    switch (result.Type)
                    {
                    case CertificateQueryResultType.Querying:
                    case CertificateQueryResultType.QueryFailed:
                        break;

                    case CertificateQueryResultType.System:
                        subitem.ForeColor = Color.Green;
                        subitem.Text      = "小蚁系统";
                        break;

                    case CertificateQueryResultType.Invalid:
                        subitem.ForeColor = Color.Red;
                        subitem.Text      = $"[证书错误][{asset.Issuer}]";
                        break;

                    case CertificateQueryResultType.Expired:
                        subitem.ForeColor = Color.Yellow;
                        subitem.Text      = $"[证书已过期]{result.Certificate.Subject}[{asset.Issuer}]";
                        break;

                    case CertificateQueryResultType.Good:
                        subitem.ForeColor = Color.Black;
                        subitem.Text      = $"{result.Certificate.Subject}[{asset.Issuer}]";
                        break;
                    }
                    switch (result.Type)
                    {
                    case CertificateQueryResultType.System:
                    case CertificateQueryResultType.Missing:
                    case CertificateQueryResultType.Invalid:
                    case CertificateQueryResultType.Expired:
                    case CertificateQueryResultType.Good:
                        item.Group = listView2.Groups["checked"];
                        break;
                    }
                }
            }
        }