Exemplo n.º 1
0
        public void TestDeserialize()
        {
            byte[] privateKey = new byte[32];
            using (RandomNumberGenerator rng = RandomNumberGenerator.Create())
            {
                rng.GetBytes(privateKey);
            }
            KeyPair key = new KeyPair(privateKey);
            VerificationContract contract1 = new VerificationContract
            {
                Script        = Neo.SmartContract.Contract.CreateSignatureRedeemScript(key.PublicKey),
                ParameterList = new[] { ContractParameterType.Signature }
            };
            MemoryStream stream = new MemoryStream();
            BinaryWriter writer = new BinaryWriter(stream);
            BinaryReader reader = new BinaryReader(stream);

            contract1.Serialize(writer);
            stream.Seek(0, SeekOrigin.Begin);
            VerificationContract contract2 = new VerificationContract();

            contract2.Deserialize(reader);
            Assert.AreEqual(Encoding.Default.GetString(contract2.Script), Encoding.Default.GetString(contract1.Script));
            Assert.AreEqual(1, contract2.ParameterList.Length);
            Assert.AreEqual(ContractParameterType.Signature, contract2.ParameterList[0]);
        }
Exemplo n.º 2
0
 private void CheckSignatures()
 {
     if (context.Signatures.Count(p => p != null) >= context.M && context.TransactionHashes.All(p => context.Transactions.ContainsKey(p)))
     {
         VerificationContract contract = VerificationContract.CreateMultiSigContract(context.Validators[context.MyIndex].EncodePoint(true).ToScriptHash(), context.M, context.Validators);
         Block block = context.MakeHeader();
         ContractParametersContext sc = new ContractParametersContext(block);
         for (int i = 0, j = 0; i < context.Validators.Length && j < context.M; i++)
         {
             if (context.Signatures[i] != null)
             {
                 sc.AddSignature(contract, context.Validators[i], context.Signatures[i]);
                 j++;
             }
         }
         sc.Verifiable.Scripts = sc.GetScripts();
         block.Transactions    = context.TransactionHashes.Select(p => context.Transactions[p]).ToArray();
         Log($"relay block: {block.Hash}");
         if (!localNode.Relay(block))
         {
             Log($"reject block: {block.Hash}");
         }
         context.State |= ConsensusState.BlockSent;
     }
 }
Exemplo n.º 3
0
        public void TestSerialize()
        {
            byte[] privateKey = new byte[32];
            using (RandomNumberGenerator rng = RandomNumberGenerator.Create())
            {
                rng.GetBytes(privateKey);
            }
            KeyPair key = new KeyPair(privateKey);
            VerificationContract contract1 = new VerificationContract
            {
                Script        = Neo.SmartContract.Contract.CreateSignatureRedeemScript(key.PublicKey),
                ParameterList = new[] { ContractParameterType.Signature }
            };
            MemoryStream stream = new MemoryStream();
            BinaryWriter writer = new BinaryWriter(stream);

            contract1.Serialize(writer);
            stream.Seek(0, SeekOrigin.Begin);
            byte[] byteArray = new byte[stream.Length];
            stream.Read(byteArray, 0, (int)stream.Length);
            byte[] script = Neo.SmartContract.Contract.CreateSignatureRedeemScript(key.PublicKey);
            byte[] result = new byte[62];
            result[20] = 0x01;
            result[21] = 0x00;
            result[22] = 0x27;
            Array.Copy(script, 0, result, 23, 39);
            Assert.AreEqual(Encoding.Default.GetString(result), Encoding.Default.GetString(byteArray));
        }
