7 Commits

18 changed files with 800 additions and 744 deletions

View File

@@ -1,5 +1,6 @@
using System.Data;
using System.Diagnostics;
using System.Net;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms.VisualStyles;
@@ -58,7 +59,7 @@ namespace FireWallet
List<Batch> temp = new List<Batch>();
foreach (Batch batch in batches)
{
if (batch.domain != domain && batch.method != operation)
if (batch.domain != domain || batch.method != operation)
{
temp.Add(batch);
}
@@ -122,7 +123,7 @@ namespace FireWallet
List<Batch> temp = new List<Batch>();
foreach (Batch batch in batches)
{
if (batch.domain != domain && batch.method != operation)
if (batch.domain != domain || batch.method != operation)
{
temp.Add(batch);
}
@@ -182,7 +183,7 @@ namespace FireWallet
List<Batch> temp = new List<Batch>();
foreach (Batch batch in batches)
{
if (batch.domain != domain && batch.method != operation)
if (batch.domain != domain || batch.method != operation)
{
temp.Add(batch);
}
@@ -238,7 +239,7 @@ namespace FireWallet
List<Batch> temp = new List<Batch>();
foreach (Batch batch in batches)
{
if (batch.domain != domain && batch.method != operation)
if (batch.domain != domain || batch.method != operation)
{
temp.Add(batch);
}
@@ -750,6 +751,10 @@ namespace FireWallet
{
AddBatch(b.domain, b.method, b.toAddress);
}
else if (b.method == "UPDATE")
{
AddBatch(b.domain, b.method, b.update);
}
else
{
AddBatch(b.domain, b.method);
@@ -792,21 +797,26 @@ namespace FireWallet
req.Content = new StringContent(content);
// Send request
HttpResponseMessage resp = await httpClient.SendAsync(req);
try
{
resp.EnsureSuccessStatusCode();
HttpResponseMessage resp = await httpClient.SendAsync(req);
if (resp.StatusCode != HttpStatusCode.OK)
{
AddLog("Post Error: " + resp.StatusCode.ToString());
AddLog(await resp.Content.ReadAsStringAsync());
AddLog(content);
return "Error";
}
return await resp.Content.ReadAsStringAsync();
}
catch (Exception ex)
{
AddLog("Post Error: " + ex.Message);
AddLog(await resp.Content.ReadAsStringAsync());
AddLog(content);
return "Error";
}
return await resp.Content.ReadAsStringAsync();
}
}
public class Batch
@@ -868,6 +878,10 @@ namespace FireWallet
return "[\"UPDATE\", \"" + domain + "\", " + records + "]";
}
else if (method == "UPDATE")
{
return "[\"UPDATE\", \"" + domain + "\", {\"records\":[]}]";
}
return "[\"" + method + "\", \"" + domain + "\"]";
}
}

View File

@@ -72,7 +72,7 @@
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", "TRANSFER", "FINALIZE", "CANCEL" });
comboBoxMode.Items.AddRange(new object[] { "OPEN", "BID", "REVEAL", "REDEEM", "REGISTER", "RENEW", "TRANSFER", "FINALIZE", "CANCEL" });
comboBoxMode.Location = new Point(346, 42);
comboBoxMode.Name = "comboBoxMode";
comboBoxMode.Size = new Size(226, 29);

View File

