From de14b98c6f2f4b643c7834b15dccd0b796cadbc0 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Wed, 7 Jun 2023 23:27:42 +1000 Subject: [PATCH] batching: Finished first version --- FireWallet/BatchForm.cs | 191 +++++++++++++--- FireWallet/BatchImportForm.Designer.cs | 181 ++++++++++++++++ FireWallet/BatchImportForm.cs | 289 +++++++++++++++++++++++++ FireWallet/BatchImportForm.resx | 120 ++++++++++ FireWallet/DomainForm.cs | 14 +- FireWallet/MainForm.Designer.cs | 16 ++ FireWallet/MainForm.cs | 34 +-- 7 files changed, 781 insertions(+), 64 deletions(-) create mode 100644 FireWallet/BatchImportForm.Designer.cs create mode 100644 FireWallet/BatchImportForm.cs create mode 100644 FireWallet/BatchImportForm.resx diff --git a/FireWallet/BatchForm.cs b/FireWallet/BatchForm.cs index 48dd768..1b3da5a 100644 --- a/FireWallet/BatchForm.cs +++ b/FireWallet/BatchForm.cs @@ -1,14 +1,6 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; +using System.Data; using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using Microsoft.VisualBasic.Devices; +using Newtonsoft.Json.Linq; using Point = System.Drawing.Point; namespace FireWallet @@ -55,7 +47,19 @@ namespace FireWallet deleteTX.Width = 25; deleteTX.Height = 25; deleteTX.TextAlign = ContentAlignment.MiddleCenter; - deleteTX.Click += (sender, e) => { panelTXs.Controls.Remove(tx); FixSpacing(); }; + deleteTX.Click += (sender, e) => { + panelTXs.Controls.Remove(tx); + FixSpacing(); + List temp = new List(); + foreach (Batch batch in batches) + { + if (batch.domain != domain && batch.method != operation) + { + temp.Add(batch); + } + } + batches = temp.ToArray(); + }; deleteTX.FlatStyle = FlatStyle.Flat; deleteTX.Font = new Font(deleteTX.Font.FontFamily, 9F, FontStyle.Bold); tx.Controls.Add(deleteTX); @@ -65,7 +69,11 @@ namespace FireWallet } public void AddBatch(string domain, string operation, decimal bid, decimal lockup) { - if (operation != "BID") return; + if (operation != "BID") + { + AddBatch(domain, operation); + return; + } batches = batches.Concat(new Batch[] { new Batch(domain, operation, bid, lockup) }).ToArray(); Panel tx = new Panel(); tx.Left = 0; @@ -102,7 +110,19 @@ namespace FireWallet deleteTX.Width = 25; deleteTX.Height = 25; deleteTX.TextAlign = ContentAlignment.MiddleCenter; - deleteTX.Click += (sender, e) => { panelTXs.Controls.Remove(tx); FixSpacing(); }; + deleteTX.Click += (sender, e) => { + panelTXs.Controls.Remove(tx); + FixSpacing(); + List temp = new List(); + foreach (Batch batch in batches) + { + if (batch.domain != domain && batch.method != operation) + { + temp.Add(batch); + } + } + batches = temp.ToArray(); + }; deleteTX.FlatStyle = FlatStyle.Flat; deleteTX.Font = new Font(deleteTX.Font.FontFamily, 9F, FontStyle.Bold); tx.Controls.Add(deleteTX); @@ -318,10 +338,40 @@ namespace FireWallet AddLog("Batch Cancelled"); this.Close(); } - - private void buttonSend_Click(object sender, EventArgs e) + HttpClient httpClient = new HttpClient(); + private async void buttonSend_Click(object sender, EventArgs e) { - MessageBox.Show("Send to do"); + string batchTX = "[" +string.Join(", ", batches.Select(batch => batch.ToString())) + "]"; + string content = "{\"method\": \"sendbatch\",\"params\":[ " + batchTX + "]}"; + string responce = await APIPost("",true,content); + + if (responce == "Error") + { + AddLog("Error sending batch"); + NotifyForm notifyForm = new NotifyForm("Error sending batch"); + notifyForm.ShowDialog(); + notifyForm.Dispose(); + return; + } + + JObject jObject = JObject.Parse(responce); + if (jObject["error"].ToString() != "") + { + AddLog("Error: "); + AddLog(jObject["error"].ToString()); + NotifyForm notifyForm = new NotifyForm("Error: \n" + jObject["error"].ToString()); + notifyForm.ShowDialog(); + notifyForm.Dispose(); + return; + } + + JObject result = JObject.Parse(jObject["result"].ToString()); + string hash = result["hash"].ToString(); + AddLog("Batch sent with hash: " + hash); + NotifyForm notifyForm2 = new NotifyForm("Batch sent\nThis might take a while to mine.", "Explorer", mainForm.userSettings["explorer-tx"]+hash); + notifyForm2.ShowDialog(); + notifyForm2.Dispose(); + this.Close(); } private void BatchForm_FormClosing(object sender, FormClosingEventArgs e) @@ -339,7 +389,7 @@ namespace FireWallet StreamWriter sw = new StreamWriter(saveFileDialog.FileName); foreach (Batch b in batches) { - sw.WriteLine(b.domain + "," + b.operation + "," + b.bid + "," + b.lockup); + sw.WriteLine(b.domain + "," + b.method + "," + b.bid + "," + b.lockup); } sw.Dispose(); } @@ -348,7 +398,7 @@ namespace FireWallet private void buttonImport_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); - openFileDialog.Filter = "CSV File|*.csv"; + openFileDialog.Filter = "CSV File|*.csv|TXT File|*.txt"; openFileDialog.Title = "Open Batch"; if (openFileDialog.ShowDialog() == DialogResult.OK) { @@ -358,49 +408,118 @@ namespace FireWallet while ((line = sr.ReadLine()) != null) { string[] split = line.Split(','); - if (split.Length == 2) + try { - AddBatch(split[0], split[1]); - } - else if (split.Length == 4) - { - AddBatch(split[0], split[1], Convert.ToDecimal(split[2]), Convert.ToDecimal(split[3])); - } - else if (split.Length == 1) - { - // Select operation and import domains - string operation = "OPEN"; - string[] newDomains = new string[domains.Length + 1]; - for (int i = 0; i < domains.Length; i++) + if (split.Length == 2) { - newDomains[i] = domains[i]; + AddBatch(split[0], split[1]); + } + else if (split.Length == 4) + { + AddBatch(split[0], split[1], Convert.ToDecimal(split[2]), Convert.ToDecimal(split[3])); + } + else + { + // Select operation and import domains + string[] newDomains = new string[domains.Length + 1]; + for (int i = 0; i < domains.Length; i++) + { + newDomains[i] = domains[i]; + } + newDomains[domains.Length] = line.Trim(); + domains = newDomains; + } + } + catch (Exception ex) + { + AddLog("Error importing batch: " + ex.Message); + NotifyForm notifyForm = new NotifyForm("Error importing batch"); + notifyForm.ShowDialog(); + notifyForm.Dispose(); + } + } + if (domains.Length > 0) + { + BatchImportForm batchImportForm = new BatchImportForm(domains); + batchImportForm.ShowDialog(); + if (batchImportForm.batches != null) + { + foreach (Batch b in batchImportForm.batches) + { + AddBatch(b.domain, b.method, b.bid, b.lockup); } - newDomains[domains.Length] = split[0].Trim(); } } sr.Dispose(); } } + + /// + /// Post to HSD API + /// + /// Path to post to + /// Whether to use port 12039 + /// Content to post + /// + private async Task APIPost(string path, bool wallet, string content) + { + string key = mainForm.nodeSettings["Key"]; + string ip = mainForm.nodeSettings["IP"]; + string port = "1203"; + if (mainForm.network == 1) + { + port = "1303"; + } + if (wallet) port = port + "9"; + else port = port + "7"; + + HttpRequestMessage req = new HttpRequestMessage(HttpMethod.Post, "http://" + ip + ":" + port + "/" + path); + req.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes("x:" + key))); + req.Content = new StringContent(content); + + // Send request + HttpResponseMessage resp = await httpClient.SendAsync(req); + + try + { + resp.EnsureSuccessStatusCode(); + } + catch (Exception ex) + { + AddLog("Post Error: " + ex.Message); + return "Error"; + } + + return await resp.Content.ReadAsStringAsync(); + } } public class Batch { public string domain { get; } - public string operation { get; } + public string method { get; } public decimal bid { get; } public decimal lockup { get; } public Batch(string domain, string operation) { this.domain = domain; - this.operation = operation; + this.method = operation; bid = 0; lockup = 0; } public Batch(string domain, string operation, decimal bid, decimal lockup) { this.domain = domain; - this.operation = operation; + this.method = operation; this.bid = bid; this.lockup = lockup; } + public override string ToString() + { + if (method == "BID") + { + return "[\"BID\", \"" + domain + "\", " + bid + ", " + lockup + "]"; + } + return "[\"" + method + "\", \"" + domain + "\"]"; + } } } diff --git a/FireWallet/BatchImportForm.Designer.cs b/FireWallet/BatchImportForm.Designer.cs new file mode 100644 index 0000000..144965b --- /dev/null +++ b/FireWallet/BatchImportForm.Designer.cs @@ -0,0 +1,181 @@ +namespace FireWallet +{ + partial class BatchImportForm + { + /// + /// 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() + { + listBoxDomains = new ListBox(); + label1 = new Label(); + comboBoxMode = new ComboBox(); + label2 = new Label(); + label3 = new Label(); + label4 = new Label(); + textBoxBid = new TextBox(); + textBoxBlind = new TextBox(); + buttonImport = new Button(); + buttonCancel = new Button(); + SuspendLayout(); + // + // listBoxDomains + // + listBoxDomains.FormattingEnabled = true; + listBoxDomains.ItemHeight = 15; + listBoxDomains.Location = new System.Drawing.Point(12, 42); + listBoxDomains.Name = "listBoxDomains"; + listBoxDomains.Size = new System.Drawing.Size(241, 484); + listBoxDomains.TabIndex = 0; + // + // label1 + // + label1.AutoSize = true; + label1.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); + label1.Location = new System.Drawing.Point(12, 9); + label1.Name = "label1"; + label1.Size = new System.Drawing.Size(75, 21); + label1.TabIndex = 1; + label1.Text = "Domains:"; + // + // comboBoxMode + // + comboBoxMode.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxMode.FlatStyle = FlatStyle.Flat; + comboBoxMode.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); + comboBoxMode.FormattingEnabled = true; + comboBoxMode.Items.AddRange(new object[] { "OPEN", "BID", "REVEAL", "REDEEM", "RENEW" }); + comboBoxMode.Location = new System.Drawing.Point(346, 42); + comboBoxMode.Name = "comboBoxMode"; + comboBoxMode.Size = new System.Drawing.Size(226, 29); + comboBoxMode.TabIndex = 2; + // + // label2 + // + label2.AutoSize = true; + label2.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); + label2.Location = new System.Drawing.Point(287, 45); + label2.Name = "label2"; + label2.Size = new System.Drawing.Size(53, 21); + label2.TabIndex = 3; + label2.Text = "Mode:"; + // + // label3 + // + label3.AutoSize = true; + label3.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); + label3.Location = new System.Drawing.Point(305, 111); + label3.Name = "label3"; + label3.Size = new System.Drawing.Size(35, 21); + label3.TabIndex = 3; + label3.Text = "Bid:"; + // + // label4 + // + label4.AutoSize = true; + label4.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); + label4.Location = new System.Drawing.Point(292, 159); + label4.Name = "label4"; + label4.Size = new System.Drawing.Size(48, 21); + label4.TabIndex = 3; + label4.Text = "Blind:"; + // + // textBoxBid + // + textBoxBid.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); + textBoxBid.Location = new System.Drawing.Point(346, 108); + textBoxBid.Name = "textBoxBid"; + textBoxBid.Size = new System.Drawing.Size(226, 29); + textBoxBid.TabIndex = 4; + // + // textBoxBlind + // + textBoxBlind.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); + textBoxBlind.Location = new System.Drawing.Point(346, 156); + textBoxBlind.Name = "textBoxBlind"; + textBoxBlind.Size = new System.Drawing.Size(226, 29); + textBoxBlind.TabIndex = 5; + // + // buttonImport + // + buttonImport.FlatStyle = FlatStyle.Flat; + buttonImport.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); + buttonImport.Location = new System.Drawing.Point(851, 485); + buttonImport.Name = "buttonImport"; + buttonImport.Size = new System.Drawing.Size(87, 38); + buttonImport.TabIndex = 6; + buttonImport.Text = "Import"; + buttonImport.UseVisualStyleBackColor = true; + buttonImport.Click += buttonImport_Click; + // + // buttonCancel + // + buttonCancel.FlatStyle = FlatStyle.Flat; + buttonCancel.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); + buttonCancel.Location = new System.Drawing.Point(731, 485); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new System.Drawing.Size(87, 38); + buttonCancel.TabIndex = 6; + buttonCancel.Text = "Cancel"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // BatchImportForm + // + AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new System.Drawing.Size(950, 535); + Controls.Add(buttonCancel); + Controls.Add(buttonImport); + Controls.Add(textBoxBlind); + Controls.Add(textBoxBid); + Controls.Add(label4); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(comboBoxMode); + Controls.Add(label1); + Controls.Add(listBoxDomains); + FormBorderStyle = FormBorderStyle.Fixed3D; + MaximizeBox = false; + Name = "BatchImportForm"; + Text = "Import"; + Load += BatchImportForm_Load; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private ListBox listBoxDomains; + private Label label1; + private ComboBox comboBoxMode; + private Label label2; + private Label label3; + private Label label4; + private TextBox textBoxBid; + private TextBox textBoxBlind; + private Button buttonImport; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/FireWallet/BatchImportForm.cs b/FireWallet/BatchImportForm.cs new file mode 100644 index 0000000..821ba0f --- /dev/null +++ b/FireWallet/BatchImportForm.cs @@ -0,0 +1,289 @@ +using System.Runtime.InteropServices; + +namespace FireWallet +{ + public partial class BatchImportForm : Form + { + string dir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\FireWallet\\"; + Dictionary theme; + string[] domains; + public Batch[] batches { get; set; } + + public BatchImportForm(string[] domains) + { + InitializeComponent(); + this.domains = domains; + comboBoxMode.SelectedIndex = 1; + } + + private void BatchImportForm_Load(object sender, EventArgs e) + { + UpdateTheme(); + foreach (string domain in domains) + { + listBoxDomains.Items.Add(domain); + } + } + #region Logging + public 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); + } + + // 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); + } + 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.GetType() == typeof(ToolStrip) || + c.GetType() == typeof(ListBox)) + { + 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.WriteLine("selected-bg: #000000"); + sw.WriteLine("selected-fg: #ffffff"); + sw.WriteLine("error: #ff0000"); + + 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 buttonCancel_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void buttonImport_Click(object sender, EventArgs e) + { + if (comboBoxMode.Text == "BID") + { + batches = new Batch[0]; + foreach (string domain in listBoxDomains.Items) + { + if (domain != "") + { + try + { + decimal bid = Convert.ToDecimal(textBoxBid.Text); + decimal lockup = Convert.ToDecimal(textBoxBlind.Text) + bid; + + Batch[] newBatch = new Batch[batches.Length + 1]; + Array.Copy(batches, newBatch, batches.Length); + newBatch[newBatch.Length - 1] = new Batch(domain, "BID", bid , lockup); + batches = newBatch; + } catch (Exception ex) + { + NotifyForm notify = new NotifyForm("Import error: \n" + ex.Message); + notify.ShowDialog(); + notify.Dispose(); + } + } + } + this.Close(); + } else if (comboBoxMode.Text == "OPEN" || comboBoxMode.Text == "REVEAL" || comboBoxMode.Text == "REDEEM" || comboBoxMode.Text == "RENEW") + { + batches = new Batch[0]; + foreach (string domain in listBoxDomains.Items) + { + if (domain != "") + { + Batch[] newBatch = new Batch[batches.Length + 1]; + Array.Copy(batches, newBatch, batches.Length); + newBatch[newBatch.Length - 1] = new Batch(domain, comboBoxMode.Text); + batches = newBatch; + } + } + this.Close(); + } else + { + MessageBox.Show("Please select a mode"); + } + } + } +} +public class Batch +{ + public string domain { get; } + public string operation { get; } + public decimal bid { get; } + public decimal lockup { get; } + public Batch(string domain, string operation) + { + this.domain = domain; + this.operation = operation; + bid = 0; + lockup = 0; + } + public Batch(string domain, string operation, decimal bid, decimal lockup) + { + this.domain = domain; + this.operation = operation; + this.bid = bid; + this.lockup = lockup; + } +} diff --git a/FireWallet/BatchImportForm.resx b/FireWallet/BatchImportForm.resx new file mode 100644 index 0000000..a395bff --- /dev/null +++ b/FireWallet/BatchImportForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/FireWallet/DomainForm.cs b/FireWallet/DomainForm.cs index 79215b1..d91398b 100644 --- a/FireWallet/DomainForm.cs +++ b/FireWallet/DomainForm.cs @@ -1,18 +1,6 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Diagnostics; -using System.Drawing; -using System.Linq; -using System.Net.Http; +using System.Diagnostics; using System.Runtime.InteropServices; -using System.Text; using System.Text.RegularExpressions; -using System.Threading.Tasks; -using System.Windows.Forms; -using BitMiracle.LibTiff.Classic; -using Microsoft.VisualBasic.Devices; using Newtonsoft.Json.Linq; namespace FireWallet diff --git a/FireWallet/MainForm.Designer.cs b/FireWallet/MainForm.Designer.cs index a118bc6..5822c9d 100644 --- a/FireWallet/MainForm.Designer.cs +++ b/FireWallet/MainForm.Designer.cs @@ -84,6 +84,7 @@ namespace FireWallet panelDomains = new Panel(); labelDomainSearch = new Label(); textBoxDomainSearch = new TextBox(); + buttonBatch = new Button(); statusStripmain.SuspendLayout(); panelaccount.SuspendLayout(); groupBoxaccount.SuspendLayout(); @@ -247,6 +248,7 @@ namespace FireWallet // // panelNav // + panelNav.Controls.Add(buttonBatch); panelNav.Controls.Add(buttonNavDomains); panelNav.Controls.Add(buttonNavReceive); panelNav.Controls.Add(buttonNavSend); @@ -630,6 +632,19 @@ namespace FireWallet textBoxDomainSearch.TabIndex = 0; textBoxDomainSearch.KeyDown += textBoxDomainSearch_KeyDown; // + // buttonBatch + // + buttonBatch.FlatStyle = FlatStyle.Flat; + buttonBatch.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); + buttonBatch.Location = new Point(12, 245); + buttonBatch.Name = "buttonBatch"; + buttonBatch.Size = new Size(89, 30); + buttonBatch.TabIndex = 3; + buttonBatch.TabStop = false; + buttonBatch.Text = "Batch"; + buttonBatch.UseVisualStyleBackColor = true; + buttonBatch.Click += buttonBatch_Click; + // // MainForm // AutoScaleDimensions = new SizeF(7F, 15F); @@ -721,5 +736,6 @@ namespace FireWallet private Panel panelDomains; private Label labelDomainSearch; private TextBox textBoxDomainSearch; + private Button buttonBatch; } } \ No newline at end of file diff --git a/FireWallet/MainForm.cs b/FireWallet/MainForm.cs index bed5510..1544b4b 100644 --- a/FireWallet/MainForm.cs +++ b/FireWallet/MainForm.cs @@ -1,16 +1,9 @@ -using System; using System.Diagnostics; -using System.IO; -using System.Net; -using System.Net.Http; using System.Runtime.InteropServices; -using System.Security.Policy; -using System.Windows.Forms; using Newtonsoft.Json.Linq; using Point = System.Drawing.Point; using Size = System.Drawing.Size; using IronBarCode; -using static System.Windows.Forms.DataFormats; namespace FireWallet { @@ -21,7 +14,7 @@ namespace FireWallet public Dictionary nodeSettings { get; set; } public Dictionary userSettings { get; set; } public Dictionary theme { get; set; } - public int Network { get; set; } + public int network { get; set; } public string account { get; set; } public string password { get; set; } public decimal balance { get; set; } @@ -105,8 +98,8 @@ namespace FireWallet this.Close(); return; } - Network = Convert.ToInt32(nodeSettings["Network"]); - switch (Network) + network = Convert.ToInt32(nodeSettings["Network"]); + switch (network) { case 0: toolStripStatusLabelNetwork.Text = "Network: Mainnet"; @@ -509,7 +502,7 @@ namespace FireWallet string key = nodeSettings["Key"]; string ip = nodeSettings["IP"]; string port = "1203"; - if (Network == 1) + if (network == 1) { port = "1303"; } @@ -547,7 +540,7 @@ namespace FireWallet string ip = nodeSettings["IP"]; string port = "1203"; - if (Network == 1) + if (network == 1) { port = "1303"; } @@ -624,10 +617,10 @@ namespace FireWallet Control[] tmpControls = new Control[txCount]; for (int i = 0; i < txCount; i++) { - + // Get last tx JObject tx = JObject.Parse(txs[txs.Count - 1 - i].ToString()); - + string hash = tx["hash"].ToString(); string date = tx["mdate"].ToString(); @@ -1035,7 +1028,7 @@ namespace FireWallet } - + #region Batching public void AddBatch(string domain, string operation) { @@ -1067,5 +1060,16 @@ namespace FireWallet batchForm.Dispose(); } #endregion + + private void buttonBatch_Click(object sender, EventArgs e) + { + if (!batchMode) + { + batchForm = new BatchForm(this); + batchForm.Show(); + batchMode = true; + } + else batchForm.Focus(); + } } } \ No newline at end of file