main: Cleaned up unused code and fixed transfers

This commit is contained in:
Nathan Woodburn 2023-07-15 20:46:58 +10:00
parent 6c3fc72cf5
commit 91150a2b07
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
8 changed files with 162 additions and 360 deletions

View File

@ -29,43 +29,22 @@
private void InitializeComponent() private void InitializeComponent()
{ {
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DomainForm)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DomainForm));
groupBoxInfo = new GroupBox();
labelInfo = new Label();
labelName = new Label(); labelName = new Label();
buttonExplorer = new Button(); buttonExplorer = new Button();
buttonRenew = new Button(); buttonRenew = new Button();
buttonTransfer = new Button(); buttonTransfer = new Button();
groupBoxManage = new GroupBox(); groupBoxManage = new GroupBox();
labelTransfer = new Label();
textBoxTransferAddress = new TextBox(); textBoxTransferAddress = new TextBox();
buttonCancel = new Button(); buttonCancel = new Button();
buttonFinalize = new Button(); buttonFinalize = new Button();
groupBoxDNS = new GroupBox(); groupBoxSign = new GroupBox();
panelDNS = new Panel(); textBoxSignMessage = new TextBox();
groupBoxInfo.SuspendLayout(); labelSignMessage = new Label();
groupBoxManage.SuspendLayout(); groupBoxManage.SuspendLayout();
groupBoxDNS.SuspendLayout(); groupBoxSign.SuspendLayout();
SuspendLayout(); SuspendLayout();
// //
// groupBoxInfo
//
groupBoxInfo.Controls.Add(labelInfo);
groupBoxInfo.Font = new Font("Segoe UI", 14F, FontStyle.Regular, GraphicsUnit.Point);
groupBoxInfo.Location = new Point(12, 52);
groupBoxInfo.Name = "groupBoxInfo";
groupBoxInfo.Size = new Size(280, 163);
groupBoxInfo.TabIndex = 0;
groupBoxInfo.TabStop = false;
groupBoxInfo.Text = "Info";
//
// labelInfo
//
labelInfo.AutoSize = true;
labelInfo.Location = new Point(6, 28);
labelInfo.Name = "labelInfo";
labelInfo.Size = new Size(45, 25);
labelInfo.TabIndex = 0;
labelInfo.Text = "Info";
//
// labelName // labelName
// //
labelName.AutoSize = true; labelName.AutoSize = true;
@ -94,7 +73,7 @@
buttonRenew.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); buttonRenew.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
buttonRenew.Location = new Point(6, 31); buttonRenew.Location = new Point(6, 31);
buttonRenew.Name = "buttonRenew"; buttonRenew.Name = "buttonRenew";
buttonRenew.Size = new Size(89, 30); buttonRenew.Size = new Size(141, 30);
buttonRenew.TabIndex = 1; buttonRenew.TabIndex = 1;
buttonRenew.Text = "Renew"; buttonRenew.Text = "Renew";
buttonRenew.UseVisualStyleBackColor = true; buttonRenew.UseVisualStyleBackColor = true;
@ -104,7 +83,7 @@
// //
buttonTransfer.FlatStyle = FlatStyle.Flat; buttonTransfer.FlatStyle = FlatStyle.Flat;
buttonTransfer.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); buttonTransfer.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
buttonTransfer.Location = new Point(375, 67); buttonTransfer.Location = new Point(655, 70);
buttonTransfer.Name = "buttonTransfer"; buttonTransfer.Name = "buttonTransfer";
buttonTransfer.Size = new Size(89, 30); buttonTransfer.Size = new Size(89, 30);
buttonTransfer.TabIndex = 1; buttonTransfer.TabIndex = 1;
@ -114,33 +93,43 @@
// //
// groupBoxManage // groupBoxManage
// //
groupBoxManage.Controls.Add(labelTransfer);
groupBoxManage.Controls.Add(textBoxTransferAddress); groupBoxManage.Controls.Add(textBoxTransferAddress);
groupBoxManage.Controls.Add(buttonRenew); groupBoxManage.Controls.Add(buttonRenew);
groupBoxManage.Controls.Add(buttonCancel); groupBoxManage.Controls.Add(buttonCancel);
groupBoxManage.Controls.Add(buttonFinalize); groupBoxManage.Controls.Add(buttonFinalize);
groupBoxManage.Controls.Add(buttonTransfer); groupBoxManage.Controls.Add(buttonTransfer);
groupBoxManage.Font = new Font("Segoe UI", 14F, FontStyle.Regular, GraphicsUnit.Point); groupBoxManage.Font = new Font("Segoe UI", 14F, FontStyle.Regular, GraphicsUnit.Point);
groupBoxManage.Location = new Point(298, 52); groupBoxManage.Location = new Point(12, 52);
groupBoxManage.Name = "groupBoxManage"; groupBoxManage.Name = "groupBoxManage";
groupBoxManage.Size = new Size(470, 163); groupBoxManage.Size = new Size(756, 136);
groupBoxManage.TabIndex = 2; groupBoxManage.TabIndex = 2;
groupBoxManage.TabStop = false; groupBoxManage.TabStop = false;
groupBoxManage.Text = "Manage"; groupBoxManage.Text = "Manage";
// //
// labelTransfer
//
labelTransfer.AutoSize = true;
labelTransfer.Location = new Point(6, 72);
labelTransfer.Name = "labelTransfer";
labelTransfer.Size = new Size(83, 25);
labelTransfer.TabIndex = 3;
labelTransfer.Text = "Transfer:";
//
// textBoxTransferAddress // textBoxTransferAddress
// //
textBoxTransferAddress.Location = new Point(6, 66); textBoxTransferAddress.Location = new Point(95, 68);
textBoxTransferAddress.Name = "textBoxTransferAddress"; textBoxTransferAddress.Name = "textBoxTransferAddress";
textBoxTransferAddress.Size = new Size(363, 32); textBoxTransferAddress.Size = new Size(554, 32);
textBoxTransferAddress.TabIndex = 2; textBoxTransferAddress.TabIndex = 2;
// //
// buttonCancel // buttonCancel
// //
buttonCancel.FlatStyle = FlatStyle.Flat; buttonCancel.FlatStyle = FlatStyle.Flat;
buttonCancel.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); buttonCancel.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
buttonCancel.Location = new Point(6, 67); buttonCancel.Location = new Point(242, 70);
buttonCancel.Name = "buttonCancel"; buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(89, 30); buttonCancel.Size = new Size(141, 30);
buttonCancel.TabIndex = 1; buttonCancel.TabIndex = 1;
buttonCancel.Text = "Cancel"; buttonCancel.Text = "Cancel";
buttonCancel.UseVisualStyleBackColor = true; buttonCancel.UseVisualStyleBackColor = true;
@ -151,44 +140,53 @@
// //
buttonFinalize.FlatStyle = FlatStyle.Flat; buttonFinalize.FlatStyle = FlatStyle.Flat;
buttonFinalize.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); buttonFinalize.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
buttonFinalize.Location = new Point(6, 67); buttonFinalize.Location = new Point(95, 70);
buttonFinalize.Name = "buttonFinalize"; buttonFinalize.Name = "buttonFinalize";
buttonFinalize.Size = new Size(89, 30); buttonFinalize.Size = new Size(141, 30);
buttonFinalize.TabIndex = 1; buttonFinalize.TabIndex = 1;
buttonFinalize.Text = "Finalize"; buttonFinalize.Text = "Finalize";
buttonFinalize.UseVisualStyleBackColor = true; buttonFinalize.UseVisualStyleBackColor = true;
buttonFinalize.Visible = false; buttonFinalize.Visible = false;
buttonFinalize.Click += buttonFinalize_Click; buttonFinalize.Click += buttonFinalize_Click;
// //
// groupBoxDNS // groupBoxSign
// //
groupBoxDNS.Controls.Add(panelDNS); groupBoxSign.Controls.Add(textBoxSignMessage);
groupBoxDNS.Location = new Point(12, 221); groupBoxSign.Controls.Add(labelSignMessage);
groupBoxDNS.Name = "groupBoxDNS"; groupBoxSign.Font = new Font("Segoe UI", 14F, FontStyle.Regular, GraphicsUnit.Point);
groupBoxDNS.Size = new Size(756, 224); groupBoxSign.Location = new Point(12, 194);
groupBoxDNS.TabIndex = 3; groupBoxSign.Name = "groupBoxSign";
groupBoxDNS.TabStop = false; groupBoxSign.Size = new Size(756, 257);
groupBoxDNS.Text = "DNS"; groupBoxSign.TabIndex = 3;
groupBoxSign.TabStop = false;
groupBoxSign.Text = "Sign";
// //
// panelDNS // textBoxSignMessage
// //
panelDNS.AutoSize = true; textBoxSignMessage.Location = new Point(6, 56);
panelDNS.Dock = DockStyle.Fill; textBoxSignMessage.Multiline = true;
panelDNS.Location = new Point(3, 19); textBoxSignMessage.Name = "textBoxSignMessage";
panelDNS.Name = "panelDNS"; textBoxSignMessage.Size = new Size(744, 195);
panelDNS.Size = new Size(750, 202); textBoxSignMessage.TabIndex = 1;
panelDNS.TabIndex = 0; //
// labelSignMessage
//
labelSignMessage.AutoSize = true;
labelSignMessage.Location = new Point(6, 28);
labelSignMessage.Name = "labelSignMessage";
labelSignMessage.Size = new Size(90, 25);
labelSignMessage.TabIndex = 0;
labelSignMessage.Text = "Message:";
// //
// DomainForm // DomainForm
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(780, 457); ClientSize = new Size(780, 457);
Controls.Add(groupBoxDNS); Controls.Add(groupBoxSign);
Controls.Add(groupBoxManage); Controls.Add(groupBoxManage);
Controls.Add(buttonExplorer); Controls.Add(buttonExplorer);
Controls.Add(labelName); Controls.Add(labelName);
Controls.Add(groupBoxInfo);
FormBorderStyle = FormBorderStyle.Fixed3D; FormBorderStyle = FormBorderStyle.Fixed3D;
Icon = (Icon)resources.GetObject("$this.Icon"); Icon = (Icon)resources.GetObject("$this.Icon");
MaximizeBox = false; MaximizeBox = false;
@ -197,29 +195,26 @@
ShowInTaskbar = false; ShowInTaskbar = false;
Text = "DomainsForm"; Text = "DomainsForm";
Load += DomainForm_Load; Load += DomainForm_Load;
groupBoxInfo.ResumeLayout(false);
groupBoxInfo.PerformLayout();
groupBoxManage.ResumeLayout(false); groupBoxManage.ResumeLayout(false);
groupBoxManage.PerformLayout(); groupBoxManage.PerformLayout();
groupBoxDNS.ResumeLayout(false); groupBoxSign.ResumeLayout(false);
groupBoxDNS.PerformLayout(); groupBoxSign.PerformLayout();
ResumeLayout(false); ResumeLayout(false);
PerformLayout(); PerformLayout();
} }
#endregion #endregion
private GroupBox groupBoxInfo;
private Label labelName; private Label labelName;
private Button buttonExplorer; private Button buttonExplorer;
private Label labelInfo;
private Button buttonRenew; private Button buttonRenew;
private Button buttonTransfer; private Button buttonTransfer;
private GroupBox groupBoxManage; private GroupBox groupBoxManage;
private TextBox textBoxTransferAddress; private TextBox textBoxTransferAddress;
private Button buttonFinalize; private Button buttonFinalize;
private Button buttonCancel; private Button buttonCancel;
private GroupBox groupBoxDNS; private Label labelTransfer;
private Panel panelDNS; private GroupBox groupBoxSign;
private TextBox textBoxSignMessage;
private Label labelSignMessage;
} }
} }