@@ -263,6 +263,21 @@ namespace FireWallet
}
this.Close();
}
else if (comboBoxMode.Text == "REGISTER")
{
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,"UPDATE",new DNS[0]);
batches = newBatch;
}
}
this.Close();
}
else if (comboBoxMode.Text == "TRANSFER")
{
batches = new Batch[0];

View File

@@ -363,6 +363,12 @@ namespace FireWallet
string contentDNS = "{\"method\": \"getnameresource\", \"params\": [\"" + domain + "\"]}";
string responseDNS = await APIPost("", false, contentDNS);
JObject jObjectDNS = JObject.Parse(responseDNS);
if (jObjectDNS["result"].ToString() == "")
{
return;
}
JObject result = (JObject)jObjectDNS["result"];
JArray records = (JArray)result["records"];
// For each record

View File

@@ -279,6 +279,14 @@ namespace FireWallet
string contentDNS = "{\"method\": \"getnameresource\", \"params\": [\"" + domain + "\"]}";
string responseDNS = await APIPost("", false, contentDNS);
JObject jObjectDNS = JObject.Parse(responseDNS);
if (jObjectDNS["result"].ToString() == "")
{
// Not registered
groupBoxDNS.Visible = false;
return;
}
JObject result = (JObject)jObjectDNS["result"];
JArray records = (JArray)result["records"];
// For each record
@@ -814,7 +822,14 @@ namespace FireWallet
if (!DNSEdit.cancel)
{
string records = string.Join(", ", DNSEdit.DNSrecords.Select(record => record.ToString()));
string records = "";
if (DNSEdit.DNSrecords != null)
{
if (DNSEdit.DNSrecords.Count() > 0)
{
records = string.Join(", ", DNSEdit.DNSrecords.Select(record => record.ToString()));
}
}
string content = "{\"method\": \"sendupdate\", \"params\": [\"" + domain + "\", {\"records\": [" + records + "]}]}";
string response = await APIPost("", true, content);

BIN
FireWallet/FW.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

View File

@@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<ApplicationIcon>FW2.ico</ApplicationIcon>
<ApplicationIcon>FW.ico</ApplicationIcon>
<Title>FireWallet</Title>
<PackageProjectUrl>https://l.woodburn.au</PackageProjectUrl>
<PackageIcon>HSDBatcher.png</PackageIcon>
@@ -16,7 +16,7 @@
</PropertyGroup>
<ItemGroup>
<Content Include="FW2.ico" />
<Content Include="FW.ico" />
</ItemGroup>
<ItemGroup>

View File

@@ -65,6 +65,7 @@ namespace FireWallet
buttonNavSend = new Button();
buttonNavPortfolio = new Button();
panelPortfolio = new Panel();
buttonRedeemAll = new Button();
buttonRevealAll = new Button();
groupBoxTransactions = new GroupBox();
groupBoxinfo = new GroupBox();
@@ -126,6 +127,7 @@ namespace FireWallet
textBoxExAddr = new TextBox();
labelSettings4 = new Label();
textBoxExTX = new TextBox();
buttonSendAll = new Button();
statusStripmain.SuspendLayout();
panelaccount.SuspendLayout();
groupBoxaccount.SuspendLayout();
@@ -445,6 +447,8 @@ namespace FireWallet
//
// panelPortfolio
//
panelPortfolio.Controls.Add(buttonSendAll);
panelPortfolio.Controls.Add(buttonRedeemAll);
panelPortfolio.Controls.Add(buttonRevealAll);
panelPortfolio.Controls.Add(groupBoxTransactions);
panelPortfolio.Controls.Add(groupBoxinfo);
@@ -455,13 +459,25 @@ namespace FireWallet
panelPortfolio.TabIndex = 7;
panelPortfolio.Visible = false;
//
// buttonRedeemAll
//
buttonRedeemAll.FlatStyle = FlatStyle.Flat;
buttonRedeemAll.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
buttonRedeemAll.Location = new Point(649, 12);
buttonRedeemAll.Name = "buttonRedeemAll";
buttonRedeemAll.Size = new Size(106, 44);
buttonRedeemAll.TabIndex = 9;
buttonRedeemAll.Text = "Redeem All";
buttonRedeemAll.UseVisualStyleBackColor = true;
buttonRedeemAll.Click += buttonRedeemAll_Click;
//
// buttonRevealAll
//
buttonRevealAll.FlatStyle = FlatStyle.Flat;
buttonRevealAll.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
buttonRevealAll.Location = new Point(537, 12);
buttonRevealAll.Name = "buttonRevealAll";
buttonRevealAll.Size = new Size(89, 44);
buttonRevealAll.Size = new Size(106, 44);
buttonRevealAll.TabIndex = 9;
buttonRevealAll.Text = "Reveal All";
buttonRevealAll.UseVisualStyleBackColor = true;
@@ -1105,6 +1121,18 @@ namespace FireWallet
textBoxExTX.Size = new Size(307, 29);
textBoxExTX.TabIndex = 1;
//
// buttonSendAll
//
buttonSendAll.FlatStyle = FlatStyle.Flat;
buttonSendAll.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
buttonSendAll.Location = new Point(761, 12);
buttonSendAll.Name = "buttonSendAll";
buttonSendAll.Size = new Size(106, 44);
buttonSendAll.TabIndex = 9;
buttonSendAll.Text = "Send All TXs";
buttonSendAll.UseVisualStyleBackColor = true;
buttonSendAll.Click += buttonSendAll_Click;
//
// MainForm
//
AutoScaleDimensions = new SizeF(7F, 15F);
@@ -1251,5 +1279,7 @@ namespace FireWallet
private Label labelDomainSort;
private ToolStripSeparator toolStripSeparator1;
private ToolStripMenuItem otherProjectsToolStripMenuItem;
private Button buttonRedeemAll;
private Button buttonSendAll;
}
}

