public GetTransactionListResult getTransactionList(string BurstAddress, string lastIndex)
        {
            GetTransactionListResult GTL = new GetTransactionListResult();

            BNWalletAPIClasses.ErrorCodes er;
            HttpResponseMessage           resp = new HttpResponseMessage();
            string respStr;
            double LastIndex = Convert.ToDouble(lastIndex);

            LastIndex = LastIndex - 1;
            lastIndex = LastIndex.ToString();

            fp = new FormUrlEncodedContent(new[]
            {
                new KeyValuePair <string, string>("requestType", "getAccountTransactions"),
                new KeyValuePair <string, string>("account", BurstAddress),
                new KeyValuePair <string, string>("lastIndex", lastIndex),
            });

            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);
                    GTL.success  = false;
                    GTL.errormsg = er.errorDescription;
                }
                else
                {
                    BNWalletAPIClasses.GetTransactions gtlr = JsonConvert.DeserializeObject <BNWalletAPIClasses.GetTransactions>(respStr);
                    GTL.success      = true;
                    GTL.transactions = gtlr.transactions;
                }
            }
            else
            {
                GTL.success  = false;
                GTL.errormsg = "Receive blank response from API call";
            }
            return(GTL);
        }
Ejemplo n.º 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();
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private async void LoadMore_Tapped(object sender, TappedRoutedEventArgs e)
        {
            MessageDialog alertDialog = new MessageDialog("Loading more transactions may take a longer time to load, continue?");

            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)
            {
                GetTransactionListResult gtlr = BNWAPI.getTransactionList(BurstAddress.Text, TransactionNumber.Text);
                if (gtlr.success)
                {
                    TransactionList_ListView.Items.Clear();
                    //TransactionList_ListView.Items.Add("Date & Time" + "                    " + "Amount + Fee" + "     "+"Account" + "                                            " + "Confirmations");
                    for (int i = 0; i < gtlr.transactions.Length; i++)
                    {
                        DateTime date            = UnixTimeStampToDateTime(gtlr.transactions[i].timestamp);
                        string   transactionlist = gtlr.transactions[i].transaction;
                        string   amount          = gtlr.transactions[i].amountNQT;
                        double   amnt            = Convert.ToDouble(amount);
                        amnt = amnt / 100000000;
                        string newamnt = amnt.ToString("#,0.00000000");
                        string Fee     = gtlr.transactions[i].feeNQT;
                        double feeamnt = Convert.ToDouble(Fee);
                        feeamnt = feeamnt / 100000000;
                        string newFeeAmnt    = feeamnt.ToString("#,0");
                        string SenderAccount = gtlr.transactions[i].senderRS;
                        string Confirmations = gtlr.transactions[i].confirmations;
                        double Conf          = Convert.ToDouble(Confirmations);
                        string Recipient     = gtlr.transactions[i].recipientRS;
                        if (Recipient == BurstAddress.Text)
                        {
                            newamnt = "+" + newamnt;
                        }
                        else
                        {
                            newamnt       = "-" + newamnt;
                            SenderAccount = Recipient;
                            if (SenderAccount == "")
                            {
                                SenderAccount = "/                                                      ";
                            }
                        }

                        if (Conf > 9)
                        {
                            Conf = 10;
                            string newConf = Conf.ToString() + "+";
                            TransactionList_ListView.Items.Add(date + "    " + newamnt + "+" + newFeeAmnt + "    " + SenderAccount + "     " + newConf);
                        }
                        else
                        {
                            string newConf = Conf.ToString();
                            TransactionList_ListView.Items.Add(date + "    " + newamnt + "+" + newFeeAmnt + "    " + SenderAccount + "     " + newConf);
                        }
                    }
                }
            }
            else
            {
            }
        }
