public GetTransactionResult getTransaction(string transaction)
        {
            GetTransactionResult GTR = new GetTransactionResult();

            BNWalletAPIClasses.ErrorCodes er;
            HttpResponseMessage           resp = new HttpResponseMessage();
            string respStr;

            fp = new FormUrlEncodedContent(new[]
            {
                new KeyValuePair <string, string>("requestType", "getTransaction"),
                new KeyValuePair <string, string>("transaction", transaction)
            });

            try
            {
                resp    = client.PostAsync("burst", fp).Result;
                respStr = resp.Content.ReadAsStringAsync().Result;
            }
            catch

            {
                respStr = null;
            }
            if (!string.IsNullOrEmpty(respStr))
            {
                if (respStr.Contains("\"errorCode\":"))
                {
                    er           = JsonConvert.DeserializeObject <BNWalletAPIClasses.ErrorCodes>(respStr);
                    GTR.success  = false;
                    GTR.errormsg = er.errorDescription;
                    //GAIR.errorMsg = fp;
                }
                else
                {
                    BNWalletAPIClasses.getTransactionResponse gtr = JsonConvert.DeserializeObject <BNWalletAPIClasses.getTransactionResponse>(respStr);
                    GTR.success       = true;
                    GTR.feeNQT        = gtr.feeNQT;
                    GTR.senderRS      = gtr.senderRS;
                    GTR.amountNQT     = gtr.amountNQT;
                    GTR.recipientRS   = gtr.recipientRS;
                    GTR.ecBlockHeight = gtr.ecBlockHeight;
                }
            }
            else
            {
                GTR.success  = false;
                GTR.errormsg = "Receive blank response from API call";
            }
            return(GTR);
        }
コード例 #2
0
        private async void TransactionList_ListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            GetTransactionListResult gtlr = BNWAPI.getTransactionList(BurstAddress.Text, TransactionNumber.Text);

            if (gtlr.success)
            {
                for (int i = 0; i < gtlr.transactions.Length; i++)
                {
                    if (i == TransactionList_ListView.SelectedIndex)
                    {
                        GetTransactionResult gtr = BNWAPI.getTransaction(gtlr.transactions[i].transaction);
                        if (gtr.success)
                        {
                            double amntdblconf = Convert.ToDouble(gtr.amountNQT);
                            amntdblconf = amntdblconf / 100000000;
                            string Amount = amntdblconf.ToString("#,0.00000000");



                            double feeamntconf = Convert.ToDouble(gtr.feeNQT);
                            feeamntconf = feeamntconf / 100000000;
                            string Fee = feeamntconf.ToString("#,0.00000000");

                            MessageDialog ConfirmationDetailsDialog = new MessageDialog("Sender Address: " + gtr.senderRS + "\n" + "Amount of Burst sent: " + Amount + "\n" + "Fee: " + Fee + "\n" + "Recipient Address: " + gtr.recipientRS
                                                                                        + "\n" + "Block Height: " + gtr.ecBlockHeight + "\n" + "Confirmations: " + gtlr.transactions[i].confirmations);
                            ConfirmationDetailsDialog.Title = "Transaction " + gtlr.transactions[i].transaction + " Info";
                            ConfirmationDetailsDialog.Commands.Add(new UICommand("Ok")
                            {
                                Id = 0
                            });
                            var ConfResult = await ConfirmationDetailsDialog.ShowAsync();
                        }
                    }
                }
            }
        }
コード例 #3
0
        private async void Send_Burst_btn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                UARDB = new UserAccountRuntimeDB();
                UAR   = UARDB.Get();
                UserAccountsDB userAccountDB = new UserAccountsDB();
                UserAccounts[] userAccount   = userAccountDB.GetAccountList();
                string         SecretPhrase  = StringCipher.Decrypt(userAccount[userAccountIndex[WalletName.Text]].PassPhrase);

                MessageDialog alertDialog = new MessageDialog("Are you sure all the details are correct?");
                alertDialog.Title = "Confirmation";
                alertDialog.Commands.Add(new UICommand("Yes")
                {
                    Id = 0
                });
                alertDialog.Commands.Add(new UICommand("No")
                {
                    Id = 1
                });
                alertDialog.DefaultCommandIndex = 0;
                alertDialog.CancelCommandIndex  = 1;
                var result = await alertDialog.ShowAsync();

                if ((int)result.Id == 0)
                {
                    double amntdbl = Convert.ToDouble(Amount.Text);
                    amntdbl = amntdbl * 100000000;
                    string amount = amntdbl.ToString();

                    double amntdblconf = Convert.ToDouble(amount);
                    amntdblconf = amntdblconf / 100000000;
                    Amount.Text = amntdblconf.ToString("#,0.00000000");

                    if (Fee.Text == "")
                    {
                        Fee.Text = "0";
                    }
                    double feeamnt = Convert.ToDouble(Fee.Text);
                    feeamnt = feeamnt * 100000000;
                    string fee = feeamnt.ToString();

                    double feeamntconf = Convert.ToDouble(fee);
                    feeamntconf = feeamntconf / 100000000;
                    Fee.Text    = feeamntconf.ToString("#,0.00000000");


                    BNWAPI = new BNWalletAPI();
                    GetsendMoneyResult gsmr = BNWAPI.sendMoney(Recepient_Address.Text, amount, fee, SecretPhrase, Message.Text, cbEncrypt.IsChecked.HasValue);
                    if (gsmr.success)
                    {
                        GetTransactionResult gtr = BNWAPI.getTransaction(gsmr.transaction);
                        if (gtr.success)
                        {
                            GetMiningInfo gmi = BNWAPI.getMiningInfo();
                            if (gmi.success)
                            {
                                MessageDialog ConfirmationDetailsDialog = new MessageDialog("Sender Address: " + gtr.senderRS + "\n" + "Amount of Burst sent: " + Amount.Text + "\n" + "Fee: " + Fee.Text + "\n" + "Recipient Address: " + gtr.recipientRS + "\n" + "Signature Hash: " + gsmr.signatureHash
                                                                                            + "\n" + "Transaction ID: " + gsmr.transaction + "\n" + "Block Height: " + gmi.height);
                                ConfirmationDetailsDialog.Title = "Confirmation Details";
                                ConfirmationDetailsDialog.Commands.Add(new UICommand("Ok")
                                {
                                    Id = 0
                                });
                                var ConfResult = await ConfirmationDetailsDialog.ShowAsync();

                                if ((int)result.Id == 0)
                                {
                                    Recepient_Address.Text = "";
                                    Amount.Text            = "";
                                    Fee.Text     = "";
                                    Message.Text = "";
                                    PopulateWalletList();
                                }
                            }
                        }
                    }
                    else
                    {
                        MessageDialog ConfirmationDetailsDialog = new MessageDialog("Received Error: " + gsmr.errorMsg);
                        ConfirmationDetailsDialog.Title = "API Error";
                        ConfirmationDetailsDialog.Commands.Add(new UICommand("Ok")
                        {
                            Id = 0
                        });
                        var ConfResult = await ConfirmationDetailsDialog.ShowAsync();
                    }
                }
                else
                {
                }
            }
            catch
            {
                MessageDialog ConfirmationDetailsDialog = new MessageDialog("Received Error: A valid Burst Wallet needs to be selected before any funds can be sent");
                ConfirmationDetailsDialog.Title = "Error";
                ConfirmationDetailsDialog.Commands.Add(new UICommand("Ok")
                {
                    Id = 0
                });
                var ConfResult = await ConfirmationDetailsDialog.ShowAsync();
            }
        }