mirror of
https://github.com/Nathanwoodburn/FireWallet.git
synced 2024-12-25 23:38:15 +11:00
main: Added transfers
This commit is contained in:
parent
de14b98c6f
commit
d073b7621f
@ -130,6 +130,65 @@ namespace FireWallet
|
||||
panelTXs.Controls.Add(tx);
|
||||
UpdateTheme();
|
||||
}
|
||||
public void AddBatch(string domain, string operation, string toAddress)
|
||||
{
|
||||
if (operation != "TRANSFER")
|
||||
{
|
||||
AddBatch(domain, operation);
|
||||
return;
|
||||
}
|
||||
batches = batches.Concat(new Batch[] { new Batch(domain, operation, toAddress) }).ToArray();
|
||||
Panel tx = new Panel();
|
||||
tx.Left = 0;
|
||||
tx.Top = panelTXs.Controls.Count * 52 + 2;
|
||||
tx.Width = panelTXs.Width - SystemInformation.VerticalScrollBarWidth;
|
||||
tx.Height = 50;
|
||||
tx.BorderStyle = BorderStyle.FixedSingle;
|
||||
|
||||
Label action = new Label();
|
||||
action.Text = operation;
|
||||
action.Location = new Point(10, 10);
|
||||
action.AutoSize = true;
|
||||
tx.Controls.Add(action);
|
||||
Label target = new Label();
|
||||
target.Text = domain;
|
||||
target.Location = new Point(10, 30);
|
||||
target.AutoSize = true;
|
||||
tx.Controls.Add(target);
|
||||
|
||||
Label toAddressLabel = new Label();
|
||||
toAddressLabel.Text = "-> " + toAddress;
|
||||
toAddressLabel.Location = new Point(200, 10);
|
||||
toAddressLabel.AutoSize = true;
|
||||
tx.Controls.Add(toAddressLabel);
|
||||
|
||||
|
||||
Button deleteTX = new Button();
|
||||
deleteTX.Text = "X";
|
||||
deleteTX.Location = new Point(tx.Width - 40, 10);
|
||||
deleteTX.Width = 25;
|
||||
deleteTX.Height = 25;
|
||||
deleteTX.TextAlign = ContentAlignment.MiddleCenter;
|
||||
deleteTX.Click += (sender, e) => {
|
||||
panelTXs.Controls.Remove(tx);
|
||||
FixSpacing();
|
||||
List<Batch> temp = new List<Batch>();
|
||||
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);
|
||||
|
||||
panelTXs.Controls.Add(tx);
|
||||
UpdateTheme();
|
||||
}
|
||||
|
||||
private void FixSpacing()
|
||||
{
|
||||
@ -389,7 +448,17 @@ namespace FireWallet
|
||||
StreamWriter sw = new StreamWriter(saveFileDialog.FileName);
|
||||
foreach (Batch b in batches)
|
||||
{
|
||||
sw.WriteLine(b.domain + "," + b.method + "," + b.bid + "," + b.lockup);
|
||||
if (b.method == "BID")
|
||||
{
|
||||
sw.WriteLine(b.domain + "," + b.method + "," + b.bid + "," + b.lockup, b.toAddress);
|
||||
}
|
||||
else if (b.method == "TRANSFER")
|
||||
{
|
||||
sw.WriteLine(b.domain + "," + b.method + "," + b.toAddress);
|
||||
} else
|
||||
{
|
||||
sw.WriteLine(b.domain + "," + b.method);
|
||||
}
|
||||
}
|
||||
sw.Dispose();
|
||||
}
|
||||
@ -414,6 +483,10 @@ namespace FireWallet
|
||||
{
|
||||
AddBatch(split[0], split[1]);
|
||||
}
|
||||
else if (split.Length == 3)
|
||||
{
|
||||
AddBatch(split[0], split[1], split[2]);
|
||||
}
|
||||
else if (split.Length == 4)
|
||||
{
|
||||
AddBatch(split[0], split[1], Convert.ToDecimal(split[2]), Convert.ToDecimal(split[3]));
|
||||
@ -446,7 +519,16 @@ namespace FireWallet
|
||||
{
|
||||
foreach (Batch b in batchImportForm.batches)
|
||||
{
|
||||
AddBatch(b.domain, b.method, b.bid, b.lockup);
|
||||
if (b.method == "BID")
|
||||
{
|
||||
AddBatch(b.domain, b.method, b.bid, b.lockup);
|
||||
} else if (b.method == "TRANSFER")
|
||||
{
|
||||
AddBatch(b.domain, b.method, b.toAddress);
|
||||
} else
|
||||
{
|
||||
AddBatch(b.domain, b.method);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -499,25 +581,47 @@ namespace FireWallet
|
||||
public string method { get; }
|
||||
public decimal bid { get; }
|
||||
public decimal lockup { get; }
|
||||
public Batch(string domain, string operation)
|
||||
public string toAddress { get; }
|
||||
public Batch(string domain, string method)
|
||||
{
|
||||
this.domain = domain;
|
||||
this.method = operation;
|
||||
this.method = method;
|
||||
bid = 0;
|
||||
lockup = 0;
|
||||
toAddress = "";
|
||||
}
|
||||
public Batch(string domain, string method, string toAddress)
|
||||
{
|
||||
this.domain = domain;
|
||||
this.method = method;
|
||||
this.toAddress = toAddress;
|
||||
bid = 0;
|
||||
lockup = 0;
|
||||
}
|
||||
public Batch(string domain, string operation, decimal bid, decimal lockup)
|
||||
public Batch(string domain, string method, decimal bid, decimal lockup)
|
||||
{
|
||||
this.domain = domain;
|
||||
this.method = operation;
|
||||
this.method = method;
|
||||
this.bid = bid;
|
||||
this.lockup = lockup;
|
||||
toAddress = "";
|
||||
}
|
||||
public Batch(string domain, string method, decimal bid, decimal lockup, string toAddress)
|
||||
{
|
||||
this.domain = domain;
|
||||
this.method = method;
|
||||
this.bid = bid;
|
||||
this.lockup = lockup;
|
||||
this.toAddress = toAddress;
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
if (method == "BID")
|
||||
{
|
||||
return "[\"BID\", \"" + domain + "\", " + bid + ", " + lockup + "]";
|
||||
} else if (method == "TRANSFER")
|
||||
{
|
||||
return "[\"TRANSFER\", \"" + domain + "\", \"" + toAddress + "\"]";
|
||||
}
|
||||
return "[\"" + method + "\", \"" + domain + "\"]";
|
||||
}
|
||||
|
73
FireWallet/BatchImportForm.Designer.cs
generated
73
FireWallet/BatchImportForm.Designer.cs
generated
@ -38,6 +38,12 @@
|
||||
textBoxBlind = new TextBox();
|
||||
buttonImport = new Button();
|
||||
buttonCancel = new Button();
|
||||
label5 = new Label();
|
||||
groupBoxBid = new GroupBox();
|
||||
groupBoxtransfer = new GroupBox();
|
||||
textBoxToAddress = new TextBox();
|
||||
groupBoxBid.SuspendLayout();
|
||||
groupBoxtransfer.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// listBoxDomains
|
||||
@ -65,11 +71,12 @@
|
||||
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.Items.AddRange(new object[] { "OPEN", "BID", "REVEAL", "REDEEM", "RENEW", "TRANSFER", "FINALIZE" });
|
||||
comboBoxMode.Location = new System.Drawing.Point(346, 42);
|
||||
comboBoxMode.Name = "comboBoxMode";
|
||||
comboBoxMode.Size = new System.Drawing.Size(226, 29);
|
||||
comboBoxMode.TabIndex = 2;
|
||||
comboBoxMode.SelectedIndexChanged += comboBoxMode_SelectedIndexChanged;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
@ -85,7 +92,7 @@
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
label3.Location = new System.Drawing.Point(305, 111);
|
||||
label3.Location = new System.Drawing.Point(25, 25);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new System.Drawing.Size(35, 21);
|
||||
label3.TabIndex = 3;
|
||||
@ -95,7 +102,7 @@
|
||||
//
|
||||
label4.AutoSize = true;
|
||||
label4.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
label4.Location = new System.Drawing.Point(292, 159);
|
||||
label4.Location = new System.Drawing.Point(12, 73);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new System.Drawing.Size(48, 21);
|
||||
label4.TabIndex = 3;
|
||||
@ -104,7 +111,7 @@
|
||||
// textBoxBid
|
||||
//
|
||||
textBoxBid.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
textBoxBid.Location = new System.Drawing.Point(346, 108);
|
||||
textBoxBid.Location = new System.Drawing.Point(66, 22);
|
||||
textBoxBid.Name = "textBoxBid";
|
||||
textBoxBid.Size = new System.Drawing.Size(226, 29);
|
||||
textBoxBid.TabIndex = 4;
|
||||
@ -112,7 +119,7 @@
|
||||
// textBoxBlind
|
||||
//
|
||||
textBoxBlind.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
textBoxBlind.Location = new System.Drawing.Point(346, 156);
|
||||
textBoxBlind.Location = new System.Drawing.Point(66, 70);
|
||||
textBoxBlind.Name = "textBoxBlind";
|
||||
textBoxBlind.Size = new System.Drawing.Size(226, 29);
|
||||
textBoxBlind.TabIndex = 5;
|
||||
@ -141,17 +148,57 @@
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// label5
|
||||
//
|
||||
label5.AutoSize = true;
|
||||
label5.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
label5.Location = new System.Drawing.Point(6, 19);
|
||||
label5.Name = "label5";
|
||||
label5.Size = new System.Drawing.Size(67, 21);
|
||||
label5.TabIndex = 7;
|
||||
label5.Text = "Send To:";
|
||||
//
|
||||
// groupBoxBid
|
||||
//
|
||||
groupBoxBid.Controls.Add(textBoxBid);
|
||||
groupBoxBid.Controls.Add(label3);
|
||||
groupBoxBid.Controls.Add(label4);
|
||||
groupBoxBid.Controls.Add(textBoxBlind);
|
||||
groupBoxBid.Location = new System.Drawing.Point(287, 99);
|
||||
groupBoxBid.Name = "groupBoxBid";
|
||||
groupBoxBid.Size = new System.Drawing.Size(370, 200);
|
||||
groupBoxBid.TabIndex = 8;
|
||||
groupBoxBid.TabStop = false;
|
||||
groupBoxBid.Text = "Bid Settings";
|
||||
//
|
||||
// groupBoxtransfer
|
||||
//
|
||||
groupBoxtransfer.Controls.Add(textBoxToAddress);
|
||||
groupBoxtransfer.Controls.Add(label5);
|
||||
groupBoxtransfer.Location = new System.Drawing.Point(287, 99);
|
||||
groupBoxtransfer.Name = "groupBoxtransfer";
|
||||
groupBoxtransfer.Size = new System.Drawing.Size(370, 200);
|
||||
groupBoxtransfer.TabIndex = 0;
|
||||
groupBoxtransfer.TabStop = false;
|
||||
groupBoxtransfer.Text = "Transfer Settings";
|
||||
//
|
||||
// textBoxToAddress
|
||||
//
|
||||
textBoxToAddress.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
textBoxToAddress.Location = new System.Drawing.Point(6, 43);
|
||||
textBoxToAddress.Name = "textBoxToAddress";
|
||||
textBoxToAddress.Size = new System.Drawing.Size(358, 29);
|
||||
textBoxToAddress.TabIndex = 8;
|
||||
//
|
||||
// BatchImportForm
|
||||
//
|
||||
AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new System.Drawing.Size(950, 535);
|
||||
Controls.Add(groupBoxtransfer);
|
||||
Controls.Add(groupBoxBid);
|
||||
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);
|
||||
@ -161,6 +208,10 @@
|
||||
Name = "BatchImportForm";
|
||||
Text = "Import";
|
||||
Load += BatchImportForm_Load;
|
||||
groupBoxBid.ResumeLayout(false);
|
||||
groupBoxBid.PerformLayout();
|
||||
groupBoxtransfer.ResumeLayout(false);
|
||||
groupBoxtransfer.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
@ -177,5 +228,9 @@
|
||||
private TextBox textBoxBlind;
|
||||
private Button buttonImport;
|
||||
private Button buttonCancel;
|
||||
private Label label5;
|
||||
private GroupBox groupBoxBid;
|
||||
private GroupBox groupBoxtransfer;
|
||||
private TextBox textBoxToAddress;
|
||||
}
|
||||
}
|
@ -234,18 +234,21 @@ namespace FireWallet
|
||||
|
||||
Batch[] newBatch = new Batch[batches.Length + 1];
|
||||
Array.Copy(batches, newBatch, batches.Length);
|
||||
newBatch[newBatch.Length - 1] = new Batch(domain, "BID", bid , lockup);
|
||||
newBatch[newBatch.Length - 1] = new Batch(domain, "BID", bid, lockup);
|
||||
batches = newBatch;
|
||||
} catch (Exception ex)
|
||||
}
|
||||
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")
|
||||
}
|
||||
else if (comboBoxMode.Text == "OPEN" || comboBoxMode.Text == "REVEAL" || comboBoxMode.Text == "REDEEM"
|
||||
|| comboBoxMode.Text == "RENEW" || comboBoxMode.Text == "FINALIZE")
|
||||
{
|
||||
batches = new Batch[0];
|
||||
foreach (string domain in listBoxDomains.Items)
|
||||
@ -259,11 +262,46 @@ namespace FireWallet
|
||||
}
|
||||
}
|
||||
this.Close();
|
||||
} else
|
||||
}
|
||||
else if (comboBoxMode.Text == "TRANSFER")
|
||||
{
|
||||
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, textBoxToAddress.Text);
|
||||
batches = newBatch;
|
||||
}
|
||||
}
|
||||
this.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Please select a mode");
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBoxMode_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (comboBoxMode.Text == "BID")
|
||||
{
|
||||
groupBoxBid.Visible = true;
|
||||
groupBoxtransfer.Visible = false;
|
||||
}
|
||||
else if (comboBoxMode.Text == "TRANSFER")
|
||||
{
|
||||
groupBoxBid.Visible = false;
|
||||
groupBoxtransfer.Visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
groupBoxBid.Visible = false;
|
||||
groupBoxtransfer.Visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public class Batch
|
||||
@ -272,12 +310,22 @@ public class Batch
|
||||
public string operation { get; }
|
||||
public decimal bid { get; }
|
||||
public decimal lockup { get; }
|
||||
public string toAddress { get; }
|
||||
public Batch(string domain, string operation)
|
||||
{
|
||||
this.domain = domain;
|
||||
this.operation = operation;
|
||||
bid = 0;
|
||||
lockup = 0;
|
||||
toAddress = "";
|
||||
}
|
||||
public Batch(string domain, string operation, string toAddress)
|
||||
{
|
||||
this.domain = domain;
|
||||
this.operation = operation;
|
||||
this.toAddress = toAddress;
|
||||
bid = 0;
|
||||
lockup = 0;
|
||||
}
|
||||
public Batch(string domain, string operation, decimal bid, decimal lockup)
|
||||
{
|
||||
@ -285,5 +333,6 @@ public class Batch
|
||||
this.operation = operation;
|
||||
this.bid = bid;
|
||||
this.lockup = lockup;
|
||||
toAddress = "";
|
||||
}
|
||||
}
|
||||
|
30
FireWallet/DomainForm.Designer.cs
generated
30
FireWallet/DomainForm.Designer.cs
generated
@ -47,6 +47,8 @@
|
||||
groupBoxBids = new GroupBox();
|
||||
panelBids = new Panel();
|
||||
groupBoxAction = new GroupBox();
|
||||
buttonTransfer = new Button();
|
||||
buttonRenew = new Button();
|
||||
textBoxBlind = new TextBox();
|
||||
textBoxBid = new TextBox();
|
||||
labelBlind = new Label();
|
||||
@ -240,6 +242,8 @@
|
||||
//
|
||||
// groupBoxAction
|
||||
//
|
||||
groupBoxAction.Controls.Add(buttonTransfer);
|
||||
groupBoxAction.Controls.Add(buttonRenew);
|
||||
groupBoxAction.Controls.Add(textBoxBlind);
|
||||
groupBoxAction.Controls.Add(textBoxBid);
|
||||
groupBoxAction.Controls.Add(labelBlind);
|
||||
@ -255,6 +259,30 @@
|
||||
groupBoxAction.Text = "Bid";
|
||||
groupBoxAction.Visible = false;
|
||||
//
|
||||
// buttonTransfer
|
||||
//
|
||||
buttonTransfer.FlatStyle = FlatStyle.Flat;
|
||||
buttonTransfer.Location = new System.Drawing.Point(253, 22);
|
||||
buttonTransfer.Name = "buttonTransfer";
|
||||
buttonTransfer.Size = new System.Drawing.Size(155, 37);
|
||||
buttonTransfer.TabIndex = 6;
|
||||
buttonTransfer.Text = "Transfer";
|
||||
buttonTransfer.UseVisualStyleBackColor = true;
|
||||
buttonTransfer.Visible = false;
|
||||
buttonTransfer.Click += buttonTransfer_Click;
|
||||
//
|
||||
// buttonRenew
|
||||
//
|
||||
buttonRenew.FlatStyle = FlatStyle.Flat;
|
||||
buttonRenew.Location = new System.Drawing.Point(414, 22);
|
||||
buttonRenew.Name = "buttonRenew";
|
||||
buttonRenew.Size = new System.Drawing.Size(155, 37);
|
||||
buttonRenew.TabIndex = 6;
|
||||
buttonRenew.Text = "Renew";
|
||||
buttonRenew.UseVisualStyleBackColor = true;
|
||||
buttonRenew.Visible = false;
|
||||
buttonRenew.Click += buttonRenew_Click;
|
||||
//
|
||||
// textBoxBlind
|
||||
//
|
||||
textBoxBlind.Location = new System.Drawing.Point(60, 64);
|
||||
@ -382,5 +410,7 @@
|
||||
private Button buttonActionAlt;
|
||||
private Button buttonActionMain;
|
||||
private Button buttonExplorer;
|
||||
private Button buttonRenew;
|
||||
private Button buttonTransfer;
|
||||
}
|
||||
}
|
@ -17,6 +17,8 @@ namespace FireWallet
|
||||
string state;
|
||||
string explorerTX;
|
||||
string explorerName;
|
||||
int TransferEnd;
|
||||
|
||||
|
||||
public MainForm mainForm { get; set; }
|
||||
|
||||
@ -234,7 +236,6 @@ namespace FireWallet
|
||||
string content = "{\"method\": \"getnameinfo\", \"params\": [\"" + domain + "\"]}";
|
||||
string response = await APIPost("", false, content);
|
||||
JObject jObject = JObject.Parse(response);
|
||||
|
||||
// Get block height
|
||||
string Nodeinfo = await APIGet("", false);
|
||||
JObject jObjectInfo = JObject.Parse(Nodeinfo);
|
||||
@ -259,11 +260,19 @@ namespace FireWallet
|
||||
labelStatusHighest.Text = convertHNS(info["highest"].ToString()) + " HNS";
|
||||
labelStatusPaid.Text = convertHNS(info["value"].ToString()) + " HNS";
|
||||
|
||||
if (info["transfer"].ToString() == "0") labelStatusTransferring.Text = "No";
|
||||
else labelStatusTransferring.Text = "Yes";
|
||||
|
||||
JObject stats = (JObject)info["stats"];
|
||||
|
||||
if (info["transfer"].ToString() == "0")
|
||||
{
|
||||
labelStatusTransferring.Text = "No";
|
||||
TransferEnd = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
labelStatusTransferring.Text = "Yes";
|
||||
TransferEnd = Convert.ToInt32(stats["transferLockupEnd"].ToString());
|
||||
}
|
||||
|
||||
if (state == "CLOSED")
|
||||
{
|
||||
string expires = stats["blocksUntilExpire"].ToString() + " Blocks (~" + stats["daysUntilExpire"].ToString() + " days)";
|
||||
@ -294,13 +303,13 @@ namespace FireWallet
|
||||
else groupBoxDNS.Visible = false;
|
||||
|
||||
//Setup action box
|
||||
ActionSetup(state);
|
||||
ActionSetupAsync(state);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// No info -> Domain not yet auctioned
|
||||
labelStatusMain.Text = "Available";
|
||||
ActionSetup("AVAILABLE");
|
||||
ActionSetupAsync("AVAILABLE");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -611,9 +620,18 @@ namespace FireWallet
|
||||
sw.Dispose();
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void ActionSetup(string state)
|
||||
private async Task<bool> DomainOwned()
|
||||
{
|
||||
string ownedDomains = await APIGet("wallet/hot/name?own=true", true);
|
||||
JArray ownedList = JArray.Parse(ownedDomains);
|
||||
foreach (JObject d in ownedList) if (d["name"].ToString() == domain) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private async void ActionSetupAsync(string state)
|
||||
{
|
||||
own = await DomainOwned();
|
||||
this.state = state;
|
||||
switch (state)
|
||||
{
|
||||
@ -641,8 +659,22 @@ namespace FireWallet
|
||||
{
|
||||
if (labelStatusTransferring.Text == "Yes")
|
||||
{
|
||||
// Check if can finalize
|
||||
groupBoxAction.Show();
|
||||
groupBoxAction.Text = "Finalize";
|
||||
|
||||
// Check if can finalize
|
||||
if (height >= TransferEnd)
|
||||
{
|
||||
buttonActionMain.Text = "Send Finalize";
|
||||
buttonActionAlt.Text = "Finalize in Batch";
|
||||
}
|
||||
else
|
||||
{
|
||||
labelBid.Text = "Finalize transfer in " + (TransferEnd - height).ToString() + " blocks";
|
||||
labelBid.Show();
|
||||
buttonActionMain.Text = "Cancel Transfer";
|
||||
buttonActionAlt.Text = "Cancel in Batch";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -650,6 +682,8 @@ namespace FireWallet
|
||||
groupBoxAction.Text = "Edit";
|
||||
buttonActionMain.Text = "Edit DNS";
|
||||
buttonActionAlt.Text = "Edit in Batch";
|
||||
buttonRenew.Show();
|
||||
buttonTransfer.Show();
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -684,7 +718,6 @@ namespace FireWallet
|
||||
{
|
||||
textBoxBlind.Text = "0";
|
||||
}
|
||||
await APIPost("", true, "{\"method\": \"selectwallet\", \"params\": [\"" + explorerTX + "\"]}");
|
||||
decimal bid = Convert.ToDecimal(textBoxBid.Text);
|
||||
decimal blind = Convert.ToDecimal(textBoxBlind.Text);
|
||||
decimal lockup = bid + blind;
|
||||
@ -722,7 +755,6 @@ namespace FireWallet
|
||||
}
|
||||
else if (state == "REVEAL")
|
||||
{
|
||||
await APIPost("", true, "{\"method\": \"selectwallet\", \"params\": [\"" + explorerTX + "\"]}");
|
||||
decimal bid = Convert.ToDecimal(textBoxBid.Text);
|
||||
decimal blind = Convert.ToDecimal(textBoxBlind.Text);
|
||||
decimal lockup = bid + blind;
|
||||
@ -759,7 +791,6 @@ namespace FireWallet
|
||||
}
|
||||
else if (state == "AVAILABLE")
|
||||
{
|
||||
await APIPost("", true, "{\"method\": \"selectwallet\", \"params\": [\"" + explorerTX + "\"]}");
|
||||
decimal bid = Convert.ToDecimal(textBoxBid.Text);
|
||||
decimal blind = Convert.ToDecimal(textBoxBlind.Text);
|
||||
decimal lockup = bid + blind;
|
||||
@ -793,6 +824,46 @@ namespace FireWallet
|
||||
notifyForm.Dispose();
|
||||
}
|
||||
}
|
||||
else if (state == "CLOSED")
|
||||
{
|
||||
if (labelStatusTransferring.Text == "Yes")
|
||||
{
|
||||
string content = "{\"method\": \"sendfinalize\", \"params\": [\"" + domain + "\"]}";
|
||||
if (height < TransferEnd)
|
||||
{
|
||||
content = "{\"method\": \"sendcancel\", \"params\": [\"" + domain + "\"]}";
|
||||
}
|
||||
string response = await APIPost("", true, content);
|
||||
|
||||
if (response == "Error")
|
||||
{
|
||||
NotifyForm notifyForm = new NotifyForm("Error sending finalize");
|
||||
notifyForm.ShowDialog();
|
||||
notifyForm.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
JObject jObject = JObject.Parse(response);
|
||||
if (jObject["result"].ToString() == "")
|
||||
{
|
||||
JObject error = (JObject)jObject["error"];
|
||||
string message = (string)error["message"];
|
||||
NotifyForm notifyForm2 = new NotifyForm("Error sending finalize: \n" + message);
|
||||
notifyForm2.ShowDialog();
|
||||
notifyForm2.Dispose();
|
||||
return;
|
||||
}
|
||||
JObject result = (JObject)jObject["result"];
|
||||
string hash = (string)result["hash"];
|
||||
|
||||
NotifyForm notifyForm = new NotifyForm("Finalize sent: " + hash, "Explorer", explorerTX + hash);
|
||||
notifyForm.ShowDialog();
|
||||
notifyForm.Dispose();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void Explorer_Click(object sender, EventArgs e)
|
||||
@ -835,7 +906,19 @@ namespace FireWallet
|
||||
}
|
||||
else if (state == "CLOSED")
|
||||
{
|
||||
|
||||
if (labelStatusTransferring.Text == "Yes")
|
||||
{
|
||||
if (height >= TransferEnd)
|
||||
{
|
||||
mainForm.AddBatch(domain, "FINALIZE");
|
||||
this.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
mainForm.AddBatch(domain, "CANCEL");
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -852,5 +935,15 @@ namespace FireWallet
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonRenew_Click(object sender, EventArgs e)
|
||||
{
|
||||
mainForm.AddBatch(domain, "RENEW");
|
||||
}
|
||||
|
||||
private void buttonTransfer_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Transfer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
28
FireWallet/MainForm.Designer.cs
generated
28
FireWallet/MainForm.Designer.cs
generated
@ -50,6 +50,7 @@ namespace FireWallet
|
||||
labelaccountusername = new Label();
|
||||
buttonaccountnew = new Button();
|
||||
panelNav = new Panel();
|
||||
buttonBatch = new Button();
|
||||
buttonNavDomains = new Button();
|
||||
buttonNavReceive = new Button();
|
||||
buttonNavSend = new Button();
|
||||
@ -84,7 +85,6 @@ namespace FireWallet
|
||||
panelDomains = new Panel();
|
||||
labelDomainSearch = new Label();
|
||||
textBoxDomainSearch = new TextBox();
|
||||
buttonBatch = new Button();
|
||||
statusStripmain.SuspendLayout();
|
||||
panelaccount.SuspendLayout();
|
||||
groupBoxaccount.SuspendLayout();
|
||||
@ -259,6 +259,19 @@ namespace FireWallet
|
||||
panelNav.Size = new Size(114, 553);
|
||||
panelNav.TabIndex = 6;
|
||||
//
|
||||
// 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;
|
||||
//
|
||||
// buttonNavDomains
|
||||
//
|
||||
buttonNavDomains.FlatStyle = FlatStyle.Flat;
|
||||
@ -632,19 +645,6 @@ 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);
|
||||
|
@ -126,6 +126,7 @@ namespace FireWallet
|
||||
sw.WriteLine("explorer-block: https://niami.io/block/");
|
||||
sw.WriteLine("explorer-domain: https://niami.io/domain/");
|
||||
sw.WriteLine("confirmations: 1");
|
||||
sw.WriteLine("portfolio-tx: 20");
|
||||
sw.Dispose();
|
||||
}
|
||||
|
||||
@ -475,6 +476,17 @@ namespace FireWallet
|
||||
toolStripStatusLabelstatus.Text = "Status: Node Connected";
|
||||
}
|
||||
|
||||
// Try to keep wallet unlocked
|
||||
string path = "wallet/" + account + "/unlock";
|
||||
string content = "{\"passphrase\": \"" + password + "\",\"timeout\": 60}";
|
||||
|
||||
await APIPost(path, true, content);
|
||||
|
||||
path = "";
|
||||
content = "{\"method\": \"selectwallet\",\"params\":[ \"" + account + "\"]}";
|
||||
|
||||
await APIPost(path, true, content);
|
||||
|
||||
}
|
||||
private async Task UpdateBalance()
|
||||
{
|
||||
@ -614,6 +626,8 @@ namespace FireWallet
|
||||
JArray txs = JArray.Parse(APIresponse);
|
||||
int txCount = txs.Count;
|
||||
if (txCount > groupBoxTransactions.Height / 55) txCount = (int)Math.Floor(groupBoxTransactions.Height / 55.0);
|
||||
if (userSettings.ContainsKey("portfolio-tx")) txCount = Convert.ToInt32(userSettings["portfolio-tx"]);
|
||||
if (txCount > txs.Count) txCount = txs.Count;
|
||||
Control[] tmpControls = new Control[txCount];
|
||||
for (int i = 0; i < txCount; i++)
|
||||
{
|
||||
@ -625,9 +639,9 @@ namespace FireWallet
|
||||
string date = tx["mdate"].ToString();
|
||||
|
||||
Panel tmpPanel = new Panel();
|
||||
tmpPanel.Width = groupBoxTransactions.Width - 20;
|
||||
tmpPanel.Width = groupBoxTransactions.Width - SystemInformation.VerticalScrollBarWidth - 20;
|
||||
tmpPanel.Height = 50;
|
||||
tmpPanel.Location = new Point(10, 20 + (i * 55));
|
||||
tmpPanel.Location = new Point(5, (i * 55));
|
||||
tmpPanel.BorderStyle = BorderStyle.FixedSingle;
|
||||
tmpPanel.BackColor = ColorTranslator.FromHtml(theme["background-alt"]);
|
||||
tmpPanel.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]);
|
||||
@ -692,7 +706,12 @@ namespace FireWallet
|
||||
|
||||
}
|
||||
groupBoxTransactions.Controls.Clear();
|
||||
groupBoxTransactions.Controls.AddRange(tmpControls);
|
||||
Panel txPanel = new Panel();
|
||||
txPanel.Width = groupBoxTransactions.Width - SystemInformation.VerticalScrollBarWidth;
|
||||
txPanel.Controls.AddRange(tmpControls);
|
||||
txPanel.AutoScroll = true;
|
||||
txPanel.Dock = DockStyle.Fill;
|
||||
groupBoxTransactions.Controls.Add(txPanel);
|
||||
|
||||
|
||||
}
|
||||
@ -728,11 +747,6 @@ namespace FireWallet
|
||||
private void timerNodeStatus_Tick(object sender, EventArgs e)
|
||||
{
|
||||
NodeStatus();
|
||||
// If logged in, update info
|
||||
if (panelaccount.Visible == false)
|
||||
{
|
||||
GetTXHistory();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region Nav
|
||||
@ -1018,6 +1032,7 @@ namespace FireWallet
|
||||
{
|
||||
if (e.KeyValue == 13)
|
||||
{
|
||||
textBoxDomainSearch.Text = textBoxDomainSearch.Text.Trim().ToLower();
|
||||
e.SuppressKeyPress = true;
|
||||
DomainForm domainForm = new DomainForm(textBoxDomainSearch.Text, userSettings["explorer-tx"], userSettings["explorer-domain"]);
|
||||
domainForm.mainForm = this;
|
||||
|
Loading…
Reference in New Issue
Block a user