コード例 #1
0
ファイル: WalletKey.cs プロジェクト: 520hacker/knoledge-spv
        public void Generate()
        {
            PrivateKey = new ExtKey().GetWif(_network);
            PubKey     = PrivateKey.ExtKey.Neuter().GetWif(_network);

            if (_parent != null)
            {
                _parent.Keys.Add(this);
                _parent.Update();
            }
        }
コード例 #2
0
ファイル: FormMain.cs プロジェクト: 520hacker/knoledge-spv
        private void comboBoxWallet_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBoxWallet.SelectedItem != null)
            {
                _wallet = (KnoledgeWallet)comboBoxWallet.SelectedItem;
                _wallet.Update();

                UpdateAddressComboBox();

                comboBoxAddress.Text         = "";
                comboBoxAddress.SelectedItem = _wallet.CurrentAddress;

                UpdateListView(_wallet.Transactions);
            }
        }
コード例 #3
0
ファイル: FormMain.cs プロジェクト: 520hacker/knoledge-spv
        private async void UpdateUI()
        {
            if (_isClosing)
            {
                return;
            }

            if (_updatingUI)
            {
                return;
            }

            await Task.Factory.StartNew(() =>
            {
                _updatingUI = true;
                int nodes   = 0;

                if (!IsNetworkAvailable())
                {
                    UpdateStatusLabel("No network connnection.");
                }
                else
                {
                    if (_group != null && !CanConnect())
                    {
                        nodes = _group.ConnectedNodes.Count;
                    }

                    if (nodes == 1)
                    {
                        UpdateStatusButton(string.Format("Connected to {0} node on {1}", nodes, Network.ToString()), nodes);
                    }
                    else
                    {
                        UpdateStatusButton(string.Format("Connected to {0} nodes on {1}", nodes, Network.ToString()), nodes);
                    }
                }


                ConcurrentChain chain = GetChain();
                int height            = chain.Tip == null ? 0 : chain.Height;
                int localHeight       = 0;
                bool outOfDate        = true;

                if (chain != null && chain.Tip != null)
                {
                    DateTimeOffset date = chain.Tip.Header.BlockTime.ToLocalTime();
                    DateTimeOffset now  = DateTimeOffset.Now;
                    TimeSpan difference = now - date;

                    outOfDate   = difference.TotalMinutes > 45;
                    localHeight = chain.Tip == null ? 0 : chain.Height;
                }

                string chainStatus = string.Format("Local chain height = {0}", localHeight);

                if (localHeight != 0)
                {
                    chainStatus = string.Format("{0}{1} Latest Block Date = {2}", chainStatus, Environment.NewLine, chain.Tip.Header.BlockTime.ToLocalTime().ToString("R"));
                }

                if (nodes > 0)
                {
                    if (height == 0 || height > localHeight)
                    {
                        outOfDate = true;
                        UpdateStatusLabel("Synchronising...");
                    }
                }

                if (outOfDate)
                {
                    UpdateInfoButton(ChainStatus.OutofDate, chainStatus);
                }
                else
                {
                    UpdateInfoButton(ChainStatus.UptoDate, chainStatus);
                }

                if (_wallet != null)
                {
                    _wallet.Update();

                    int txCount = _wallet.Transactions.Count;

                    if (_transactions != txCount)
                    {
                        UpdateListView(_wallet.Transactions);
                        UpdateBalanceLabel(_wallet.GetBalanceString());
                        _transactions = txCount;
                    }
                }

                if (_isSaving)
                {
                    UpdateStatusLabel("Saving...");
                }

                _updatingUI = false;
            });
        }