Exemplo n.º 4
0
        private bool OnCreateAddressCommand(string[] args)
        {
            if (Program.Wallet == null)
            {
                Console.WriteLine("You have to open the wallet first.");
                return(true);
            }
            if (args.Length > 3)
            {
                Console.WriteLine("error");
                return(true);
            }
            ushort count = 1;

            if (args.Length >= 3)
            {
                count = ushort.Parse(args[2]);
            }
            List <string> addresses = new List <string>();

            for (int i = 1; i <= count; i++)
            {
                KeyPair key = Program.Wallet.CreateKey();
                VerificationContract contract = Program.Wallet.GetContracts(key.PublicKeyHash).First(p => p.IsStandard);
                addresses.Add(contract.Address);
                Console.SetCursorPosition(0, Console.CursorTop);
                Console.Write($"[{i}/{count}]");
            }
            Console.WriteLine();
            string path = "address.txt";

            Console.WriteLine($"export addresses to {path}");
            File.WriteAllLines(path, addresses);
            return(true);
        }
Exemplo n.º 5
0
        public void TestCreateAccountBySmartContract()
        {
            byte[] privateKey = new byte[32];
            using (RandomNumberGenerator rng = RandomNumberGenerator.Create())
            {
                rng.GetBytes(privateKey);
            }
            KeyPair key = new KeyPair(privateKey);
            VerificationContract contract = new VerificationContract
            {
                Script        = Contract.CreateSignatureRedeemScript(key.PublicKey),
                ParameterList = new[] { ContractParameterType.Signature }
            };
            var account   = wallet.CreateAccount(contract, key);
            var dbAccount = wallet.GetAccount(account.ScriptHash);

            account.Should().Be(dbAccount);

            byte[] privateKey2 = new byte[32];
            using (RandomNumberGenerator rng = RandomNumberGenerator.Create())
            {
                rng.GetBytes(privateKey2);
            }
            KeyPair  key2      = new KeyPair(privateKey2);
            Contract contract2 = new Contract
            {
                Script        = Contract.CreateSignatureRedeemScript(key2.PublicKey),
                ParameterList = new[] { ContractParameterType.Signature }
            };
            var account2   = wallet.CreateAccount(contract2, key2);
            var dbAccount2 = wallet.GetAccount(account2.ScriptHash);

            account2.Should().Be(dbAccount2);
        }
        /// <summary>
        /// Copy the current wallet's address
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCopyAddress_Click(object sender, RoutedEventArgs e)
        {
            string copiedAddress = "";

            foreach (UInt160 scriptHash in Constant.CurrentWallet.GetAddresses().ToArray())
            {
                VerificationContract contract = Constant.CurrentWallet.GetContract(scriptHash);

                copiedAddress += contract.Address;

                copiedAddress += ",";
            }

            // Remove ',' from copiedAddress
            copiedAddress = copiedAddress.Substring(0, copiedAddress.Length - 1);

            try
            {
                Clipboard.SetText(copiedAddress);
            }
            catch (ArgumentNullException ex)
            {
                StaticUtils.ShowMessageBox(StaticUtils.ErrorBrush, StringTable.GetInstance().GetString("STR_ERR_ADDR_COPY", iLang));
                return;
            }
            catch (Exception ex)
            {
            }
            StaticUtils.ShowMessageBox(StaticUtils.GreenBrush, StringTable.GetInstance().GetString("STR_MW_ADDRESS_COPIED_SUCCESS", iLang));
        }
Exemplo n.º 7
0
        private bool OnCreateWalletCommand(string[] args)
        {
            if (args.Length < 3)
            {
                Console.WriteLine("error");
                return(true);
            }
            using (SecureString password = ReadSecureString("password"))
                using (SecureString password2 = ReadSecureString("password"))
                {
                    if (!password.CompareTo(password2))
                    {
                        Console.WriteLine("error");
                        return(true);
                    }
                    Program.Wallet = UserWallet.Create(args[2], password);
                }
            VerificationContract contract = Program.Wallet.GetContracts().First(p => p.IsStandard);
            KeyPair key = (KeyPair)Program.Wallet.GetKey(contract.PublicKeyHash);

            Console.WriteLine($"address: {contract.Address}");
            Console.WriteLine($" pubkey: {key.PublicKey.EncodePoint(true).ToHexString()}");
            Console.WriteLine($"   Type: {key.nVersion}");
            return(true);
        }
