mirror of
https://github.com/Nathanwoodburn/FireWallet.git
synced 2025-12-06 08:33:00 +11:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
14a685690c
|
|||
|
816e16a9aa
|
|||
|
036819169d
|
|||
|
1675ac48f3
|
|||
|
f44aac35f0
|
|||
|
bf2e41058d
|
|||
|
2109879f93
|
|||
|
112b719d78
|
|||
|
2395c4ca29
|
@@ -32,36 +32,7 @@ namespace FireWallet
|
||||
this.explorerTX = explorerTX;
|
||||
this.explorerName = explorerName;
|
||||
this.mainForm = mainForm;
|
||||
}
|
||||
|
||||
#region Theming
|
||||
private void UpdateTheme()
|
||||
{
|
||||
// Check if file exists
|
||||
if (!Directory.Exists(dir))
|
||||
{
|
||||
CreateConfig(dir);
|
||||
}
|
||||
if (!File.Exists(dir + "theme.txt"))
|
||||
{
|
||||
CreateConfig(dir);
|
||||
}
|
||||
|
||||
// Read file
|
||||
StreamReader sr = new StreamReader(dir + "theme.txt");
|
||||
theme = new Dictionary<string, string>();
|
||||
while (!sr.EndOfStream)
|
||||
{
|
||||
string line = sr.ReadLine();
|
||||
string[] split = line.Split(':');
|
||||
theme.Add(split[0].Trim(), split[1].Trim());
|
||||
}
|
||||
sr.Dispose();
|
||||
|
||||
if (!theme.ContainsKey("background") || !theme.ContainsKey("background-alt") || !theme.ContainsKey("foreground") || !theme.ContainsKey("foreground-alt"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.theme = mainForm.theme;
|
||||
|
||||
// Apply theme
|
||||
this.BackColor = ColorTranslator.FromHtml(theme["background"]);
|
||||
@@ -73,35 +44,12 @@ namespace FireWallet
|
||||
// Need to specify this for each groupbox to override the black text
|
||||
foreach (Control c in Controls)
|
||||
{
|
||||
ThemeControl(c);
|
||||
mainForm.ThemeControl(c);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Transparancy
|
||||
applyTransparency(theme);
|
||||
|
||||
|
||||
applyTransparency(mainForm.theme);
|
||||
}
|
||||
private void ThemeControl(Control c)
|
||||
{
|
||||
if (c.GetType() == typeof(GroupBox) || c.GetType() == typeof(Panel))
|
||||
{
|
||||
c.ForeColor = ColorTranslator.FromHtml(theme["foreground"]);
|
||||
foreach (Control sub in c.Controls)
|
||||
{
|
||||
ThemeControl(sub);
|
||||
}
|
||||
}
|
||||
if (c.GetType() == typeof(TextBox) || c.GetType() == typeof(Button)
|
||||
|| c.GetType() == typeof(ComboBox) || c.GetType() == typeof(StatusStrip))
|
||||
{
|
||||
c.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]);
|
||||
c.BackColor = ColorTranslator.FromHtml(theme["background-alt"]);
|
||||
}
|
||||
}
|
||||
|
||||
#region Theme
|
||||
private void applyTransparency(Dictionary<string, string> theme)
|
||||
{
|
||||
if (theme.ContainsKey("transparent-mode"))
|
||||
@@ -148,26 +96,6 @@ namespace FireWallet
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateConfig(string dir)
|
||||
{
|
||||
if (!Directory.Exists(dir))
|
||||
{
|
||||
Directory.CreateDirectory(dir);
|
||||
}
|
||||
StreamWriter sw = new StreamWriter(dir + "theme.txt");
|
||||
sw.WriteLine("background: #000000");
|
||||
sw.WriteLine("foreground: #8e05c2");
|
||||
sw.WriteLine("background-alt: #3e065f");
|
||||
sw.WriteLine("foreground-alt: #ffffff");
|
||||
sw.WriteLine("transparent-mode: off");
|
||||
sw.WriteLine("transparency-key: main");
|
||||
sw.WriteLine("transparency-percent: 90");
|
||||
|
||||
sw.Dispose();
|
||||
|
||||
}
|
||||
|
||||
// Required for mica effect
|
||||
internal enum AccentState
|
||||
{
|
||||
@@ -209,7 +137,6 @@ namespace FireWallet
|
||||
|
||||
private void DomainForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
UpdateTheme();
|
||||
own = false;
|
||||
StreamReader sr = new StreamReader(dir + "node.txt");
|
||||
nodeSettings = new Dictionary<string, string>();
|
||||
@@ -330,6 +257,16 @@ namespace FireWallet
|
||||
{
|
||||
labelStatusMain.Text = "Error";
|
||||
}
|
||||
|
||||
|
||||
if (labelStatusReserved.Text == "True")
|
||||
{
|
||||
buttonActionAlt.Hide();
|
||||
buttonActionMain.Hide();
|
||||
groupBoxAction.Text = "Reserved";
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<PackageIcon>HSDBatcher.png</PackageIcon>
|
||||
<RepositoryUrl>https://github.com/Nathanwoodburn/FireWallet</RepositoryUrl>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<Version>2.5</Version>
|
||||
<Version>2.6</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -50,6 +50,9 @@ namespace FireWallet
|
||||
UpdateTheme();
|
||||
if (await LoadNode() != true) this.Close();
|
||||
|
||||
|
||||
if (this.Disposing || this.IsDisposed) return;
|
||||
|
||||
if (userSettings.ContainsKey("hide-splash"))
|
||||
{
|
||||
if (userSettings["hide-splash"] == "false")
|
||||
@@ -89,6 +92,11 @@ namespace FireWallet
|
||||
AddLog("Loaded");
|
||||
Opacity = 1;
|
||||
batchMode = false;
|
||||
// Pull form to front
|
||||
this.WindowState = FormWindowState.Minimized;
|
||||
this.Show();
|
||||
this.WindowState = FormWindowState.Normal;
|
||||
|
||||
textBoxaccountpassword.Focus();
|
||||
}
|
||||
private void MainForm_Closing(object sender, FormClosingEventArgs e)
|
||||
@@ -298,6 +306,7 @@ namespace FireWallet
|
||||
#region Logging
|
||||
public void AddLog(string message)
|
||||
{
|
||||
if (message.Contains("Get Error: No connection could be made because the target machine actively refused it")) return;
|
||||
StreamWriter sw = new StreamWriter(dir + "log.txt", true);
|
||||
sw.WriteLine(DateTime.Now.ToString() + ": " + message);
|
||||
sw.Dispose();
|
||||
@@ -738,10 +747,9 @@ namespace FireWallet
|
||||
/// <returns></returns>
|
||||
public async Task<string> APIPost(string path, bool wallet, string content)
|
||||
{
|
||||
if (content == "{\"passphrase\": \"\" ,\"timeout\": 60}")
|
||||
if (content == "{\"passphrase\": \"\",\"timeout\": 60}")
|
||||
{
|
||||
// For some reason, the API doesn't like an empty password, so we'll just use a default one
|
||||
content = "{\"passphrase\": \"password\" ,\"timeout\": 60}";
|
||||
return "";
|
||||
}
|
||||
string key = nodeSettings["Key"];
|
||||
string ip = nodeSettings["IP"];
|
||||
@@ -767,6 +775,8 @@ namespace FireWallet
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddLog("Post Error: " + ex.Message);
|
||||
AddLog(await resp.Content.ReadAsStringAsync());
|
||||
AddLog("Content: " + content);
|
||||
return "Error";
|
||||
}
|
||||
|
||||
@@ -835,6 +845,7 @@ namespace FireWallet
|
||||
decimal progress = Convert.ToDecimal(chain["progress"].ToString());
|
||||
labelSyncPercent.Text = "Sync: " + decimal.Round(progress * 100, 2) + "%";
|
||||
|
||||
|
||||
// Exit if set to 0 TXs
|
||||
if (userSettings.ContainsKey("portfolio-tx"))
|
||||
{
|
||||
@@ -854,28 +865,57 @@ namespace FireWallet
|
||||
labelPendingCount.Text = "Unconfirmed TX: " + pendingTxs.Count.ToString();
|
||||
|
||||
|
||||
// Get TX's
|
||||
APIresponse = await APIGet("wallet/" + account + "/tx/history", true);
|
||||
// Check how many TX there are
|
||||
APIresponse = await APIGet("wallet/"+ account,true);
|
||||
JObject wallet = JObject.Parse(APIresponse);
|
||||
if (!wallet.ContainsKey("balance"))
|
||||
{
|
||||
AddLog("GetInfo Error");
|
||||
AddLog(APIresponse);
|
||||
return;
|
||||
}
|
||||
JObject balance = JObject.Parse(wallet["balance"].ToString());
|
||||
int TotalTX = Convert.ToInt32(balance["tx"].ToString());
|
||||
int toGet = 10;
|
||||
if (userSettings.ContainsKey("portfolio-tx")) toGet = Convert.ToInt32(userSettings["portfolio-tx"]);
|
||||
|
||||
if (toGet > TotalTX) toGet = TotalTX;
|
||||
int toSkip = TotalTX - toGet;
|
||||
|
||||
// GET TXs
|
||||
APIresponse = await APIPost("", true, "{\"method\": \"listtransactions\",\"params\": [\"default\"," +toGet+","+ toSkip+ "]}");
|
||||
|
||||
if (APIresponse == "Error")
|
||||
{
|
||||
AddLog("GetInfo Error");
|
||||
return;
|
||||
}
|
||||
JArray txs = JArray.Parse(APIresponse);
|
||||
int txCount = txs.Count;
|
||||
if (txCount > groupBoxTransactions.Height / 55) txCount = (int)Math.Floor(groupBoxTransactions.Height / 55.0);
|
||||
if (userSettings.ContainsKey("portfolio-tx")) txCount = Convert.ToInt32(userSettings["portfolio-tx"]);
|
||||
if (txCount > txs.Count) txCount = txs.Count;
|
||||
Control[] tmpControls = new Control[txCount];
|
||||
for (int i = 0; i < txCount; i++)
|
||||
JObject TXGET = JObject.Parse(APIresponse);
|
||||
|
||||
// Check for error
|
||||
if (TXGET["error"].ToString() != "")
|
||||
{
|
||||
AddLog("GetInfo Error");
|
||||
AddLog(APIresponse);
|
||||
return;
|
||||
}
|
||||
|
||||
JArray txs = JArray.Parse(TXGET["result"].ToString());
|
||||
Control[] tmpControls = new Control[toGet];
|
||||
for (int i = 0; i < toGet; i++)
|
||||
{
|
||||
|
||||
// Get last tx
|
||||
JObject tx = JObject.Parse(txs[txs.Count - 1 - i].ToString());
|
||||
JObject tx = JObject.Parse(await APIGet("wallet/" + account + "/tx/" + txs[toGet - i - 1]["txid"].ToString(), true));
|
||||
|
||||
string hash = tx["hash"].ToString();
|
||||
string date = tx["mdate"].ToString();
|
||||
|
||||
date = DateTime.Parse(date).ToShortDateString();
|
||||
|
||||
|
||||
|
||||
|
||||
Panel tmpPanel = new Panel();
|
||||
tmpPanel.Width = groupBoxTransactions.Width - SystemInformation.VerticalScrollBarWidth - 20;
|
||||
tmpPanel.Height = 50;
|
||||
@@ -913,24 +953,49 @@ namespace FireWallet
|
||||
|
||||
tmpPanel.Controls.Add(labelHash);
|
||||
|
||||
// Count inputs and outputs
|
||||
JArray inputs = JArray.Parse(tx["inputs"].ToString());
|
||||
JArray outputs = JArray.Parse(tx["outputs"].ToString());
|
||||
int inputCount = inputs.Count;
|
||||
int outputCount = outputs.Count;
|
||||
|
||||
int costHNS = int.Parse(txs[toGet - i - 1]["amount"].ToString());
|
||||
string cost = "";
|
||||
if (costHNS < 0)
|
||||
{
|
||||
cost = "Spent: " + (costHNS * -1).ToString() + " HNS";
|
||||
}
|
||||
else if (costHNS > 0)
|
||||
{
|
||||
cost = "Received: " + costHNS.ToString() + " HNS";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Label labelInputOutput = new Label()
|
||||
{
|
||||
Text = "Inputs: " + inputCount + " Outputs: " + outputCount,
|
||||
Text = "Inputs: " + inputCount + " Outputs: " + outputCount + "\n" + cost,
|
||||
AutoSize = true,
|
||||
Location = new Point(300, 20)
|
||||
Location = new Point(300, 5)
|
||||
};
|
||||
tmpPanel.Controls.Add(labelInputOutput);
|
||||
|
||||
|
||||
tmpPanel.Click += (sender, e) =>
|
||||
{
|
||||
TXForm txForm = new TXForm(this, tx);
|
||||
TXForm txForm = new TXForm(this, hash);
|
||||
txForm.Show();
|
||||
};
|
||||
foreach (Control c in tmpPanel.Controls)
|
||||
{
|
||||
c.Click += (sender, e) =>
|
||||
{
|
||||
TXForm txForm = new TXForm(this, hash);
|
||||
txForm.Show();
|
||||
};
|
||||
}
|
||||
|
||||
tmpControls[i] = tmpPanel;
|
||||
|
||||
|
||||
@@ -1363,6 +1428,7 @@ namespace FireWallet
|
||||
notifyForm.ShowDialog();
|
||||
notifyForm.Dispose();
|
||||
this.Close();
|
||||
Thread.Sleep(1000);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1384,36 +1450,47 @@ namespace FireWallet
|
||||
notifyForm.ShowDialog();
|
||||
notifyForm.Dispose();
|
||||
this.Close();
|
||||
Thread.Sleep(1000);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Check if npm installed
|
||||
testInstalled = new Process();
|
||||
testInstalled.StartInfo.FileName = "npm";
|
||||
testInstalled.StartInfo.Arguments = "-v";
|
||||
testInstalled.StartInfo.FileName = "cmd.exe";
|
||||
testInstalled.StartInfo.Arguments = "npm -v";
|
||||
testInstalled.StartInfo.RedirectStandardOutput = true;
|
||||
testInstalled.StartInfo.UseShellExecute = false;
|
||||
testInstalled.StartInfo.CreateNoWindow = true;
|
||||
testInstalled.StartInfo.CreateNoWindow = false;
|
||||
testInstalled.Start();
|
||||
// Wait 3 seconds and then kill
|
||||
Thread.Sleep(3000);
|
||||
testInstalled.Kill();
|
||||
outputInstalled = testInstalled.StandardOutput.ReadToEnd();
|
||||
testInstalled.WaitForExit();
|
||||
|
||||
if (outputInstalled.Length < 3)
|
||||
if (Regex.IsMatch(outputInstalled, @"^\d+\.\d+\.\d+$"))
|
||||
{
|
||||
AddLog("NPM is not installed");
|
||||
AddLog(outputInstalled);
|
||||
NotifyForm notifyForm = new NotifyForm("NPM is not installed\nPlease install it to install HSD dependencies");
|
||||
notifyForm.ShowDialog();
|
||||
notifyForm.Dispose();
|
||||
this.Close();
|
||||
Thread.Sleep(1000);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
AddLog("Prerequisites installed");
|
||||
|
||||
ProcessStartInfo startInfo = new ProcessStartInfo();
|
||||
startInfo.FileName = "git";
|
||||
startInfo.Arguments = $"clone {repositoryUrl} {destinationPath}";
|
||||
|
||||
if (repositoryUrl == "https://github.com/handshake-org/hsd.git")
|
||||
{
|
||||
startInfo.Arguments = $"clone --depth 1 --branch latest {repositoryUrl} {destinationPath}";
|
||||
}
|
||||
|
||||
startInfo.RedirectStandardOutput = true;
|
||||
startInfo.UseShellExecute = false;
|
||||
startInfo.CreateNoWindow = hideScreen;
|
||||
@@ -1591,13 +1668,6 @@ namespace FireWallet
|
||||
domainTMP.Left = 10;
|
||||
domainTMP.BorderStyle = BorderStyle.FixedSingle;
|
||||
|
||||
// On Click open domain
|
||||
domainTMP.Click += new EventHandler((sender, e) =>
|
||||
{
|
||||
DomainForm domainForm = new DomainForm(this, name["name"].ToString(), userSettings["explorer-tx"], userSettings["explorer-domain"]);
|
||||
domainForm.Show();
|
||||
});
|
||||
|
||||
Label domainName = new Label();
|
||||
domainName.Text = Domains[i];
|
||||
domainName.Top = 5;
|
||||
@@ -1636,8 +1706,23 @@ namespace FireWallet
|
||||
}
|
||||
|
||||
|
||||
// On Click open domain
|
||||
domainTMP.Click += new EventHandler((sender, e) =>
|
||||
{
|
||||
DomainForm domainForm = new DomainForm(this, name["name"].ToString(), userSettings["explorer-tx"], userSettings["explorer-domain"]);
|
||||
domainForm.Show();
|
||||
});
|
||||
|
||||
|
||||
foreach (Control c in domainTMP.Controls)
|
||||
{
|
||||
c.Click += new EventHandler((sender, e) =>
|
||||
{
|
||||
DomainForm domainForm = new DomainForm(this, name["name"].ToString(), userSettings["explorer-tx"], userSettings["explorer-domain"]);
|
||||
domainForm.Show();
|
||||
});
|
||||
}
|
||||
|
||||
panelDomainList.Controls.Add(domainTMP);
|
||||
i++;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,8 @@ namespace FireWallet
|
||||
{
|
||||
MainForm mainForm;
|
||||
JObject tx;
|
||||
public TXForm(MainForm mainForm, JObject tx)
|
||||
string txid;
|
||||
public TXForm(MainForm mainForm, string txid)
|
||||
{
|
||||
InitializeComponent();
|
||||
// Theme
|
||||
@@ -29,16 +30,20 @@ namespace FireWallet
|
||||
}
|
||||
|
||||
this.mainForm = mainForm;
|
||||
this.tx = tx;
|
||||
|
||||
this.Text = "TX: " + tx["hash"].ToString();
|
||||
this.txid = txid;
|
||||
}
|
||||
|
||||
private async void TXForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
tx = JObject.Parse(await mainForm.APIGet("wallet/"+mainForm.account+"/tx/" + txid,true));
|
||||
|
||||
this.Text = "TX: " + tx["hash"].ToString();
|
||||
labelHash.Text = "Hash: " + tx["hash"].ToString();
|
||||
mainForm.AddLog("Viewing TX: " + tx["hash"].ToString());
|
||||
|
||||
// Disable scrolling on the panels until they are populated
|
||||
panelInputs.Visible = false;
|
||||
panelOutputs.Visible = false;
|
||||
|
||||
// For each input
|
||||
JArray inputs = (JArray)tx["inputs"];
|
||||
@@ -131,6 +136,9 @@ namespace FireWallet
|
||||
|
||||
panelOutputs.Controls.Add(PanelOutput);
|
||||
}
|
||||
|
||||
panelInputs.Visible = true;
|
||||
panelOutputs.Visible = true;
|
||||
}
|
||||
|
||||
private void Explorer_Click(object sender, EventArgs e)
|
||||
|
||||
@@ -224,15 +224,15 @@
|
||||
{
|
||||
"Name" = "8:Microsoft Visual Studio"
|
||||
"ProductName" = "8:FireWallet"
|
||||
"ProductCode" = "8:{D203173F-39CF-4D8C-810D-FF6840540AF3}"
|
||||
"PackageCode" = "8:{419FAC68-35FF-48D7-AD7D-83813C7CF72A}"
|
||||
"ProductCode" = "8:{CA9B8BF8-C03C-4C1F-BF5E-768B5897DB34}"
|
||||
"PackageCode" = "8:{A830408F-C770-4E8D-BEE3-22D4736728B5}"
|
||||
"UpgradeCode" = "8:{0C86F725-6B01-4173-AA05-3F0EDF481362}"
|
||||
"AspNetVersion" = "8:"
|
||||
"RestartWWWService" = "11:FALSE"
|
||||
"RemovePreviousVersions" = "11:TRUE"
|
||||
"DetectNewerInstalledVersion" = "11:TRUE"
|
||||
"InstallAllUsers" = "11:FALSE"
|
||||
"ProductVersion" = "8:2.5"
|
||||
"ProductVersion" = "8:2.6"
|
||||
"Manufacturer" = "8:Nathan.Woodburn/"
|
||||
"ARPHELPTELEPHONE" = "8:"
|
||||
"ARPHELPLINK" = "8:https://l.woodburn.au/discord"
|
||||
|
||||
Reference in New Issue
Block a user