main: Added reveal and renew all buttons

This commit is contained in:
Nathan Woodburn 2023-06-12 14:23:02 +10:00
parent 72be43e16d
commit f4900cf9d6
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
3 changed files with 161 additions and 23 deletions

View File

@ -1,5 +1,6 @@
using System.Data; using System.Data;
using System.Diagnostics; using System.Diagnostics;
using System.Linq;
using System.Net; using System.Net;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Security.Principal; using System.Security.Principal;
@ -489,6 +490,11 @@ namespace FireWallet
NotifyForm notifyForm = new NotifyForm("Error: \nBatch output addresses would exceed lookahead\nYour batch might have too many TXs."); NotifyForm notifyForm = new NotifyForm("Error: \nBatch output addresses would exceed lookahead\nYour batch might have too many TXs.");
notifyForm.ShowDialog(); notifyForm.ShowDialog();
notifyForm.Dispose(); notifyForm.Dispose();
} else if (jObject["error"].ToString().Contains("Name is not registered"))
{
NotifyForm notifyForm = new NotifyForm("Error: \nName is not registered\nRemember you can't renew domains in transfer");
notifyForm.ShowDialog();
notifyForm.Dispose();
} }
else else
{ {

View File

@ -59,6 +59,8 @@ namespace FireWallet
buttonNavSend = new Button(); buttonNavSend = new Button();
buttonNavPortfolio = new Button(); buttonNavPortfolio = new Button();
panelPortfolio = new Panel(); panelPortfolio = new Panel();
buttonRenewAll = new Button();
buttonRevealAll = new Button();
groupBoxTransactions = new GroupBox(); groupBoxTransactions = new GroupBox();
groupBoxinfo = new GroupBox(); groupBoxinfo = new GroupBox();
labelPendingCount = new Label(); labelPendingCount = new Label();
@ -87,6 +89,7 @@ namespace FireWallet
textBoxReceiveAddress = new TextBox(); textBoxReceiveAddress = new TextBox();
labelReceive1 = new Label(); labelReceive1 = new Label();
panelDomains = new Panel(); panelDomains = new Panel();
buttonExportDomains = new Button();
groupBoxDomains = new GroupBox(); groupBoxDomains = new GroupBox();
panelDomainList = new Panel(); panelDomainList = new Panel();
labelDomainSearch = new Label(); labelDomainSearch = new Label();
@ -174,6 +177,7 @@ namespace FireWallet
toolStripStatusLabelLedger.Name = "toolStripStatusLabelLedger"; toolStripStatusLabelLedger.Name = "toolStripStatusLabelLedger";
toolStripStatusLabelLedger.Size = new Size(71, 17); toolStripStatusLabelLedger.Size = new Size(71, 17);
toolStripStatusLabelLedger.Text = "Cold Wallet:"; toolStripStatusLabelLedger.Text = "Cold Wallet:";
toolStripStatusLabelLedger.Visible = false;
// //
// toolStripSplitButtonlogout // toolStripSplitButtonlogout
// //
@ -386,15 +390,40 @@ namespace FireWallet
// //
// panelPortfolio // panelPortfolio
// //
panelPortfolio.Controls.Add(buttonRevealAll);
panelPortfolio.Controls.Add(groupBoxTransactions); panelPortfolio.Controls.Add(groupBoxTransactions);
panelPortfolio.Controls.Add(groupBoxinfo); panelPortfolio.Controls.Add(groupBoxinfo);
panelPortfolio.Controls.Add(groupBoxbalance); panelPortfolio.Controls.Add(groupBoxbalance);
panelPortfolio.Location = new Point(1085, 47); panelPortfolio.Location = new Point(1065, 80);
panelPortfolio.Name = "panelPortfolio"; panelPortfolio.Name = "panelPortfolio";
panelPortfolio.Size = new Size(956, 538); panelPortfolio.Size = new Size(956, 538);
panelPortfolio.TabIndex = 7; panelPortfolio.TabIndex = 7;
panelPortfolio.Visible = false; panelPortfolio.Visible = false;
// //
// buttonRenewAll
//
buttonRenewAll.FlatStyle = FlatStyle.Flat;
buttonRenewAll.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
buttonRenewAll.Location = new Point(813, 9);
buttonRenewAll.Name = "buttonRenewAll";
buttonRenewAll.Size = new Size(89, 32);
buttonRenewAll.TabIndex = 10;
buttonRenewAll.Text = "Renew All";
buttonRenewAll.UseVisualStyleBackColor = true;
buttonRenewAll.Click += buttonRenewAll_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.TabIndex = 9;
buttonRevealAll.Text = "Reveal All";
buttonRevealAll.UseVisualStyleBackColor = true;
buttonRevealAll.Click += buttonRevealAll_Click;
//
// groupBoxTransactions // groupBoxTransactions
// //
groupBoxTransactions.Dock = DockStyle.Bottom; groupBoxTransactions.Dock = DockStyle.Bottom;
@ -632,7 +661,7 @@ namespace FireWallet
panelRecieve.Controls.Add(labelReceive2); panelRecieve.Controls.Add(labelReceive2);
panelRecieve.Controls.Add(textBoxReceiveAddress); panelRecieve.Controls.Add(textBoxReceiveAddress);
panelRecieve.Controls.Add(labelReceive1); panelRecieve.Controls.Add(labelReceive1);
panelRecieve.Location = new Point(117, 34); panelRecieve.Location = new Point(1140, 24);
panelRecieve.Name = "panelRecieve"; panelRecieve.Name = "panelRecieve";
panelRecieve.Size = new Size(995, 523); panelRecieve.Size = new Size(995, 523);
panelRecieve.TabIndex = 17; panelRecieve.TabIndex = 17;
@ -692,15 +721,29 @@ namespace FireWallet
// //
// panelDomains // panelDomains
// //
panelDomains.Controls.Add(buttonRenewAll);
panelDomains.Controls.Add(buttonExportDomains);
panelDomains.Controls.Add(groupBoxDomains); panelDomains.Controls.Add(groupBoxDomains);
panelDomains.Controls.Add(labelDomainSearch); panelDomains.Controls.Add(labelDomainSearch);
panelDomains.Controls.Add(textBoxDomainSearch); panelDomains.Controls.Add(textBoxDomainSearch);
panelDomains.Location = new Point(1129, 22); panelDomains.Location = new Point(120, 48);
panelDomains.Name = "panelDomains"; panelDomains.Name = "panelDomains";
panelDomains.Size = new Size(920, 536); panelDomains.Size = new Size(920, 536);
panelDomains.TabIndex = 18; panelDomains.TabIndex = 18;
panelDomains.Visible = false; panelDomains.Visible = false;
// //
// buttonExportDomains
//
buttonExportDomains.FlatStyle = FlatStyle.Flat;
buttonExportDomains.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
buttonExportDomains.Location = new Point(351, 9);
buttonExportDomains.Name = "buttonExportDomains";
buttonExportDomains.Size = new Size(102, 32);
buttonExportDomains.TabIndex = 3;
buttonExportDomains.Text = "Export";
buttonExportDomains.UseVisualStyleBackColor = true;
buttonExportDomains.Click += export_Click;
//
// groupBoxDomains // groupBoxDomains
// //
groupBoxDomains.Controls.Add(panelDomainList); groupBoxDomains.Controls.Add(panelDomainList);
@ -749,7 +792,7 @@ namespace FireWallet
panelSettings.Controls.Add(buttonSettingsSave); panelSettings.Controls.Add(buttonSettingsSave);
panelSettings.Controls.Add(groupBoxSettingsExplorer); panelSettings.Controls.Add(groupBoxSettingsExplorer);
panelSettings.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); panelSettings.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
panelSettings.Location = new Point(121, 21); panelSettings.Location = new Point(1065, 211);
panelSettings.Name = "panelSettings"; panelSettings.Name = "panelSettings";
panelSettings.Size = new Size(930, 550); panelSettings.Size = new Size(930, 550);
panelSettings.TabIndex = 19; panelSettings.TabIndex = 19;
@ -965,13 +1008,13 @@ namespace FireWallet
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1152, 575); ClientSize = new Size(1152, 575);
Controls.Add(panelaccount); Controls.Add(panelaccount);
Controls.Add(panelPortfolio);
Controls.Add(panelRecieve); Controls.Add(panelRecieve);
Controls.Add(panelSettings);
Controls.Add(panelDomains); Controls.Add(panelDomains);
Controls.Add(panelSend); Controls.Add(panelSend);
Controls.Add(panelPortfolio);
Controls.Add(panelNav); Controls.Add(panelNav);
Controls.Add(statusStripmain); Controls.Add(statusStripmain);
Controls.Add(panelSettings);
Icon = (Icon)resources.GetObject("$this.Icon"); Icon = (Icon)resources.GetObject("$this.Icon");
Name = "MainForm"; Name = "MainForm";
Opacity = 0D; Opacity = 0D;
@ -1091,5 +1134,8 @@ namespace FireWallet
private Button buttonSettingsRescan; private Button buttonSettingsRescan;
private ToolStripStatusLabel toolStripStatusLabelLedger; private ToolStripStatusLabel toolStripStatusLabelLedger;
private Button buttonAddressVerify; private Button buttonAddressVerify;
private Button buttonRevealAll;
private Button buttonExportDomains;
private Button buttonRenewAll;
} }
} }