Exemplo n.º 8
0
 public ContractDetailsDialog(VerificationContract contract)
 {
     InitializeComponent();
     textBox1.Text = Wallet.ToAddress(contract.ScriptHash);
     textBox2.Text = contract.ScriptHash.ToString();
     textBox3.Text = contract.Script.ToHexString();
 }
Exemplo n.º 9
0
        public void TestEquals()
        {
            byte[] privateKey = new byte[32];
            using (RandomNumberGenerator rng = RandomNumberGenerator.Create())
            {
                rng.GetBytes(privateKey);
            }
            KeyPair key = new KeyPair(privateKey);
            VerificationContract contract1 = new VerificationContract
            {
                Script        = Neo.SmartContract.Contract.CreateSignatureRedeemScript(key.PublicKey),
                ParameterList = new[] { ContractParameterType.Signature }
            };
            object tempObject = contract1;
            VerificationContract contract2 = new VerificationContract
            {
                Script        = Neo.SmartContract.Contract.CreateSignatureRedeemScript(key.PublicKey),
                ParameterList = new[] { ContractParameterType.Signature }
            };

            Assert.AreEqual(true, contract1.Equals(tempObject));
            Assert.AreEqual(true, contract1.Equals(contract1));
            Assert.AreEqual(false, contract1.Equals(null));
            Assert.AreEqual(true, contract1.Equals(contract2));
        }
Exemplo n.º 10
0
        private void AddContractToListView(VerificationContract contract, bool selected = false)
        {
            ListViewItem item = listView1.Items[contract.Address];

            if (item?.Tag is UInt160)
            {
                listView1.Items.Remove(item);
                item = null;
            }
            if (item == null)
            {
                ListViewGroup group = contract.IsStandard ? listView1.Groups["standardContractGroup"] : listView1.Groups["nonstandardContractGroup"];
                item = listView1.Items.Add(new ListViewItem(new[]
                {
                    new ListViewItem.ListViewSubItem
                    {
                        Name = "address",
                        Text = contract.Address
                    },
                    new ListViewItem.ListViewSubItem
                    {
                        Name = "ans"
                    },
                    new ListViewItem.ListViewSubItem
                    {
                        Name = "anc"
                    }
                }, -1, group)
                {
                    Name = contract.Address,
                    Tag  = contract
                });
            }
            item.Selected = selected;
        }
Exemplo n.º 11
0
 public override void AddContract(VerificationContract contract)
 {
     base.AddContract(contract);
     using (WalletDataContext ctx = new WalletDataContext(DbPath))
     {
         Contract db_contract = ctx.Contracts.FirstOrDefault(p => p.ScriptHash.SequenceEqual(contract.ScriptHash.ToArray()));
         if (db_contract != null)
         {
             db_contract.PublicKeyHash = contract.PublicKeyHash.ToArray();
         }
         else
         {
             Address db_address = ctx.Addresses.FirstOrDefault(p => p.ScriptHash.SequenceEqual(contract.ScriptHash.ToArray()));
             if (db_address == null)
             {
                 ctx.Addresses.Add(new Address
                 {
                     ScriptHash = contract.ScriptHash.ToArray()
                 });
             }
             ctx.Contracts.Add(new Contract
             {
                 RawData       = contract.ToArray(),
                 ScriptHash    = contract.ScriptHash.ToArray(),
                 PublicKeyHash = contract.PublicKeyHash.ToArray()
             });
         }
         ctx.SaveChanges();
     }
 }
Exemplo n.º 12
0
        public VerificationContract GetContract()
        {
            UInt160 publicKeyHash = ((ECPoint)comboBox1.SelectedItem).EncodePoint(true).ToScriptHash();

            ContractParameterType[] parameterList = textBox1.Text.HexToBytes().Select(p => (ContractParameterType)p).ToArray();
            byte[] redeemScript = textBox2.Text.HexToBytes();
            return(VerificationContract.Create(publicKeyHash, parameterList, redeemScript));
        }
Exemplo n.º 13
0
        public override StealthKeyPair CreateKey(byte[] payloadPrivKey, byte[] viewPrivKey)
        {
            StealthKeyPair account = base.CreateKey(payloadPrivKey, viewPrivKey);

            OnCreateAccount(account);
            AddContract(VerificationContract.CreateRingSignatureContract(account.ToStelathPubKeys()));
            return(account);
        }
