Example #1
0
        private void CalculateBonusUnavailable(uint height)
        {
            var unspent = Constant.CurrentWallet.FindUnspentCoins()
                          .Where(p => p.Output.AssetId.Equals(Blockchain.GoverningToken.Hash))
                          .Select(p => p.Reference)
            ;

            ICollection <CoinReference> references = new HashSet <CoinReference>();

            foreach (var group in unspent.GroupBy(p => p.PrevHash))
            {
                int         height_start;
                Transaction tx = Blockchain.Default.GetTransaction(group.Key, out height_start);
                if (tx == null)
                {
                    continue; // not enough of the chain available
                }
                foreach (var reference in group)
                {
                    references.Add(reference);
                }
            }

            TxbClaimTotal.Text = String.Format(StringTable.GetInstance().GetString("STR_CLAIM_UNAVAILABLE", iLang), Blockchain.CalculateBonus(references, height).ToString());
        }
Example #2
0
        private void BtnIssueLaunch_Click(object sender, RoutedEventArgs e)
        {
            bool ret = false;

            using (AlertDialog dlg = new AlertDialog(Application.Current.MainWindow, StringTable.GetInstance().GetString("STR_ALERT_DLG_TITLE", iLang), StringTable.GetInstance().GetString("STR_ISSUE_ASSET_QUESTION", iLang)))
            {
                ret = (bool)dlg.ShowDialog();
            }

            if (ret == false)
            {
                return;
            }

            try
            {
                Global.Helper.SignAndShowInformation(issueTx);
                StaticUtils.ShowMessageBox(StaticUtils.GreenBrush, StringTable.GetInstance().GetString("STR_SUC_TX_SUCCESSED", iLang));
            }
            catch (Exception)
            {
                StaticUtils.ShowMessageBox(StaticUtils.ErrorBrush, StringTable.GetInstance().GetString("STR_ERR_INCOMPLETEDSIGNATUREMESSAGE", iLang));
            }

            TxbIssueTxResult.Text = "";
            txbIssueFee.Text      = String.Format(StringTable.GetInstance().GetString("STR_SMART_CONTRACT_FEE", iLang), "0");

            BtnIssueLaunch.IsEnabled = false;
            BtnIssueLaunch.Style     = FindResource("QurasDisableAddAssetButtonStyle") as Style;
        }
 public void RefreshLanguage()
 {
     TxbHeader.Text                         = StringTable.GetInstance().GetString("STR_SMARTCONTRACT_DEPLOY_BUTTON", iLang);
     TxbComment.Text                        = StringTable.GetInstance().GetString("STR_SMARTCONTRACT_DEPLOY_COMMENT", iLang);
     TxbSmartContractInfo.Text              = StringTable.GetInstance().GetString("STR_DSCP_SMART_CONTRACT_INFO", iLang);
     TxbContractName.Tag                    = StringTable.GetInstance().GetString("STR_DSCP_SMART_CONTRACT_NAME", iLang);
     TxbContractVersion.Tag                 = StringTable.GetInstance().GetString("STR_DSCP_SMART_CONTRACT_VERSION", iLang);
     TxbContractAuthor.Tag                  = StringTable.GetInstance().GetString("STR_DSCP_SMART_CONTRACT_AUTHOR", iLang);
     TxbContractEmail.Tag                   = StringTable.GetInstance().GetString("STR_DSCP_SMART_CONTRACT_EMAIL", iLang);
     TxbContractDescription.Tag             = StringTable.GetInstance().GetString("STR_DSCP_SMART_CONTRACT_DESCRIPTION", iLang);
     TxbParameters.Text                     = StringTable.GetInstance().GetString("STR_DSCP_PARAMETERS_TITLE", iLang);
     TxbContractParameters.Tag              = StringTable.GetInstance().GetString("STR_DSCP_SMART_CONTRACT_PARAMETERS", iLang);
     TxbContractReturnTypes.Tag             = StringTable.GetInstance().GetString("STR_DSCP_SMART_CONTRACT_RETURN_TYPE", iLang);
     TxbSmartContractCode.Text              = StringTable.GetInstance().GetString("STR_DSCP_SMART_CONTRACT_CODE", iLang);
     TxbSmartContractCodes.Tag              = StringTable.GetInstance().GetString("STR_DSCP_SMART_CONTRACT_CODES", iLang);
     btnLoad.Content                        = StringTable.GetInstance().GetString("STR_DSCP_BUTTON_LOAD", iLang);
     TxbInvocationTxScriptHash.Tag          = StringTable.GetInstance().GetString("STR_DSCP_INVOCATION_TX_SCRIPT_HASH", iLang);
     TxbSmartContractScriptHashComment.Text = StringTable.GetInstance().GetString("STR_DSCP_SMART_CONTRACT_SCRIPT_HASH_COMMENT", iLang);
     TxbSmartContractScriptHash.Tag         = StringTable.GetInstance().GetString("STR_DSCP_SMART_CONTRACT_SCRIPT_HASH", iLang);
     TxbSmartContractResultComment.Text     = StringTable.GetInstance().GetString("STR_DSCP_SMART_CONTRACT_RESULT_COMMENT", iLang);
     TxbSmartContractResult.Tag             = StringTable.GetInstance().GetString("STR_DSCP_SMART_CONTRACT_RESULT", iLang);
     TxbSmartContractFee.Text               = String.Format(StringTable.GetInstance().GetString("STR_SMART_CONTRACT_FEE", iLang), currentFee.ToString());
     ChkNeedStorage.Content                 = StringTable.GetInstance().GetString("STR_DSCP_NEED_STORAGE", iLang);
     ChkNeedVM.Content                      = StringTable.GetInstance().GetString("STR_DSCP_NEED_VM", iLang);
     btnTest.Content                        = StringTable.GetInstance().GetString("STR_DSCP_BUTTON_TEST", iLang);
     btnDeploy.Content                      = StringTable.GetInstance().GetString("STR_DSCP_BUTTON_DEPLOY", iLang);
 }
        /// <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));
        }
