Merge branch 'develop'

This commit is contained in:
Nathan Woodburn 2023-07-15 22:29:22 +10:00
commit 14dad4ba35
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
10 changed files with 1782 additions and 1655 deletions

View File

@ -2,31 +2,29 @@
using FireWallet; using FireWallet;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
namespace FireWalletLite namespace FireWalletLite;
public partial class DomainForm : Form
{ {
public partial class DomainForm : Form private readonly string Domain;
{ private readonly MainForm Main;
private MainForm Main;
private string Domain;
public DomainForm(MainForm main, string domain) public DomainForm(MainForm main, string domain)
{ {
InitializeComponent(); InitializeComponent();
this.Main = main; Main = main;
this.Domain = domain; Domain = domain;
Text = domain + "/"; Text = domain + "/";
// Theme form // Theme form
BackColor = ColorTranslator.FromHtml(main.Theme["background"]); BackColor = ColorTranslator.FromHtml(main.Theme["background"]);
ForeColor = ColorTranslator.FromHtml(main.Theme["foreground"]); ForeColor = ColorTranslator.FromHtml(main.Theme["foreground"]);
foreach (Control control in Controls) foreach (Control control in Controls) main.ThemeControl(control);
{
main.ThemeControl(control);
}
labelName.Text = domain + "/"; labelName.Text = domain + "/";
} }
private void buttonExplorer_Click(object sender, EventArgs e) private void buttonExplorer_Click(object sender, EventArgs e)
{ {
ProcessStartInfo psi = new ProcessStartInfo var psi = new ProcessStartInfo
{ {
FileName = Main.DomainExplorer + Domain, FileName = Main.DomainExplorer + Domain,
UseShellExecute = true UseShellExecute = true
@ -38,13 +36,10 @@ namespace FireWalletLite
{ {
if (!File.Exists(Main.dir + "domains.json")) return; if (!File.Exists(Main.dir + "domains.json")) return;
JArray domains = JArray.Parse(File.ReadAllText(Main.dir + "domains.json")); var domains = JArray.Parse(File.ReadAllText(Main.dir + "domains.json"));
foreach (JObject domain in domains) foreach (JObject domain in domains)
{
if (domain["name"].ToString() == Domain) if (domain["name"].ToString() == Domain)
{
if (domain.ContainsKey("status")) if (domain.ContainsKey("status"))
{
switch (domain["status"].ToString()) switch (domain["status"].ToString())
{ {
case "transferring": case "transferring":
@ -59,43 +54,41 @@ namespace FireWalletLite
break; break;
} }
} }
}
}
}
private async void buttonRenew_Click(object sender, EventArgs e) private async void buttonRenew_Click(object sender, EventArgs e)
{ {
string content = "{\"method\": \"renew\", \"params\": [\"" + Domain + "\"]}"; var content = "{\"method\": \"renew\", \"params\": [\"" + Domain + "\"]}";
string response = await Main.APIPost("", true, content); var response = await Main.APIPost("", true, content);
if (response == "Error") if (response == "Error")
{ {
NotifyForm notify = new NotifyForm("Error renewing domain"); var notify = new NotifyForm("Error renewing domain");
notify.ShowDialog(); notify.ShowDialog();
notify.Dispose(); notify.Dispose();
return; return;
} }
JObject jObject = JObject.Parse(response);
var jObject = JObject.Parse(response);
if (jObject.ContainsKey("result")) if (jObject.ContainsKey("result"))
{ {
Main.AddLog(jObject["result"].ToString()); Main.AddLog(jObject["result"].ToString());
JObject result = (JObject)jObject["result"]; var result = (JObject)jObject["result"];
if (result.ContainsKey("txid")) if (result.ContainsKey("txid"))
{ {
string txid = result["txid"].ToString(); var txid = result["txid"].ToString();
NotifyForm notify = new NotifyForm("Renewed domain", "Explorer", Main.TXExplorer + txid); var notify = new NotifyForm("Renewed domain", "Explorer", Main.TXExplorer + txid);
notify.ShowDialog(); notify.ShowDialog();
notify.Dispose(); notify.Dispose();
} }
else else
{ {
NotifyForm notify = new NotifyForm("Error renewing domain"); var notify = new NotifyForm("Error renewing domain");
notify.ShowDialog(); notify.ShowDialog();
notify.Dispose(); notify.Dispose();
} }
} }
else else
{ {
NotifyForm notify = new NotifyForm("Error renewing domain"); var notify = new NotifyForm("Error renewing domain");
notify.ShowDialog(); notify.ShowDialog();
notify.Dispose(); notify.Dispose();
Main.AddLog(jObject.ToString()); Main.AddLog(jObject.ToString());
@ -104,37 +97,40 @@ namespace FireWalletLite
private async void buttonTransfer_Click(object sender, EventArgs e) private async void buttonTransfer_Click(object sender, EventArgs e)
{ {
string address = textBoxTransferAddress.Text; var address = textBoxTransferAddress.Text;
bool valid = await Main.ValidAddress(address); var valid = await Main.ValidAddress(address);
if (!valid) if (!valid)
{ {
NotifyForm notify = new NotifyForm("Invalid address"); var notify = new NotifyForm("Invalid address");
notify.ShowDialog(); notify.ShowDialog();
notify.Dispose(); notify.Dispose();
return; return;
} }
string path = "wallet/" + Main.Account + "/transfer";
string content = "{\"passphrase\": \"" + Main.Password + "\", \"name\": \"" + Domain + "\", \"broadcast\": true, \"sign\": true, \"address\": \"" + address + "\"}"; var path = "wallet/" + Main.Account + "/transfer";
string response = await Main.APIPost(path, true, content); var content = "{\"passphrase\": \"" + Main.Password + "\", \"name\": \"" + Domain +
"\", \"broadcast\": true, \"sign\": true, \"address\": \"" + address + "\"}";
var response = await Main.APIPost(path, true, content);
if (response == "Error") if (response == "Error")
{ {
NotifyForm notify = new NotifyForm("Error transferring domain"); var notify = new NotifyForm("Error transferring domain");
notify.ShowDialog(); notify.ShowDialog();
notify.Dispose(); notify.Dispose();
return; return;
} }
JObject jObject = JObject.Parse(response);
var jObject = JObject.Parse(response);
if (jObject.ContainsKey("hash")) if (jObject.ContainsKey("hash"))
{ {
string txid = jObject["hash"].ToString(); var txid = jObject["hash"].ToString();
NotifyForm notify = new NotifyForm("Transferred domain", "Explorer", Main.TXExplorer + txid); var notify = new NotifyForm("Transferred domain", "Explorer", Main.TXExplorer + txid);
notify.ShowDialog(); notify.ShowDialog();
notify.Dispose(); notify.Dispose();
AddDomainInfo("transferring"); AddDomainInfo("transferring");
} }
else else
{ {
NotifyForm notify = new NotifyForm("Error transferring domain"); var notify = new NotifyForm("Error transferring domain");
notify.ShowDialog(); notify.ShowDialog();
notify.Dispose(); notify.Dispose();
} }
@ -142,56 +138,61 @@ namespace FireWalletLite
private void buttonFinalize_Click(object sender, EventArgs e) private void buttonFinalize_Click(object sender, EventArgs e)
{ {
string path = "wallet/" + Main.Account + "/finalize"; var path = "wallet/" + Main.Account + "/finalize";
string content = "{\"passphrase\": \"" + Main.Password + "\", \"name\": \"" + Domain + "\", \"broadcast\": true, \"sign\": true}"; var content = "{\"passphrase\": \"" + Main.Password + "\", \"name\": \"" + Domain +
string response = Main.APIPost(path, true, content).Result; "\", \"broadcast\": true, \"sign\": true}";
var response = Main.APIPost(path, true, content).Result;
if (response == "Error") if (response == "Error")
{ {
NotifyForm notify = new NotifyForm("Error finalizing transfer"); var notify = new NotifyForm("Error finalizing transfer");
notify.ShowDialog(); notify.ShowDialog();
notify.Dispose(); notify.Dispose();
return; return;
} }
JObject jObject = JObject.Parse(response);
var jObject = JObject.Parse(response);
if (jObject.ContainsKey("hash")) if (jObject.ContainsKey("hash"))
{ {
string txid = jObject["hash"].ToString(); var txid = jObject["hash"].ToString();
NotifyForm notify = new NotifyForm("Finalized domain", "Explorer", Main.TXExplorer + txid); var notify = new NotifyForm("Finalized domain", "Explorer", Main.TXExplorer + txid);
notify.ShowDialog(); notify.ShowDialog();
notify.Dispose(); notify.Dispose();
AddDomainInfo("closed"); AddDomainInfo("closed");
} }
else else
{ {
NotifyForm notify = new NotifyForm("Error finalizing domain"); var notify = new NotifyForm("Error finalizing domain");
notify.ShowDialog(); notify.ShowDialog();
notify.Dispose(); notify.Dispose();
} }
} }
private void buttonCancel_Click(object sender, EventArgs e) private void buttonCancel_Click(object sender, EventArgs e)
{ {
string path = "wallet/" + Main.Account + "/cancel"; var path = "wallet/" + Main.Account + "/cancel";
string content = "{\"passphrase\": \"" + Main.Password + "\", \"name\": \"" + Domain + "\", \"broadcast\": true, \"sign\": true}"; var content = "{\"passphrase\": \"" + Main.Password + "\", \"name\": \"" + Domain +
string response = Main.APIPost(path, true, content).Result; "\", \"broadcast\": true, \"sign\": true}";
var response = Main.APIPost(path, true, content).Result;
if (response == "Error") if (response == "Error")
{ {
NotifyForm notify = new NotifyForm("Error cancelling transfer"); var notify = new NotifyForm("Error cancelling transfer");
notify.ShowDialog(); notify.ShowDialog();
notify.Dispose(); notify.Dispose();
return; return;
} }
JObject jObject = JObject.Parse(response);
var jObject = JObject.Parse(response);
if (jObject.ContainsKey("hash")) if (jObject.ContainsKey("hash"))
{ {
string txid = jObject["hash"].ToString(); var txid = jObject["hash"].ToString();
NotifyForm notify = new NotifyForm("Canceled transfer", "Explorer", Main.TXExplorer + txid); var notify = new NotifyForm("Canceled transfer", "Explorer", Main.TXExplorer + txid);
notify.ShowDialog(); notify.ShowDialog();
notify.Dispose(); notify.Dispose();
AddDomainInfo("closed"); AddDomainInfo("closed");
} }
else else
{ {
NotifyForm notify = new NotifyForm("Error cancelling transfer"); var notify = new NotifyForm("Error cancelling transfer");
notify.ShowDialog(); notify.ShowDialog();
notify.Dispose(); notify.Dispose();
} }
@ -201,37 +202,32 @@ namespace FireWalletLite
{ {
if (File.Exists(Main.dir + "domains.json")) if (File.Exists(Main.dir + "domains.json"))
{ {
bool found = false; var found = false;
JArray domains = JArray.Parse(File.ReadAllText(Main.dir + "domains.json")); var domains = JArray.Parse(File.ReadAllText(Main.dir + "domains.json"));
foreach (JObject domain in domains) foreach (JObject domain in domains)
{
if (domain["name"].ToString() == Domain) if (domain["name"].ToString() == Domain)
{ {
found = true; found = true;
if (domain.ContainsKey("status")) if (domain.ContainsKey("status"))
{
domain["status"] = status; domain["status"] = status;
}
else else
{
domain.Add("status", status); domain.Add("status", status);
} }
}
}
if (!found) if (!found)
{ {
JObject domain = new JObject(); var domain = new JObject();
domain["name"] = Domain; domain["name"] = Domain;
domain["status"] = status; domain["status"] = status;
domains.Add(domain); domains.Add(domain);
} }
File.WriteAllText(Main.dir + "domains.json", domains.ToString()); File.WriteAllText(Main.dir + "domains.json", domains.ToString());
} }
else else
{ {
JArray domains = new JArray(); var domains = new JArray();
JObject domain = new JObject(); var domain = new JObject();
domain["name"] = Domain; domain["name"] = Domain;
domain["status"] = status; domain["status"] = status;
domains.Add(domain); domains.Add(domain);
@ -243,12 +239,12 @@ namespace FireWalletLite
{ {
if (buttonSign.Text == "Save") if (buttonSign.Text == "Save")
{ {
SaveFileDialog saveFileDialog = new SaveFileDialog(); var saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "Text File|*.txt"; saveFileDialog.Filter = "Text File|*.txt";
saveFileDialog.Title = "Save Signature"; saveFileDialog.Title = "Save Signature";
if (saveFileDialog.ShowDialog() == DialogResult.OK) if (saveFileDialog.ShowDialog() == DialogResult.OK)
{ {
JObject signature = new JObject(); var signature = new JObject();
signature["domain"] = Domain; signature["domain"] = Domain;
signature["message"] = textBoxSignMessage.Text; signature["message"] = textBoxSignMessage.Text;
signature["signature"] = textBoxSignature.Text; signature["signature"] = textBoxSignature.Text;
@ -258,23 +254,27 @@ namespace FireWalletLite
return; return;
} }
if (textBoxSignMessage.Text == "") if (textBoxSignMessage.Text == "")
{ {
NotifyForm notify = new NotifyForm("Enter a message to sign"); var notify = new NotifyForm("Enter a message to sign");
notify.ShowDialog(); notify.ShowDialog();
notify.Dispose(); notify.Dispose();
return; return;
} }
string content = "{\"method\": \"signmessagewithname\", \"params\": [\"" + Domain + "\", \"" + textBoxSignMessage.Text + "\"]}";
string response = await Main.APIPost("", true, content); var content = "{\"method\": \"signmessagewithname\", \"params\": [\"" + Domain + "\", \"" +
textBoxSignMessage.Text + "\"]}";
var response = await Main.APIPost("", true, content);
if (response == "Error") if (response == "Error")
{ {
NotifyForm notify = new NotifyForm("Error signing message"); var notify = new NotifyForm("Error signing message");
notify.ShowDialog(); notify.ShowDialog();
notify.Dispose(); notify.Dispose();
return; return;
} }
JObject jObject = JObject.Parse(response);
var jObject = JObject.Parse(response);
if (jObject.ContainsKey("result")) if (jObject.ContainsKey("result"))
{ {
textBoxSignature.Text = jObject["result"].ToString(); textBoxSignature.Text = jObject["result"].ToString();
@ -283,7 +283,7 @@ namespace FireWalletLite
else else
{ {
Main.AddLog(response); Main.AddLog(response);
NotifyForm notify = new NotifyForm("Error signing message"); var notify = new NotifyForm("Error signing message");
notify.ShowDialog(); notify.ShowDialog();
notify.Dispose(); notify.Dispose();
} }
@ -293,5 +293,4 @@ namespace FireWalletLite
{ {
buttonSign.Text = "Sign"; buttonSign.Text = "Sign";
} }
}
} }

View File

@ -1,24 +1,22 @@
using FireWallet; using FireWallet;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
namespace FireWalletLite namespace FireWalletLite;
public partial class FirstLoginForm : Form
{ {
public partial class FirstLoginForm : Form private readonly MainForm main;
{ private string seedPhrase;
String seedPhrase;
MainForm main;
public FirstLoginForm(string seedPhrase, MainForm mainForm) public FirstLoginForm(string seedPhrase, MainForm mainForm)
{ {
InitializeComponent(); InitializeComponent();
this.seedPhrase = seedPhrase; this.seedPhrase = seedPhrase;
this.main = mainForm; main = mainForm;
// Theme form // Theme form
this.BackColor = ColorTranslator.FromHtml(mainForm.Theme["background"]); BackColor = ColorTranslator.FromHtml(mainForm.Theme["background"]);
this.ForeColor = ColorTranslator.FromHtml(mainForm.Theme["foreground"]); ForeColor = ColorTranslator.FromHtml(mainForm.Theme["foreground"]);
foreach (Control control in Controls) foreach (Control control in Controls) mainForm.ThemeControl(control);
{
mainForm.ThemeControl(control);
}
textBoxSeed.Text = seedPhrase; textBoxSeed.Text = seedPhrase;
} }
@ -26,34 +24,33 @@ namespace FireWalletLite
{ {
if (textBoxPassword.Text.Length < 8) if (textBoxPassword.Text.Length < 8)
{ {
NotifyForm notifyForm = new NotifyForm("Please choose a longer password!"); var notifyForm = new NotifyForm("Please choose a longer password!");
notifyForm.ShowDialog(); notifyForm.ShowDialog();
notifyForm.Dispose(); notifyForm.Dispose();
return; return;
} }
if (textBoxPassword.Text != textBoxPassword2.Text) if (textBoxPassword.Text != textBoxPassword2.Text)
{ {
NotifyForm notifyForm = new NotifyForm("Passwords do not match!"); var notifyForm = new NotifyForm("Passwords do not match!");
notifyForm.ShowDialog(); notifyForm.ShowDialog();
notifyForm.Dispose(); notifyForm.Dispose();
return; return;
} }
// Encrypt wallet // Encrypt wallet
string content = "{\"method\":\"encryptwallet\",\"params\":[\"" + textBoxPassword.Text + "\"]}"; var content = "{\"method\":\"encryptwallet\",\"params\":[\"" + textBoxPassword.Text + "\"]}";
string response = await main.APIPost("",true,content); var response = await main.APIPost("", true, content);
main.AddLog("Encrypt wallet: " + response); main.AddLog("Encrypt wallet: " + response);
JObject jObject = JObject.Parse(response); var jObject = JObject.Parse(response);
if (jObject["error"].ToString() != "") if (jObject["error"].ToString() != "")
{ {
NotifyForm notifyForm = new NotifyForm("Error encrypting wallet: " + jObject["error"].ToString()); var notifyForm = new NotifyForm("Error encrypting wallet: " + jObject["error"]);
notifyForm.ShowDialog(); notifyForm.ShowDialog();
notifyForm.Dispose(); notifyForm.Dispose();
return; return;
} else
{
this.Close();
}
} }
Close();
} }
} }

View File

@ -2,35 +2,30 @@ using System.Diagnostics;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using FireWallet; using FireWallet;
namespace FireWalletLite namespace FireWalletLite;
{
public partial class Loader : Form
{
#region Constants
MainForm mainForm = new MainForm();
bool hideScreen = false;
Process HSDProcess;
#endregion
public partial class Loader : Form
{
public Loader() public Loader()
{ {
InitializeComponent(); InitializeComponent();
SplashScreen splashScreen = new SplashScreen(false); var splashScreen = new SplashScreen(false);
splashScreen.Show(); splashScreen.Show();
Application.DoEvents(); Application.DoEvents();
DateTime start = DateTime.Now; var start = DateTime.Now;
// Install and load node // Install and load node
string dir = mainForm.dir; var dir = mainForm.dir;
HSDProcess = new Process(); HSDProcess = new Process();
if (!Directory.Exists(dir)) Environment.Exit(1); if (!Directory.Exists(dir)) Environment.Exit(1);
string hsdPath = dir + "hsd\\bin\\hsd.exe"; var hsdPath = dir + "hsd\\bin\\hsd.exe";
if (!Directory.Exists(dir + "hsd")) if (!Directory.Exists(dir + "hsd"))
{ {
string repositoryUrl = "https://github.com/handshake-org/hsd.git"; var repositoryUrl = "https://github.com/handshake-org/hsd.git";
string destinationPath = dir + "hsd"; var destinationPath = dir + "hsd";
CloneRepository(repositoryUrl, destinationPath); CloneRepository(repositoryUrl, destinationPath);
} }
// Start HSD // Start HSD
HSDProcess.StartInfo.RedirectStandardInput = true; HSDProcess.StartInfo.RedirectStandardInput = true;
HSDProcess.StartInfo.RedirectStandardOutput = false; HSDProcess.StartInfo.RedirectStandardOutput = false;
@ -48,41 +43,55 @@ namespace FireWalletLite
{ {
HSDProcess.StartInfo.RedirectStandardError = false; HSDProcess.StartInfo.RedirectStandardError = false;
} }
HSDProcess.Start(); HSDProcess.Start();
while ((DateTime.Now - start).TotalSeconds < 5) while ((DateTime.Now - start).TotalSeconds < 5)
{ {
Thread.Sleep(10); Thread.Sleep(10);
Application.DoEvents(); Application.DoEvents();
} }
splashScreen.CloseSplash(); splashScreen.CloseSplash();
while (!splashScreen.IsClosed) while (!splashScreen.IsClosed)
{ {
Thread.Sleep(10); Thread.Sleep(10);
Application.DoEvents(); Application.DoEvents();
} }
splashScreen.Dispose(); splashScreen.Dispose();
mainForm.Show(); mainForm.Show();
} }
#region Constants
private readonly MainForm mainForm = new();
private readonly bool hideScreen = true;
private readonly Process HSDProcess;
#endregion
#region Git #region Git
public void CloneRepository(string repositoryUrl, string destinationPath) public void CloneRepository(string repositoryUrl, string destinationPath)
{ {
try try
{ {
// Check if git is installed // Check if git is installed
Process testInstalled = new Process(); var testInstalled = new Process();
testInstalled.StartInfo.FileName = "git"; testInstalled.StartInfo.FileName = "git";
testInstalled.StartInfo.Arguments = "-v"; testInstalled.StartInfo.Arguments = "-v";
testInstalled.StartInfo.RedirectStandardOutput = true; testInstalled.StartInfo.RedirectStandardOutput = true;
testInstalled.StartInfo.UseShellExecute = false; testInstalled.StartInfo.UseShellExecute = false;
testInstalled.StartInfo.CreateNoWindow = true; testInstalled.StartInfo.CreateNoWindow = true;
testInstalled.Start(); testInstalled.Start();
string outputInstalled = testInstalled.StandardOutput.ReadToEnd(); var outputInstalled = testInstalled.StandardOutput.ReadToEnd();
testInstalled.WaitForExit(); testInstalled.WaitForExit();
if (!outputInstalled.Contains("git version")) if (!outputInstalled.Contains("git version"))
{ {
mainForm.AddLog("Git is not installed"); mainForm.AddLog("Git is not installed");
NotifyForm notifyForm = new NotifyForm("Git is not installed\nPlease install it to install HSD dependencies", "Install", "https://git-scm.com/download/win"); var notifyForm = new NotifyForm("Git is not installed\nPlease install it to install HSD dependencies",
"Install", "https://git-scm.com/download/win");
notifyForm.ShowDialog(); notifyForm.ShowDialog();
notifyForm.Dispose(); notifyForm.Dispose();
Environment.Exit(21); Environment.Exit(21);
@ -103,7 +112,8 @@ namespace FireWalletLite
if (!outputInstalled.Contains("v")) if (!outputInstalled.Contains("v"))
{ {
mainForm.AddLog("Node is not installed"); mainForm.AddLog("Node is not installed");
NotifyForm notifyForm = new NotifyForm("Node is not installed\nPlease install it to install HSD dependencies", "Install", "https://nodejs.org/en/download"); var notifyForm = new NotifyForm("Node is not installed\nPlease install it to install HSD dependencies",
"Install", "https://nodejs.org/en/download");
notifyForm.ShowDialog(); notifyForm.ShowDialog();
notifyForm.Dispose(); notifyForm.Dispose();
Environment.Exit(22); Environment.Exit(22);
@ -128,7 +138,8 @@ namespace FireWalletLite
{ {
mainForm.AddLog("NPM is not installed"); mainForm.AddLog("NPM is not installed");
mainForm.AddLog(outputInstalled); mainForm.AddLog(outputInstalled);
NotifyForm notifyForm = new NotifyForm("NPM is not installed\nPlease install it to install HSD dependencies", "Install", "https://docs.npmjs.com/downloading-and-installing-node-js-and-npm"); var notifyForm = new NotifyForm("NPM is not installed\nPlease install it to install HSD dependencies",
"Install", "https://docs.npmjs.com/downloading-and-installing-node-js-and-npm");
notifyForm.ShowDialog(); notifyForm.ShowDialog();
notifyForm.Dispose(); notifyForm.Dispose();
Environment.Exit(23); Environment.Exit(23);
@ -137,30 +148,25 @@ namespace FireWalletLite
mainForm.AddLog("Prerequisites installed"); mainForm.AddLog("Prerequisites installed");
ProcessStartInfo startInfo = new ProcessStartInfo(); var startInfo = new ProcessStartInfo();
startInfo.FileName = "git"; startInfo.FileName = "git";
startInfo.Arguments = $"clone {repositoryUrl} {destinationPath}"; startInfo.Arguments = $"clone {repositoryUrl} {destinationPath}";
if (repositoryUrl == "https://github.com/handshake-org/hsd.git") if (repositoryUrl == "https://github.com/handshake-org/hsd.git")
{
startInfo.Arguments = $"clone --depth 1 --branch latest {repositoryUrl} {destinationPath}"; startInfo.Arguments = $"clone --depth 1 --branch latest {repositoryUrl} {destinationPath}";
}
startInfo.RedirectStandardOutput = true; startInfo.RedirectStandardOutput = true;
startInfo.UseShellExecute = false; startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = hideScreen; startInfo.CreateNoWindow = hideScreen;
Process process = new Process(); var process = new Process();
process.StartInfo = startInfo; process.StartInfo = startInfo;
process.Start(); process.Start();
string output = process.StandardOutput.ReadToEnd(); var output = process.StandardOutput.ReadToEnd();
process.WaitForExit(); process.WaitForExit();
while (!process.HasExited) while (!process.HasExited) output += process.StandardOutput.ReadToEnd();
{
output += process.StandardOutput.ReadToEnd();
}
var psiNpmRunDist = new ProcessStartInfo var psiNpmRunDist = new ProcessStartInfo
{ {
FileName = "cmd", FileName = "cmd",
@ -178,38 +184,39 @@ namespace FireWalletLite
mainForm.AddLog(ex.Message); mainForm.AddLog(ex.Message);
if (ex.Message.Contains("to start process 'git'")) if (ex.Message.Contains("to start process 'git'"))
{ {
NotifyForm notifyForm = new NotifyForm("Git needs to be installed\nCheck logs for more details"); var notifyForm = new NotifyForm("Git needs to be installed\nCheck logs for more details");
notifyForm.ShowDialog(); notifyForm.ShowDialog();
notifyForm.Dispose(); notifyForm.Dispose();
} }
else if (ex.Message.Contains("to start process 'node'")) else if (ex.Message.Contains("to start process 'node'"))
{ {
NotifyForm notifyForm = new NotifyForm("Node needs to be installed\nCheck logs for more details"); var notifyForm = new NotifyForm("Node needs to be installed\nCheck logs for more details");
notifyForm.ShowDialog(); notifyForm.ShowDialog();
notifyForm.Dispose(); notifyForm.Dispose();
} }
else if (ex.Message.Contains("to start process 'npm'")) else if (ex.Message.Contains("to start process 'npm'"))
{ {
NotifyForm notifyForm = new NotifyForm("NPM needs to be installed\nCheck logs for more details"); var notifyForm = new NotifyForm("NPM needs to be installed\nCheck logs for more details");
notifyForm.ShowDialog(); notifyForm.ShowDialog();
notifyForm.Dispose(); notifyForm.Dispose();
} }
else else
{ {
var notifyForm = new NotifyForm("Git/NPM Install FAILED\nCheck logs for more details");
NotifyForm notifyForm = new NotifyForm("Git/NPM Install FAILED\nCheck logs for more details");
notifyForm.ShowDialog(); notifyForm.ShowDialog();
notifyForm.Dispose(); notifyForm.Dispose();
} }
Environment.Exit(24); Environment.Exit(24);
} }
} }
public bool CheckNodeInstalled() public bool CheckNodeInstalled()
{ {
try try
{ {
// Create a new process to execute the 'node' command // Create a new process to execute the 'node' command
Process process = new Process(); var process = new Process();
process.StartInfo.FileName = "node"; process.StartInfo.FileName = "node";
process.StartInfo.Arguments = "--version"; process.StartInfo.Arguments = "--version";
process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardOutput = true;
@ -218,7 +225,7 @@ namespace FireWalletLite
// Start the process and read the output // Start the process and read the output
process.Start(); process.Start();
string output = process.StandardOutput.ReadToEnd(); var output = process.StandardOutput.ReadToEnd();
// Wait for the process to exit // Wait for the process to exit
process.WaitForExit(); process.WaitForExit();
@ -232,7 +239,6 @@ namespace FireWalletLite
return false; return false;
} }
} }
#endregion
} #endregion
} }

View File

@ -44,7 +44,6 @@
LoginButton = new Button(); LoginButton = new Button();
panelPortfolio = new Panel(); panelPortfolio = new Panel();
groupBoxHistory = new GroupBox(); groupBoxHistory = new GroupBox();
panelHistory = new Panel();
buttonRenew = new Button(); buttonRenew = new Button();
groupBoxDomains = new GroupBox(); groupBoxDomains = new GroupBox();
panelDomainList = new Panel(); panelDomainList = new Panel();
@ -59,7 +58,6 @@
((System.ComponentModel.ISupportInitialize)pictureBoxLogo).BeginInit(); ((System.ComponentModel.ISupportInitialize)pictureBoxLogo).BeginInit();
groupBoxLogin.SuspendLayout(); groupBoxLogin.SuspendLayout();
panelPortfolio.SuspendLayout(); panelPortfolio.SuspendLayout();
groupBoxHistory.SuspendLayout();
groupBoxDomains.SuspendLayout(); groupBoxDomains.SuspendLayout();
panelNav.SuspendLayout(); panelNav.SuspendLayout();
groupBoxAccount.SuspendLayout(); groupBoxAccount.SuspendLayout();
@ -195,7 +193,6 @@
// //
// groupBoxHistory // groupBoxHistory
// //
groupBoxHistory.Controls.Add(panelHistory);
groupBoxHistory.Location = new Point(102, 226); groupBoxHistory.Location = new Point(102, 226);
groupBoxHistory.Name = "groupBoxHistory"; groupBoxHistory.Name = "groupBoxHistory";
groupBoxHistory.Size = new Size(299, 293); groupBoxHistory.Size = new Size(299, 293);
@ -203,14 +200,6 @@
groupBoxHistory.TabStop = false; groupBoxHistory.TabStop = false;
groupBoxHistory.Text = "History"; groupBoxHistory.Text = "History";
// //
// panelHistory
//
panelHistory.Dock = DockStyle.Fill;
panelHistory.Location = new Point(3, 19);
panelHistory.Name = "panelHistory";
panelHistory.Size = new Size(293, 271);
panelHistory.TabIndex = 0;
//
// buttonRenew // buttonRenew
// //
buttonRenew.Enabled = false; buttonRenew.Enabled = false;
@ -331,7 +320,6 @@
groupBoxLogin.ResumeLayout(false); groupBoxLogin.ResumeLayout(false);
groupBoxLogin.PerformLayout(); groupBoxLogin.PerformLayout();
panelPortfolio.ResumeLayout(false); panelPortfolio.ResumeLayout(false);
groupBoxHistory.ResumeLayout(false);
groupBoxDomains.ResumeLayout(false); groupBoxDomains.ResumeLayout(false);
panelNav.ResumeLayout(false); panelNav.ResumeLayout(false);
groupBoxAccount.ResumeLayout(false); groupBoxAccount.ResumeLayout(false);
@ -365,6 +353,5 @@
private ToolStripStatusLabel LabelSyncWarning; private ToolStripStatusLabel LabelSyncWarning;
private ToolStripDropDownButton DropDownHelp; private ToolStripDropDownButton DropDownHelp;
private GroupBox groupBoxHistory; private GroupBox groupBoxHistory;
private Panel panelHistory;
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,25 +1,26 @@
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace FireWallet namespace FireWallet;
public partial class NotifyForm : Form
{ {
public partial class NotifyForm : Form private bool allowClose = true;
{ private readonly string altLink;
string dir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\FireWallet\\";
Dictionary<string, string> theme; private readonly string dir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
string altLink; "\\FireWallet\\";
bool Linkcopy;
bool allowClose = true; private readonly bool Linkcopy;
private Dictionary<string, string> theme;
public NotifyForm(string Message) public NotifyForm(string Message)
{ {
InitializeComponent(); InitializeComponent();
labelmessage.Text = Message; labelmessage.Text = Message;
altLink = ""; altLink = "";
} }
public void CloseNotification()
{
this.Close();
}
public NotifyForm(string Message, string altText, string altLink) public NotifyForm(string Message, string altText, string altLink)
{ {
InitializeComponent(); InitializeComponent();
@ -30,6 +31,7 @@ namespace FireWallet
buttonOK.Focus(); buttonOK.Focus();
Linkcopy = false; Linkcopy = false;
} }
public NotifyForm(string Message, bool allowClose) public NotifyForm(string Message, bool allowClose)
{ {
InitializeComponent(); InitializeComponent();
@ -51,72 +53,95 @@ namespace FireWallet
this.Linkcopy = Linkcopy; this.Linkcopy = Linkcopy;
if (Linkcopy) if (Linkcopy)
{
// Small font to fix more data // Small font to fix more data
labelmessage.Font = new Font(labelmessage.Font.FontFamily, 10); labelmessage.Font = new Font(labelmessage.Font.FontFamily, 10);
} }
public void CloseNotification()
{
Close();
} }
#region Theming private void NotifyForm_Load(object sender, EventArgs e)
private void UpdateTheme()
{ {
// Check if file exists UpdateTheme();
if (!Directory.Exists(dir))
{
CreateConfig(dir);
}
if (!File.Exists(dir + "theme.txt"))
{
CreateConfig(dir);
} }
// Read file private void OK_Click(object sender, EventArgs e)
StreamReader sr = new StreamReader(dir + "theme.txt");
theme = new Dictionary<string, string>();
while (!sr.EndOfStream)
{ {
string line = sr.ReadLine(); allowClose = true;
string[] split = line.Split(':'); Close();
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")) private void buttonALT_Click(object sender, EventArgs e)
{ {
if (Linkcopy)
{
// Copy link to clipboard
Clipboard.SetText(altLink);
return; return;
} }
// Open link
var psi = new ProcessStartInfo
{
FileName = altLink,
UseShellExecute = true
};
Process.Start(psi);
}
private void NotifyForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (!allowClose) e.Cancel = true;
}
#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
var sr = new StreamReader(dir + "theme.txt");
theme = new Dictionary<string, string>();
while (!sr.EndOfStream)
{
var line = sr.ReadLine();
var 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;
// Apply theme // Apply theme
this.BackColor = ColorTranslator.FromHtml(theme["background"]); BackColor = ColorTranslator.FromHtml(theme["background"]);
// Foreground // Foreground
this.ForeColor = ColorTranslator.FromHtml(theme["foreground"]); ForeColor = ColorTranslator.FromHtml(theme["foreground"]);
// Need to specify this for each groupbox to override the black text // Need to specify this for each groupbox to override the black text
foreach (Control c in Controls) foreach (Control c in Controls) ThemeControl(c);
{
ThemeControl(c);
}
// Transparancy // Transparancy
applyTransparency(theme); applyTransparency(theme);
} }
private void ThemeControl(Control c) private void ThemeControl(Control c)
{ {
if (c.GetType() == typeof(GroupBox) || c.GetType() == typeof(Panel)) if (c.GetType() == typeof(GroupBox) || c.GetType() == typeof(Panel))
{ {
c.ForeColor = ColorTranslator.FromHtml(theme["foreground"]); c.ForeColor = ColorTranslator.FromHtml(theme["foreground"]);
foreach (Control sub in c.Controls) foreach (Control sub in c.Controls) ThemeControl(sub);
{
ThemeControl(sub);
}
} }
if (c.GetType() == typeof(TextBox) || c.GetType() == typeof(Button) if (c.GetType() == typeof(TextBox) || c.GetType() == typeof(Button)
|| c.GetType() == typeof(ComboBox) || c.GetType() == typeof(StatusStrip)) || c.GetType() == typeof(ComboBox) || c.GetType() == typeof(StatusStrip))
{ {
@ -128,7 +153,6 @@ namespace FireWallet
private void applyTransparency(Dictionary<string, string> theme) private void applyTransparency(Dictionary<string, string> theme)
{ {
if (theme.ContainsKey("transparent-mode")) if (theme.ContainsKey("transparent-mode"))
{
switch (theme["transparent-mode"]) switch (theme["transparent-mode"])
{ {
case "mica": case "mica":
@ -147,38 +171,31 @@ namespace FireWallet
break; break;
case "key": case "key":
if (theme.ContainsKey("transparency-key")) if (theme.ContainsKey("transparency-key"))
{
switch (theme["transparency-key"]) switch (theme["transparency-key"])
{ {
case "alt": case "alt":
this.TransparencyKey = ColorTranslator.FromHtml(theme["background-alt"]); TransparencyKey = ColorTranslator.FromHtml(theme["background-alt"]);
break; break;
case "main": case "main":
this.TransparencyKey = ColorTranslator.FromHtml(theme["background"]); TransparencyKey = ColorTranslator.FromHtml(theme["background"]);
break; break;
default: default:
this.TransparencyKey = ColorTranslator.FromHtml(theme["transparency-key"]); TransparencyKey = ColorTranslator.FromHtml(theme["transparency-key"]);
break; break;
} }
}
break; break;
case "percent": case "percent":
if (theme.ContainsKey("transparency-percent")) if (theme.ContainsKey("transparency-percent"))
{
Opacity = Convert.ToDouble(theme["transparency-percent"]) / 100; Opacity = Convert.ToDouble(theme["transparency-percent"]) / 100;
}
break; break;
} }
} }
}
private void CreateConfig(string dir) private void CreateConfig(string dir)
{ {
if (!Directory.Exists(dir)) if (!Directory.Exists(dir)) Directory.CreateDirectory(dir);
{ var sw = new StreamWriter(dir + "theme.txt");
Directory.CreateDirectory(dir);
}
StreamWriter sw = new StreamWriter(dir + "theme.txt");
sw.WriteLine("background: #000000"); sw.WriteLine("background: #000000");
sw.WriteLine("foreground: #8e05c2"); sw.WriteLine("foreground: #8e05c2");
sw.WriteLine("background-alt: #3e065f"); sw.WriteLine("background-alt: #3e065f");
@ -188,7 +205,6 @@ namespace FireWallet
sw.WriteLine("transparency-percent: 90"); sw.WriteLine("transparency-percent: 90");
sw.Dispose(); sw.Dispose();
} }
// Required for mica effect // Required for mica effect
@ -228,39 +244,6 @@ namespace FireWallet
[DllImport("user32.dll")] [DllImport("user32.dll")]
internal static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttributeData data); internal static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttributeData data);
} }
#endregion #endregion
private void NotifyForm_Load(object sender, EventArgs e)
{
UpdateTheme();
}
private void OK_Click(object sender, EventArgs e)
{
allowClose = true;
this.Close();
}
private void buttonALT_Click(object sender, EventArgs e)
{
if (Linkcopy)
{
// Copy link to clipboard
Clipboard.SetText(altLink);
return;
}
// Open link
ProcessStartInfo psi = new ProcessStartInfo
{
FileName = altLink,
UseShellExecute = true
};
Process.Start(psi);
}
private void NotifyForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (!allowClose) e.Cancel = true;
}
}
} }

View File

@ -1,17 +1,16 @@
namespace FireWalletLite namespace FireWalletLite;
internal static class Program
{ {
internal static class Program
{
/// <summary> /// <summary>
/// The main entry point for the application. /// The main entry point for the application.
/// </summary> /// </summary>
[STAThread] [STAThread]
static void Main() private static void Main()
{ {
// To customize application configuration such as set high DPI settings or default font, // To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration. // see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize(); ApplicationConfiguration.Initialize();
Application.Run(new Loader()); Application.Run(new Loader());
} }
}
} }

View File

@ -1,42 +1,39 @@
using QRCoder; using QRCoder;
namespace FireWalletLite namespace FireWalletLite;
public partial class ReceiveForm : Form
{ {
public partial class ReceiveForm : Form private readonly string address;
{ private MainForm main;
string address;
MainForm main;
public ReceiveForm(string address, MainForm main) public ReceiveForm(string address, MainForm main)
{ {
InitializeComponent(); InitializeComponent();
this.address = address; this.address = address;
this.main = main; this.main = main;
// Theme form // Theme form
this.BackColor = ColorTranslator.FromHtml(main.Theme["background"]); BackColor = ColorTranslator.FromHtml(main.Theme["background"]);
this.ForeColor = ColorTranslator.FromHtml(main.Theme["foreground"]); ForeColor = ColorTranslator.FromHtml(main.Theme["foreground"]);
foreach (Control control in Controls) foreach (Control control in Controls) main.ThemeControl(control);
{
main.ThemeControl(control);
}
textBoxReceive.Text = address; textBoxReceive.Text = address;
textBoxReceive.Left = (this.ClientSize.Width - textBoxReceive.Width) / 2; textBoxReceive.Left = (ClientSize.Width - textBoxReceive.Width) / 2;
label1.Left = (this.ClientSize.Width - label1.Width) / 2; label1.Left = (ClientSize.Width - label1.Width) / 2;
buttonCopy.Left = (this.ClientSize.Width - buttonCopy.Width) / 2; buttonCopy.Left = (ClientSize.Width - buttonCopy.Width) / 2;
var qrcode = new QRCodeGenerator();
QRCodeGenerator qrcode = new QRCodeGenerator(); var qrData = qrcode.CreateQrCode(address, QRCodeGenerator.ECCLevel.Q);
QRCodeData qrData = qrcode.CreateQrCode(address, QRCodeGenerator.ECCLevel.Q); var qrCode = new QRCode(qrData);
QRCode qrCode = new QRCode(qrData);
pictureBoxReceiveQR.Image = qrCode.GetGraphic(20, main.Theme["foreground"], main.Theme["background"]); pictureBoxReceiveQR.Image = qrCode.GetGraphic(20, main.Theme["foreground"], main.Theme["background"]);
pictureBoxReceiveQR.SizeMode = PictureBoxSizeMode.Zoom; pictureBoxReceiveQR.SizeMode = PictureBoxSizeMode.Zoom;
pictureBoxReceiveQR.Width = this.ClientSize.Width / 2; pictureBoxReceiveQR.Width = ClientSize.Width / 2;
pictureBoxReceiveQR.Height = this.ClientSize.Width / 2; pictureBoxReceiveQR.Height = ClientSize.Width / 2;
pictureBoxReceiveQR.Left = (this.ClientSize.Width - pictureBoxReceiveQR.Width) / 2; pictureBoxReceiveQR.Left = (ClientSize.Width - pictureBoxReceiveQR.Width) / 2;
} }
private void buttonCopy_Click(object sender, EventArgs e) private void buttonCopy_Click(object sender, EventArgs e)
{ {
Clipboard.SetText(address); Clipboard.SetText(address);
} }
}
} }

View File

@ -1,61 +1,56 @@
using FireWallet; using FireWallet;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
namespace FireWalletLite namespace FireWalletLite;
public partial class SendForm : Form
{ {
public partial class SendForm : Form private readonly int fee = 1;
{ private readonly MainForm main;
int fee = 1; private readonly decimal unlockedbalance;
decimal unlockedbalance;
MainForm main;
public SendForm(decimal Unlockedbalance, MainForm main) public SendForm(decimal Unlockedbalance, MainForm main)
{ {
InitializeComponent(); InitializeComponent();
this.main = main; this.main = main;
this.unlockedbalance = Unlockedbalance; unlockedbalance = Unlockedbalance;
// Theme form // Theme form
this.BackColor = ColorTranslator.FromHtml(main.Theme["background"]); BackColor = ColorTranslator.FromHtml(main.Theme["background"]);
this.ForeColor = ColorTranslator.FromHtml(main.Theme["foreground"]); ForeColor = ColorTranslator.FromHtml(main.Theme["foreground"]);
foreach (Control control in Controls) foreach (Control control in Controls) main.ThemeControl(control);
{
main.ThemeControl(control);
}
labelMax.Text = "Max: " + (unlockedbalance - fee).ToString() + " HNS"; labelMax.Text = "Max: " + (unlockedbalance - fee) + " HNS";
if (unlockedbalance < fee) if (unlockedbalance < fee) labelMax.Text = "Max: 0 HNS";
{
labelMax.Text = "Max: 0 HNS";
//buttonSend.Enabled = false; //buttonSend.Enabled = false;
}
// Allign controls // Allign controls
labelAddress.Left = (this.ClientSize.Width - labelAddress.Width) / 2; labelAddress.Left = (ClientSize.Width - labelAddress.Width) / 2;
labelAmount.Left = (this.ClientSize.Width - labelAmount.Width) / 2; labelAmount.Left = (ClientSize.Width - labelAmount.Width) / 2;
textBoxAddress.Left = (this.ClientSize.Width - textBoxAddress.Width) / 2; textBoxAddress.Left = (ClientSize.Width - textBoxAddress.Width) / 2;
labelMax.Left = (this.ClientSize.Width - labelMax.Width) / 2; labelMax.Left = (ClientSize.Width - labelMax.Width) / 2;
textBoxAmount.Left = (this.ClientSize.Width - textBoxAmount.Width - labelHNSToken.Width - 10) / 2; textBoxAmount.Left = (ClientSize.Width - textBoxAmount.Width - labelHNSToken.Width - 10) / 2;
labelHNSToken.Left = textBoxAmount.Left + textBoxAmount.Width + 10; labelHNSToken.Left = textBoxAmount.Left + textBoxAmount.Width + 10;
buttonSend.Left = (this.ClientSize.Width - buttonSend.Width) / 2; buttonSend.Left = (ClientSize.Width - buttonSend.Width) / 2;
} }
private async void buttonSend_Click(object sender, EventArgs e) private async void buttonSend_Click(object sender, EventArgs e)
{ {
buttonSend.Enabled = false; buttonSend.Enabled = false;
string address = textBoxAddress.Text; var address = textBoxAddress.Text;
if (textBoxAddress.Text.Substring(0,1) == "@") if (textBoxAddress.Text.Substring(0, 1) == "@")
{ {
// HIP-02 not supported yet // HIP-02 not supported yet
NotifyForm notify = new NotifyForm("HIP-02 not supported yet"); var notify = new NotifyForm("HIP-02 not supported yet");
notify.ShowDialog(); notify.ShowDialog();
notify.Dispose(); notify.Dispose();
buttonSend.Enabled = true; buttonSend.Enabled = true;
return; return;
} }
bool valid = await main.ValidAddress(address);
var valid = await main.ValidAddress(address);
if (!valid) if (!valid)
{ {
NotifyForm notify = new NotifyForm("Invalid address"); var notify = new NotifyForm("Invalid address");
notify.ShowDialog(); notify.ShowDialog();
notify.Dispose(); notify.Dispose();
buttonSend.Enabled = true; buttonSend.Enabled = true;
@ -65,42 +60,43 @@ namespace FireWalletLite
decimal amount = 0; decimal amount = 0;
if (!decimal.TryParse(textBoxAmount.Text, out amount)) if (!decimal.TryParse(textBoxAmount.Text, out amount))
{ {
NotifyForm notify = new NotifyForm("Invalid amount"); var notify = new NotifyForm("Invalid amount");
notify.ShowDialog();
notify.Dispose();
return;
}
if (amount > unlockedbalance - fee)
{
NotifyForm notify = new NotifyForm("Insufficient balance");
notify.ShowDialog(); notify.ShowDialog();
notify.Dispose(); notify.Dispose();
return; return;
} }
string content = "{\"method\": \"sendtoaddress\",\"params\": [ \"" + address + "\", " + if (amount > unlockedbalance - fee)
amount.ToString() + "]}"; {
string output = await main.APIPost("", true, content); var notify = new NotifyForm("Insufficient balance");
JObject APIresp = JObject.Parse(output); notify.ShowDialog();
notify.Dispose();
return;
}
var content = "{\"method\": \"sendtoaddress\",\"params\": [ \"" + address + "\", " +
amount + "]}";
var output = await main.APIPost("", true, content);
var APIresp = JObject.Parse(output);
if (APIresp["error"].ToString() != "") if (APIresp["error"].ToString() != "")
{ {
main.AddLog("Failed:"); main.AddLog("Failed:");
main.AddLog(APIresp.ToString()); main.AddLog(APIresp.ToString());
JObject error = JObject.Parse(APIresp["error"].ToString()); var error = JObject.Parse(APIresp["error"].ToString());
string ErrorMessage = error["message"].ToString(); var ErrorMessage = error["message"].ToString();
NotifyForm notify = new NotifyForm("Error Transaction Failed\n" + ErrorMessage); var notify = new NotifyForm("Error Transaction Failed\n" + ErrorMessage);
notify.ShowDialog(); notify.ShowDialog();
notify.Dispose(); notify.Dispose();
return; return;
} }
string hash = APIresp["result"].ToString();
string link = main.TXExplorer + hash; var hash = APIresp["result"].ToString();
NotifyForm notifySuccess = new NotifyForm("Transaction Sent\nThis transaction could take up to 20 minutes to mine", var link = main.TXExplorer + hash;
var notifySuccess = new NotifyForm("Transaction Sent\nThis transaction could take up to 20 minutes to mine",
"Explorer", link); "Explorer", link);
notifySuccess.ShowDialog(); notifySuccess.ShowDialog();
notifySuccess.Dispose(); notifySuccess.Dispose();
this.Close(); Close();
}
} }
} }

View File

@ -1,27 +1,28 @@
using System.Diagnostics; using System.Diagnostics;
using System.Drawing.Imaging; using System.Drawing.Imaging;
namespace FireWallet;
namespace FireWallet public partial class SplashScreen : Form
{ {
public partial class SplashScreen : Form private bool close;
{ private float opacity;
private Bitmap splash;
public SplashScreen(bool timer) public SplashScreen(bool timer)
{ {
InitializeComponent(); InitializeComponent();
close = false; close = false;
IsClosed = false; IsClosed = false;
} }
bool close;
float opacity = 0.0f; public bool IsClosed { get; set; }
private void SplashScreen_FormClosing(object sender, FormClosingEventArgs e) private void SplashScreen_FormClosing(object sender, FormClosingEventArgs e)
{ {
if (!close) if (!close) e.Cancel = true;
{
e.Cancel = true;
} }
}
public bool IsClosed { get; set; }
public void CloseSplash() public void CloseSplash()
{ {
close = true; close = true;
@ -30,37 +31,41 @@ namespace FireWallet
timerIn.Stop(); timerIn.Stop();
timerOut.Start(); timerOut.Start();
} }
private void label2_Click(object sender, EventArgs e) private void label2_Click(object sender, EventArgs e)
{ {
ProcessStartInfo psi = new ProcessStartInfo var psi = new ProcessStartInfo
{ {
FileName = "https://nathan.woodburn.au", FileName = "https://nathan.woodburn.au",
UseShellExecute = true UseShellExecute = true
}; };
Process.Start(psi); Process.Start(psi);
} }
Bitmap splash;
//new Bitmap(Properties.Resources.FWSplash); //new Bitmap(Properties.Resources.FWSplash);
private void SplashScreen_Load(object sender, EventArgs e) private void SplashScreen_Load(object sender, EventArgs e)
{ {
splash = pictureBoxNew.Image as Bitmap; splash = pictureBoxNew.Image as Bitmap;
pictureBoxNew.Visible = true; pictureBoxNew.Visible = true;
this.TransparencyKey = Color.FromArgb(0, 0, 0); TransparencyKey = Color.FromArgb(0, 0, 0);
pictureBoxNew.Invalidate(); pictureBoxNew.Invalidate();
} }
public Image SetImageOpacity(Image image, float opacity) public Image SetImageOpacity(Image image, float opacity)
{ {
try try
{ {
Bitmap bmp = new Bitmap(image.Width, image.Height); var bmp = new Bitmap(image.Width, image.Height);
using (Graphics gfx = Graphics.FromImage(bmp)) using (var gfx = Graphics.FromImage(bmp))
{ {
ColorMatrix matrix = new ColorMatrix(); var matrix = new ColorMatrix();
matrix.Matrix33 = opacity; matrix.Matrix33 = opacity;
ImageAttributes attributes = new ImageAttributes(); var attributes = new ImageAttributes();
attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
gfx.DrawImage(image, new Rectangle(0, 0, bmp.Width, bmp.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, attributes); gfx.DrawImage(image, new Rectangle(0, 0, bmp.Width, bmp.Height), 0, 0, image.Width, image.Height,
GraphicsUnit.Pixel, attributes);
} }
return bmp; return bmp;
} }
catch catch
@ -68,6 +73,7 @@ namespace FireWallet
return null; return null;
} }
} }
private void timerIn_Tick(object sender, EventArgs e) private void timerIn_Tick(object sender, EventArgs e)
{ {
if (opacity >= 1) if (opacity >= 1)
@ -75,22 +81,24 @@ namespace FireWallet
timerIn.Stop(); timerIn.Stop();
return; return;
} }
opacity += 0.05f; opacity += 0.05f;
pictureBoxNew.Image = SetImageOpacity(splash, opacity); pictureBoxNew.Image = SetImageOpacity(splash, opacity);
pictureBoxNew.Invalidate(); pictureBoxNew.Invalidate();
} }
private void timerOut_Tick(object sender, EventArgs e) private void timerOut_Tick(object sender, EventArgs e)
{ {
if (opacity <= 0) if (opacity <= 0)
{ {
timerOut.Stop(); timerOut.Stop();
IsClosed = true; IsClosed = true;
this.Close(); Close();
return; return;
} }
opacity -= 0.05f; opacity -= 0.05f;
pictureBoxNew.Image = SetImageOpacity(splash, opacity); pictureBoxNew.Image = SetImageOpacity(splash, opacity);
pictureBoxNew.Invalidate(); pictureBoxNew.Invalidate();
} }
}
} }