17 Commits

Author SHA1 Message Date
14a685690c package: Increased version 2023-06-14 15:29:22 +10:00
816e16a9aa main: On load bring to front 2023-06-14 15:28:59 +10:00
036819169d tx: Get TX on load to lower memory use 2023-06-14 15:20:08 +10:00
1675ac48f3 main: Only get the number of TXs needed
This should speed up the loading on larger wallets
2023-06-14 15:19:16 +10:00
f44aac35f0 domain: Removed OPEN button from reserved domains 2023-06-14 14:09:20 +10:00
bf2e41058d main: Fixed click on text in domains and tx history doesn't open window 2023-06-14 14:07:03 +10:00
2109879f93 Merge remote-tracking branch 'origin/master' 2023-06-13 23:58:32 +10:00
112b719d78 main: Fixed npm installed checks and fixed HSD install 2023-06-13 23:58:24 +10:00
2395c4ca29 main: Fixed npm installed checks 2023-06-13 23:57:10 +10:00
752d20f369 main: Updated version 2023-06-13 23:26:16 +10:00
dc53d7eb0f assets: removed tmp logo 2023-06-13 23:26:06 +10:00
3783cfe759 main: Added error checks in case HSD doesn't start 2023-06-13 23:04:16 +10:00
71395f253b main: Added agent to internal HSD node 2023-06-13 22:51:48 +10:00
b34c6507b8 domains: Fixed opening domain error 2023-06-13 22:51:23 +10:00
b93c981fcd main: Added better errors for git, node or npm not installed 2023-06-13 11:30:54 +10:00
c7184be5ef main: Fixed installer problem (need to increase file version number) 2023-06-12 21:55:43 +10:00
b934ba2184 Added TXWindow 2023-06-12 21:36:07 +10:00
8 changed files with 313 additions and 116 deletions

View File

