diff --git a/FireWallet/CreateForm.Designer.cs b/FireWallet/CreateForm.Designer.cs
new file mode 100644
index 0000000..cba3b36
--- /dev/null
+++ b/FireWallet/CreateForm.Designer.cs
@@ -0,0 +1,190 @@
+namespace FireWallet
+{
+ partial class CreateForm
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ labelWelcome = new Label();
+ groupBoxNode = new GroupBox();
+ labelNodeStatus = new Label();
+ comboBoxNodeNetwork = new ComboBox();
+ buttonSave = new Button();
+ buttonNodeTest = new Button();
+ textBoxNodeKey = new TextBox();
+ textBoxNodeIP = new TextBox();
+ labelNodeKey = new Label();
+ labelNodeNetowrk = new Label();
+ labelNodeIP = new Label();
+ groupBoxNode.SuspendLayout();
+ SuspendLayout();
+ //
+ // labelWelcome
+ //
+ labelWelcome.AutoSize = true;
+ labelWelcome.Font = new Font("Segoe UI", 18F, FontStyle.Bold, GraphicsUnit.Point);
+ labelWelcome.Location = new Point(12, 9);
+ labelWelcome.Name = "labelWelcome";
+ labelWelcome.Size = new Size(358, 64);
+ labelWelcome.TabIndex = 0;
+ labelWelcome.Text = "Welcome to Fire Wallet\r\nPlease add your node settings";
+ labelWelcome.TextAlign = ContentAlignment.TopCenter;
+ //
+ // groupBoxNode
+ //
+ groupBoxNode.Controls.Add(labelNodeStatus);
+ groupBoxNode.Controls.Add(comboBoxNodeNetwork);
+ groupBoxNode.Controls.Add(buttonSave);
+ groupBoxNode.Controls.Add(buttonNodeTest);
+ groupBoxNode.Controls.Add(textBoxNodeKey);
+ groupBoxNode.Controls.Add(textBoxNodeIP);
+ groupBoxNode.Controls.Add(labelNodeKey);
+ groupBoxNode.Controls.Add(labelNodeNetowrk);
+ groupBoxNode.Controls.Add(labelNodeIP);
+ groupBoxNode.Location = new Point(12, 92);
+ groupBoxNode.Name = "groupBoxNode";
+ groupBoxNode.Size = new Size(402, 163);
+ groupBoxNode.TabIndex = 1;
+ groupBoxNode.TabStop = false;
+ groupBoxNode.Text = "Node";
+ //
+ // labelNodeStatus
+ //
+ labelNodeStatus.AutoSize = true;
+ labelNodeStatus.Location = new Point(87, 138);
+ labelNodeStatus.Name = "labelNodeStatus";
+ labelNodeStatus.Size = new Size(88, 15);
+ labelNodeStatus.TabIndex = 9;
+ labelNodeStatus.Text = "Not Connected";
+ //
+ // comboBoxNodeNetwork
+ //
+ comboBoxNodeNetwork.FlatStyle = FlatStyle.Popup;
+ comboBoxNodeNetwork.FormattingEnabled = true;
+ comboBoxNodeNetwork.Items.AddRange(new object[] { "Mainnet", "Regtest" });
+ comboBoxNodeNetwork.Location = new Point(62, 45);
+ comboBoxNodeNetwork.Name = "comboBoxNodeNetwork";
+ comboBoxNodeNetwork.Size = new Size(121, 23);
+ comboBoxNodeNetwork.TabIndex = 8;
+ comboBoxNodeNetwork.Text = "Mainnet";
+ //
+ // buttonSave
+ //
+ buttonSave.FlatStyle = FlatStyle.Flat;
+ buttonSave.Location = new Point(314, 134);
+ buttonSave.Name = "buttonSave";
+ buttonSave.Size = new Size(75, 23);
+ buttonSave.TabIndex = 7;
+ buttonSave.Text = "Finish";
+ buttonSave.UseVisualStyleBackColor = true;
+ buttonSave.Click += SaveSettings;
+ //
+ // buttonNodeTest
+ //
+ buttonNodeTest.FlatStyle = FlatStyle.Flat;
+ buttonNodeTest.Location = new Point(6, 134);
+ buttonNodeTest.Name = "buttonNodeTest";
+ buttonNodeTest.Size = new Size(75, 23);
+ buttonNodeTest.TabIndex = 6;
+ buttonNodeTest.Text = "Test";
+ buttonNodeTest.UseVisualStyleBackColor = true;
+ buttonNodeTest.Click += TestAPI;
+ //
+ // textBoxNodeKey
+ //
+ textBoxNodeKey.Location = new Point(62, 71);
+ textBoxNodeKey.Name = "textBoxNodeKey";
+ textBoxNodeKey.Size = new Size(327, 23);
+ textBoxNodeKey.TabIndex = 5;
+ //
+ // textBoxNodeIP
+ //
+ textBoxNodeIP.Location = new Point(62, 16);
+ textBoxNodeIP.Name = "textBoxNodeIP";
+ textBoxNodeIP.Size = new Size(327, 23);
+ textBoxNodeIP.TabIndex = 3;
+ textBoxNodeIP.Text = "127.0.0.1";
+ //
+ // labelNodeKey
+ //
+ labelNodeKey.AutoSize = true;
+ labelNodeKey.Location = new Point(6, 74);
+ labelNodeKey.Name = "labelNodeKey";
+ labelNodeKey.Size = new Size(50, 15);
+ labelNodeKey.TabIndex = 2;
+ labelNodeKey.Text = "API Key:";
+ //
+ // labelNodeNetowrk
+ //
+ labelNodeNetowrk.AutoSize = true;
+ labelNodeNetowrk.Location = new Point(6, 48);
+ labelNodeNetowrk.Name = "labelNodeNetowrk";
+ labelNodeNetowrk.Size = new Size(32, 15);
+ labelNodeNetowrk.TabIndex = 1;
+ labelNodeNetowrk.Text = "Port:";
+ //
+ // labelNodeIP
+ //
+ labelNodeIP.AutoSize = true;
+ labelNodeIP.Location = new Point(6, 19);
+ labelNodeIP.Name = "labelNodeIP";
+ labelNodeIP.Size = new Size(20, 15);
+ labelNodeIP.TabIndex = 0;
+ labelNodeIP.Text = "IP:";
+ //
+ // CreateForm
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(438, 281);
+ Controls.Add(groupBoxNode);
+ Controls.Add(labelWelcome);
+ FormBorderStyle = FormBorderStyle.Fixed3D;
+ Name = "CreateForm";
+ Text = "Setup";
+ Load += CreateForm_Load;
+ Resize += CreateForm_Resize;
+ groupBoxNode.ResumeLayout(false);
+ groupBoxNode.PerformLayout();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private Label labelWelcome;
+ private GroupBox groupBoxNode;
+ private TextBox textBoxNodeKey;
+ private TextBox textBoxNodeIP;
+ private Label labelNodeKey;
+ private Label labelNodeNetowrk;
+ private Label labelNodeIP;
+ private Button buttonNodeTest;
+ private Button buttonSave;
+ private ComboBox comboBoxNodeNetwork;
+ private Label labelNodeStatus;
+ }
+}
\ No newline at end of file
diff --git a/FireWallet/CreateForm.cs b/FireWallet/CreateForm.cs
new file mode 100644
index 0000000..8bb0b0d
--- /dev/null
+++ b/FireWallet/CreateForm.cs
@@ -0,0 +1,295 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Net.Http;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using System.Xml.Linq;
+
+namespace FireWallet
+{
+ public partial class CreateForm : Form
+ {
+ string dir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\FireWallet\\";
+ public CreateForm()
+ {
+ InitializeComponent();
+ }
+ private void CreateForm_Load(object sender, EventArgs e)
+ {
+ AddLog("Starting Setup");
+ UpdateTheme();
+ SizeForm();
+ }
+
+ #region API
+ async void TestAPI(object sender, EventArgs e)
+ {
+ // This will curl the below URL and return the result
+ //curl http://x:api-key@127.0.0.1:12039/wallet/$id/account
+
+ string key = textBoxNodeKey.Text;
+ string ip = textBoxNodeIP.Text;
+ int network = comboBoxNodeNetwork.SelectedIndex;
+ string port = "1203";
+ if (network == 1)
+ {
+ port = "1303";
+ }
+
+
+
+ // Create HTTP client
+ HttpClient httpClient = new HttpClient();
+
+ AddLog("Testing: http://x:" + key + "@" + ip + " Network:" + comboBoxNodeNetwork.Text);
+ try
+ {
+ HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://" + ip + ":" + port + "7");
+ // Add API key to header
+ request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes("x:" + key)));
+ // Send request and log response
+ HttpResponseMessage response = await httpClient.SendAsync(request);
+ response.EnsureSuccessStatusCode();
+ AddLog("Node Connected");
+ labelNodeStatus.Text = "Node Connected";
+ }
+ // Log errors to log textbox
+ catch (Exception ex)
+ {
+ AddLog("Node Failed: " + ex.Message);
+ labelNodeStatus.Text = "Node Connection failed";
+ }
+ }
+
+ #endregion
+
+ #region Logging
+ private void AddLog(string message)
+ {
+ StreamWriter sw = new StreamWriter(dir + "log.txt", true);
+ sw.WriteLine(DateTime.Now.ToString() + ": " + message);
+ sw.Dispose();
+ }
+ #endregion
+ #region Theming
+ private void UpdateTheme()
+ {
+ // Check if file exists
+ if (!Directory.Exists(dir))
+ {
+ CreateConfig(dir);
+ }
+ if (!File.Exists(dir + "theme.txt"))
+ {
+ CreateConfig(dir);
+ }
+
+ AddLog("Reading theme file");
+ // Read file
+ StreamReader sr = new StreamReader(dir + "theme.txt");
+ Dictionary theme = new Dictionary();
+ 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"))
+ {
+ AddLog("Theme file is missing key");
+ return;
+ }
+
+ // Apply theme
+ this.BackColor = ColorTranslator.FromHtml(theme["background"]);
+
+ // Foreground
+ this.ForeColor = ColorTranslator.FromHtml(theme["foreground"]);
+
+
+ // Need to specify this for each groupbox to override the black text
+ foreach (Control c in Controls)
+ {
+ if (c.GetType() == typeof(GroupBox))
+ {
+ c.ForeColor = ColorTranslator.FromHtml(theme["foreground"]);
+ foreach (Control sub in c.Controls)
+ {
+ if (sub.GetType() == typeof(TextBox) || sub.GetType() == typeof(Button)
+ || sub.GetType() == typeof(ComboBox))
+ {
+ sub.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]);
+ sub.BackColor = ColorTranslator.FromHtml(theme["background-alt"]);
+ }
+
+ }
+ }
+ if (c.GetType() == typeof(TextBox) || c.GetType() == typeof(Button)
+ || c.GetType() == typeof(ComboBox))
+ {
+ c.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]);
+ c.BackColor = ColorTranslator.FromHtml(theme["background-alt"]);
+ }
+ }
+
+
+
+
+ // Transparancy
+
+ AddLog("Finished applying theme");
+ AddLog("Applying transparency");
+ applyTransparency(theme);
+
+
+ }
+
+ private void applyTransparency(Dictionary theme)
+ {
+ if (theme.ContainsKey("transparent-mode"))
+ {
+ switch (theme["transparent-mode"])
+ {
+ case "mica":
+ var accent = new AccentPolicy { AccentState = AccentState.ACCENT_ENABLE_BLURBEHIND };
+ var accentStructSize = Marshal.SizeOf(accent);
+ var accentPtr = Marshal.AllocHGlobal(accentStructSize);
+ Marshal.StructureToPtr(accent, accentPtr, false);
+ var data = new WindowCompositionAttributeData
+ {
+ Attribute = WindowCompositionAttribute.WCA_ACCENT_POLICY,
+ SizeOfData = accentStructSize,
+ Data = accentPtr
+ };
+ User32.SetWindowCompositionAttribute(Handle, ref data);
+ Marshal.FreeHGlobal(accentPtr);
+ break;
+ case "key":
+ if (theme.ContainsKey("transparency-key"))
+ {
+ switch (theme["transparency-key"])
+ {
+ case "alt":
+ this.TransparencyKey = ColorTranslator.FromHtml(theme["background-alt"]);
+ break;
+ case "main":
+ this.TransparencyKey = ColorTranslator.FromHtml(theme["background"]);
+ break;
+ default:
+ this.TransparencyKey = ColorTranslator.FromHtml(theme["transparency-key"]);
+ break;
+ }
+ }
+ else
+ {
+ AddLog("No transparency-key found in theme file");
+ }
+ break;
+ case "percent":
+ if (theme.ContainsKey("transparency-percent"))
+ {
+ Opacity = Convert.ToDouble(theme["transparency-percent"]) / 100;
+ }
+ else
+ {
+ AddLog("No transparency-percent found in theme file");
+ }
+ break;
+ }
+ }
+ }
+
+ 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();
+ AddLog("Created theme file");
+ }
+
+ // Required for mica effect
+ internal enum AccentState
+ {
+ ACCENT_DISABLED = 0,
+ ACCENT_ENABLE_GRADIENT = 1,
+ ACCENT_ENABLE_TRANSPARENTGRADIENT = 2,
+ ACCENT_ENABLE_BLURBEHIND = 3,
+ ACCENT_INVALID_STATE = 4
+ }
+
+ internal enum WindowCompositionAttribute
+ {
+ WCA_ACCENT_POLICY = 19
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct AccentPolicy
+ {
+ public AccentState AccentState;
+ public int AccentFlags;
+ public int GradientColor;
+ public int AnimationId;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct WindowCompositionAttributeData
+ {
+ public WindowCompositionAttribute Attribute;
+ public IntPtr Data;
+ public int SizeOfData;
+ }
+
+ internal static class User32
+ {
+ [DllImport("user32.dll")]
+ internal static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttributeData data);
+ }
+ #endregion
+ #region Sizing
+ private void CreateForm_Resize(object sender, EventArgs e)
+ {
+ SizeForm();
+ }
+ private void SizeForm()
+ {
+ labelWelcome.Left = (this.ClientSize.Width - labelWelcome.Size.Width) / 2;
+ }
+ #endregion
+
+
+ private void SaveSettings(object sender, EventArgs e)
+ {
+ buttonNodeTest.PerformClick();
+
+ if (labelNodeStatus.Text != "Node Connected")
+ {
+ return;
+ }
+ StreamWriter sw = new StreamWriter(dir + "node.txt");
+ sw.WriteLine("IP: " + textBoxNodeIP.Text);
+ sw.WriteLine("Network: " + comboBoxNodeNetwork.SelectedIndex);
+ sw.WriteLine("Key: " + textBoxNodeKey.Text);
+ sw.Dispose();
+ this.Close();
+ }
+ }
+}
diff --git a/FireWallet/Form1.resx b/FireWallet/CreateForm.resx
similarity index 93%
rename from FireWallet/Form1.resx
rename to FireWallet/CreateForm.resx
index 1af7de1..a395bff 100644
--- a/FireWallet/Form1.resx
+++ b/FireWallet/CreateForm.resx
@@ -1,24 +1,24 @@
-
diff --git a/FireWallet/Form1.Designer.cs b/FireWallet/Form1.Designer.cs
deleted file mode 100644
index a6602bd..0000000
--- a/FireWallet/Form1.Designer.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-namespace FireWallet
-{
- partial class Form1
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.components = new System.ComponentModel.Container();
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(800, 450);
- this.Text = "Form1";
- }
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/FireWallet/Form1.cs b/FireWallet/Form1.cs
deleted file mode 100644
index 4e5a416..0000000
--- a/FireWallet/Form1.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace FireWallet
-{
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- }
-}
\ No newline at end of file
diff --git a/FireWallet/MainForm.Designer.cs b/FireWallet/MainForm.Designer.cs
new file mode 100644
index 0000000..1bcf042
--- /dev/null
+++ b/FireWallet/MainForm.Designer.cs
@@ -0,0 +1,212 @@
+namespace FireWallet
+{
+ partial class MainForm
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ components = new System.ComponentModel.Container();
+ statusStripmain = new StatusStrip();
+ toolStripStatusLabelNetwork = new ToolStripStatusLabel();
+ toolStripStatusLabelstatus = new ToolStripStatusLabel();
+ timerNodeStatus = new System.Windows.Forms.Timer(components);
+ panelaccount = new Panel();
+ groupBoxaccount = new GroupBox();
+ label1 = new Label();
+ comboBoxusername = new ComboBox();
+ textBox1 = new TextBox();
+ button2 = new Button();
+ labelaccountpassword = new Label();
+ labelaccountusername = new Label();
+ button1 = new Button();
+ statusStripmain.SuspendLayout();
+ panelaccount.SuspendLayout();
+ groupBoxaccount.SuspendLayout();
+ SuspendLayout();
+ //
+ // statusStripmain
+ //
+ statusStripmain.Dock = DockStyle.Top;
+ statusStripmain.Items.AddRange(new ToolStripItem[] { toolStripStatusLabelNetwork, toolStripStatusLabelstatus });
+ statusStripmain.Location = new Point(0, 0);
+ statusStripmain.Name = "statusStripmain";
+ statusStripmain.Size = new Size(1074, 22);
+ statusStripmain.SizingGrip = false;
+ statusStripmain.TabIndex = 0;
+ statusStripmain.Text = "statusStrip1";
+ //
+ // toolStripStatusLabelNetwork
+ //
+ toolStripStatusLabelNetwork.Margin = new Padding(0, 3, 50, 2);
+ toolStripStatusLabelNetwork.Name = "toolStripStatusLabelNetwork";
+ toolStripStatusLabelNetwork.Size = new Size(58, 17);
+ toolStripStatusLabelNetwork.Text = "Network: ";
+ //
+ // toolStripStatusLabelstatus
+ //
+ toolStripStatusLabelstatus.Margin = new Padding(0, 3, 50, 2);
+ toolStripStatusLabelstatus.Name = "toolStripStatusLabelstatus";
+ toolStripStatusLabelstatus.Size = new Size(126, 17);
+ toolStripStatusLabelstatus.Text = "Status: Not Connected";
+ //
+ // timerNodeStatus
+ //
+ timerNodeStatus.Enabled = true;
+ timerNodeStatus.Interval = 10000;
+ timerNodeStatus.Tick += timerNodeStatus_Tick;
+ //
+ // panelaccount
+ //
+ panelaccount.BackColor = Color.Transparent;
+ panelaccount.Controls.Add(groupBoxaccount);
+ panelaccount.Dock = DockStyle.Fill;
+ panelaccount.Location = new Point(0, 22);
+ panelaccount.Name = "panelaccount";
+ panelaccount.Size = new Size(1074, 642);
+ panelaccount.TabIndex = 1;
+ //
+ // groupBoxaccount
+ //
+ groupBoxaccount.Controls.Add(label1);
+ groupBoxaccount.Controls.Add(comboBoxusername);
+ groupBoxaccount.Controls.Add(textBox1);
+ groupBoxaccount.Controls.Add(button2);
+ groupBoxaccount.Controls.Add(labelaccountpassword);
+ groupBoxaccount.Controls.Add(labelaccountusername);
+ groupBoxaccount.Controls.Add(button1);
+ groupBoxaccount.FlatStyle = FlatStyle.Popup;
+ groupBoxaccount.Location = new Point(458, 155);
+ groupBoxaccount.Name = "groupBoxaccount";
+ groupBoxaccount.Size = new Size(308, 241);
+ groupBoxaccount.TabIndex = 5;
+ groupBoxaccount.TabStop = false;
+ groupBoxaccount.Text = "Login";
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Font = new Font("Segoe UI", 15.75F, FontStyle.Regular, GraphicsUnit.Point);
+ label1.Location = new Point(6, 19);
+ label1.Name = "label1";
+ label1.Size = new Size(281, 30);
+ label1.TabIndex = 7;
+ label1.Text = "Please Login to your account";
+ //
+ // comboBoxusername
+ //
+ comboBoxusername.FlatStyle = FlatStyle.Popup;
+ comboBoxusername.FormattingEnabled = true;
+ comboBoxusername.Location = new Point(97, 67);
+ comboBoxusername.Name = "comboBoxusername";
+ comboBoxusername.Size = new Size(190, 23);
+ comboBoxusername.TabIndex = 6;
+ //
+ // textBox1
+ //
+ textBox1.Location = new Point(97, 101);
+ textBox1.Name = "textBox1";
+ textBox1.Size = new Size(190, 23);
+ textBox1.TabIndex = 5;
+ textBox1.UseSystemPasswordChar = true;
+ //
+ // button2
+ //
+ button2.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
+ button2.Location = new Point(188, 164);
+ button2.Name = "button2";
+ button2.Size = new Size(99, 41);
+ button2.TabIndex = 3;
+ button2.Text = "button2";
+ button2.UseVisualStyleBackColor = true;
+ //
+ // labelaccountpassword
+ //
+ labelaccountpassword.AutoSize = true;
+ labelaccountpassword.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
+ labelaccountpassword.Location = new Point(12, 103);
+ labelaccountpassword.Name = "labelaccountpassword";
+ labelaccountpassword.Size = new Size(79, 21);
+ labelaccountpassword.TabIndex = 4;
+ labelaccountpassword.Text = "Password:";
+ //
+ // labelaccountusername
+ //
+ labelaccountusername.AutoSize = true;
+ labelaccountusername.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
+ labelaccountusername.Location = new Point(12, 67);
+ labelaccountusername.Name = "labelaccountusername";
+ labelaccountusername.Size = new Size(69, 21);
+ labelaccountusername.TabIndex = 1;
+ labelaccountusername.Text = "Account:";
+ //
+ // button1
+ //
+ button1.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
+ button1.Location = new Point(6, 164);
+ button1.Name = "button1";
+ button1.Size = new Size(99, 41);
+ button1.TabIndex = 2;
+ button1.Text = "button1";
+ button1.UseVisualStyleBackColor = true;
+ //
+ // MainForm
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(1074, 664);
+ Controls.Add(panelaccount);
+ Controls.Add(statusStripmain);
+ Name = "MainForm";
+ Text = "FireWallet";
+ FormClosing += MainForm_Closing;
+ Load += MainForm_Load;
+ Resize += Form1_Resize;
+ statusStripmain.ResumeLayout(false);
+ statusStripmain.PerformLayout();
+ panelaccount.ResumeLayout(false);
+ groupBoxaccount.ResumeLayout(false);
+ groupBoxaccount.PerformLayout();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private StatusStrip statusStripmain;
+ private ToolStripStatusLabel toolStripStatusLabelNetwork;
+ private ToolStripStatusLabel toolStripStatusLabelstatus;
+ private System.Windows.Forms.Timer timerNodeStatus;
+ private Panel panelaccount;
+ private Button button2;
+ private Button button1;
+ private Label labelaccountusername;
+ private Label labelaccountpassword;
+ private GroupBox groupBoxaccount;
+ private Label label1;
+ private ComboBox comboBoxusername;
+ private TextBox textBox1;
+ }
+}
\ No newline at end of file
diff --git a/FireWallet/MainForm.cs b/FireWallet/MainForm.cs
new file mode 100644
index 0000000..8e2ee92
--- /dev/null
+++ b/FireWallet/MainForm.cs
@@ -0,0 +1,340 @@
+using System.Runtime.InteropServices;
+
+namespace FireWallet
+{
+ public partial class MainForm : Form
+ {
+ #region Variables
+ string dir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\FireWallet\\";
+ Dictionary nodeSettings;
+ Dictionary theme;
+ int Network;
+
+ #endregion
+ #region Application
+ public MainForm()
+ {
+ InitializeComponent();
+ }
+ private void MainForm_Load(object sender, EventArgs e)
+ {
+ AddLog("Loading");
+ UpdateTheme();
+ LoadNode();
+
+
+
+ AddLog("Finished loading");
+ ResizeForm();
+ }
+ private void MainForm_Closing(object sender, FormClosingEventArgs e)
+ {
+ AddLog("Closing");
+ }
+ #endregion
+
+
+
+
+ #region Settings
+ private void LoadNode()
+ {
+ AddLog("Loading Node");
+ if (!File.Exists(dir + "node.txt"))
+ {
+ AddLog("Node file not found");
+ AddLog("Starting Node Setup");
+ CreateForm cf = new CreateForm();
+ cf.ShowDialog();
+ // Initial run
+ }
+ if (!File.Exists(dir + "node.txt"))
+ {
+ AddLog("Node setup failed");
+ this.Close();
+ return;
+ }
+
+ StreamReader sr = new StreamReader(dir + "node.txt");
+ nodeSettings = new Dictionary();
+ while (!sr.EndOfStream)
+ {
+ string line = sr.ReadLine();
+ string[] split = line.Split(':');
+ nodeSettings.Add(split[0].Trim(), split[1].Trim());
+ }
+ sr.Dispose();
+
+ if (!nodeSettings.ContainsKey("Network") || !nodeSettings.ContainsKey("Key") || !nodeSettings.ContainsKey("IP"))
+ {
+ AddLog("Node Settings file is missing key");
+ this.Close();
+ return;
+ }
+ Network = Convert.ToInt32(nodeSettings["Network"]);
+ switch (Network)
+ {
+ case 0:
+ toolStripStatusLabelNetwork.Text = "Network: Mainnet";
+ break;
+ case 1:
+ toolStripStatusLabelNetwork.Text = "Network: Regtest";
+ break;
+ case 2:
+ toolStripStatusLabelNetwork.Text = "Network: Testnet";
+ break;
+ }
+ NodeStatus();
+
+
+ }
+
+
+ #endregion
+ #region Logging
+ private void AddLog(string message)
+ {
+ StreamWriter sw = new StreamWriter(dir + "log.txt", true);
+ sw.WriteLine(DateTime.Now.ToString() + ": " + message);
+ sw.Dispose();
+ }
+ #endregion
+ #region Theming
+ private void UpdateTheme()
+ {
+ // Check if file exists
+ if (!Directory.Exists(dir))
+ {
+ CreateConfig(dir);
+ }
+ if (!File.Exists(dir + "theme.txt"))
+ {
+ CreateConfig(dir);
+ }
+
+ AddLog("Reading theme file");
+ // Read file
+ StreamReader sr = new StreamReader(dir + "theme.txt");
+ theme = new Dictionary();
+ 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"))
+ {
+ AddLog("Theme file is missing key");
+ return;
+ }
+
+ // Apply theme
+ this.BackColor = ColorTranslator.FromHtml(theme["background"]);
+
+ // Foreground
+ this.ForeColor = ColorTranslator.FromHtml(theme["foreground"]);
+
+
+ // Need to specify this for each groupbox to override the black text
+ foreach (Control c in Controls)
+ {
+ ThemeControl(c);
+ }
+
+
+
+
+ // Transparancy
+
+ AddLog("Finished applying theme");
+ AddLog("Applying transparency");
+ applyTransparency(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"]);
+ }
+ }
+
+ private void applyTransparency(Dictionary theme)
+ {
+ if (theme.ContainsKey("transparent-mode"))
+ {
+ switch (theme["transparent-mode"])
+ {
+ case "mica":
+ var accent = new AccentPolicy { AccentState = AccentState.ACCENT_ENABLE_BLURBEHIND };
+ var accentStructSize = Marshal.SizeOf(accent);
+ var accentPtr = Marshal.AllocHGlobal(accentStructSize);
+ Marshal.StructureToPtr(accent, accentPtr, false);
+ var data = new WindowCompositionAttributeData
+ {
+ Attribute = WindowCompositionAttribute.WCA_ACCENT_POLICY,
+ SizeOfData = accentStructSize,
+ Data = accentPtr
+ };
+ User32.SetWindowCompositionAttribute(Handle, ref data);
+ Marshal.FreeHGlobal(accentPtr);
+ break;
+ case "key":
+ if (theme.ContainsKey("transparency-key"))
+ {
+ switch (theme["transparency-key"])
+ {
+ case "alt":
+ this.TransparencyKey = ColorTranslator.FromHtml(theme["background-alt"]);
+ break;
+ case "main":
+ this.TransparencyKey = ColorTranslator.FromHtml(theme["background"]);
+ break;
+ default:
+ this.TransparencyKey = ColorTranslator.FromHtml(theme["transparency-key"]);
+ break;
+ }
+ }
+ else
+ {
+ AddLog("No transparency-key found in theme file");
+ }
+ break;
+ case "percent":
+ if (theme.ContainsKey("transparency-percent"))
+ {
+ Opacity = Convert.ToDouble(theme["transparency-percent"]) / 100;
+ }
+ else
+ {
+ AddLog("No transparency-percent found in theme file");
+ }
+ break;
+ }
+ }
+ }
+
+ 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();
+ AddLog("Created theme file");
+ }
+
+ // Required for mica effect
+ internal enum AccentState
+ {
+ ACCENT_DISABLED = 0,
+ ACCENT_ENABLE_GRADIENT = 1,
+ ACCENT_ENABLE_TRANSPARENTGRADIENT = 2,
+ ACCENT_ENABLE_BLURBEHIND = 3,
+ ACCENT_INVALID_STATE = 4
+ }
+
+ internal enum WindowCompositionAttribute
+ {
+ WCA_ACCENT_POLICY = 19
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct AccentPolicy
+ {
+ public AccentState AccentState;
+ public int AccentFlags;
+ public int GradientColor;
+ public int AnimationId;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct WindowCompositionAttributeData
+ {
+ public WindowCompositionAttribute Attribute;
+ public IntPtr Data;
+ public int SizeOfData;
+ }
+
+ internal static class User32
+ {
+ [DllImport("user32.dll")]
+ internal static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttributeData data);
+ }
+ #endregion
+
+ private void timerNodeStatus_Tick(object sender, EventArgs e)
+ {
+ NodeStatus();
+ }
+ private async void NodeStatus()
+ {
+ // This will curl the below URL and return the result
+ //curl http://x:api-key@127.0.0.1:12039/wallet/$id/account
+
+ string key = nodeSettings["Key"];
+ string ip = nodeSettings["IP"];
+
+ string port = "1203";
+ if (Network == 1)
+ {
+ port = "1303";
+ }
+
+
+
+ // Create HTTP client
+ HttpClient httpClient = new HttpClient();
+
+ try
+ {
+ HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://" + ip + ":" + port + "7");
+ // Add API key to header
+ request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes("x:" + key)));
+ // Send request and log response
+ HttpResponseMessage response = await httpClient.SendAsync(request);
+ response.EnsureSuccessStatusCode();
+
+ toolStripStatusLabelstatus.Text = "Status: Node Connected";
+ }
+ // Log errors to log textbox
+ catch (Exception ex)
+ {
+ AddLog("Connection Failed: " + ex.Message);
+ toolStripStatusLabelstatus.Text = "Status: Node Not Connected";
+ }
+ }
+
+ private void Form1_Resize(object sender, EventArgs e)
+ {
+ ResizeForm();
+ }
+ private void ResizeForm()
+ {
+ groupBoxaccount.Left = (this.ClientSize.Width - groupBoxaccount.Width) / 2;
+ groupBoxaccount.Top = (this.ClientSize.Height - groupBoxaccount.Height) / 2;
+ }
+ }
+}
\ No newline at end of file
diff --git a/FireWallet/MainForm.resx b/FireWallet/MainForm.resx
new file mode 100644
index 0000000..d230ef8
--- /dev/null
+++ b/FireWallet/MainForm.resx
@@ -0,0 +1,126 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 17
+
+
+ 133, 17
+
+
\ No newline at end of file
diff --git a/FireWallet/Program.cs b/FireWallet/Program.cs
index e79f5fe..6478cc2 100644
--- a/FireWallet/Program.cs
+++ b/FireWallet/Program.cs
@@ -11,7 +11,7 @@ namespace FireWallet
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
- Application.Run(new Form1());
+ Application.Run(new MainForm());
}
}
}
\ No newline at end of file