Example #5
0
        public void RefreshLanguage()
        {
            TxbCommentHeader.Text = StringTable.GetInstance().GetString("STR_WP_COMMENT_HEADER", iLang);
            TxbCommentBody.Text   = StringTable.GetInstance().GetString("STR_WP_COMMENT_BODY", iLang);

            btnNewWallet.Content = StringTable.GetInstance().GetString("STR_WP_NEW_WALLET", iLang);
            btnRestore.Content   = StringTable.GetInstance().GetString("STR_WP_RESTORE", iLang);
        }
Example #6
0
        public void Junk()
        {
            const string stringToTest = "asdwafeafwe\nwefrawefefsefrawerawefasefsea\nafefeafesfaef34123412312=a/;p3,41i412n4ui120-if890ajg8iasug8a9";

            StringTable.GetInstance().LoadFromString(stringToTest);

            StringTable.GetInstance().ClearWords();
        }
Example #7
0
        public void EmptyString()
        {
            const string stringToTest = "";

            StringTable.GetInstance().LoadFromString(stringToTest);

            StringTable.GetInstance().ClearWords();
        }
 public void RefreshLanguage()
 {
     TxbCommentHeader.Text  = StringTable.GetInstance().GetString("STR_NW_COMMENT_HEADER", iLang);
     txbWalletPath.Tag      = StringTable.GetInstance().GetString("STR_NW_WALLET_PATH", iLang);
     rdbAnonymous.Content   = StringTable.GetInstance().GetString("STR_NW_ANONYMOUS", iLang);
     rdbTransparent.Content = StringTable.GetInstance().GetString("STR_NW_TRANSPARENT", iLang);
     rdbStealth.Content     = StringTable.GetInstance().GetString("STR_NW_STEALTH", iLang);
     btnNext.Content        = StringTable.GetInstance().GetString("STR_NW_NEXT", iLang);
 }
        public void RefreshLanguage()
        {
            TxbHistoryTitle.Text = StringTable.GetInstance().GetString("STR_HP_TITLE", iLang);

            foreach (HistoryItem item in stackHistoryPan.Children)
            {
                item.RefreshLanguage();
            }
        }
Example #10
0
        public void TooManyLocales()
        {
            const string stringToTest =
                "score=>Score:~~~Pointages:~~~übereinstimmen:\n" +
                "life=>Life:~~~Vies:~~~Leben:";

            StringTable.GetInstance().LoadFromString(stringToTest);

            StringTable.GetInstance().ClearWords();
        }