@@ -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)
{
@@ -804,9 +741,6 @@ namespace FireWallet
}
else if (state == "AVAILABLE")
{
decimal bid = Convert.ToDecimal(textBoxBid.Text);
decimal blind = Convert.ToDecimal(textBoxBlind.Text);
decimal lockup = bid + blind;
string content = "{\"method\": \"sendopen\", \"params\": [\"" + domain + "\"]}";
string response = await APIPost("", true, content);

View File

@@ -12,6 +12,7 @@
<PackageIcon>HSDBatcher.png</PackageIcon>
<RepositoryUrl>https://github.com/Nathanwoodburn/FireWallet</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Version>2.6</Version>
</PropertyGroup>
<ItemGroup>
@@ -36,6 +37,11 @@
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Update="Properties\Settings.Designer.cs">
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
@@ -45,4 +51,11 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Update="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
</Project>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.9 KiB

View File

@@ -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)
@@ -189,6 +197,13 @@ namespace FireWallet
Notifyinstall.CloseNotification();
Notifyinstall.Dispose();
}
if (!Directory.Exists(dir + "hsd\\node_modules"))
{
AddLog("HSD install failed");
this.Close();
return false;
}
hsdProcess = new Process();
bool hideScreen = true;
@@ -203,12 +218,19 @@ namespace FireWallet
{
hsdProcess.StartInfo.CreateNoWindow = hideScreen;
if (hideScreen)
{
hsdProcess.StartInfo.RedirectStandardError = true;
} else
{
hsdProcess.StartInfo.RedirectStandardError = false;
}
hsdProcess.StartInfo.RedirectStandardInput = true;
hsdProcess.StartInfo.RedirectStandardOutput = false;
hsdProcess.StartInfo.UseShellExecute = false;
hsdProcess.StartInfo.RedirectStandardError = false;
hsdProcess.StartInfo.FileName = "node.exe";
hsdProcess.StartInfo.Arguments = dir + "hsd/bin/hsd --index-tx --index-address --api-key " + nodeSettings["Key"];
hsdProcess.StartInfo.Arguments = dir + "hsd/bin/hsd --agent=FireWallet --index-tx --index-address --api-key " + nodeSettings["Key"];
string bobPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Bob\\hsd_data";
if (Directory.Exists(bobPath))
@@ -218,6 +240,24 @@ namespace FireWallet
hsdProcess.Start();
// Wait for HSD to start
await Task.Delay(2000);
// Check if HSD is running
if (hsdProcess.HasExited)
{
AddLog("HSD Failed to start");
AddLog(hsdProcess.StandardError.ReadToEnd());
NotifyForm Notifyinstall = new NotifyForm("HSD Failed to start\nPlease check the logs");
Notifyinstall.ShowDialog();
Notifyinstall.Dispose();
// Wait for the notification to show
await Task.Delay(1000);
this.Close();
await Task.Delay(1000);
return false;
}
}
catch (Exception ex)
{
@@ -225,9 +265,7 @@ namespace FireWallet
AddLog(ex.Message);
this.Close();
await Task.Delay(1000);
AddLog("Close Failed");
}
}
}
timerNodeStatus.Start();
@@ -268,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();
@@ -660,7 +699,10 @@ namespace FireWallet
if (await APIGet("", false) == "Error")
{
toolStripStatusLabelstatus.Text = "Status: Node Not Connected";
if (toolStripStatusLabelstatus.Text != "Status: HSD Starting")
{
toolStripStatusLabelstatus.Text = "Status: Node Not Connected";
}
return;
}
else
@@ -705,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"];
@@ -734,6 +775,8 @@ namespace FireWallet
catch (Exception ex)
{
AddLog("Post Error: " + ex.Message);
AddLog(await resp.Content.ReadAsStringAsync());
AddLog("Content: " + content);
return "Error";
}
@@ -802,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"))
{
@@ -821,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;
@@ -880,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;
@@ -1312,9 +1410,87 @@ namespace FireWallet
}
}
// Check if git is installed
Process testInstalled = new Process();
testInstalled.StartInfo.FileName = "git";
testInstalled.StartInfo.Arguments = "-v";
testInstalled.StartInfo.RedirectStandardOutput = true;
testInstalled.StartInfo.UseShellExecute = false;
testInstalled.StartInfo.CreateNoWindow = true;
testInstalled.Start();
string outputInstalled = testInstalled.StandardOutput.ReadToEnd();
testInstalled.WaitForExit();
if (!outputInstalled.Contains("git version"))
{
AddLog("Git is not installed");
NotifyForm notifyForm = new NotifyForm("Git is not installed\nPlease install it to install HSD dependencies");
notifyForm.ShowDialog();
notifyForm.Dispose();
this.Close();
Thread.Sleep(1000);
return;
}
// Check if node installed
testInstalled = new Process();
testInstalled.StartInfo.FileName = "node";
testInstalled.StartInfo.Arguments = "-v";
testInstalled.StartInfo.RedirectStandardOutput = true;
testInstalled.StartInfo.UseShellExecute = false;
testInstalled.StartInfo.CreateNoWindow = true;
testInstalled.Start();
outputInstalled = testInstalled.StandardOutput.ReadToEnd();
testInstalled.WaitForExit();
if (!outputInstalled.Contains("v"))
{
AddLog("Node is not installed");
NotifyForm notifyForm = new NotifyForm("Node is not installed\nPlease install it to install HSD dependencies");
notifyForm.ShowDialog();
notifyForm.Dispose();
this.Close();
Thread.Sleep(1000);
return;
}
// Check if npm installed
testInstalled = new Process();
testInstalled.StartInfo.FileName = "cmd.exe";
testInstalled.StartInfo.Arguments = "npm -v";
testInstalled.StartInfo.RedirectStandardOutput = true;
testInstalled.StartInfo.UseShellExecute = false;
testInstalled.StartInfo.CreateNoWindow = false;
testInstalled.Start();
// Wait 3 seconds and then kill
Thread.Sleep(3000);
testInstalled.Kill();
outputInstalled = testInstalled.StandardOutput.ReadToEnd();
testInstalled.WaitForExit();
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;
@@ -1359,6 +1535,32 @@ namespace FireWallet
{
AddLog("Git/NPM Install FAILED");
AddLog(ex.Message);
if (ex.Message.Contains("to start process 'git'"))
{
NotifyForm notifyForm = new NotifyForm("Git needs to be installed\nCheck logs for more details");
notifyForm.ShowDialog();
notifyForm.Dispose();
}
else if (ex.Message.Contains("to start process 'node'"))
{
NotifyForm notifyForm = new NotifyForm("Node needs to be installed\nCheck logs for more details");
notifyForm.ShowDialog();
notifyForm.Dispose();
}
else if (ex.Message.Contains("to start process 'npm'"))
{
NotifyForm notifyForm = new NotifyForm("NPM needs to be installed\nCheck logs for more details");
notifyForm.ShowDialog();
notifyForm.Dispose();
}
else
{
NotifyForm notifyForm = new NotifyForm("Git/NPM Install FAILED\nCheck logs for more details");
notifyForm.ShowDialog();
notifyForm.Dispose();
}
this.Close();
}
}
public bool CheckNodeInstalled()
@@ -1466,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;
@@ -1511,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++;
}

View File

@@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace FireWallet.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.6.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View File

@@ -0,0 +1,6 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
</SettingsFile>

View File

@@ -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)

View File

@@ -224,15 +224,15 @@
{
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:FireWallet"
"ProductCode" = "8:{EEABCF5F-54F1-4C71-A82F-FA131D9CC8C1}"
"PackageCode" = "8:{7B12D25F-C460-4627-B920-932CD9ACCF9E}"
"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.2"
"ProductVersion" = "8:2.6"
"Manufacturer" = "8:Nathan.Woodburn/"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:https://l.woodburn.au/discord"