Exemplo n.º 14
0
        public override WalletKeyPair CreateKey(byte[] privateKey)
        {
            WalletKeyPair account = base.CreateKey(privateKey);

            OnCreateAccount(account);
            AddContract(VerificationContract.CreateSignatureContract(account.PublicKey));
            return(account);
        }
Exemplo n.º 15
0
 private void AddContractToListView(VerificationContract contract, bool selected = false)
 {
     DT_GUI_Modules.Modules.AddrStruct item;
     item.Address   = contract.Address;
     item.AmountQRS = "0";
     item.AmountUSD = "0";
     //dashboardControl1.AddAddress(item);
 }
Exemplo n.º 16
0
 public ViewContractDialog(VerificationContract contract)
 {
     InitializeComponent();
     textBox1.Text = contract.Address;
     textBox2.Text = contract.ScriptHash.ToString();
     textBox3.Text = contract.ParameterList.Cast <byte>().ToArray().ToHexString();
     textBox4.Text = contract.Script.ToHexString();
 }
        public ViewContractView(VerificationContract contract)
        {
            InitializeComponent();

            var viewModel = this.DataContext as ViewContractViewModel;

            viewModel?.SetContract(contract);
        }
Exemplo n.º 18
0
        private void AddContractToListView(VerificationContract contract, bool selected = false)
        {
            AddrStruct item;

            item.Address   = contract.Address;
            item.AmountQRS = "0";
            item.AmountQRG = "0";
            overviewPan1.AddAddress(item);
        }
Exemplo n.º 19
0
        private void viewContractToolStripMenuItem_Click(object sender, EventArgs e)
        {
            VerificationContract contract = (VerificationContract)listView1.SelectedItems[0].Tag;

            using (ViewContractDialog dialog = new ViewContractDialog(contract))
            {
                dialog.ShowDialog();
            }
        }
Exemplo n.º 20
0
        public static VerificationContract ToVerificationContract(this ECPoint point)
        {
            VerificationContract contract = new VerificationContract
            {
                Script        = SmartContract.Contract.CreateSignatureRedeemScript(point),
                ParameterList = new[] { ContractParameterType.Signature }
            };

            return(contract);
        }
Exemplo n.º 21
0
        private void TxbFeeAmount_LostFocus(object sender, RoutedEventArgs e)
        {
            try
            {
                AssetTypeItem tag   = ((ComboBoxItem)cmbAssetType.SelectedItem).Tag as AssetTypeItem;
                AssetState    asset = Blockchain.Default.GetAssetState(tag.AssetID);

                if (txbFeeAmount.Text == "")
                {
                    return;
                }

                Fixed8 fee = Fixed8.Satoshi * Convert.ToInt64(100000000 * Convert.ToDouble(txbFeeAmount.Text));

                if (fromAddress == null)
                {
                    foreach (UInt160 scriptHash in Constant.CurrentWallet.GetAddresses().ToArray())
                    {
                        VerificationContract contract = Constant.CurrentWallet.GetContract(scriptHash);
                        fromAddress = contract.Address;
                    }
                }

                if (Wallet.GetAddressVersion(fromAddress) == Wallet.AnonymouseAddressVersion || Wallet.GetAddressVersion(fromAddress) == Wallet.StealthAddressVersion)
                {
                    if (asset.AssetType == AssetType.GoverningToken)
                    {
                        if (asset.AFee < fee)
                        {
                            throw new Exception();
                        }
                    }
                    else
                    {
                        if (Fixed8.Satoshi * 10000000 + asset.AFee < fee)
                        {
                            throw new Exception();
                        }
                    }
                }
                else
                {
                    if (asset.FeeMin > fee || asset.FeeMax < fee)
                    {
                        throw new Exception();
                    }
                }
            }
            catch (Exception)
            {
                txbFeeAmount.Text = "";
                StaticUtils.ShowMessageBox(StaticUtils.ErrorBrush, StringTable.GetInstance().GetString("STR_RP_ERR_INPUT_FEE_IN_LIMIT", iLang));
            }
        }