Example #11
0
        public void StringTable_Normal02()
        {
            //Initialiser les variables
            ErrorCode resultat = StringTable.GetInstance().Parse(File.ReadAllText("Data/LE_PETIT_ROBERT_JUNIOR.tttytt"));

            //Valider
            Assert.AreEqual(ErrorCode.BAD_FILE_FORMAT, resultat);
            //Clean Up
            //Rien à faire!
        }
Example #12
0
        public void StringTable_Normal01()
        {
            //Initialiser les variables
            ErrorCode resultat = StringTable.GetInstance().Parse(File.ReadAllText("Data/st.txt"));

            //Valider
            Assert.AreEqual(ErrorCode.OK, resultat);
            //Clean Up
            //Rien à faire!
        }
Example #13
0
        public void StringTable_GetValue02()
        {
            //Initialiser les variables
            string resultat = StringTable.GetInstance().GetValue(Language.French, "ID_BABLAAKAJLA");

            //Valider
            Assert.AreEqual("ID INVALIDE", resultat);
            //Clean Up
            //Rien à faire!
        }
Example #14
0
        public void StringTable_GetValue01()
        {
            //Initialiser les variables
            string resultat = StringTable.GetInstance().GetValue(Language.French, "ID_TOTAL_TIME");

            //Valider
            Assert.AreEqual("Temps total", resultat);
            //Clean Up
            //Rien à faire!
        }
Example #15
0
        public void WrongValueSplitter()
        {
            const string stringToTest =
                "score=>Score:~~Pointages:\n" +
                "life=>Life:~|~Vies:";

            StringTable.GetInstance().LoadFromString(stringToTest);

            StringTable.GetInstance().ClearWords();
        }
Example #16
0
        public void WrongKey()
        {
            const string stringToTest =
                "score|Score:~~~Pointages:\n" +
                "life-)Life:~~~Vies:";

            StringTable.GetInstance().LoadFromString(stringToTest);

            StringTable.GetInstance().ClearWords();
        }
Example #17
0
        public void StringTable_Specifique01()
        {
            //Initialiser les variables
            ErrorCode resultat = StringTable.GetInstance().Parse(File.ReadAllText(null));

            //Valider
            Assert.AreEqual(ErrorCode.MISSING_FIELD, resultat);
            //Clean Up
            //Rien à faire!
        }
Example #18
0
 public SlidingTextWindow(SourceText text)
 {
     _text            = text;
     _basis           = 0;
     _offset          = 0;
     _textEnd         = text.Length;
     _strings         = StringTable.GetInstance();
     _characterWindow = s_windowPool.Allocate();
     _lexemeStart     = 0;
 }
Example #19
0
        public void TooLittleLocales()
        {
            const string stringToTest =
                "score=>Score:\n" +
                "life=>Life:";

            StringTable.GetInstance().LoadFromString(stringToTest);

            StringTable.GetInstance().ClearWords();
        }
Example #20
0
 public SlidingTextWindow(SourceText text)
 {
     this.text            = text;
     this.basis           = 0;
     this.offset          = 0;
     this.textEnd         = text.Length;
     this.strings         = StringTable.GetInstance();
     this.characterWindow = windowPool.Allocate();
     this.lexemeStart     = 0;
 }
