diff --git a/FireWalletLite/FireWalletLite.csproj b/FireWalletLite/FireWalletLite.csproj
index b84ab7a..1e4aa7b 100644
--- a/FireWalletLite/FireWalletLite.csproj
+++ b/FireWalletLite/FireWalletLite.csproj
@@ -14,6 +14,7 @@
+
diff --git a/FireWalletLite/MainForm.cs b/FireWalletLite/MainForm.cs
index 34d8645..2d8e86a 100644
--- a/FireWalletLite/MainForm.cs
+++ b/FireWalletLite/MainForm.cs
@@ -6,11 +6,17 @@ using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Net;
+using System.Net.Security;
+using System.Security.Cryptography.X509Certificates;
+using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using FireWallet;
using Newtonsoft.Json.Linq;
+using DnsClient;
+using DnsClient.Protocol;
+using System.Security.Policy;
namespace FireWalletLite
{
@@ -20,6 +26,7 @@ namespace FireWalletLite
public string dir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\FireWalletLite\\";
public int daysToExpire = 90; // How many days to check for domain exiries. If domain will expire in less than this, prompt user to renew.
public string TXExplorer = "https://niami.io/tx/"; // Transaction explorer URL
+ public string DomainExplorer = "https://niami.io/domain/"; // Domain explorer URL
public Dictionary Theme { get; set; }
HttpClient httpClient = new HttpClient();
Decimal Balance { get; set; }
@@ -193,7 +200,7 @@ namespace FireWalletLite
available = decimal.Round(available, 2);
locked = decimal.Round(locked, 2);
Balance = available;
- labelBalance.Text = "Balance: " + available;
+ labelBalance.Text = "Balance: " + available + " HNS";
// Get domain count
UpdateDomains();
@@ -270,6 +277,14 @@ namespace FireWalletLite
return "Error";
}
}
+ public async Task ValidAddress(string address)
+ {
+ string output = await APIPost("", false, "{\"method\": \"validateaddress\",\"params\": [ \"" + address + "\" ]}");
+ JObject APIresp = JObject.Parse(output);
+ JObject result = JObject.Parse(APIresp["result"].ToString());
+ if (result["isvalid"].ToString() == "True") return true;
+ else return false;
+ }
public string[] Domains { get; set; }
public string[] DomainsRenewable { get; set; }
private async void UpdateDomains()
@@ -297,7 +312,6 @@ namespace FireWalletLite
panelDomainList.Controls.Add(noDomainsLabel);
noDomainsLabel.Left = panelDomainList.Width / 2 - noDomainsLabel.Width / 2;
noDomainsLabel.Top = 10;
- return;
}
foreach (JObject name in names)
@@ -348,9 +362,8 @@ namespace FireWalletLite
expiry.Left = domainTMP.Width - expiry.Width - 100;
domainTMP.Controls.Add(expiry);
}
-
- /*
// On Click open domain
+ /*
domainTMP.Click += new EventHandler((sender, e) =>
{
DomainForm domainForm = new DomainForm(this, name["name"].ToString(), UserSettings["explorer-tx"], UserSettings["explorer-domain"]);
@@ -520,7 +533,6 @@ namespace FireWalletLite
}
return;
}
-
JObject result = JObject.Parse(jObject["result"].ToString());
string hash = result["hash"].ToString();
AddLog("Batch sent with hash: " + hash);
diff --git a/FireWalletLite/SendForm.Designer.cs b/FireWalletLite/SendForm.Designer.cs
index 7854147..195008b 100644
--- a/FireWalletLite/SendForm.Designer.cs
+++ b/FireWalletLite/SendForm.Designer.cs
@@ -29,13 +29,94 @@
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SendForm));
+ labelAddress = new Label();
+ textBoxAddress = new TextBox();
+ labelAmount = new Label();
+ textBoxAmount = new TextBox();
+ labelHNSToken = new Label();
+ buttonSend = new Button();
+ labelMax = new Label();
SuspendLayout();
//
+ // labelAddress
+ //
+ labelAddress.AutoSize = true;
+ labelAddress.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
+ labelAddress.Location = new Point(268, 10);
+ labelAddress.Name = "labelAddress";
+ labelAddress.Size = new Size(69, 21);
+ labelAddress.TabIndex = 0;
+ labelAddress.Text = "Address:";
+ //
+ // textBoxAddress
+ //
+ textBoxAddress.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
+ textBoxAddress.Location = new Point(131, 34);
+ textBoxAddress.Name = "textBoxAddress";
+ textBoxAddress.Size = new Size(391, 29);
+ textBoxAddress.TabIndex = 1;
+ //
+ // labelAmount
+ //
+ labelAmount.AutoSize = true;
+ labelAmount.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
+ labelAmount.Location = new Point(268, 98);
+ labelAmount.Name = "labelAmount";
+ labelAmount.Size = new Size(69, 21);
+ labelAmount.TabIndex = 2;
+ labelAmount.Text = "Amount:";
+ //
+ // textBoxAmount
+ //
+ textBoxAmount.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
+ textBoxAmount.Location = new Point(183, 122);
+ textBoxAmount.Name = "textBoxAmount";
+ textBoxAmount.Size = new Size(208, 29);
+ textBoxAmount.TabIndex = 3;
+ //
+ // labelHNSToken
+ //
+ labelHNSToken.AutoSize = true;
+ labelHNSToken.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
+ labelHNSToken.Location = new Point(397, 125);
+ labelHNSToken.Name = "labelHNSToken";
+ labelHNSToken.Size = new Size(42, 21);
+ labelHNSToken.TabIndex = 4;
+ labelHNSToken.Text = "HNS";
+ //
+ // buttonSend
+ //
+ buttonSend.FlatStyle = FlatStyle.Flat;
+ buttonSend.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
+ buttonSend.Location = new Point(257, 247);
+ buttonSend.Name = "buttonSend";
+ buttonSend.Size = new Size(97, 40);
+ buttonSend.TabIndex = 5;
+ buttonSend.Text = "Send";
+ buttonSend.UseVisualStyleBackColor = true;
+ buttonSend.Click += buttonSend_Click;
+ //
+ // labelMax
+ //
+ labelMax.AutoSize = true;
+ labelMax.Location = new Point(277, 164);
+ labelMax.Name = "labelMax";
+ labelMax.Size = new Size(33, 15);
+ labelMax.TabIndex = 6;
+ labelMax.Text = "MAX";
+ //
// SendForm
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
- ClientSize = new Size(800, 450);
+ ClientSize = new Size(653, 299);
+ Controls.Add(labelMax);
+ Controls.Add(buttonSend);
+ Controls.Add(labelHNSToken);
+ Controls.Add(textBoxAmount);
+ Controls.Add(labelAmount);
+ Controls.Add(textBoxAddress);
+ Controls.Add(labelAddress);
FormBorderStyle = FormBorderStyle.Fixed3D;
Icon = (Icon)resources.GetObject("$this.Icon");
Margin = new Padding(4, 3, 4, 3);
@@ -45,8 +126,17 @@
ShowInTaskbar = false;
Text = "Send HNS";
ResumeLayout(false);
+ PerformLayout();
}
#endregion
+
+ private Label labelAddress;
+ private TextBox textBoxAddress;
+ private Label labelAmount;
+ private TextBox textBoxAmount;
+ private Label labelHNSToken;
+ private Button buttonSend;
+ private Label labelMax;
}
}
\ No newline at end of file
diff --git a/FireWalletLite/SendForm.cs b/FireWalletLite/SendForm.cs
index 985505e..6e4d655 100644
--- a/FireWalletLite/SendForm.cs
+++ b/FireWalletLite/SendForm.cs
@@ -7,6 +7,8 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
+using FireWallet;
+using Newtonsoft.Json.Linq;
namespace FireWalletLite
{
@@ -20,6 +22,94 @@ namespace FireWalletLite
InitializeComponent();
this.main = main;
this.unlockedbalance = Unlockedbalance;
+
+ // Theme form
+ this.BackColor = ColorTranslator.FromHtml(main.Theme["background"]);
+ this.ForeColor = ColorTranslator.FromHtml(main.Theme["foreground"]);
+ foreach (Control control in Controls)
+ {
+ main.ThemeControl(control);
+ }
+
+ labelMax.Text = "Max: " + (unlockedbalance - fee).ToString() + " HNS";
+ if (unlockedbalance < fee)
+ {
+ labelMax.Text = "Max: 0 HNS";
+ //buttonSend.Enabled = false;
+ }
+
+ // Allign controls
+ labelAddress.Left = (this.ClientSize.Width - labelAddress.Width) / 2;
+ labelAmount.Left = (this.ClientSize.Width - labelAmount.Width) / 2;
+ textBoxAddress.Left = (this.ClientSize.Width - textBoxAddress.Width) / 2;
+ labelMax.Left = (this.ClientSize.Width - labelMax.Width) / 2;
+ textBoxAmount.Left = (this.ClientSize.Width - textBoxAmount.Width - labelHNSToken.Width - 10) / 2;
+ labelHNSToken.Left = textBoxAmount.Left + textBoxAmount.Width + 10;
+ buttonSend.Left = (this.ClientSize.Width - buttonSend.Width) / 2;
+ }
+
+ private async void buttonSend_Click(object sender, EventArgs e)
+ {
+ buttonSend.Enabled = false;
+ string address = textBoxAddress.Text;
+ if (textBoxAddress.Text.Substring(0,1) == "@")
+ {
+ // HIP-02 not supported yet
+ NotifyForm notify = new NotifyForm("HIP-02 not supported yet");
+ notify.ShowDialog();
+ notify.Dispose();
+ buttonSend.Enabled = true;
+ return;
+ }
+ bool valid = await main.ValidAddress(address);
+ if (!valid)
+ {
+ NotifyForm notify = new NotifyForm("Invalid address");
+ notify.ShowDialog();
+ notify.Dispose();
+ buttonSend.Enabled = true;
+ return;
+ }
+
+ decimal amount = 0;
+ if (!decimal.TryParse(textBoxAmount.Text, out amount))
+ {
+ NotifyForm notify = new NotifyForm("Invalid amount");
+ notify.ShowDialog();
+ notify.Dispose();
+ return;
+ }
+ if (amount > unlockedbalance - fee)
+ {
+ NotifyForm notify = new NotifyForm("Insufficient balance");
+ notify.ShowDialog();
+ notify.Dispose();
+ return;
+ }
+
+ string content = "{\"method\": \"sendtoaddress\",\"params\": [ \"" + address + "\", " +
+ amount.ToString() + "]}";
+ string output = await main.APIPost("", true, content);
+ JObject APIresp = JObject.Parse(output);
+ if (APIresp["error"].ToString() != "")
+ {
+ main.AddLog("Failed:");
+ main.AddLog(APIresp.ToString());
+ JObject error = JObject.Parse(APIresp["error"].ToString());
+ string ErrorMessage = error["message"].ToString();
+
+ NotifyForm notify = new NotifyForm("Error Transaction Failed\n" + ErrorMessage);
+ notify.ShowDialog();
+ notify.Dispose();
+ return;
+ }
+ string hash = APIresp["result"].ToString();
+ string link = main.TXExplorer + hash;
+ NotifyForm notifySuccess = new NotifyForm("Transaction Sent\nThis transaction could take up to 20 minutes to mine",
+ "Explorer", link);
+ notifySuccess.ShowDialog();
+ notifySuccess.Dispose();
+ this.Close();
}
}
}