Exemplo n.º 22
0
        private void RestoreAccountsDialog_Load(object sender, EventArgs e)
        {
            IEnumerable <KeyPair> keys = Program.CurrentWallet.GetKeys();

            keys = keys.Where(account => Program.CurrentWallet.GetContracts(account.PublicKeyHash).All(contract => !contract.IsStandard));
            IEnumerable <VerificationContract> contracts = keys.Select(p => VerificationContract.CreateSignatureContract(p.PublicKey));

            listView1.Items.AddRange(contracts.Select(p => new ListViewItem(p.Address)
            {
                Tag = p
            }).ToArray());
        }
Exemplo n.º 23
0
        private void cmbAssetType_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                AssetTypeItem tag   = ((ComboBoxItem)cmbAssetType.SelectedItem).Tag as AssetTypeItem;
                AssetState    asset = Blockchain.Default.GetAssetState(tag.AssetID);

                if (fromAddress == null)
                {
                    foreach (UInt160 scriptHash in Constant.CurrentWallet.GetAddresses().ToArray())
                    {
                        VerificationContract contract = Constant.CurrentWallet.GetContract(scriptHash);
                        fromAddress = contract.Address;
                    }
                }

                if (Wallet.GetAddressVersion(fromAddress) == Wallet.AnonymouseAddressVersion || Wallet.GetAddressVersion(fromAddress) == Wallet.StealthAddressVersion)
                {
                    /*if (asset.AssetType == AssetType.GoverningToken)
                     * {
                     *  TxbFee.Text = String.Format(StringTable.GetInstance().GetString("STR_SP_FEE", iLang), asset.AFee.ToString(), asset.GetName(), asset.AFee.ToString(), asset.GetName());
                     * }
                     * else
                     * {*/
                    TxbFee.Text = String.Format(StringTable.GetInstance().GetString("STR_SP_FEE", iLang), (Fixed8.Satoshi * 10000000 + asset.AFee).ToString(), "XQG", (Fixed8.Satoshi * 10000000 + asset.AFee).ToString(), "XQG");
                    //}
                }
                else
                {
                    /*if (asset.AssetType == AssetType.GoverningToken)
                     * {
                     *  TxbFee.Text = String.Format(StringTable.GetInstance().GetString("STR_SP_FEE", iLang), asset.FeeMin.ToString(), asset.GetName(), asset.FeeMax.ToString(), asset.GetName());
                     * }
                     * else
                     * {*/
                    TxbFee.Text = String.Format(StringTable.GetInstance().GetString("STR_SP_FEE", iLang), (asset.FeeMin).ToString(), "XQG", (asset.FeeMax).ToString(), "XQG");
                    //}
                }

                if (tag != null)
                {
                    TxbSpendable.Text = String.Format(StringTable.GetInstance().GetString("STR_SP_SPENDABLE", iLang), tag.Value.ToString(), tag.Name);
                }
                else
                {
                    TxbSpendable.Text = String.Format(StringTable.GetInstance().GetString("STR_SP_SPENDABLE", iLang), 0, "");
                }
            }
            catch (Exception)
            {
                TxbSpendable.Text = String.Format(StringTable.GetInstance().GetString("STR_SP_SPENDABLE", iLang), 0, "");
            }
        }
Exemplo n.º 24
0
 public VerificationContract GetContract()
 {
     ECPoint[] publicKeys = listBox1.Items.OfType <string>().Select(p => ECPoint.DecodePoint(p.HexToBytes(), ECCurve.Secp256r1)).ToArray();
     foreach (ECPoint publicKey in publicKeys)
     {
         KeyPair key = Program.CurrentWallet.GetKey(publicKey.EncodePoint(true).ToScriptHash());
         if (key != null)
         {
             return(VerificationContract.CreateMultiSigContract(key.PublicKeyHash, (int)numericUpDown2.Value, publicKeys));
         }
     }
     return(null);
 }
