mirror of
https://github.com/Nathanwoodburn/FireWallet.git
synced 2024-11-10 09:18:15 +11:00
main: Added Register support
This commit is contained in:
parent
8f241fc90a
commit
9f33c74bb0
@ -1,5 +1,6 @@
|
|||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Net;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows.Forms.VisualStyles;
|
using System.Windows.Forms.VisualStyles;
|
||||||
@ -58,7 +59,7 @@ namespace FireWallet
|
|||||||
List<Batch> temp = new List<Batch>();
|
List<Batch> temp = new List<Batch>();
|
||||||
foreach (Batch batch in batches)
|
foreach (Batch batch in batches)
|
||||||
{
|
{
|
||||||
if (batch.domain != domain && batch.method != operation)
|
if (batch.domain != domain || batch.method != operation)
|
||||||
{
|
{
|
||||||
temp.Add(batch);
|
temp.Add(batch);
|
||||||
}
|
}
|
||||||
@ -122,7 +123,7 @@ namespace FireWallet
|
|||||||
List<Batch> temp = new List<Batch>();
|
List<Batch> temp = new List<Batch>();
|
||||||
foreach (Batch batch in batches)
|
foreach (Batch batch in batches)
|
||||||
{
|
{
|
||||||
if (batch.domain != domain && batch.method != operation)
|
if (batch.domain != domain || batch.method != operation)
|
||||||
{
|
{
|
||||||
temp.Add(batch);
|
temp.Add(batch);
|
||||||
}
|
}
|
||||||
@ -182,7 +183,7 @@ namespace FireWallet
|
|||||||
List<Batch> temp = new List<Batch>();
|
List<Batch> temp = new List<Batch>();
|
||||||
foreach (Batch batch in batches)
|
foreach (Batch batch in batches)
|
||||||
{
|
{
|
||||||
if (batch.domain != domain && batch.method != operation)
|
if (batch.domain != domain || batch.method != operation)
|
||||||
{
|
{
|
||||||
temp.Add(batch);
|
temp.Add(batch);
|
||||||
}
|
}
|
||||||
@ -238,7 +239,7 @@ namespace FireWallet
|
|||||||
List<Batch> temp = new List<Batch>();
|
List<Batch> temp = new List<Batch>();
|
||||||
foreach (Batch batch in batches)
|
foreach (Batch batch in batches)
|
||||||
{
|
{
|
||||||
if (batch.domain != domain && batch.method != operation)
|
if (batch.domain != domain || batch.method != operation)
|
||||||
{
|
{
|
||||||
temp.Add(batch);
|
temp.Add(batch);
|
||||||
}
|
}
|
||||||
@ -750,6 +751,10 @@ namespace FireWallet
|
|||||||
{
|
{
|
||||||
AddBatch(b.domain, b.method, b.toAddress);
|
AddBatch(b.domain, b.method, b.toAddress);
|
||||||
}
|
}
|
||||||
|
else if (b.method == "UPDATE")
|
||||||
|
{
|
||||||
|
AddBatch(b.domain, b.method, b.update);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddBatch(b.domain, b.method);
|
AddBatch(b.domain, b.method);
|
||||||
@ -792,22 +797,27 @@ namespace FireWallet
|
|||||||
req.Content = new StringContent(content);
|
req.Content = new StringContent(content);
|
||||||
|
|
||||||
// Send request
|
// Send request
|
||||||
HttpResponseMessage resp = await httpClient.SendAsync(req);
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
resp.EnsureSuccessStatusCode();
|
HttpResponseMessage resp = await httpClient.SendAsync(req);
|
||||||
}
|
if (resp.StatusCode != HttpStatusCode.OK)
|
||||||
catch (Exception ex)
|
|
||||||
{
|
{
|
||||||
AddLog("Post Error: " + ex.Message);
|
AddLog("Post Error: " + resp.StatusCode.ToString());
|
||||||
AddLog(await resp.Content.ReadAsStringAsync());
|
AddLog(await resp.Content.ReadAsStringAsync());
|
||||||
AddLog(content);
|
AddLog(content);
|
||||||
return "Error";
|
return "Error";
|
||||||
}
|
}
|
||||||
|
|
||||||
return await resp.Content.ReadAsStringAsync();
|
return await resp.Content.ReadAsStringAsync();
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
AddLog("Post Error: " + ex.Message);
|
||||||
|
return "Error";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public class Batch
|
public class Batch
|
||||||
{
|
{
|
||||||
@ -868,6 +878,10 @@ namespace FireWallet
|
|||||||
return "[\"UPDATE\", \"" + domain + "\", " + records + "]";
|
return "[\"UPDATE\", \"" + domain + "\", " + records + "]";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else if (method == "UPDATE")
|
||||||
|
{
|
||||||
|
return "[\"UPDATE\", \"" + domain + "\", {\"records\":[]}]";
|
||||||
|
}
|
||||||
return "[\"" + method + "\", \"" + domain + "\"]";
|
return "[\"" + method + "\", \"" + domain + "\"]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
FireWallet/BatchImportForm.Designer.cs
generated
2
FireWallet/BatchImportForm.Designer.cs
generated
@ -72,7 +72,7 @@
|
|||||||
comboBoxMode.FlatStyle = FlatStyle.Flat;
|
comboBoxMode.FlatStyle = FlatStyle.Flat;
|
||||||
comboBoxMode.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
comboBoxMode.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
||||||
comboBoxMode.FormattingEnabled = true;
|
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.Location = new Point(346, 42);
|
||||||
comboBoxMode.Name = "comboBoxMode";
|
comboBoxMode.Name = "comboBoxMode";
|
||||||
comboBoxMode.Size = new Size(226, 29);
|
comboBoxMode.Size = new Size(226, 29);
|
||||||
|
@ -263,6 +263,21 @@ namespace FireWallet
|
|||||||
}
|
}
|
||||||
this.Close();
|
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")
|
else if (comboBoxMode.Text == "TRANSFER")
|
||||||
{
|
{
|
||||||
batches = new Batch[0];
|
batches = new Batch[0];
|
||||||
|
@ -363,6 +363,12 @@ namespace FireWallet
|
|||||||
string contentDNS = "{\"method\": \"getnameresource\", \"params\": [\"" + domain + "\"]}";
|
string contentDNS = "{\"method\": \"getnameresource\", \"params\": [\"" + domain + "\"]}";
|
||||||
string responseDNS = await APIPost("", false, contentDNS);
|
string responseDNS = await APIPost("", false, contentDNS);
|
||||||
JObject jObjectDNS = JObject.Parse(responseDNS);
|
JObject jObjectDNS = JObject.Parse(responseDNS);
|
||||||
|
|
||||||
|
if (jObjectDNS["result"].ToString() == "")
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
JObject result = (JObject)jObjectDNS["result"];
|
JObject result = (JObject)jObjectDNS["result"];
|
||||||
JArray records = (JArray)result["records"];
|
JArray records = (JArray)result["records"];
|
||||||
// For each record
|
// For each record
|
||||||
|
@ -279,6 +279,14 @@ namespace FireWallet
|
|||||||
string contentDNS = "{\"method\": \"getnameresource\", \"params\": [\"" + domain + "\"]}";
|
string contentDNS = "{\"method\": \"getnameresource\", \"params\": [\"" + domain + "\"]}";
|
||||||
string responseDNS = await APIPost("", false, contentDNS);
|
string responseDNS = await APIPost("", false, contentDNS);
|
||||||
JObject jObjectDNS = JObject.Parse(responseDNS);
|
JObject jObjectDNS = JObject.Parse(responseDNS);
|
||||||
|
|
||||||
|
if (jObjectDNS["result"].ToString() == "")
|
||||||
|
{
|
||||||
|
// Not registered
|
||||||
|
groupBoxDNS.Visible = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
JObject result = (JObject)jObjectDNS["result"];
|
JObject result = (JObject)jObjectDNS["result"];
|
||||||
JArray records = (JArray)result["records"];
|
JArray records = (JArray)result["records"];
|
||||||
// For each record
|
// For each record
|
||||||
@ -814,7 +822,14 @@ namespace FireWallet
|
|||||||
|
|
||||||
if (!DNSEdit.cancel)
|
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 content = "{\"method\": \"sendupdate\", \"params\": [\"" + domain + "\", {\"records\": [" + records + "]}]}";
|
||||||
string response = await APIPost("", true, content);
|
string response = await APIPost("", true, content);
|
||||||
|
Loading…
Reference in New Issue
Block a user