private string NewAddressForExchange()
        {
            string privateKey;
            string publicKey;
            CryptoHelper.GenerateKeyPair(out privateKey, out publicKey);

            string fingerPrint = CryptoHelper.Hash(publicKey);
            int issuerId = FiatCoinHelper.GetIssuerId(exchangePayFrom.SelectedValue.ToString());
            string currencyCode = exchangeCurrency.SelectedValue.ToString();
            var account = new PaymentAccount
            {
                Address = FiatCoinHelper.ToAddress(issuerId, fingerPrint),
                CurrencyCode = currencyCode,
                Balance = 0.00m,
                PublicKey = publicKey,
                PrivateKey = null
            };
            // register
            string requestUri = string.Format("issuer/api/{0}/accounts/register", issuerId);
            var registerRequest = new RegisterRequest
            {
                PaymentAccount = account.Mask()
            };
            HttpContent content = new StringContent(JsonHelper.Serialize(registerRequest));
            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            HttpResponseMessage response = HttpClient.PostAsync(requestUri, content).Result;
            response.EnsureSuccessStatusCode();

            account.PrivateKey = privateKey;
            this.m_Wallet.PaymentAccounts.Add(account);
            return account.Address;
        }
        private void miNewAddress_Click(object sender, RoutedEventArgs e)
        {
            string privateKey;
            string publicKey;
            CryptoHelper.GenerateKeyPair(out privateKey, out publicKey);

            string fingerPrint = CryptoHelper.Hash(publicKey);
            int issuerId = 0;
            try
            {
                issuerId = (int)comboBoxIssuer.SelectedValue;
            }
            catch(Exception)
            {
                MessageBox.Show("请选择开户银行","警告", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            string currencyCode = (string)comboBoxCurrencyCode.SelectedValue;
            if(currencyCode == null)
            {
                MessageBox.Show("请选择交易货币代码", "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            var account = new PaymentAccount
            {
                Address = FiatCoinHelper.ToAddress(issuerId, fingerPrint),
                CurrencyCode = currencyCode,
                Balance = 0.00m,
                PublicKey = publicKey,
                PrivateKey = null
            };

            // register
            string requestUri = string.Format("issuer/api/{0}/accounts/register", issuerId);
            var registerRequest = new RegisterRequest
            {
                PaymentAccount = account.Mask()
            };
            HttpContent content = new StringContent(JsonHelper.Serialize(registerRequest));
            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            HttpResponseMessage response = HttpClient.PostAsync(requestUri, content).Result;
            response.EnsureSuccessStatusCode();

            account.PrivateKey = privateKey;
            this.m_Wallet.PaymentAccounts.Add(account);

            //Allocate initial balance
            string baseAccount = "8gMAAA==+u3qZ1H9Ha0dOT6WX3d7Hr9npKQRreoFdGp4VourKtQ=";
            requestUri = string.Format("issuer/api/{0}/accounts/pay", issuerId);
            Random ran = new Random();
            int i_ranAmount = ran.Next(1, 499);
            float f_ranAmount = (float)(i_ranAmount * 0.01);
            var payRequest = new DirectPayRequest
            {
                PaymentTransaction = new PaymentTransaction
                {
                    Source = baseAccount,
                    Dest = Convert.ToBase64String(BitConverter.GetBytes(issuerId)) + fingerPrint,
                    Amount = Convert.ToDecimal(f_ranAmount),
                    CurrencyCode = currencyCode,
                    MemoData = "Initial-balance"
                }
            };
            payRequest.Signature = CryptoHelper.Sign("RUNTMiAAAAA7Fyutk/Pd2VotgUewM7QpS0lTMUwZC0PewDg47HFhIoq0rjlnUTraDpS5gurmvVybU357HBOZkX3aKon4FcSdrLKIvEgjHUbRuUt2bze5HNflkQRitCWbxYc7FVGxlog=", payRequest.ToMessage());
            content = new StringContent(JsonHelper.Serialize(payRequest));
            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            response = HttpClient.PostAsync(requestUri, content).Result;
            response.EnsureSuccessStatusCode();

            GetAccountBalances();
            this.UpdateAddressDataGrid();
            this.Save();
        }