Exemplo n.º 25
0
        private void TxbReceiveAddress_LostFocus(object sender, RoutedEventArgs e)
        {
            try
            {
                AssetTypeItem tag   = ((ComboBoxItem)cmbAssetType.SelectedItem).Tag as AssetTypeItem;
                AssetState    asset = Blockchain.Default.GetAssetState(tag.AssetID);

                if (fromAddress == null)
                {
                    foreach (UInt160 scriptHash in Constant.CurrentWallet.GetAddresses().ToArray())
                    {
                        VerificationContract contract = Constant.CurrentWallet.GetContract(scriptHash);
                        fromAddress = contract.Address;
                    }
                }

                if (Wallet.GetAddressVersion(fromAddress) == Wallet.AnonymouseAddressVersion || Wallet.GetAddressVersion(fromAddress) == Wallet.StealthAddressVersion)
                {
                    TxbFee.Text            = String.Format(StringTable.GetInstance().GetString("STR_SP_AFEE", iLang), Blockchain.UtilityToken.A_Fee.ToString(), "XQG");
                    txbFeeAmount.IsEnabled = false;
                    txbFeeAmount.Text      = Blockchain.UtilityToken.A_Fee.ToString();
                }
                else
                {
                    if (Wallet.GetAddressVersion(txbReceiveAddress.Text) == Wallet.AnonymouseAddressVersion || Wallet.GetAddressVersion(txbReceiveAddress.Text) == Wallet.StealthAddressVersion)
                    {
                        TxbFee.Text            = String.Format(StringTable.GetInstance().GetString("STR_SP_AFEE", iLang), asset.AFee.ToString(), "XQG");
                        txbFeeAmount.IsEnabled = false;
                        txbFeeAmount.Text      = asset.AFee.ToString();
                    }
                    else
                    {
                        TxbFee.Text            = String.Format(StringTable.GetInstance().GetString("STR_SP_FEE", iLang), (asset.FeeMin).ToString(), "XQG", (asset.FeeMax).ToString(), "XQG");
                        txbFeeAmount.IsEnabled = true;
                    }
                }

                if (tag != null)
                {
                    TxbSpendable.Text = String.Format(StringTable.GetInstance().GetString("STR_SP_SPENDABLE", iLang), tag.Value.ToString(), tag.Name);
                }
                else
                {
                    TxbSpendable.Text = String.Format(StringTable.GetInstance().GetString("STR_SP_SPENDABLE", iLang), 0, "");
                }
            }
            catch (Exception)
            {
                TxbSpendable.Text = String.Format(StringTable.GetInstance().GetString("STR_SP_SPENDABLE", iLang), 0, "");
            }
        }
Exemplo n.º 26
0
 private Dictionary <UInt160, UserWalletAccount> LoadAccounts()
 {
     using (WalletDataContext ctx = new WalletDataContext(path))
     {
         foreach (Contract db_contract in ctx.Contracts.Include(p => p.Account))
         {
             VerificationContract contract = db_contract.RawData.AsSerializable <VerificationContract>();
             UserWalletAccount    account  = ctx.Addresses.Select(p => p.ScriptHash).AsEnumerable().Select(p => new UserWalletAccount(new UInt160(p))).ToDictionary(p => p.ScriptHash)[contract.ScriptHash];
             account.Contract = contract;
             account.Key      = new KeyPair(DecryptPrivateKey(db_contract.Account.PrivateKeyEncrypted));
         }
         return(ctx.Addresses.Select(p => p.ScriptHash).AsEnumerable().Select(p => new UserWalletAccount(new UInt160(p))).ToDictionary(p => p.ScriptHash));
     }
 }
        public void SetContract(VerificationContract contract)
        {
            this.Address       = contract.Address;
            this.ScriptHash    = contract.ScriptHash.ToString();
            this.ParameterList = contract.ParameterList.Cast <byte>().ToArray().ToHexString();

            this.RedeemScriptHex = contract.Script.ToHexString();

            // Update properties
            NotifyPropertyChanged(nameof(this.Address));
            NotifyPropertyChanged(nameof(this.ScriptHash));
            NotifyPropertyChanged(nameof(this.ParameterList));
            NotifyPropertyChanged(nameof(this.RedeemScriptHex));
        }
