mirror of
https://github.com/Nathanwoodburn/FireWallet.git
synced 2024-11-24 08:08:14 +11:00
main: Added node info
This commit is contained in:
parent
2473e4a571
commit
a4c1f0c895
110
FireWallet/MainForm.Designer.cs
generated
110
FireWallet/MainForm.Designer.cs
generated
@ -49,6 +49,13 @@
|
|||||||
buttonSend = new Button();
|
buttonSend = new Button();
|
||||||
buttonPortfolio = new Button();
|
buttonPortfolio = new Button();
|
||||||
panelPortfolio = new Panel();
|
panelPortfolio = new Panel();
|
||||||
|
groupBoxTransactions = new GroupBox();
|
||||||
|
groupBoxinfo = new GroupBox();
|
||||||
|
labelPendingCount = new Label();
|
||||||
|
labelSyncPercent = new Label();
|
||||||
|
labelHeight = new Label();
|
||||||
|
groupBoxbalance = new GroupBox();
|
||||||
|
labelBalanceTotal = new Label();
|
||||||
labelLocked = new Label();
|
labelLocked = new Label();
|
||||||
labelBalance = new Label();
|
labelBalance = new Label();
|
||||||
statusStripmain.SuspendLayout();
|
statusStripmain.SuspendLayout();
|
||||||
@ -56,6 +63,8 @@
|
|||||||
groupBoxaccount.SuspendLayout();
|
groupBoxaccount.SuspendLayout();
|
||||||
panelNav.SuspendLayout();
|
panelNav.SuspendLayout();
|
||||||
panelPortfolio.SuspendLayout();
|
panelPortfolio.SuspendLayout();
|
||||||
|
groupBoxinfo.SuspendLayout();
|
||||||
|
groupBoxbalance.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// statusStripmain
|
// statusStripmain
|
||||||
@ -251,29 +260,106 @@
|
|||||||
//
|
//
|
||||||
// panelPortfolio
|
// panelPortfolio
|
||||||
//
|
//
|
||||||
panelPortfolio.Controls.Add(labelLocked);
|
panelPortfolio.Controls.Add(groupBoxTransactions);
|
||||||
panelPortfolio.Controls.Add(labelBalance);
|
panelPortfolio.Controls.Add(groupBoxinfo);
|
||||||
|
panelPortfolio.Controls.Add(groupBoxbalance);
|
||||||
panelPortfolio.Location = new Point(120, 25);
|
panelPortfolio.Location = new Point(120, 25);
|
||||||
panelPortfolio.Name = "panelPortfolio";
|
panelPortfolio.Name = "panelPortfolio";
|
||||||
panelPortfolio.Size = new Size(956, 538);
|
panelPortfolio.Size = new Size(956, 538);
|
||||||
panelPortfolio.TabIndex = 7;
|
panelPortfolio.TabIndex = 7;
|
||||||
panelPortfolio.Visible = false;
|
panelPortfolio.Visible = false;
|
||||||
//
|
//
|
||||||
|
// groupBoxTransactions
|
||||||
|
//
|
||||||
|
groupBoxTransactions.Dock = DockStyle.Bottom;
|
||||||
|
groupBoxTransactions.Location = new Point(0, 113);
|
||||||
|
groupBoxTransactions.Name = "groupBoxTransactions";
|
||||||
|
groupBoxTransactions.Size = new Size(956, 425);
|
||||||
|
groupBoxTransactions.TabIndex = 8;
|
||||||
|
groupBoxTransactions.TabStop = false;
|
||||||
|
groupBoxTransactions.Text = "Transactions";
|
||||||
|
//
|
||||||
|
// groupBoxinfo
|
||||||
|
//
|
||||||
|
groupBoxinfo.Controls.Add(labelPendingCount);
|
||||||
|
groupBoxinfo.Controls.Add(labelSyncPercent);
|
||||||
|
groupBoxinfo.Controls.Add(labelHeight);
|
||||||
|
groupBoxinfo.Location = new Point(281, 3);
|
||||||
|
groupBoxinfo.Name = "groupBoxinfo";
|
||||||
|
groupBoxinfo.Size = new Size(232, 104);
|
||||||
|
groupBoxinfo.TabIndex = 8;
|
||||||
|
groupBoxinfo.TabStop = false;
|
||||||
|
groupBoxinfo.Text = "Info";
|
||||||
|
//
|
||||||
|
// labelPendingCount
|
||||||
|
//
|
||||||
|
labelPendingCount.AutoSize = true;
|
||||||
|
labelPendingCount.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
||||||
|
labelPendingCount.Location = new Point(3, 56);
|
||||||
|
labelPendingCount.Name = "labelPendingCount";
|
||||||
|
labelPendingCount.Size = new Size(116, 21);
|
||||||
|
labelPendingCount.TabIndex = 2;
|
||||||
|
labelPendingCount.Text = "labelPendingTX";
|
||||||
|
//
|
||||||
|
// labelSyncPercent
|
||||||
|
//
|
||||||
|
labelSyncPercent.AutoSize = true;
|
||||||
|
labelSyncPercent.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
||||||
|
labelSyncPercent.Location = new Point(133, 14);
|
||||||
|
labelSyncPercent.Name = "labelSyncPercent";
|
||||||
|
labelSyncPercent.Size = new Size(89, 21);
|
||||||
|
labelSyncPercent.TabIndex = 1;
|
||||||
|
labelSyncPercent.Text = "labelSync%";
|
||||||
|
//
|
||||||
|
// labelHeight
|
||||||
|
//
|
||||||
|
labelHeight.AutoSize = true;
|
||||||
|
labelHeight.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
||||||
|
labelHeight.Location = new Point(3, 14);
|
||||||
|
labelHeight.Name = "labelHeight";
|
||||||
|
labelHeight.Size = new Size(89, 21);
|
||||||
|
labelHeight.TabIndex = 0;
|
||||||
|
labelHeight.Text = "labelHeight";
|
||||||
|
//
|
||||||
|
// groupBoxbalance
|
||||||
|
//
|
||||||
|
groupBoxbalance.Controls.Add(labelBalanceTotal);
|
||||||
|
groupBoxbalance.Controls.Add(labelLocked);
|
||||||
|
groupBoxbalance.Controls.Add(labelBalance);
|
||||||
|
groupBoxbalance.Location = new Point(12, 3);
|
||||||
|
groupBoxbalance.Name = "groupBoxbalance";
|
||||||
|
groupBoxbalance.Size = new Size(263, 104);
|
||||||
|
groupBoxbalance.TabIndex = 2;
|
||||||
|
groupBoxbalance.TabStop = false;
|
||||||
|
groupBoxbalance.Text = "Balance";
|
||||||
|
//
|
||||||
|
// labelBalanceTotal
|
||||||
|
//
|
||||||
|
labelBalanceTotal.AutoSize = true;
|
||||||
|
labelBalanceTotal.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
||||||
|
labelBalanceTotal.Location = new Point(21, 60);
|
||||||
|
labelBalanceTotal.Name = "labelBalanceTotal";
|
||||||
|
labelBalanceTotal.Size = new Size(75, 21);
|
||||||
|
labelBalanceTotal.TabIndex = 2;
|
||||||
|
labelBalanceTotal.Text = "labelTotal";
|
||||||
|
//
|
||||||
// labelLocked
|
// labelLocked
|
||||||
//
|
//
|
||||||
labelLocked.AutoSize = true;
|
labelLocked.AutoSize = true;
|
||||||
labelLocked.Location = new Point(36, 87);
|
labelLocked.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
||||||
|
labelLocked.Location = new Point(21, 39);
|
||||||
labelLocked.Name = "labelLocked";
|
labelLocked.Name = "labelLocked";
|
||||||
labelLocked.Size = new Size(70, 15);
|
labelLocked.Size = new Size(92, 21);
|
||||||
labelLocked.TabIndex = 1;
|
labelLocked.TabIndex = 1;
|
||||||
labelLocked.Text = "labelLocked";
|
labelLocked.Text = "labelLocked";
|
||||||
//
|
//
|
||||||
// labelBalance
|
// labelBalance
|
||||||
//
|
//
|
||||||
labelBalance.AutoSize = true;
|
labelBalance.AutoSize = true;
|
||||||
labelBalance.Location = new Point(36, 37);
|
labelBalance.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
||||||
|
labelBalance.Location = new Point(21, 18);
|
||||||
labelBalance.Name = "labelBalance";
|
labelBalance.Name = "labelBalance";
|
||||||
labelBalance.Size = new Size(73, 15);
|
labelBalance.Size = new Size(96, 21);
|
||||||
labelBalance.TabIndex = 0;
|
labelBalance.TabIndex = 0;
|
||||||
labelBalance.Text = "labelBalance";
|
labelBalance.Text = "labelBalance";
|
||||||
//
|
//
|
||||||
@ -298,7 +384,10 @@
|
|||||||
groupBoxaccount.PerformLayout();
|
groupBoxaccount.PerformLayout();
|
||||||
panelNav.ResumeLayout(false);
|
panelNav.ResumeLayout(false);
|
||||||
panelPortfolio.ResumeLayout(false);
|
panelPortfolio.ResumeLayout(false);
|
||||||
panelPortfolio.PerformLayout();
|
groupBoxinfo.ResumeLayout(false);
|
||||||
|
groupBoxinfo.PerformLayout();
|
||||||
|
groupBoxbalance.ResumeLayout(false);
|
||||||
|
groupBoxbalance.PerformLayout();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
}
|
}
|
||||||
@ -327,5 +416,12 @@
|
|||||||
private Panel panelPortfolio;
|
private Panel panelPortfolio;
|
||||||
private Label labelLocked;
|
private Label labelLocked;
|
||||||
private Label labelBalance;
|
private Label labelBalance;
|
||||||
|
private GroupBox groupBoxbalance;
|
||||||
|
private Label labelBalanceTotal;
|
||||||
|
private GroupBox groupBoxinfo;
|
||||||
|
private Label labelHeight;
|
||||||
|
private Label labelPendingCount;
|
||||||
|
private Label labelSyncPercent;
|
||||||
|
private GroupBox groupBoxTransactions;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Security.Policy;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
namespace FireWallet
|
namespace FireWallet
|
||||||
@ -16,6 +17,9 @@ namespace FireWallet
|
|||||||
double balance;
|
double balance;
|
||||||
double balanceLocked;
|
double balanceLocked;
|
||||||
int screen; // 0 = login, 1 = portfolio
|
int screen; // 0 = login, 1 = portfolio
|
||||||
|
int height;
|
||||||
|
double syncProgress;
|
||||||
|
int pendingTransactions;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
#region Application
|
#region Application
|
||||||
@ -25,7 +29,6 @@ namespace FireWallet
|
|||||||
}
|
}
|
||||||
private void MainForm_Load(object sender, EventArgs e)
|
private void MainForm_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
AddLog("Loading");
|
|
||||||
UpdateTheme();
|
UpdateTheme();
|
||||||
LoadNode();
|
LoadNode();
|
||||||
|
|
||||||
@ -39,7 +42,6 @@ namespace FireWallet
|
|||||||
}
|
}
|
||||||
panelNav.Dock = DockStyle.Left;
|
panelNav.Dock = DockStyle.Left;
|
||||||
|
|
||||||
AddLog("Finished loading");
|
|
||||||
ResizeForm();
|
ResizeForm();
|
||||||
panelNav.Visible = false;
|
panelNav.Visible = false;
|
||||||
screen = 0;
|
screen = 0;
|
||||||
@ -59,11 +61,8 @@ namespace FireWallet
|
|||||||
#region Settings
|
#region Settings
|
||||||
private void LoadNode()
|
private void LoadNode()
|
||||||
{
|
{
|
||||||
AddLog("Loading Node");
|
|
||||||
if (!File.Exists(dir + "node.txt"))
|
if (!File.Exists(dir + "node.txt"))
|
||||||
{
|
{
|
||||||
AddLog("Node file not found");
|
|
||||||
AddLog("Starting Node Setup");
|
|
||||||
CreateForm cf = new CreateForm();
|
CreateForm cf = new CreateForm();
|
||||||
cf.ShowDialog();
|
cf.ShowDialog();
|
||||||
// Initial run
|
// Initial run
|
||||||
@ -132,7 +131,6 @@ namespace FireWallet
|
|||||||
CreateConfig(dir);
|
CreateConfig(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
AddLog("Reading theme file");
|
|
||||||
// Read file
|
// Read file
|
||||||
StreamReader sr = new StreamReader(dir + "theme.txt");
|
StreamReader sr = new StreamReader(dir + "theme.txt");
|
||||||
theme = new Dictionary<string, string>();
|
theme = new Dictionary<string, string>();
|
||||||
@ -168,8 +166,6 @@ namespace FireWallet
|
|||||||
|
|
||||||
this.Width = Screen.PrimaryScreen.Bounds.Width / 5 * 3;
|
this.Width = Screen.PrimaryScreen.Bounds.Width / 5 * 3;
|
||||||
this.Height = Screen.PrimaryScreen.Bounds.Height / 5 * 3;
|
this.Height = Screen.PrimaryScreen.Bounds.Height / 5 * 3;
|
||||||
AddLog("Finished applying theme");
|
|
||||||
AddLog("Applying transparency");
|
|
||||||
applyTransparency(theme);
|
applyTransparency(theme);
|
||||||
|
|
||||||
|
|
||||||
@ -342,6 +338,7 @@ namespace FireWallet
|
|||||||
comboBoxaccount.Items.Add("No accounts found");
|
comboBoxaccount.Items.Add("No accounts found");
|
||||||
comboBoxaccount.Enabled = false;
|
comboBoxaccount.Enabled = false;
|
||||||
}
|
}
|
||||||
|
textBoxaccountpassword.Focus();
|
||||||
}
|
}
|
||||||
private async Task<bool> Login()
|
private async Task<bool> Login()
|
||||||
{
|
{
|
||||||
@ -371,12 +368,61 @@ namespace FireWallet
|
|||||||
notifyForm.Dispose();
|
notifyForm.Dispose();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
AddLog("Login successful");
|
|
||||||
UpdateBalance();
|
UpdateBalance();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async void LoginClick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
account = comboBoxaccount.Text;
|
||||||
|
password = textBoxaccountpassword.Text;
|
||||||
|
bool loggedin = await Login();
|
||||||
|
if (loggedin)
|
||||||
|
{
|
||||||
|
toolStripStatusLabelaccount.Text = "Account: " + account;
|
||||||
|
textBoxaccountpassword.Text = "";
|
||||||
|
panelaccount.Visible = false;
|
||||||
|
toolStripSplitButtonlogout.Visible = true;
|
||||||
|
panelNav.Visible = true;
|
||||||
|
screen = 1;
|
||||||
|
buttonPortfolio.PerformClick();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PasswordEntered(object sender, KeyEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.KeyValue == 13)
|
||||||
|
{
|
||||||
|
LoginClick(sender, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AccountChoose(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
textBoxaccountpassword.Focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void Logout(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
toolStripSplitButtonlogout.Visible = false;
|
||||||
|
string path = "wallet/" + account + "/lock";
|
||||||
|
string content = "";
|
||||||
|
string APIresponse = await APIPost(path, true, content);
|
||||||
|
if (!APIresponse.Contains("true"))
|
||||||
|
{
|
||||||
|
AddLog("Logout failed");
|
||||||
|
NotifyForm notifyForm = new NotifyForm("Logout Failed\n" + APIresponse);
|
||||||
|
notifyForm.ShowDialog();
|
||||||
|
notifyForm.Dispose();
|
||||||
|
panelaccount.Visible = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
panelaccount.Visible = true;
|
||||||
|
panelNav.Visible = false;
|
||||||
|
toolStripStatusLabelaccount.Text = "Account: Not Logged In";
|
||||||
|
screen = 0;
|
||||||
|
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region API
|
#region API
|
||||||
HttpClient httpClient = new HttpClient();
|
HttpClient httpClient = new HttpClient();
|
||||||
@ -393,7 +439,7 @@ namespace FireWallet
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
private async void UpdateBalance()
|
private async Task UpdateBalance()
|
||||||
{
|
{
|
||||||
string response = await APIGet("wallet/" + account + "/balance?account=default", true);
|
string response = await APIGet("wallet/" + account + "/balance?account=default", true);
|
||||||
if (response == "Error") return;
|
if (response == "Error") return;
|
||||||
@ -471,72 +517,57 @@ namespace FireWallet
|
|||||||
return "Error";
|
return "Error";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async void GetInfo()
|
||||||
|
{
|
||||||
|
// Get height and progress
|
||||||
|
String APIresponse = await APIGet("", false);
|
||||||
|
JObject resp = JObject.Parse(APIresponse);
|
||||||
|
JObject chain = JObject.Parse(resp["chain"].ToString());
|
||||||
|
labelHeight.Text = "Height: " + chain["height"].ToString();
|
||||||
|
decimal progress = Convert.ToDecimal(chain["progress"].ToString());
|
||||||
|
labelSyncPercent.Text = "Sync: " + decimal.Round(progress * 100, 2) + "%";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Get Unconfirmed TX
|
||||||
|
string path = "wallet/" + account + "/tx/unconfirmed";
|
||||||
|
APIresponse = await APIGet(path, true);
|
||||||
|
if (APIresponse == "Error")
|
||||||
|
{
|
||||||
|
AddLog("GetInfo Error");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JArray txs = JArray.Parse(APIresponse);
|
||||||
|
labelPendingCount.Text = "Unconfirmed TX: " + resp.Count.ToString();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
#region Timers
|
#region Timers
|
||||||
private void timerNodeStatus_Tick(object sender, EventArgs e)
|
private void timerNodeStatus_Tick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
NodeStatus();
|
NodeStatus();
|
||||||
|
// If logged in, update info
|
||||||
|
if (panelaccount.Visible == false)
|
||||||
|
{
|
||||||
|
GetInfo();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private async void LoginClick(object sender, EventArgs e)
|
#region Nav
|
||||||
{
|
private async void buttonPortfolio_Click(object sender, EventArgs e)
|
||||||
account = comboBoxaccount.Text;
|
|
||||||
password = textBoxaccountpassword.Text;
|
|
||||||
bool loggedin = await Login();
|
|
||||||
if (loggedin)
|
|
||||||
{
|
|
||||||
toolStripStatusLabelaccount.Text = "Account: " + account;
|
|
||||||
textBoxaccountpassword.Text = "";
|
|
||||||
panelaccount.Visible = false;
|
|
||||||
toolStripSplitButtonlogout.Visible = true;
|
|
||||||
panelNav.Visible = true;
|
|
||||||
screen = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void PasswordEntered(object sender, KeyEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.KeyValue == 13)
|
|
||||||
{
|
|
||||||
LoginClick(sender, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void AccountChoose(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
textBoxaccountpassword.Focus();
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void Logout(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
toolStripSplitButtonlogout.Visible = false;
|
|
||||||
string path = "wallet/" + account + "/lock";
|
|
||||||
string content = "";
|
|
||||||
string APIresponse = await APIPost(path, true, content);
|
|
||||||
if (!APIresponse.Contains("true"))
|
|
||||||
{
|
|
||||||
AddLog("Logout failed");
|
|
||||||
NotifyForm notifyForm = new NotifyForm("Logout Failed\n" + APIresponse);
|
|
||||||
notifyForm.ShowDialog();
|
|
||||||
notifyForm.Dispose();
|
|
||||||
panelaccount.Visible = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
AddLog("Logout successful");
|
|
||||||
panelaccount.Visible = true;
|
|
||||||
panelNav.Visible = false;
|
|
||||||
toolStripStatusLabelaccount.Text = "Account: Not Logged In";
|
|
||||||
screen = 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonPortfolio_Click(object sender, EventArgs e)
|
|
||||||
{
|
{
|
||||||
panelPortfolio.Show();
|
panelPortfolio.Show();
|
||||||
UpdateBalance();
|
await UpdateBalance();
|
||||||
labelBalance.Text = "Balance: " + balance.ToString() + " HNS";
|
GetInfo();
|
||||||
|
labelBalance.Text = "Available: " + balance.ToString() + " HNS";
|
||||||
labelLocked.Text = "Locked: " + balanceLocked.ToString() + " HNS";
|
labelLocked.Text = "Locked: " + balanceLocked.ToString() + " HNS";
|
||||||
|
labelBalanceTotal.Text = "Total: " + (balance + balanceLocked).ToString() + " HNS";
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user