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 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, ""); } }
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, ""); } }
public void AddAsset(UInt256 assetId, string assetName, Fixed8 value) { ComboBoxItem item = new ComboBoxItem(); AssetTypeItem tagItem = new AssetTypeItem(assetId, assetName, value); item.Tag = tagItem; item.Content = assetName; cmbAssetType.Items.Add(item); if (cmbAssetType.SelectedItem == null) { cmbAssetType.SelectedIndex = 0; } }
public void RefreshAsset(UInt256 assetId, Fixed8 value) { foreach (ComboBoxItem item in cmbAssetType.Items) { if (((AssetTypeItem)item.Tag).AssetID == assetId) { ((AssetTypeItem)item.Tag).Value = value; break; } } if (cmbAssetType.SelectedItem == null) { TxbSpendable.Text = String.Format(StringTable.GetInstance().GetString("STR_SP_SPENDABLE", iLang), 0, ""); return; } AssetTypeItem tag = ((ComboBoxItem)cmbAssetType.SelectedItem).Tag as AssetTypeItem; if (tag != null) { TxbSpendable.Text = String.Format(StringTable.GetInstance().GetString("STR_SP_SPENDABLE", iLang), tag.Value.ToString(), tag.Name); } }