Example #21
0
        public void RefreshLanguage()
        {
            TxbSettingsTitle.Text   = StringTable.GetInstance().GetString("STR_SETTINGS_TITLE", iLang);
            TxbComment.Text         = StringTable.GetInstance().GetString("STR_SETTINGS_TITLE_COMMENT", iLang);
            TxbLanguageTitle.Text   = StringTable.GetInstance().GetString("STR_SETTINGS_LANGUAGE_TITLE", iLang);
            TxbLanguageComment.Text = StringTable.GetInstance().GetString("STR_SETTINGS_LANGUAGE_COMMENT", iLang);

            TxbZkSnarksTitle.Text    = StringTable.GetInstance().GetString("STR_SETTINGS_ZKS_TITLE", iLang);
            TxbZkSnarksComment.Text  = StringTable.GetInstance().GetString("STR_SETTINGS_ZKS_COMMENT", iLang);
            TxbVerifyKeyTitle.Text   = StringTable.GetInstance().GetString("STR_SETTINGS_ZKS_VK_TITLE", iLang);
            TxbVerifyKeyComment.Text = StringTable.GetInstance().GetString("STR_SETTINGS_ZKS_VK_COMMENT", iLang);
            TxbPublicKeyTitle.Text   = StringTable.GetInstance().GetString("STR_SETTINGS_ZKS_PK_TITLE", iLang);
            TxbPublicKeyComment.Text = StringTable.GetInstance().GetString("STR_SETTINGS_ZKS_PK_COMMENT", iLang);
            TxbZKModuleTitle.Text    = StringTable.GetInstance().GetString("STR_SETTINGS_ZKS_ZKMODULE_TITLE", iLang);
            TxbZKModuleComment.Text  = StringTable.GetInstance().GetString("STR_SETTINGS_ZKS_ZKMODULE_COMMENT", iLang);

            TxbVerifyKeyStatusDownloaded.Text    = StringTable.GetInstance().GetString("STR_SETTINGS_ZKS_VK_DOWNLOADED", iLang);
            TxbVerifyKeyStatusLoaded.Text        = StringTable.GetInstance().GetString("STR_SETTINGS_ZKS_VK_LOADED", iLang);
            TxbVerifyKeyStatusNotDownloaded.Text = StringTable.GetInstance().GetString("STR_SETTINGS_ZKS_VK_NOT_DOWNLOADED", iLang);
            TxbVerifyKeyStatusDownloading.Text   = StringTable.GetInstance().GetString("STR_SETTINGS_ZKS_VK_DOWNLOADING", iLang);

            TxbPublicKeyStatusDownloaded.Text    = StringTable.GetInstance().GetString("STR_SETTINGS_ZKS_PK_DOWNLOADED", iLang);
            TxbPublicKeyStatusLoaded.Text        = StringTable.GetInstance().GetString("STR_SETTINGS_ZKS_PK_LOADED", iLang);
            TxbPublicKeyStatusNotDownloaded.Text = StringTable.GetInstance().GetString("STR_SETTINGS_ZKS_PK_NOT_DOWNLOADED", iLang);
            TxbPublicKeyStatusDownloading.Text   = StringTable.GetInstance().GetString("STR_SETTINGS_ZKS_PK_DOWNLOADING", iLang);

            TxbZKModuleStatusDownloaded.Text = StringTable.GetInstance().GetString("STR_SETTINGS_ZKS_ZKM_DOWNLOADED", iLang);
            TxbZKModuleStatusLoaded.Text     = StringTable.GetInstance().GetString("STR_SETTINGS_ZKS_ZKM_LOADED", iLang);
            TxbZKModuleStatusNotLoaded.Text  = StringTable.GetInstance().GetString("STR_SETTINGS_ZKS_ZKM_NOT_LOADED", iLang);

            TxbVerifyKeyStatusLoading.Text = StringTable.GetInstance().GetString("STR_SETTINGS_KEYS_LOADING", iLang);
            TxbPublicKeyStatusLoading.Text = StringTable.GetInstance().GetString("STR_SETTINGS_KEYS_LOADING", iLang);
            TxbZKModuleStatusLoading.Text  = StringTable.GetInstance().GetString("STR_SETTINGS_KEYS_LOADING", iLang);

            TxbUpdateComment.Text = String.Format(StringTable.GetInstance().GetString("STR_UPDATE_COMMENT", iLang), Constant.GetLocalWalletVersion().ToString(), Constant.GetNewestWalletVersionFromServer().ToString());

            TxbRepairTittle.Text  = StringTable.GetInstance().GetString("STR_SETTINGS_REPAIR_TITLE", iLang);
            TxbRepairComment.Text = StringTable.GetInstance().GetString("STR_SETTINGS_REPAIR_COMMENT", iLang);

            btnVKDownload.Content   = StringTable.GetInstance().GetString("STR_SETTINGS_BUTTON_DOWNLOAD", iLang);
            btnPKDownload.Content   = StringTable.GetInstance().GetString("STR_SETTINGS_BUTTON_DOWNLOAD", iLang);
            btnZKModuleLoad.Content = StringTable.GetInstance().GetString("STR_SETTINGS_BUTTON_LOAD", iLang);
            btnUpdate.Content       = StringTable.GetInstance().GetString("STR_SETTINGS_BUTTON_UPDATE", iLang);
            btnRepair.Content       = StringTable.GetInstance().GetString("STR_SETTINGS_BUTTON_REPAIR", iLang);

            TxbUpdateTitle.Text       = StringTable.GetInstance().GetString("STR_SETTINGS_UPDATE_TITLE", iLang);
            TxbUpdateDownloading.Text = StringTable.GetInstance().GetString("STR_SETTINGS_ZKS_VK_DOWNLOADING", iLang);
            TxbUpdateDownloaded.Text  = StringTable.GetInstance().GetString("STR_SETTINGS_ZKS_PK_DOWNLOADED", iLang);
            TxbUpdateOld.Text         = StringTable.GetInstance().GetString("STR_SETTINGS_STATUS_OLDVERSION", iLang);
            TxbUpdateUpdated.Text     = StringTable.GetInstance().GetString("STR_SETTINGS_STATUS_UPDATED", iLang);
            TxbUpdateFailed.Text      = StringTable.GetInstance().GetString("STR_SETTINGS_STATUS_FAILED", iLang);

            TxbClaimTitle.Text = StringTable.GetInstance().GetString("STR_SETTINGS_CLAIM_TITLE", iLang);
            btnClaim.Content   = StringTable.GetInstance().GetString("STR_SETTINGS_BUTTON_CLAIM", iLang);
        }
