mirror of
https://github.com/Nathanwoodburn/FireWallet.git
synced 2024-11-24 08:08:14 +11:00
main: Added redeem and send all
This commit is contained in:
parent
a4a35ad62e
commit
d41c72faff
32
FireWallet/MainForm.Designer.cs
generated
32
FireWallet/MainForm.Designer.cs
generated
@ -65,6 +65,7 @@ namespace FireWallet
|
|||||||
buttonNavSend = new Button();
|
buttonNavSend = new Button();
|
||||||
buttonNavPortfolio = new Button();
|
buttonNavPortfolio = new Button();
|
||||||
panelPortfolio = new Panel();
|
panelPortfolio = new Panel();
|
||||||
|
buttonRedeemAll = new Button();
|
||||||
buttonRevealAll = new Button();
|
buttonRevealAll = new Button();
|
||||||
groupBoxTransactions = new GroupBox();
|
groupBoxTransactions = new GroupBox();
|
||||||
groupBoxinfo = new GroupBox();
|
groupBoxinfo = new GroupBox();
|
||||||
@ -126,6 +127,7 @@ namespace FireWallet
|
|||||||
textBoxExAddr = new TextBox();
|
textBoxExAddr = new TextBox();
|
||||||
labelSettings4 = new Label();
|
labelSettings4 = new Label();
|
||||||
textBoxExTX = new TextBox();
|
textBoxExTX = new TextBox();
|
||||||
|
buttonSendAll = new Button();
|
||||||
statusStripmain.SuspendLayout();
|
statusStripmain.SuspendLayout();
|
||||||
panelaccount.SuspendLayout();
|
panelaccount.SuspendLayout();
|
||||||
groupBoxaccount.SuspendLayout();
|
groupBoxaccount.SuspendLayout();
|
||||||
@ -445,6 +447,8 @@ namespace FireWallet
|
|||||||
//
|
//
|
||||||
// panelPortfolio
|
// panelPortfolio
|
||||||
//
|
//
|
||||||
|
panelPortfolio.Controls.Add(buttonSendAll);
|
||||||
|
panelPortfolio.Controls.Add(buttonRedeemAll);
|
||||||
panelPortfolio.Controls.Add(buttonRevealAll);
|
panelPortfolio.Controls.Add(buttonRevealAll);
|
||||||
panelPortfolio.Controls.Add(groupBoxTransactions);
|
panelPortfolio.Controls.Add(groupBoxTransactions);
|
||||||
panelPortfolio.Controls.Add(groupBoxinfo);
|
panelPortfolio.Controls.Add(groupBoxinfo);
|
||||||
@ -455,13 +459,25 @@ namespace FireWallet
|
|||||||
panelPortfolio.TabIndex = 7;
|
panelPortfolio.TabIndex = 7;
|
||||||
panelPortfolio.Visible = false;
|
panelPortfolio.Visible = false;
|
||||||
//
|
//
|
||||||
|
// buttonRedeemAll
|
||||||
|
//
|
||||||
|
buttonRedeemAll.FlatStyle = FlatStyle.Flat;
|
||||||
|
buttonRedeemAll.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
||||||
|
buttonRedeemAll.Location = new Point(649, 12);
|
||||||
|
buttonRedeemAll.Name = "buttonRedeemAll";
|
||||||
|
buttonRedeemAll.Size = new Size(106, 44);
|
||||||
|
buttonRedeemAll.TabIndex = 9;
|
||||||
|
buttonRedeemAll.Text = "Redeem All";
|
||||||
|
buttonRedeemAll.UseVisualStyleBackColor = true;
|
||||||
|
buttonRedeemAll.Click += buttonRedeemAll_Click;
|
||||||
|
//
|
||||||
// buttonRevealAll
|
// buttonRevealAll
|
||||||
//
|
//
|
||||||
buttonRevealAll.FlatStyle = FlatStyle.Flat;
|
buttonRevealAll.FlatStyle = FlatStyle.Flat;
|
||||||
buttonRevealAll.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
buttonRevealAll.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
||||||
buttonRevealAll.Location = new Point(537, 12);
|
buttonRevealAll.Location = new Point(537, 12);
|
||||||
buttonRevealAll.Name = "buttonRevealAll";
|
buttonRevealAll.Name = "buttonRevealAll";
|
||||||
buttonRevealAll.Size = new Size(89, 44);
|
buttonRevealAll.Size = new Size(106, 44);
|
||||||
buttonRevealAll.TabIndex = 9;
|
buttonRevealAll.TabIndex = 9;
|
||||||
buttonRevealAll.Text = "Reveal All";
|
buttonRevealAll.Text = "Reveal All";
|
||||||
buttonRevealAll.UseVisualStyleBackColor = true;
|
buttonRevealAll.UseVisualStyleBackColor = true;
|
||||||
@ -1105,6 +1121,18 @@ namespace FireWallet
|
|||||||
textBoxExTX.Size = new Size(307, 29);
|
textBoxExTX.Size = new Size(307, 29);
|
||||||
textBoxExTX.TabIndex = 1;
|
textBoxExTX.TabIndex = 1;
|
||||||
//
|
//
|
||||||
|
// buttonSendAll
|
||||||
|
//
|
||||||
|
buttonSendAll.FlatStyle = FlatStyle.Flat;
|
||||||
|
buttonSendAll.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
||||||
|
buttonSendAll.Location = new Point(761, 12);
|
||||||
|
buttonSendAll.Name = "buttonSendAll";
|
||||||
|
buttonSendAll.Size = new Size(106, 44);
|
||||||
|
buttonSendAll.TabIndex = 9;
|
||||||
|
buttonSendAll.Text = "Send All TXs";
|
||||||
|
buttonSendAll.UseVisualStyleBackColor = true;
|
||||||
|
buttonSendAll.Click += buttonSendAll_Click;
|
||||||
|
//
|
||||||
// MainForm
|
// MainForm
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
@ -1251,5 +1279,7 @@ namespace FireWallet
|
|||||||
private Label labelDomainSort;
|
private Label labelDomainSort;
|
||||||
private ToolStripSeparator toolStripSeparator1;
|
private ToolStripSeparator toolStripSeparator1;
|
||||||
private ToolStripMenuItem otherProjectsToolStripMenuItem;
|
private ToolStripMenuItem otherProjectsToolStripMenuItem;
|
||||||
|
private Button buttonRedeemAll;
|
||||||
|
private Button buttonSendAll;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -152,8 +152,7 @@ namespace FireWallet
|
|||||||
AddLog("Loaded");
|
AddLog("Loaded");
|
||||||
|
|
||||||
|
|
||||||
// Pull form to front
|
// Pull form to front
|
||||||
|
|
||||||
this.WindowState = FormWindowState.Minimized;
|
this.WindowState = FormWindowState.Minimized;
|
||||||
this.Show();
|
this.Show();
|
||||||
this.Opacity = 1;
|
this.Opacity = 1;
|
||||||
@ -928,21 +927,25 @@ 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.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
AddLog("Post Error: " + resp.StatusCode);
|
||||||
|
AddLog(await resp.Content.ReadAsStringAsync());
|
||||||
|
return "Error";
|
||||||
|
}
|
||||||
|
return await resp.Content.ReadAsStringAsync();
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
AddLog("Post Error: " + ex.Message);
|
AddLog("Post Error: " + ex.Message);
|
||||||
AddLog(await resp.Content.ReadAsStringAsync());
|
|
||||||
AddLog("Content: " + content);
|
|
||||||
return "Error";
|
return "Error";
|
||||||
}
|
}
|
||||||
|
|
||||||
return await resp.Content.ReadAsStringAsync();
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get from HSD API
|
/// Get from HSD API
|
||||||
@ -972,7 +975,12 @@ namespace FireWallet
|
|||||||
request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes("x:" + key)));
|
request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes("x:" + key)));
|
||||||
// Send request and log response
|
// Send request and log response
|
||||||
HttpResponseMessage response = await httpClient.SendAsync(request);
|
HttpResponseMessage response = await httpClient.SendAsync(request);
|
||||||
response.EnsureSuccessStatusCode();
|
if (!response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
AddLog("Get Error: " + response.StatusCode);
|
||||||
|
AddLog(await response.Content.ReadAsStringAsync());
|
||||||
|
return "Error";
|
||||||
|
}
|
||||||
return await response.Content.ReadAsStringAsync();
|
return await response.Content.ReadAsStringAsync();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -993,8 +1001,15 @@ namespace FireWallet
|
|||||||
AddLog("GetAddress Error");
|
AddLog("GetAddress Error");
|
||||||
return "Error";
|
return "Error";
|
||||||
}
|
}
|
||||||
JObject resp = JObject.Parse(APIresponse);
|
try
|
||||||
return resp["address"].ToString();
|
{
|
||||||
|
JObject resp = JObject.Parse(APIresponse);
|
||||||
|
return resp["address"].ToString();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return "Error";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void GetTXHistory()
|
private async void GetTXHistory()
|
||||||
@ -2361,5 +2376,83 @@ namespace FireWallet
|
|||||||
Process.Start(psi);
|
Process.Start(psi);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
private async void buttonRedeemAll_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
buttonRedeemAll.Enabled = false;
|
||||||
|
string content = "{\"method\": \"sendbatch\", \"params\":[[[\"REDEEM\"]]]}";
|
||||||
|
AddLog(content);
|
||||||
|
string response = await APIPost("", true, content);
|
||||||
|
if (response == "Error")
|
||||||
|
{
|
||||||
|
AddLog("Error sending batch");
|
||||||
|
NotifyForm notifyForm = new NotifyForm("Error sending batch");
|
||||||
|
notifyForm.ShowDialog();
|
||||||
|
notifyForm.Dispose();
|
||||||
|
buttonRedeemAll.Enabled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
JObject resp = JObject.Parse(response);
|
||||||
|
if (resp["error"].ToString() != "")
|
||||||
|
{
|
||||||
|
AddLog("Error sending batch");
|
||||||
|
AddLog(resp["error"].ToString());
|
||||||
|
JObject error = JObject.Parse(resp["error"].ToString());
|
||||||
|
NotifyForm notifyForm = new NotifyForm("Error sending batch\n" + error["message"].ToString());
|
||||||
|
notifyForm.ShowDialog();
|
||||||
|
notifyForm.Dispose();
|
||||||
|
buttonRedeemAll.Enabled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (resp.ContainsKey("result"))
|
||||||
|
{
|
||||||
|
JObject result = JObject.Parse(resp["result"].ToString());
|
||||||
|
string hash = result["hash"].ToString();
|
||||||
|
NotifyForm notifyForm = new NotifyForm("Batch sent\n" + hash, "Explorer", UserSettings["explorer-tx"] + hash);
|
||||||
|
notifyForm.ShowDialog();
|
||||||
|
notifyForm.Dispose();
|
||||||
|
}
|
||||||
|
buttonRedeemAll.Enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void buttonSendAll_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
buttonSendAll.Enabled = false;
|
||||||
|
string content = "{\"method\": \"sendbatch\", \"params\":[[[\"REVEAL\"],[\"REDEEM\"],[\"RENEW\"]]]}";
|
||||||
|
AddLog(content);
|
||||||
|
string response = await APIPost("", true, content);
|
||||||
|
if (response == "Error")
|
||||||
|
{
|
||||||
|
AddLog("Error sending batch");
|
||||||
|
NotifyForm notifyForm = new NotifyForm("Error sending batch");
|
||||||
|
notifyForm.ShowDialog();
|
||||||
|
notifyForm.Dispose();
|
||||||
|
buttonSendAll.Enabled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
JObject resp = JObject.Parse(response);
|
||||||
|
if (resp["error"].ToString() != "")
|
||||||
|
{
|
||||||
|
AddLog("Error sending batch");
|
||||||
|
AddLog(resp["error"].ToString());
|
||||||
|
JObject error = JObject.Parse(resp["error"].ToString());
|
||||||
|
NotifyForm notifyForm = new NotifyForm("Error sending batch\n" + error["message"].ToString());
|
||||||
|
notifyForm.ShowDialog();
|
||||||
|
notifyForm.Dispose();
|
||||||
|
buttonSendAll.Enabled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (resp.ContainsKey("result"))
|
||||||
|
{
|
||||||
|
JObject result = JObject.Parse(resp["result"].ToString());
|
||||||
|
string hash = result["hash"].ToString();
|
||||||
|
NotifyForm notifyForm = new NotifyForm("Batch sent\n" + hash, "Explorer", UserSettings["explorer-tx"] + hash);
|
||||||
|
notifyForm.ShowDialog();
|
||||||
|
notifyForm.Dispose();
|
||||||
|
}
|
||||||
|
buttonSendAll.Enabled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user