mirror of
https://github.com/Nathanwoodburn/FireWallet.git
synced 2024-12-25 15:28:15 +11:00
main: Added multisig detect
This commit is contained in:
parent
d8efdb98f7
commit
cefd2d18c7
42
FireWallet/MainForm.Designer.cs
generated
42
FireWallet/MainForm.Designer.cs
generated
@ -39,6 +39,7 @@ namespace FireWallet
|
||||
toolStripStatusLabelNetwork = new ToolStripStatusLabel();
|
||||
toolStripStatusLabelstatus = new ToolStripStatusLabel();
|
||||
toolStripStatusLabelaccount = new ToolStripStatusLabel();
|
||||
toolStripStatusLabelMultisig = new ToolStripStatusLabel();
|
||||
toolStripStatusLabelLedger = new ToolStripStatusLabel();
|
||||
toolStripSplitButtonlogout = new ToolStripSplitButton();
|
||||
toolStripDropDownButtonHelp = new ToolStripDropDownButton();
|
||||
@ -65,6 +66,7 @@ namespace FireWallet
|
||||
buttonNavSend = new Button();
|
||||
buttonNavPortfolio = new Button();
|
||||
panelPortfolio = new Panel();
|
||||
buttonSendAll = new Button();
|
||||
buttonRedeemAll = new Button();
|
||||
buttonRevealAll = new Button();
|
||||
groupBoxTransactions = new GroupBox();
|
||||
@ -127,7 +129,6 @@ namespace FireWallet
|
||||
textBoxExAddr = new TextBox();
|
||||
labelSettings4 = new Label();
|
||||
textBoxExTX = new TextBox();
|
||||
buttonSendAll = new Button();
|
||||
statusStripmain.SuspendLayout();
|
||||
panelaccount.SuspendLayout();
|
||||
groupBoxaccount.SuspendLayout();
|
||||
@ -151,7 +152,7 @@ namespace FireWallet
|
||||
// statusStripmain
|
||||
//
|
||||
statusStripmain.Dock = DockStyle.Top;
|
||||
statusStripmain.Items.AddRange(new ToolStripItem[] { toolStripStatusLabelNetwork, toolStripStatusLabelstatus, toolStripStatusLabelaccount, toolStripStatusLabelLedger, toolStripSplitButtonlogout, toolStripDropDownButtonHelp });
|
||||
statusStripmain.Items.AddRange(new ToolStripItem[] { toolStripStatusLabelNetwork, toolStripStatusLabelstatus, toolStripStatusLabelaccount, toolStripStatusLabelMultisig, toolStripStatusLabelLedger, toolStripSplitButtonlogout, toolStripDropDownButtonHelp });
|
||||
statusStripmain.Location = new Point(0, 0);
|
||||
statusStripmain.Name = "statusStripmain";
|
||||
statusStripmain.Size = new Size(1152, 22);
|
||||
@ -183,12 +184,20 @@ namespace FireWallet
|
||||
toolStripStatusLabelaccount.Size = new Size(55, 17);
|
||||
toolStripStatusLabelaccount.Text = "Account:";
|
||||
//
|
||||
// toolStripStatusLabelMultisig
|
||||
//
|
||||
toolStripStatusLabelMultisig.Margin = new Padding(50, 3, 50, 2);
|
||||
toolStripStatusLabelMultisig.Name = "toolStripStatusLabelMultisig";
|
||||
toolStripStatusLabelMultisig.Size = new Size(50, 17);
|
||||
toolStripStatusLabelMultisig.Text = "Multisig";
|
||||
toolStripStatusLabelMultisig.Visible = false;
|
||||
//
|
||||
// toolStripStatusLabelLedger
|
||||
//
|
||||
toolStripStatusLabelLedger.Margin = new Padding(50, 3, 50, 2);
|
||||
toolStripStatusLabelLedger.Name = "toolStripStatusLabelLedger";
|
||||
toolStripStatusLabelLedger.Size = new Size(71, 17);
|
||||
toolStripStatusLabelLedger.Text = "Cold Wallet:";
|
||||
toolStripStatusLabelLedger.Size = new Size(68, 17);
|
||||
toolStripStatusLabelLedger.Text = "Cold Wallet";
|
||||
toolStripStatusLabelLedger.Visible = false;
|
||||
//
|
||||
// toolStripSplitButtonlogout
|
||||
@ -459,6 +468,18 @@ namespace FireWallet
|
||||
panelPortfolio.TabIndex = 7;
|
||||
panelPortfolio.Visible = false;
|
||||
//
|
||||
// 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;
|
||||
//
|
||||
// buttonRedeemAll
|
||||
//
|
||||
buttonRedeemAll.FlatStyle = FlatStyle.Flat;
|
||||
@ -1121,18 +1142,6 @@ namespace FireWallet
|
||||
textBoxExTX.Size = new Size(307, 29);
|
||||
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
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
@ -1281,5 +1290,6 @@ namespace FireWallet
|
||||
private ToolStripMenuItem otherProjectsToolStripMenuItem;
|
||||
private Button buttonRedeemAll;
|
||||
private Button buttonSendAll;
|
||||
private ToolStripStatusLabel toolStripStatusLabelMultisig;
|
||||
}
|
||||
}
|
@ -37,6 +37,7 @@ namespace FireWallet
|
||||
// Batching variables
|
||||
public bool BatchMode { get; set; }
|
||||
public BatchForm BatchForm { get; set; }
|
||||
public bool multiSig { get; set; }
|
||||
#endregion
|
||||
#region Application
|
||||
public MainForm()
|
||||
@ -767,11 +768,11 @@ namespace FireWallet
|
||||
if (jObject["watchOnly"].ToString() == "True")
|
||||
{
|
||||
WatchOnly = true;
|
||||
toolStripStatusLabelLedger.Text = "Cold Wallet";
|
||||
toolStripStatusLabelLedger.Visible = true;
|
||||
buttonRevealAll.Visible = false;
|
||||
buttonRedeemAll.Visible = false;
|
||||
buttonSendAll.Visible = false;
|
||||
buttonAddressVerify.Visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -780,15 +781,38 @@ namespace FireWallet
|
||||
buttonRevealAll.Visible = true;
|
||||
buttonRedeemAll.Visible = true;
|
||||
buttonSendAll.Visible = true;
|
||||
buttonAddressVerify.Visible = false;
|
||||
}
|
||||
if (WatchOnly)
|
||||
|
||||
path = "wallet/" + Account + "/account/default";
|
||||
APIresponse = await APIGet(path, true);
|
||||
if (APIresponse.Contains("Error"))
|
||||
{
|
||||
buttonAddressVerify.Visible = true;
|
||||
AddLog("Error getting default account");
|
||||
multiSig = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
buttonAddressVerify.Visible = false;
|
||||
jObject = JObject.Parse(APIresponse);
|
||||
if (jObject["n"].ToString() == "1")
|
||||
{
|
||||
multiSig = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
multiSig = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (multiSig)
|
||||
{
|
||||
toolStripStatusLabelMultisig.Visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
toolStripStatusLabelMultisig.Visible = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1763,7 +1787,8 @@ namespace FireWallet
|
||||
{
|
||||
labelSendingError.Show();
|
||||
labelSendingError.Text = "HIP-02 lookup failed";
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
labelSendingHIPAddress.Text = address;
|
||||
labelSendingHIPAddress.Show();
|
||||
@ -1897,7 +1922,10 @@ namespace FireWallet
|
||||
{
|
||||
AddLog("Failed:");
|
||||
AddLog(APIresp.ToString());
|
||||
NotifyForm notify = new NotifyForm("Error Transaction Failed");
|
||||
JObject error = JObject.Parse(APIresp["error"].ToString());
|
||||
string ErrorMessage = error["message"].ToString();
|
||||
|
||||
NotifyForm notify = new NotifyForm("Error Transaction Failed\n" + ErrorMessage);
|
||||
notify.ShowDialog();
|
||||
return;
|
||||
}
|
||||
|
82
FireWallet/NewAccountForm.Designer.cs
generated
82
FireWallet/NewAccountForm.Designer.cs
generated
@ -46,9 +46,18 @@
|
||||
label2 = new Label();
|
||||
groupBoxSeed = new GroupBox();
|
||||
textBoxSeedPhrase = new TextBox();
|
||||
groupBoxMulti = new GroupBox();
|
||||
numericUpDownM = new NumericUpDown();
|
||||
numericUpDownN = new NumericUpDown();
|
||||
label7 = new Label();
|
||||
label6 = new Label();
|
||||
checkBoxMulti = new CheckBox();
|
||||
groupBoxMode.SuspendLayout();
|
||||
groupBoxNew.SuspendLayout();
|
||||
groupBoxSeed.SuspendLayout();
|
||||
groupBoxMulti.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownM).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownN).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonNext
|
||||
@ -241,11 +250,74 @@
|
||||
textBoxSeedPhrase.Size = new Size(438, 288);
|
||||
textBoxSeedPhrase.TabIndex = 0;
|
||||
//
|
||||
// groupBoxMulti
|
||||
//
|
||||
groupBoxMulti.Controls.Add(numericUpDownM);
|
||||
groupBoxMulti.Controls.Add(numericUpDownN);
|
||||
groupBoxMulti.Controls.Add(label7);
|
||||
groupBoxMulti.Controls.Add(label6);
|
||||
groupBoxMulti.Controls.Add(checkBoxMulti);
|
||||
groupBoxMulti.Location = new Point(125, 22);
|
||||
groupBoxMulti.Name = "groupBoxMulti";
|
||||
groupBoxMulti.Size = new Size(450, 319);
|
||||
groupBoxMulti.TabIndex = 6;
|
||||
groupBoxMulti.TabStop = false;
|
||||
groupBoxMulti.Text = "Multisig";
|
||||
//
|
||||
// numericUpDownM
|
||||
//
|
||||
numericUpDownM.Location = new Point(223, 91);
|
||||
numericUpDownM.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
|
||||
numericUpDownM.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
|
||||
numericUpDownM.Name = "numericUpDownM";
|
||||
numericUpDownM.Size = new Size(120, 23);
|
||||
numericUpDownM.TabIndex = 2;
|
||||
numericUpDownM.Value = new decimal(new int[] { 1, 0, 0, 0 });
|
||||
//
|
||||
// numericUpDownN
|
||||
//
|
||||
numericUpDownN.Location = new Point(223, 55);
|
||||
numericUpDownN.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
|
||||
numericUpDownN.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
|
||||
numericUpDownN.Name = "numericUpDownN";
|
||||
numericUpDownN.Size = new Size(120, 23);
|
||||
numericUpDownN.TabIndex = 2;
|
||||
numericUpDownN.Value = new decimal(new int[] { 1, 0, 0, 0 });
|
||||
//
|
||||
// label7
|
||||
//
|
||||
label7.AutoSize = true;
|
||||
label7.Location = new Point(6, 93);
|
||||
label7.Name = "label7";
|
||||
label7.Size = new Size(211, 15);
|
||||
label7.TabIndex = 1;
|
||||
label7.Text = "Required Signers to send a transaction:";
|
||||
//
|
||||
// label6
|
||||
//
|
||||
label6.AutoSize = true;
|
||||
label6.Location = new Point(141, 61);
|
||||
label6.Name = "label6";
|
||||
label6.Size = new Size(76, 15);
|
||||
label6.TabIndex = 1;
|
||||
label6.Text = "Total Signers:";
|
||||
//
|
||||
// checkBoxMulti
|
||||
//
|
||||
checkBoxMulti.AutoSize = true;
|
||||
checkBoxMulti.Location = new Point(6, 23);
|
||||
checkBoxMulti.Name = "checkBoxMulti";
|
||||
checkBoxMulti.Size = new Size(115, 19);
|
||||
checkBoxMulti.TabIndex = 0;
|
||||
checkBoxMulti.Text = "Create a multisig";
|
||||
checkBoxMulti.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// NewAccountForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(680, 430);
|
||||
Controls.Add(groupBoxMulti);
|
||||
Controls.Add(groupBoxSeed);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonNext);
|
||||
@ -263,6 +335,10 @@
|
||||
groupBoxNew.PerformLayout();
|
||||
groupBoxSeed.ResumeLayout(false);
|
||||
groupBoxSeed.PerformLayout();
|
||||
groupBoxMulti.ResumeLayout(false);
|
||||
groupBoxMulti.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownM).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownN).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
@ -285,5 +361,11 @@
|
||||
private Label label5;
|
||||
private GroupBox groupBoxSeed;
|
||||
private TextBox textBoxSeedPhrase;
|
||||
private GroupBox groupBoxMulti;
|
||||
private CheckBox checkBoxMulti;
|
||||
private NumericUpDown numericUpDownM;
|
||||
private NumericUpDown numericUpDownN;
|
||||
private Label label7;
|
||||
private Label label6;
|
||||
}
|
||||
}
|
@ -148,53 +148,111 @@ namespace FireWallet
|
||||
|
||||
if (page == 1)
|
||||
{
|
||||
// Create new wallet
|
||||
buttonNext.Enabled = false;
|
||||
string path = "wallet/" + textBoxNewName.Text;
|
||||
string content = "{\"passphrase\":\"" + textBoxNewPass1.Text + "\"}";
|
||||
string response = await APIPut(path, true, content);
|
||||
if (response == "Error")
|
||||
{
|
||||
NotifyForm notify = new NotifyForm("Error creating wallet");
|
||||
notify.ShowDialog();
|
||||
notify.Dispose();
|
||||
buttonNext.Enabled = true;
|
||||
return;
|
||||
}
|
||||
mainForm.AddLog("Created wallet: " + textBoxNewName.Text);
|
||||
NotifyForm notify2 = new NotifyForm("Created wallet: " + textBoxNewName.Text);
|
||||
notify2.ShowDialog();
|
||||
notify2.Dispose();
|
||||
this.Close();
|
||||
groupBoxMulti.Show();
|
||||
page = 6;
|
||||
}
|
||||
else if (page == 2)
|
||||
{
|
||||
groupBoxSeed.Show();
|
||||
buttonNext.Text = "Import";
|
||||
page = 3;
|
||||
|
||||
}
|
||||
else if (page == 3)
|
||||
{
|
||||
// Create new wallet
|
||||
buttonNext.Enabled = false;
|
||||
string path = "wallet/" + textBoxNewName.Text;
|
||||
string content = "{\"passphrase\":\"" + textBoxNewPass1.Text + "\",\"mnemonic\":\"" + textBoxSeedPhrase.Text + "\"}";
|
||||
string response = await APIPut(path, true, content);
|
||||
if (response == "Error")
|
||||
{
|
||||
NotifyForm notify = new NotifyForm("Error creating wallet");
|
||||
notify.ShowDialog();
|
||||
notify.Dispose();
|
||||
buttonNext.Enabled = true;
|
||||
return;
|
||||
}
|
||||
mainForm.AddLog("Created wallet: " + textBoxNewName.Text);
|
||||
NotifyForm notify2 = new NotifyForm("Imported wallet: " + textBoxNewName.Text);
|
||||
notify2.ShowDialog();
|
||||
notify2.Dispose();
|
||||
this.Close();
|
||||
page = 5;
|
||||
groupBoxMulti.Show();
|
||||
buttonNext.Text = "Import";
|
||||
}
|
||||
else if (page == 5)
|
||||
{
|
||||
if (!checkBoxMulti.Checked)
|
||||
{
|
||||
// Import wallet from seed
|
||||
buttonNext.Enabled = false;
|
||||
string path = "wallet/" + textBoxNewName.Text;
|
||||
string content = "{\"passphrase\":\"" + textBoxNewPass1.Text + "\",\"mnemonic\":\"" + textBoxSeedPhrase.Text + "\"}";
|
||||
string response = await APIPut(path, true, content);
|
||||
if (response == "Error")
|
||||
{
|
||||
NotifyForm notify = new NotifyForm("Error creating wallet");
|
||||
notify.ShowDialog();
|
||||
notify.Dispose();
|
||||
buttonNext.Enabled = true;
|
||||
return;
|
||||
}
|
||||
mainForm.AddLog("Created wallet: " + textBoxNewName.Text);
|
||||
NotifyForm notify2 = new NotifyForm("Imported wallet: " + textBoxNewName.Text);
|
||||
notify2.ShowDialog();
|
||||
notify2.Dispose();
|
||||
this.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Import wallet from seed and create multisig
|
||||
buttonNext.Enabled = false;
|
||||
string path = "wallet/" + textBoxNewName.Text;
|
||||
string content = "{\"passphrase\":\"" + textBoxNewPass1.Text + "\",\"mnemonic\":\"" + textBoxSeedPhrase.Text + "\", \"type\":\"multisig\",\"m\":"+numericUpDownM.Value.ToString()+ ",\"n\":" +numericUpDownN.Value.ToString() + "}";
|
||||
string response = await APIPut(path, true, content);
|
||||
if (response == "Error")
|
||||
{
|
||||
NotifyForm notify = new NotifyForm("Error creating wallet");
|
||||
notify.ShowDialog();
|
||||
notify.Dispose();
|
||||
buttonNext.Enabled = true;
|
||||
return;
|
||||
}
|
||||
mainForm.AddLog("Created wallet: " + textBoxNewName.Text);
|
||||
NotifyForm notify2 = new NotifyForm("Imported wallet: " + textBoxNewName.Text);
|
||||
notify2.ShowDialog();
|
||||
notify2.Dispose();
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
else if (page == 6)
|
||||
{
|
||||
if (!checkBoxMulti.Checked)
|
||||
{
|
||||
// Create new wallet
|
||||
buttonNext.Enabled = false;
|
||||
string path = "wallet/" + textBoxNewName.Text;
|
||||
string content = "{\"passphrase\":\"" + textBoxNewPass1.Text + "\"}";
|
||||
string response = await APIPut(path, true, content);
|
||||
if (response == "Error")
|
||||
{
|
||||
NotifyForm notify = new NotifyForm("Error creating wallet");
|
||||
notify.ShowDialog();
|
||||
notify.Dispose();
|
||||
buttonNext.Enabled = true;
|
||||
return;
|
||||
}
|
||||
mainForm.AddLog("Created wallet: " + textBoxNewName.Text);
|
||||
NotifyForm notify2 = new NotifyForm("Created wallet: " + textBoxNewName.Text);
|
||||
notify2.ShowDialog();
|
||||
notify2.Dispose();
|
||||
this.Close();
|
||||
} else
|
||||
{
|
||||
// Create new wallet
|
||||
buttonNext.Enabled = false;
|
||||
string path = "wallet/" + textBoxNewName.Text;
|
||||
string content = "{\"passphrase\":\"" + textBoxNewPass1.Text + "\", \"type\":\"multisig\",\"m\":"+numericUpDownM.Value.ToString()+ ",\"n\":" +numericUpDownN.Value.ToString() + "}";
|
||||
string response = await APIPut(path, true, content);
|
||||
if (response == "Error")
|
||||
{
|
||||
NotifyForm notify = new NotifyForm("Error creating wallet");
|
||||
notify.ShowDialog();
|
||||
notify.Dispose();
|
||||
buttonNext.Enabled = true;
|
||||
return;
|
||||
}
|
||||
mainForm.AddLog("Created wallet: " + textBoxNewName.Text);
|
||||
NotifyForm notify2 = new NotifyForm("Created wallet: " + textBoxNewName.Text);
|
||||
notify2.ShowDialog();
|
||||
notify2.Dispose();
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
|
||||
else if (page == 4)
|
||||
{
|
||||
try
|
||||
@ -228,7 +286,7 @@ namespace FireWallet
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
mainForm.AddLog(ex.Message);
|
||||
mainForm.AddLog(ex.Message);
|
||||
NotifyForm notify = new NotifyForm("Error importing wallet\n" + ex.Message);
|
||||
notify.ShowDialog();
|
||||
notify.Dispose();
|
||||
@ -256,16 +314,17 @@ namespace FireWallet
|
||||
HttpRequestMessage req = new HttpRequestMessage(HttpMethod.Put, "http://" + ip + ":" + port + "/" + path);
|
||||
req.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes("x:" + key)));
|
||||
req.Content = new StringContent(content);
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
// Send request
|
||||
HttpResponseMessage resp = await httpClient.SendAsync(req);
|
||||
|
||||
|
||||
if (resp.IsSuccessStatusCode)
|
||||
{
|
||||
return await resp.Content.ReadAsStringAsync();
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
mainForm.AddLog("Put Error: " + await resp.Content.ReadAsStringAsync());
|
||||
return "Error";
|
||||
@ -277,7 +336,7 @@ namespace FireWallet
|
||||
return "Error";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user