Ejemplo n.º 4
0
        private async void WalletList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            UserAccountsDB userAccountDB = new UserAccountsDB();

            UserAccounts[] userAccount = userAccountDB.GetAccountList();
            if (WalletList.SelectedItems.Count > 0)
            {
                string Wallet = WalletList.SelectedItems[0].ToString();
                Balance.Text = "";

                BurstAddress.Text = userAccount[userAccountIndex[Wallet]].BurstAddress;
                string SecretPhrase = StringCipher.Decrypt(userAccount[userAccountIndex[Wallet]].PassPhrase);
                BNWAPI = new BNWalletAPI();
                GetAccountIDResult gair = BNWAPI.getAccountID(SecretPhrase, "");
                try
                {
                    if (gair.success)
                    {
                        GetAccountResult gar = BNWAPI.getAccount(gair.accountRS);
                        if (gar.success)
                        {
                            if (gar.name == null)
                            {
                                WalletName.Text = "Unknown Account";
                            }
                            else
                            {
                                WalletName.Text = gar.name;
                            }

                            BurstAddress.Text = gar.accountRS;
                            WalletName.Text   = Wallet;
                            string BB;
                            BB = gar.balanceNQT;
                            double burstdbl = Convert.ToDouble(BB);
                            burstdbl               = burstdbl / 100000000;
                            Balance.Text           = "Balance: " + burstdbl.ToString("#,0.00000000") + " BURST";
                            TransactionNumber.Text = "100";

                            GetTransactionListResult gtlr = BNWAPI.getTransactionList(gair.accountRS, TransactionNumber.Text);
                            if (gtlr.success)
                            {
                                TransactionList_ListView.Items.Clear();
                                //TransactionList_ListView.Items.Add("Date & Time" + "                    " + "Amount + Fee" + "     "+"Account" + "                                            " + "Confirmations");
                                for (int i = 0; i < gtlr.transactions.Length; i++)
                                {
                                    DateTime date            = UnixTimeStampToDateTime(gtlr.transactions[i].timestamp);
                                    string   transactionlist = gtlr.transactions[i].transaction;
                                    string   amount          = gtlr.transactions[i].amountNQT;
                                    double   amnt            = Convert.ToDouble(amount);
                                    amnt = amnt / 100000000;
                                    string newamnt = amnt.ToString("#,0.00000000");
                                    string Fee     = gtlr.transactions[i].feeNQT;
                                    double feeamnt = Convert.ToDouble(Fee);
                                    feeamnt = feeamnt / 100000000;
                                    string newFeeAmnt    = feeamnt.ToString("#,0");
                                    string SenderAccount = gtlr.transactions[i].senderRS;
                                    string Confirmations = gtlr.transactions[i].confirmations;
                                    double Conf          = Convert.ToDouble(Confirmations);
                                    string Recipient     = gtlr.transactions[i].recipientRS;
                                    if (Recipient == BurstAddress.Text)
                                    {
                                        newamnt = "+" + newamnt;
                                    }
                                    else
                                    {
                                        newamnt       = "-" + newamnt;
                                        SenderAccount = Recipient;
                                        if (SenderAccount == "")
                                        {
                                            SenderAccount = "/                                                      ";
                                        }
                                    }

                                    if (Conf > 9)
                                    {
                                        Conf = 10;
                                        string newConf = Conf.ToString() + "+";
                                        TransactionList_ListView.Items.Add(date + "    " + newamnt + "+" + newFeeAmnt + "    " + SenderAccount + "     " + newConf);
                                    }
                                    else
                                    {
                                        string newConf = Conf.ToString();
                                        TransactionList_ListView.Items.Add(date + "    " + newamnt + "+" + newFeeAmnt + "    " + SenderAccount + "     " + newConf);
                                    }
                                }
                            }
                        }
                        else
                        {
                            MessageDialog ConfirmationDetailsDialog = new MessageDialog("Received Error: " + gar.errorMsg);
                            ConfirmationDetailsDialog.Title = "API Error";
                            ConfirmationDetailsDialog.Commands.Add(new UICommand("Ok")
                            {
                                Id = 0
                            });
                            var ConfResult = await ConfirmationDetailsDialog.ShowAsync();

                            TransactionList_ListView.Items.Clear();
                            Balance.Text = "Balance: 0.00000000 BURST";
                        }

                        CreateQRCode();
                    }
                    else
                    {
                        MessageDialog ConfirmationDetailsDialog = new MessageDialog("Received Error: " + gair.errorMsg);
                        ConfirmationDetailsDialog.Title = "API Error";
                        ConfirmationDetailsDialog.Commands.Add(new UICommand("Ok")
                        {
                            Id = 0
                        });
                        var ConfResult = await ConfirmationDetailsDialog.ShowAsync();
                    }
                }
                catch
                {
                    MessageDialog ConfirmationDetailsDialog = new MessageDialog("Received Error: " + gair.errorMsg);
                    ConfirmationDetailsDialog.Title = "API Error";
                    ConfirmationDetailsDialog.Commands.Add(new UICommand("Ok")
                    {
                        Id = 0
                    });
                    var ConfResult = await ConfirmationDetailsDialog.ShowAsync();
                }
            }
        }