View File

@@ -142,13 +142,20 @@ namespace FireWallet
}
}
Application.DoEvents();
while (!ss.IsClosed)
{
Thread.Sleep(100);
Application.DoEvents();
}
}
AddLog("Loaded");
// Pull form to front
Opacity = 1;
// Pull form to front
this.WindowState = FormWindowState.Minimized;
this.Show();
this.Opacity = 1;
this.WindowState = FormWindowState.Normal;
textBoxaccountpassword.Focus();
}
@@ -920,21 +927,25 @@ namespace FireWallet
req.Content = new StringContent(content);
// Send request
HttpResponseMessage resp = await httpClient.SendAsync(req);
try
{
resp.EnsureSuccessStatusCode();
HttpResponseMessage resp = await httpClient.SendAsync(req);
if (!resp.IsSuccessStatusCode)
{
AddLog("Post Error: " + resp.StatusCode);
AddLog(await resp.Content.ReadAsStringAsync());
return "Error";
}
return await resp.Content.ReadAsStringAsync();
}
catch (Exception ex)
{
AddLog("Post Error: " + ex.Message);
AddLog(await resp.Content.ReadAsStringAsync());
AddLog("Content: " + content);
return "Error";
}
return await resp.Content.ReadAsStringAsync();
}
/// <summary>
/// Get from HSD API
@@ -964,7 +975,12 @@ namespace FireWallet
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();
if (!response.IsSuccessStatusCode)
{
AddLog("Get Error: " + response.StatusCode);
AddLog(await response.Content.ReadAsStringAsync());
return "Error";
}
return await response.Content.ReadAsStringAsync();
}
@@ -985,8 +1001,15 @@ namespace FireWallet
AddLog("GetAddress Error");
return "Error";
}
JObject resp = JObject.Parse(APIresponse);
return resp["address"].ToString();
try
{
JObject resp = JObject.Parse(APIresponse);
return resp["address"].ToString();
}
catch
{
return "Error";
}
}
private async void GetTXHistory()
@@ -1595,8 +1618,6 @@ namespace FireWallet
if (!WatchOnly)
{
AddLog("Sending " + amount.ToString() + " HNS to " + address);
string content = "{\"method\": \"sendtoaddress\",\"params\": [ \"" + address + "\", " +
amount.ToString() + ", \"\", \"\", " + subtractFee + " ]}";
string output = await APIPost("", true, content);
@@ -2355,5 +2376,83 @@ namespace FireWallet
Process.Start(psi);
}
#endregion
private async void buttonRedeemAll_Click(object sender, EventArgs e)
{
buttonRedeemAll.Enabled = false;
string content = "{\"method\": \"sendbatch\", \"params\":[[[\"REDEEM\"]]]}";
AddLog(content);
string response = await APIPost("", true, content);
if (response == "Error")
{
AddLog("Error sending batch");
NotifyForm notifyForm = new NotifyForm("Error sending batch");
notifyForm.ShowDialog();
notifyForm.Dispose();
buttonRedeemAll.Enabled = true;
return;
}
JObject resp = JObject.Parse(response);
if (resp["error"].ToString() != "")
{
AddLog("Error sending batch");
AddLog(resp["error"].ToString());
JObject error = JObject.Parse(resp["error"].ToString());
NotifyForm notifyForm = new NotifyForm("Error sending batch\n" + error["message"].ToString());
notifyForm.ShowDialog();
notifyForm.Dispose();
buttonRedeemAll.Enabled = true;
return;
}
if (resp.ContainsKey("result"))
{
JObject result = JObject.Parse(resp["result"].ToString());
string hash = result["hash"].ToString();
NotifyForm notifyForm = new NotifyForm("Batch sent\n" + hash, "Explorer", UserSettings["explorer-tx"] + hash);
notifyForm.ShowDialog();
notifyForm.Dispose();
}
buttonRedeemAll.Enabled = true;
}
private async void buttonSendAll_Click(object sender, EventArgs e)
{
buttonSendAll.Enabled = false;
string content = "{\"method\": \"sendbatch\", \"params\":[[[\"REVEAL\"],[\"REDEEM\"],[\"RENEW\"]]]}";
AddLog(content);
string response = await APIPost("", true, content);
if (response == "Error")
{
AddLog("Error sending batch");
NotifyForm notifyForm = new NotifyForm("Error sending batch");
notifyForm.ShowDialog();
notifyForm.Dispose();
buttonSendAll.Enabled = true;
return;
}
JObject resp = JObject.Parse(response);
if (resp["error"].ToString() != "")
{
AddLog("Error sending batch");
AddLog(resp["error"].ToString());
JObject error = JObject.Parse(resp["error"].ToString());
NotifyForm notifyForm = new NotifyForm("Error sending batch\n" + error["message"].ToString());
notifyForm.ShowDialog();
notifyForm.Dispose();
buttonSendAll.Enabled = true;
return;
}
if (resp.ContainsKey("result"))
{
JObject result = JObject.Parse(resp["result"].ToString());
string hash = result["hash"].ToString();
NotifyForm notifyForm = new NotifyForm("Batch sent\n" + hash, "Explorer", UserSettings["explorer-tx"] + hash);
notifyForm.ShowDialog();
notifyForm.Dispose();
}
buttonSendAll.Enabled = true;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -59,5 +59,15 @@ namespace FireWallet.Properties {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap FWSplash {
get {
object obj = ResourceManager.GetObject("FWSplash", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@@ -117,4 +117,8 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="FWSplash" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\FWSplash.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

View File

@@ -28,11 +28,18 @@
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SplashScreen));
label1 = new Label();
pictureBox1 = new PictureBox();
label2 = new Label();
panelNew = new Panel();
pictureBoxNew = new PictureBox();
timerIn = new System.Windows.Forms.Timer(components);
timerOut = new System.Windows.Forms.Timer(components);
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
panelNew.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxNew).BeginInit();
SuspendLayout();
//
// label1
@@ -67,12 +74,45 @@
label2.Text = "Nathan.Woodburn/";
label2.Click += label2_Click;
//
// panelNew
//
panelNew.Controls.Add(pictureBoxNew);
panelNew.Dock = DockStyle.Fill;
panelNew.Location = new Point(0, 0);
panelNew.Name = "panelNew";
panelNew.Size = new Size(450, 450);
panelNew.TabIndex = 3;
//
// pictureBoxNew
//
pictureBoxNew.BackColor = Color.Black;
pictureBoxNew.Dock = DockStyle.Fill;
pictureBoxNew.Image = Properties.Resources.FWSplash;
pictureBoxNew.InitialImage = null;
pictureBoxNew.Location = new Point(0, 0);
pictureBoxNew.Name = "pictureBoxNew";
pictureBoxNew.Size = new Size(450, 450);
pictureBoxNew.SizeMode = PictureBoxSizeMode.Zoom;
pictureBoxNew.TabIndex = 0;
pictureBoxNew.TabStop = false;
pictureBoxNew.Visible = false;
//
// timerIn
//
timerIn.Enabled = true;
timerIn.Tick += timerIn_Tick;
//
// timerOut
//
timerOut.Tick += timerOut_Tick;
//
// SplashScreen
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
BackColor = Color.Black;
ClientSize = new Size(444, 435);
ClientSize = new Size(450, 450);
Controls.Add(panelNew);
Controls.Add(label2);
Controls.Add(pictureBox1);
Controls.Add(label1);
@@ -83,8 +123,12 @@
ShowInTaskbar = false;
StartPosition = FormStartPosition.CenterScreen;
Text = "FireWallet";
TopMost = true;
FormClosing += SplashScreen_FormClosing;
Load += SplashScreen_Load;
((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit();
panelNew.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)pictureBoxNew).EndInit();
ResumeLayout(false);
PerformLayout();
}
@@ -93,5 +137,9 @@
private Label label1;
private PictureBox pictureBox1;
private Label label2;
private Panel panelNew;
private PictureBox pictureBoxNew;
private System.Windows.Forms.Timer timerIn;
private System.Windows.Forms.Timer timerOut;
}
}