Exemplo n.º 28
0
        public VerificationContract GetContract()
        {
            ECPoint publicKey = (ECPoint)comboBox1.SelectedItem;
            uint    timestamp = dateTimePicker1.Value.ToTimestamp();

            using (ScriptBuilder sb = new ScriptBuilder())
            {
                sb.EmitPush(publicKey);
                sb.EmitPush(timestamp);
                // Lock 2.0 in mainnet tx:4e84015258880ced0387f34842b1d96f605b9cc78b308e1f0d876933c2c9134b
                sb.EmitAppCall(UInt160.Parse("d3cce84d0800172d09c88ccad61130611bd047a4"));
                return(VerificationContract.Create(publicKey.EncodePoint(true).ToScriptHash(), new[] { ContractParameterType.Signature }, sb.ToArray()));
            }
        }
Exemplo n.º 29
0
 private void 自定义CToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (ImportCustomContractDialog dialog = new ImportCustomContractDialog())
     {
         if (dialog.ShowDialog() != DialogResult.OK)
         {
             return;
         }
         VerificationContract contract = dialog.GetContract();
         Program.CurrentWallet.AddContract(contract);
         listView1.SelectedIndices.Clear();
         AddContractToListView(contract, true);
     }
 }
Exemplo n.º 30
0
 private void ChangeWallet(UserWallet wallet)
 {
     if (Program.CurrentWallet != null)
     {
         Program.CurrentWallet.BalanceChanged      -= CurrentWallet_BalanceChanged;
         Program.CurrentWallet.TransactionsChanged -= CurrentWallet_TransactionsChanged;
         Program.CurrentWallet.Dispose();
     }
     Program.CurrentWallet = wallet;
     listView3.Items.Clear();
     if (Program.CurrentWallet != null)
     {
         CurrentWallet_TransactionsChanged(null, Program.CurrentWallet.LoadTransactions());
         Program.CurrentWallet.BalanceChanged      += CurrentWallet_BalanceChanged;
         Program.CurrentWallet.TransactionsChanged += CurrentWallet_TransactionsChanged;
     }
     修改密码CToolStripMenuItem.Enabled              = Program.CurrentWallet != null;
     重建钱包数据库RToolStripMenuItem.Enabled           = Program.CurrentWallet != null;
     restoreAccountsToolStripMenuItem.Enabled    = Program.CurrentWallet != null;
     交易TToolStripMenuItem.Enabled                = Program.CurrentWallet != null;
     提取小蚁币CToolStripMenuItem.Enabled             = Program.CurrentWallet != null;
     requestCertificateToolStripMenuItem.Enabled = Program.CurrentWallet != null;
     注册资产RToolStripMenuItem.Enabled              = Program.CurrentWallet != null;
     资产分发IToolStripMenuItem.Enabled              = Program.CurrentWallet != null;
     deployContractToolStripMenuItem.Enabled     = Program.CurrentWallet != null;
     invokeContractToolStripMenuItem.Enabled     = Program.CurrentWallet != null;
     举EToolStripMenuItem.Enabled      = Program.CurrentWallet != null;
     创建新地址NToolStripMenuItem.Enabled  = Program.CurrentWallet != null;
     导入私钥IToolStripMenuItem.Enabled   = Program.CurrentWallet != null;
     创建智能合约SToolStripMenuItem.Enabled = Program.CurrentWallet != null;
     listView1.Items.Clear();
     if (Program.CurrentWallet != null)
     {
         foreach (UInt160 scriptHash in Program.CurrentWallet.GetAddresses().ToArray())
         {
             VerificationContract contract = Program.CurrentWallet.GetContract(scriptHash);
             if (contract == null)
             {
                 AddAddressToListView(scriptHash);
             }
             else
             {
                 AddContractToListView(contract);
             }
         }
     }
     balance_changed    = true;
     check_nep5_balance = true;
 }