Example #22
0
        public bool MakeAndTestTransaction()
        {
            tx = GetTransaction();

            TxbTxScriptHash.Text = tx.Script.ToHexString();

            tx.Version = 1;
            if (tx.Attributes == null)
            {
                tx.Attributes = new TransactionAttribute[0];
            }
            if (tx.Inputs == null)
            {
                tx.Inputs = new CoinReference[0];
            }
            if (tx.Outputs == null)
            {
                tx.Outputs = new TransactionOutput[0];
            }
            if (tx.Scripts == null)
            {
                tx.Scripts = new Witness[0];
            }
            ApplicationEngine engine = ApplicationEngine.Run(tx.Script, tx);
            StringBuilder     sb     = new StringBuilder();

            sb.AppendLine($"VM State: {engine.State}");
            sb.AppendLine($"Gas Consumed: {engine.GasConsumed}");
            sb.AppendLine($"Evaluation Stack: {new JArray(engine.EvaluationStack.Select(p => p.ToParameter().ToJson()))}");
            TxbTxResult.Text = sb.ToString();
            if (!engine.State.HasFlag(VMState.FAULT))
            {
                tx.Gas = engine.GasConsumed - Fixed8.FromDecimal(10);
                if (tx.Gas < Fixed8.Zero)
                {
                    tx.Gas = Fixed8.Zero;
                }
                tx.Gas = tx.Gas.Ceiling();
                Fixed8 fee = tx.Gas.Equals(Fixed8.Zero) ? net_fee : tx.Gas;
                currentFee          = fee;
                txbFee.Text         = String.Format(StringTable.GetInstance().GetString("STR_SMART_CONTRACT_FEE", iLang), fee.ToString());
                BtnLaunch.IsEnabled = true;

                BtnLaunch.Style = FindResource("QurasAddAssetButtonStyle") as Style;
                StaticUtils.ShowMessageBox(StaticUtils.GreenBrush, StringTable.GetInstance().GetString("STR_SUC_TEST_TRANSACTION", iLang));
                return(true);
            }
            else
            {
                BtnLaunch.IsEnabled = false;
                BtnLaunch.Style     = FindResource("QurasDisableAddAssetButtonStyle") as Style;
                StaticUtils.ShowMessageBox(StaticUtils.ErrorBrush, StringTable.GetInstance().GetString("STR_ERR_TEST_TRANSACTION", iLang));
                return(false);
            }
        }
 private void CurrentWallet_ErrorsOccured(object sender, string err)
 {
     if (Thread.CurrentThread != this.Dispatcher.Thread)
     {
         this.Dispatcher.BeginInvoke(new Action <object, string>(CurrentWallet_ErrorsOccured), sender, err);
     }
     else
     {
         StaticUtils.ShowMessageBox(StaticUtils.ErrorBrush, StringTable.GetInstance().GetString("STR_WALLET_REPAIR", iLang));
     }
 }
        private void calculateTotalAmount()
        {
            totalAmount = Fixed8.Zero;

            foreach (TxOutPutItem item in outPutItems)
            {
                totalAmount += item.GetAmount();
            }

            TxbTotalAmount.Text = String.Format(StringTable.GetInstance().GetString("STR_ISSUE_TOTALS", iLang), totalAmount.ToString(), assetState.GetName());
        }
        private void ShowErrorMessage(string ErrMsg)
        {
            TxbError.Text       = StringTable.GetInstance().GetString(ErrMsg, iLang);
            TxbError.Visibility = Visibility.Visible;


            errorMsgTimer.Tick    -= UpdateTimer;
            errorMsgTimer.Tick    += new EventHandler(UpdateTimer);
            errorMsgTimer.Interval = new TimeSpan(0, 0, 0, 5); // 1 hour
            errorMsgTimer.Start();
        }