View File

@ -6,17 +6,17 @@ namespace FireWalletLite
{ {
public partial class DomainForm : Form public partial class DomainForm : Form
{ {
private MainForm main; private MainForm Main;
private string domain; private string Domain;
public DomainForm(MainForm main, string domain) public DomainForm(MainForm main, string domain)
{ {
InitializeComponent(); InitializeComponent();
this.main = main; this.Main = main;
this.domain = domain; this.Domain = domain;
this.Text = domain + "/"; Text = domain + "/";
// 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);
@ -28,105 +28,45 @@ namespace FireWalletLite
{ {
ProcessStartInfo psi = new ProcessStartInfo ProcessStartInfo psi = new ProcessStartInfo
{ {
FileName = main.DomainExplorer + domain, FileName = Main.DomainExplorer + Domain,
UseShellExecute = true UseShellExecute = true
}; };
Process.Start(psi); Process.Start(psi);
} }
private void DomainForm_Load(object sender, EventArgs e)
private async void GetName()
{ {
try if (!File.Exists(Main.dir + "domains.json")) return;
JArray domains = JArray.Parse(File.ReadAllText(Main.dir + "domains.json"));
foreach (JObject domain in domains)
{ {
string content = "{\"method\": \"getnameinfo\", \"params\": [\"" + domain + "\"]}"; if (domain["name"].ToString() == Domain)
string response = await main.APIPost("", false, content);
JObject jObject = JObject.Parse(response);
// Get block height
string Nodeinfo = await main.APIGet("", false);
JObject jObjectInfo = JObject.Parse(Nodeinfo);
JObject chain = (JObject)jObjectInfo["chain"];
int height = Convert.ToInt32(chain["height"]);
labelInfo.Text = "";
if (jObject.ContainsKey("result"))
{ {
JObject result = (JObject)jObject["result"]; if (domain.ContainsKey("status"))
JObject start = (JObject)result["start"];
if (start["reserved"].ToString().ToLower() == "true") labelInfo.Text = "Reserved for ICANN domain owner\n";
if (result.ContainsKey("info"))
{ {
try switch (domain["status"].ToString())
{ {
JObject info = (JObject)result["info"]; case "transferring":
string state = info["state"].ToString(); buttonFinalize.Visible = true;
JObject stats = (JObject)info["stats"]; buttonCancel.Visible = true;
buttonTransfer.Visible = false;
if (info["transfer"].ToString() != "0") textBoxTransferAddress.Visible = false;
{ break;
labelInfo.Text += "Transferring\n"; case "closed":
int TransferEnd = Convert.ToInt32(stats["transferLockupEnd"].ToString()); buttonCancel.Visible = false;
textBoxTransferAddress.Hide(); buttonFinalize.Visible = false;
buttonTransfer.Hide(); break;
if (height >= TransferEnd)
{
buttonFinalize.Show();
}
else
{
labelInfo.Text += "Finalize in " + (TransferEnd - height).ToString() + " blocks\n";
buttonCancel.Show();
}
}
if (state == "CLOSED")
{
string expires = "Expires in ~" + stats["daysUntilExpire"].ToString() + " days\n";
labelInfo.Text += expires;
}
else labelInfo.Text += state + "\n";
// Get DNS if the domain isn't in auction
if (state == "CLOSED") GetDNS();
}
catch (Exception ex)
{
// No info -> Domain not in wallet
labelInfo.Text = "No info in node";
} }
} }
} }
else
{
labelInfo.Text = "Error getting Name";
}
} }
catch (Exception ex)
{
main.AddLog(ex.Message);
}
if (!main.Domains.Contains(domain))
{
groupBoxManage.Hide();
}
}
private void DomainForm_Load(object sender, EventArgs e)
{
GetName();
} }
private async void buttonRenew_Click(object sender, EventArgs e) private async void buttonRenew_Click(object sender, EventArgs e)
{ {
string content = "{\"method\": \"renew\", \"params\": [\"" + domain + "\"]}"; string content = "{\"method\": \"renew\", \"params\": [\"" + Domain + "\"]}";
string response = await main.APIPost("", true, content); string response = await Main.APIPost("", true, content);
if (response == "Error") if (response == "Error")
{ {
NotifyForm notify = new NotifyForm("Error renewing domain"); NotifyForm notify = new NotifyForm("Error renewing domain");
@ -137,12 +77,12 @@ namespace FireWalletLite
JObject jObject = JObject.Parse(response); JObject 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"]; JObject result = (JObject)jObject["result"];
if (result.ContainsKey("txid")) if (result.ContainsKey("txid"))
{ {
string txid = result["txid"].ToString(); string txid = result["txid"].ToString();
NotifyForm notify = new NotifyForm("Renewed domain", "Explorer", main.TXExplorer + txid); NotifyForm notify = new NotifyForm("Renewed domain", "Explorer", Main.TXExplorer + txid);
notify.ShowDialog(); notify.ShowDialog();
notify.Dispose(); notify.Dispose();
} }
@ -158,14 +98,14 @@ namespace FireWalletLite
NotifyForm notify = new NotifyForm("Error renewing domain"); NotifyForm notify = new NotifyForm("Error renewing domain");
notify.ShowDialog(); notify.ShowDialog();
notify.Dispose(); notify.Dispose();
main.AddLog(jObject.ToString()); Main.AddLog(jObject.ToString());
} }
} }
private async void buttonTransfer_Click(object sender, EventArgs e) private async void buttonTransfer_Click(object sender, EventArgs e)
{ {
string address = textBoxTransferAddress.Text; string address = textBoxTransferAddress.Text;
bool valid = await main.ValidAddress(address); bool valid = await Main.ValidAddress(address);
if (!valid) if (!valid)
{ {
NotifyForm notify = new NotifyForm("Invalid address"); NotifyForm notify = new NotifyForm("Invalid address");
@ -173,8 +113,9 @@ namespace FireWalletLite
notify.Dispose(); notify.Dispose();
return; return;
} }
string content = "{\"method\": \"transfer\", \"params\": [\"" + domain + "\", \"" + address + "\"]}"; string path = "wallet/" + Main.Account + "/transfer";
string response = await main.APIPost("", true, content); string content = "{\"passphrase\": \"" + Main.Password + "\", \"name\": \"" + Domain + "\", \"broadcast\": true, \"sign\": true, \"address\": \"" + address + "\"}";
string response = await Main.APIPost(path, true, content);
if (response == "Error") if (response == "Error")
{ {
NotifyForm notify = new NotifyForm("Error transferring domain"); NotifyForm notify = new NotifyForm("Error transferring domain");
@ -183,209 +124,118 @@ namespace FireWalletLite
return; return;
} }
JObject jObject = JObject.Parse(response); JObject jObject = JObject.Parse(response);
if (jObject.ContainsKey("result")) if (jObject.ContainsKey("hash"))
{ {
main.AddLog(jObject["result"].ToString()); string txid = jObject["hash"].ToString();
JObject result = (JObject)jObject["result"]; NotifyForm notify = new NotifyForm("Transferred domain", "Explorer", Main.TXExplorer + txid);
if (result.ContainsKey("txid")) notify.ShowDialog();
{ notify.Dispose();
string txid = result["txid"].ToString(); AddDomainInfo("transferring");
NotifyForm notify = new NotifyForm("Renewed domain", "Explorer", main.TXExplorer + txid);
notify.ShowDialog();
notify.Dispose();
}
else
{
NotifyForm notify = new NotifyForm("Error renewing domain");
notify.ShowDialog();
notify.Dispose();
}
} }
else else
{ {
NotifyForm notify = new NotifyForm("Error renewing domain"); NotifyForm notify = new NotifyForm("Error transferring domain");
notify.ShowDialog(); notify.ShowDialog();
notify.Dispose(); notify.Dispose();
main.AddLog(jObject.ToString());
} }
} }
private void buttonFinalize_Click(object sender, EventArgs e) private void buttonFinalize_Click(object sender, EventArgs e)
{ {
string content = "{\"method\": \"finalize\", \"params\": [\"" + domain + "\"]}"; string path = "wallet/" + Main.Account + "/finalize";
string response = main.APIPost("", true, content).Result; string content = "{\"passphrase\": \"" + Main.Password + "\", \"name\": \"" + Domain + "\", \"broadcast\": true, \"sign\": true}";
string response = Main.APIPost(path, true, content).Result;
if (response == "Error") if (response == "Error")
{ {
NotifyForm notify = new NotifyForm("Error finalizing tranfer"); NotifyForm notify = new NotifyForm("Error finalizing transfer");
notify.ShowDialog(); notify.ShowDialog();
notify.Dispose(); notify.Dispose();
return; return;
} }
JObject jObject = JObject.Parse(response); JObject jObject = JObject.Parse(response);
if (jObject.ContainsKey("result")) if (jObject.ContainsKey("hash"))
{ {
main.AddLog(jObject["result"].ToString()); string txid = jObject["hash"].ToString();
JObject result = (JObject)jObject["result"]; NotifyForm notify = new NotifyForm("Finalized domain", "Explorer", Main.TXExplorer + txid);
if (result.ContainsKey("txid")) notify.ShowDialog();
{ notify.Dispose();
string txid = result["txid"].ToString(); AddDomainInfo("closed");
NotifyForm notify = new NotifyForm("Finalized tranfer", "Explorer", main.TXExplorer + txid);
notify.ShowDialog();
notify.Dispose();
}
else
{
NotifyForm notify = new NotifyForm("Error finalizing tranfer");
notify.ShowDialog();
notify.Dispose();
}
} }
else else
{ {
NotifyForm notify = new NotifyForm("Error finalizing tranfer"); NotifyForm notify = new NotifyForm("Error finalizing domain");
notify.ShowDialog(); notify.ShowDialog();
notify.Dispose(); notify.Dispose();
main.AddLog(jObject.ToString());
} }
} }
private void buttonCancel_Click(object sender, EventArgs e) private void buttonCancel_Click(object sender, EventArgs e)
{ {
string content = "{\"method\": \"cancel\", \"params\": [\"" + domain + "\"]}"; string path = "wallet/" + Main.Account + "/cancel";
string response = main.APIPost("", true, content).Result; string content = "{\"passphrase\": \"" + Main.Password + "\", \"name\": \"" + Domain + "\", \"broadcast\": true, \"sign\": true}";
string response = Main.APIPost(path, true, content).Result;
if (response == "Error") if (response == "Error")
{ {
NotifyForm notify = new NotifyForm("Error cancelling tranfer"); NotifyForm notify = new NotifyForm("Error cancelling transfer");
notify.ShowDialog(); notify.ShowDialog();
notify.Dispose(); notify.Dispose();
return; return;
} }
JObject jObject = JObject.Parse(response); JObject jObject = JObject.Parse(response);
if (jObject.ContainsKey("result")) if (jObject.ContainsKey("hash"))
{ {
main.AddLog(jObject["result"].ToString()); string txid = jObject["hash"].ToString();
JObject result = (JObject)jObject["result"]; NotifyForm notify = new NotifyForm("Canceled transfer", "Explorer", Main.TXExplorer + txid);
if (result.ContainsKey("txid")) notify.ShowDialog();
{ notify.Dispose();
string txid = result["txid"].ToString(); AddDomainInfo("closed");
NotifyForm notify = new NotifyForm("Cancelled tranfer", "Explorer", main.TXExplorer + txid);
notify.ShowDialog();
notify.Dispose();
}
else
{
NotifyForm notify = new NotifyForm("Error cancelling tranfer");
notify.ShowDialog();
notify.Dispose();
}
} }
else else
{ {
NotifyForm notify = new NotifyForm("Error cancelling tranfer"); NotifyForm notify = new NotifyForm("Error cancelling transfer");
notify.ShowDialog(); notify.ShowDialog();
notify.Dispose(); notify.Dispose();
main.AddLog(jObject.ToString());
} }
} }
private void AddDomainInfo(string status)
// Get DNS records for domain. Not implemented yet
private async void GetDNS()
{ {
// Get DNS records if (File.Exists(Main.dir + "domains.json"))
string contentDNS = "{\"method\": \"getnameresource\", \"params\": [\"" + domain + "\"]}";
string responseDNS = await main.APIPost("", false, contentDNS);
JObject jObjectDNS = JObject.Parse(responseDNS);
if (jObjectDNS["result"].ToString() == "")
{ {
// Not registered bool found = false;
groupBoxDNS.Visible = false; JArray domains = JArray.Parse(File.ReadAllText(Main.dir + "domains.json"));
return; foreach (JObject domain in domains)
}
JObject result = (JObject)jObjectDNS["result"];
JArray records = (JArray)result["records"];
// For each record
int i = 0;
foreach (JObject record in records)
{
Panel DNSPanel = new Panel();
// Count for scroll width
DNSPanel.Width = panelDNS.Width - SystemInformation.VerticalScrollBarWidth - 2;
DNSPanel.Height = 60;
DNSPanel.BorderStyle = BorderStyle.FixedSingle;
DNSPanel.Top = 62 * i;
Label DNSType = new Label();
DNSType.Text = record["type"].ToString();
DNSType.Location = new System.Drawing.Point(10, 10);
DNSType.AutoSize = true;
DNSType.Font = new Font(DNSType.Font.FontFamily, 11.0f, FontStyle.Bold);
DNSPanel.Controls.Add(DNSType);
switch (DNSType.Text)
{ {
case "NS": if (domain["name"].ToString() == Domain)
Label DNSNS = new Label(); {
DNSNS.Text = record["ns"].ToString(); found = true;
DNSNS.Location = new System.Drawing.Point(10, 30); if (domain.ContainsKey("status"))
DNSNS.AutoSize = true;
DNSPanel.Controls.Add(DNSNS);
break;
case "GLUE4":
case "GLUE6":
Label DNSNS1 = new Label();
DNSNS1.Text = record["ns"].ToString();
DNSNS1.Location = new System.Drawing.Point(10, 30);
DNSNS1.AutoSize = true;
DNSPanel.Controls.Add(DNSNS1);
Label address = new Label();
address.Text = record["address"].ToString();
address.Location = new System.Drawing.Point(DNSNS1.Left + DNSNS1.Width + 20, 30);
address.AutoSize = true;
DNSPanel.Controls.Add(address);
break;
case "DS":
Label keyTag = new Label();
keyTag.Text = record["keyTag"].ToString();
keyTag.Location = new System.Drawing.Point(10, 30);
keyTag.AutoSize = true;
DNSPanel.Controls.Add(keyTag);
Label algorithm = new Label();
algorithm.Text = record["algorithm"].ToString();
algorithm.Location = new System.Drawing.Point(keyTag.Left + keyTag.Width + 10, 30);
algorithm.AutoSize = true;
DNSPanel.Controls.Add(algorithm);
Label digestType = new Label();
digestType.Text = record["digestType"].ToString();
digestType.Location = new System.Drawing.Point(algorithm.Left + algorithm.Width + 10, 30);
digestType.AutoSize = true;
DNSPanel.Controls.Add(digestType);
Label digest = new Label();
digest.Text = record["digest"].ToString();
digest.Location = new System.Drawing.Point(digestType.Left + digestType.Width + 10, 30);
digest.AutoSize = true;
DNSPanel.Controls.Add(digest);
break;
case "TXT":
JArray txts = (JArray)record["txt"];
int j = 0;
foreach (string txt in txts)
{ {
Label DNSTXT = new Label(); domain["status"] = status;
DNSTXT.Text = txt;
DNSTXT.Location = new System.Drawing.Point(10, 30 + (j * 20));
DNSTXT.AutoSize = true;
DNSPanel.Controls.Add(DNSTXT);
DNSPanel.Height = 60 + (j * 20);
j++;
} }
break; else
{
domain.Add("status", status);
}
}
} }
panelDNS.Controls.Add(DNSPanel);
i++; if (!found)
{
JObject domain = new JObject();
domain["name"] = Domain;
domain["status"] = status;
domains.Add(domain);
}
File.WriteAllText(Main.dir + "domains.json", domains.ToString());
}
else
{
JArray domains = new JArray();
JObject domain = new JObject();
domain["name"] = Domain;
domain["status"] = status;
domains.Add(domain);
File.WriteAllText(Main.dir + "domains.json", domains.ToString());
} }
} }
} }

View File

@ -1,13 +1,4 @@
using System; using FireWallet;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using FireWallet;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
namespace FireWalletLite namespace FireWalletLite

View File

@ -1,5 +1,4 @@
using System.Diagnostics; using System.Diagnostics;
using System.Net;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using FireWallet; using FireWallet;
@ -9,7 +8,7 @@ namespace FireWalletLite
{ {
#region Constants #region Constants
MainForm mainForm = new MainForm(); MainForm mainForm = new MainForm();
bool hideScreen = true; bool hideScreen = false;
Process HSDProcess; Process HSDProcess;
#endregion #endregion

View File

@ -1,10 +1,6 @@
using System.Data; using System.Diagnostics;
using System.Diagnostics;
using System.DirectoryServices.ActiveDirectory;
using System.Runtime.InteropServices;
using FireWallet; using FireWallet;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using static QRCoder.PayloadGenerator;
namespace FireWalletLite namespace FireWalletLite
{ {
@ -35,8 +31,8 @@ namespace FireWalletLite
public Dictionary<string, string> Theme { get; set; } public Dictionary<string, string> Theme { get; set; }
HttpClient httpClient = new HttpClient(); HttpClient httpClient = new HttpClient();
Decimal Balance { get; set; } Decimal Balance { get; set; }
String Account = "primary"; public String Account = "primary";
String Password { get; set; } public String Password { get; set; }
#endregion #endregion
public MainForm() public MainForm()
{ {
@ -247,7 +243,6 @@ namespace FireWalletLite
string port = "1203"; string port = "1203";
if (wallet) port = port + "9"; if (wallet) port = port + "9";
else port = port + "7"; else port = port + "7";
HttpRequestMessage req = new HttpRequestMessage(HttpMethod.Post, "http://" + ip + ":" + port + "/" + path); 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.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes("x:" + key)));
req.Content = new StringContent(content); req.Content = new StringContent(content);

View File

@ -1,15 +1,5 @@
using System; using System.Diagnostics;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace FireWallet namespace FireWallet
{ {

View File

@ -1,13 +1,4 @@
using System; using QRCoder;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using QRCoder;
namespace FireWalletLite namespace FireWalletLite
{ {

View File

@ -1,13 +1,4 @@
using System; using FireWallet;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using FireWallet;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
namespace FireWalletLite namespace FireWalletLite