View File

@ -218,7 +218,8 @@ namespace FireWallet
hsdProcess.Start(); hsdProcess.Start();
// Wait for HSD to start // Wait for HSD to start
await Task.Delay(2000); await Task.Delay(2000);
} catch (Exception ex) }
catch (Exception ex)
{ {
AddLog("HSD Failed to start"); AddLog("HSD Failed to start");
AddLog(ex.Message); AddLog(ex.Message);
@ -556,9 +557,18 @@ namespace FireWallet
path = "wallet/" + account + ""; path = "wallet/" + account + "";
APIresponse = await APIGet(path, true); APIresponse = await APIGet(path, true);
JObject jObject = JObject.Parse(APIresponse); JObject jObject = JObject.Parse(APIresponse);
if (jObject["watchOnly"].ToString() == "True") watchOnly = true; if (jObject["watchOnly"].ToString() == "True")
else watchOnly = false; {
toolStripStatusLabelLedger.Text = "Cold Wallet: " + watchOnly.ToString(); watchOnly = true;
toolStripStatusLabelLedger.Text = "Cold Wallet";
toolStripStatusLabelLedger.Visible = true;
}
else
{
watchOnly = false;
toolStripStatusLabelLedger.Visible = false;
}
if (watchOnly) if (watchOnly)
{ {
@ -583,7 +593,7 @@ namespace FireWallet
notifyForm.Dispose(); notifyForm.Dispose();
return; return;
} }
account = comboBoxaccount.Text; account = comboBoxaccount.Text;
password = textBoxaccountpassword.Text; password = textBoxaccountpassword.Text;
bool loggedin = await Login(); bool loggedin = await Login();
@ -623,6 +633,7 @@ namespace FireWallet
{ {
password = ""; // Clear password from memory as soon as possible password = ""; // Clear password from memory as soon as possible
toolStripSplitButtonlogout.Visible = false; toolStripSplitButtonlogout.Visible = false;
toolStripStatusLabelLedger.Visible = false;
string path = "wallet/" + account + "/lock"; string path = "wallet/" + account + "/lock";
string content = ""; string content = "";
string APIresponse = await APIPost(path, true, content); string APIresponse = await APIPost(path, true, content);
@ -946,7 +957,7 @@ namespace FireWallet
await UpdateBalance(); await UpdateBalance();
GetTXHistory(); GetTXHistory();
labelBalance.Text = "Available: " + balance.ToString() + " HNS"; labelBalance.Text = "Available: " + balance.ToString() + " HNS";
labelLocked.Text = "Locked: " + balanceLocked.ToString() + " HNS"; labelLocked.Text = "Locked: " + balanceLocked.ToString() + " HNS*";
labelBalanceTotal.Text = "Total: " + (balance + balanceLocked).ToString() + " HNS"; labelBalanceTotal.Text = "Total: " + (balance + balanceLocked).ToString() + " HNS";
if (theme.ContainsKey("selected-bg") && theme.ContainsKey("selected-fg")) if (theme.ContainsKey("selected-bg") && theme.ContainsKey("selected-fg"))
{ {
@ -1438,12 +1449,15 @@ namespace FireWallet
#endregion #endregion
#region Domains #region Domains
public string[] Domains { get; set; } public string[] Domains { get; set; }
public string[] DomainsRenewable { get; set; }
private async void UpdateDomains() private async void UpdateDomains()
{ {
string response = await APIGet("wallet/" + account + "/name?own=true", true); string response = await APIGet("wallet/" + account + "/name?own=true", true);
JArray names = JArray.Parse(response); JArray names = JArray.Parse(response);
Domains = new string[names.Count]; Domains = new string[names.Count];
DomainsRenewable = new string[names.Count];
int i = 0; int i = 0;
int renewable = 0;
panelDomainList.Controls.Clear(); panelDomainList.Controls.Clear();
foreach (JObject name in names) foreach (JObject name in names)
{ {
@ -1468,9 +1482,9 @@ namespace FireWallet
domainName.Left = 5; domainName.Left = 5;
domainName.AutoSize = true; domainName.AutoSize = true;
domainTMP.Controls.Add(domainName); domainTMP.Controls.Add(domainName);
Label expiry = new Label(); Label expiry = new Label();
JObject stats = JObject.Parse(name["stats"].ToString()); JObject stats = JObject.Parse(name["stats"].ToString());
if (stats.ContainsKey("daysUntilExpire")) if (stats.ContainsKey("daysUntilExpire"))
@ -1480,15 +1494,61 @@ namespace FireWallet
expiry.AutoSize = true; expiry.AutoSize = true;
expiry.Left = domainTMP.Width - expiry.Width - 100; expiry.Left = domainTMP.Width - expiry.Width - 100;
domainTMP.Controls.Add(expiry); domainTMP.Controls.Add(expiry);
}
// Add to domains renewable
DomainsRenewable[renewable] = Domains[i];
renewable++;
}
else
{
expiry.Text = "Expires: Not Registered yet";
expiry.Top = 5;
expiry.AutoSize = true;
expiry.Left = domainTMP.Width - expiry.Width - 100;
domainTMP.Controls.Add(expiry);
}
panelDomainList.Controls.Add(domainTMP); panelDomainList.Controls.Add(domainTMP);
i++; i++;
} }
} }
private async void buttonRevealAll_Click(object sender, EventArgs e)
{
string content = "{\"method\": \"sendreveal\"}";
string response = await APIPost("", true, content);
AddLog(response);
if (response == "Error")
{
AddLog("Error sending reveal");
NotifyForm notifyForm = new NotifyForm("Error sending reveal");
notifyForm.ShowDialog();
notifyForm.Dispose();
return;
}
JObject resp = JObject.Parse(response);
if (resp["error"] != null)
{
AddLog("Error sending reveal");
AddLog(resp["error"].ToString());
JObject error = JObject.Parse(resp["error"].ToString());
NotifyForm notifyForm = new NotifyForm("Error sending reveal\n" + error["message"].ToString());
notifyForm.ShowDialog();
notifyForm.Dispose();
return;
}
if (resp.ContainsKey("result"))
{
JObject result = JObject.Parse(resp["result"].ToString());
string hash = result["hash"].ToString();
NotifyForm notifyForm = new NotifyForm("Reveal sent\n" + hash, "Explorer", userSettings["explorer-tx"] + hash);
notifyForm.ShowDialog();
notifyForm.Dispose();
}
}
private void textBoxDomainSearch_KeyDown(object sender, KeyEventArgs e) private void textBoxDomainSearch_KeyDown(object sender, KeyEventArgs e)
{ {
if (e.KeyValue == 13) if (e.KeyValue == 13)
@ -1654,11 +1714,37 @@ namespace FireWallet
} }
#endregion #endregion
private void export_Click(object sender, EventArgs e)
{
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "CSV file (*.csv)|*.csv";
saveFileDialog.Title = "Export";
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
StreamWriter sw = new StreamWriter(saveFileDialog.FileName);
foreach (string domain in DomainsRenewable)
{
if (domain == null) break;
sw.WriteLine(domain);
}
sw.Dispose();
}
}
private void buttonRenewAll_Click(object sender, EventArgs e)
{
if (DomainsRenewable == null)
{
NotifyForm notifyForm = new NotifyForm("No domains found\nMake sure you have synced your domains by visiting the domain page");
notifyForm.ShowDialog();
notifyForm.Dispose();
return;
}
foreach (string domain in DomainsRenewable)
{
if (domain == null) break;
AddBatch(domain, "RENEW");
}
}
} }
} }