Example #26
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));
            }
        }
        private void btnNext_Click(object sender, RoutedEventArgs e)
        {
            string checkField = CheckParameter();

            if (checkField != "STR_NW_SUC_WALLET")
            {
                txbStatus.Text       = StringTable.GetInstance().GetString(checkField, iLang);
                txbStatus.Visibility = Visibility.Visible;
                return;
            }

            txbStatus.Text = StringTable.GetInstance().GetString(checkField, iLang);

            UserWallet wallet;

            try
            {
                if (rdbAnonymous.IsChecked == true)
                {
                    wallet = UserWallet.Create(txbWalletPath.Text, txbPassword.Password, KeyType.Anonymous);
                }
                else if (rdbTransparent.IsChecked == true)
                {
                    wallet = UserWallet.Create(txbWalletPath.Text, txbPassword.Password, KeyType.Transparent);
                }
                else if (rdbStealth.IsChecked == true)
                {
                    wallet = UserWallet.Create(txbWalletPath.Text, txbPassword.Password, KeyType.Stealth);
                }
                else
                {
                    txbStatus.Text       = StringTable.GetInstance().GetString("STR_NW_ERR_UNKNOWN", iLang);
                    txbStatus.Visibility = Visibility.Visible;
                    return;
                }

                Settings.Default.LastWalletPath = txbWalletPath.Text;
                Settings.Default.Save();
            }
            catch (Exception ex)
            {
                txbStatus.Text       = StringTable.GetInstance().GetString("STR_NW_ERR_UNKNOWN", iLang);
                txbStatus.Visibility = Visibility.Visible;
                LogManager.WriteExceptionLogs(ex);
                return;
            }

            MainWalletWnd = new MainWalletWindow(wallet);
            MainWalletWnd.Show();

            isNext = true;

            this.Close();
        }
        public void RefreshLanguage()
        {
            btnDeploySmartContract.Content = StringTable.GetInstance().GetString("STR_SMARTCONTRACT_DEPLOY_BUTTON", iLang);
            btnInvokeSmartContract.Content = StringTable.GetInstance().GetString("STR_SMARTCONTRACT_INVOKE_BUTTON", iLang);
            btnAddAssets.Content           = StringTable.GetInstance().GetString("STR_SMARTCONTRACT_ADD_ASSET_BUTTON", iLang);

            invokeSCPage.RefreshLanguage();
            deploySCPage.RefreshLanguage();
            addAssetsPage.RefreshLanguage();

            ShowPages(pageStatus);
        }
Example #29
0
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            Fixed8 bonus_available = Blockchain.CalculateBonus(Constant.CurrentWallet.GetUnclaimedCoins().Select(p => p.Reference));

            TxbClaimAvailable.Text = String.Format(StringTable.GetInstance().GetString("STR_CLAIM_AVAILABLE", iLang), bonus_available.ToString());
            if (bonus_available == Fixed8.Zero)
            {
                btnClaim.IsEnabled = false;
            }
            CalculateBonusUnavailable(Blockchain.Default.Height + 1);
            Blockchain.PersistCompleted += Blockchain_PersistCompleted;
        }
Example #30
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, "");
            }
        }