View File

@@ -1,13 +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.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
using System.Drawing.Imaging;
namespace FireWallet
{
@@ -17,8 +10,10 @@ namespace FireWallet
{
InitializeComponent();
close = false;
IsClosed = false;
}
bool close;
float opacity = 0.0f;
private void SplashScreen_FormClosing(object sender, FormClosingEventArgs e)
{
if (!close)
@@ -26,12 +21,15 @@ namespace FireWallet
e.Cancel = true;
}
}
public bool IsClosed { get; set; }
public void CloseSplash()
{
close = true;
this.Close();
}
// Fade out
timerIn.Stop();
timerOut.Start();
}
private void label2_Click(object sender, EventArgs e)
{
ProcessStartInfo psi = new ProcessStartInfo
@@ -41,5 +39,56 @@ namespace FireWallet
};
Process.Start(psi);
}
Bitmap splash = new Bitmap(Properties.Resources.FWSplash);
private void SplashScreen_Load(object sender, EventArgs e)
{
pictureBoxNew.Visible = true;
this.TransparencyKey = Color.FromArgb(0, 0, 0);
pictureBoxNew.Invalidate();
}
public Image SetImageOpacity(Image image, float opacity)
{
try
{
Bitmap bmp = new Bitmap(image.Width, image.Height);
using (Graphics gfx = Graphics.FromImage(bmp))
{
ColorMatrix matrix = new ColorMatrix();
matrix.Matrix33 = opacity;
ImageAttributes attributes = new ImageAttributes();
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);
}
return bmp;
}
catch
{
return null;
}
}
private void timerIn_Tick(object sender, EventArgs e)
{
if (opacity >= 1)
{
timerIn.Stop();
return;
}
opacity += 0.05f;
pictureBoxNew.Image = SetImageOpacity(splash, opacity);
pictureBoxNew.Invalidate();
}
private void timerOut_Tick(object sender, EventArgs e)
{
if (opacity <= 0)
{
timerOut.Stop();
IsClosed = true;
this.Close();
return;
}
opacity -= 0.05f;
pictureBoxNew.Image = SetImageOpacity(splash, opacity);
pictureBoxNew.Invalidate();
}
}
}

View File

@@ -898,6 +898,12 @@
AAAAAAAAAAAAAADQwWbM+D8RAPjBClJL0gAAAABJRU5ErkJggg==
</value>
</data>
<metadata name="timerIn.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="timerOut.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>104, 17</value>
</metadata>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAEAAAAAAAEAIAB2pAAAFgAAAIlQTkcNChoKAAAADUlIRFIAAAOEAAADAAgGAAAAfG+p9QAAIABJ

BIN
FireWallet/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

View File

@@ -173,4 +173,5 @@ You should check this file if you have any issues with the application.
# Support
If you have any issues with the application you can open an issue on GitHub or contact me on Discord (NathanWoodburn on most Handshake servers).
If you would like to support this project you can find out how at https://nathan.woodburn.au/#donate or you can help by contributing to the project on GitHub.
If you would like to support this project you can find out how at https://nathan.woodburn.au/#donate or you can help by contributing to the project on GitHub.
Also you can send HNS directly to `@firewallet`