main: Added multisig detect

This commit is contained in:
Nathan Woodburn 2023-06-26 14:31:15 +10:00
parent d8efdb98f7
commit cefd2d18c7
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
4 changed files with 243 additions and 64 deletions

View File

@ -39,6 +39,7 @@ namespace FireWallet
toolStripStatusLabelNetwork = new ToolStripStatusLabel(); toolStripStatusLabelNetwork = new ToolStripStatusLabel();
toolStripStatusLabelstatus = new ToolStripStatusLabel(); toolStripStatusLabelstatus = new ToolStripStatusLabel();
toolStripStatusLabelaccount = new ToolStripStatusLabel(); toolStripStatusLabelaccount = new ToolStripStatusLabel();
toolStripStatusLabelMultisig = new ToolStripStatusLabel();
toolStripStatusLabelLedger = new ToolStripStatusLabel(); toolStripStatusLabelLedger = new ToolStripStatusLabel();
toolStripSplitButtonlogout = new ToolStripSplitButton(); toolStripSplitButtonlogout = new ToolStripSplitButton();
toolStripDropDownButtonHelp = new ToolStripDropDownButton(); toolStripDropDownButtonHelp = new ToolStripDropDownButton();
@ -65,6 +66,7 @@ namespace FireWallet
buttonNavSend = new Button(); buttonNavSend = new Button();
buttonNavPortfolio = new Button(); buttonNavPortfolio = new Button();
panelPortfolio = new Panel(); panelPortfolio = new Panel();
buttonSendAll = new Button();
buttonRedeemAll = new Button(); buttonRedeemAll = new Button();
buttonRevealAll = new Button(); buttonRevealAll = new Button();
groupBoxTransactions = new GroupBox(); groupBoxTransactions = new GroupBox();
@ -127,7 +129,6 @@ 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();
@ -151,7 +152,7 @@ namespace FireWallet
// statusStripmain // statusStripmain
// //
statusStripmain.Dock = DockStyle.Top; 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.Location = new Point(0, 0);
statusStripmain.Name = "statusStripmain"; statusStripmain.Name = "statusStripmain";
statusStripmain.Size = new Size(1152, 22); statusStripmain.Size = new Size(1152, 22);
@ -183,12 +184,20 @@ namespace FireWallet
toolStripStatusLabelaccount.Size = new Size(55, 17); toolStripStatusLabelaccount.Size = new Size(55, 17);
toolStripStatusLabelaccount.Text = "Account:"; 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
// //
toolStripStatusLabelLedger.Margin = new Padding(50, 3, 50, 2); toolStripStatusLabelLedger.Margin = new Padding(50, 3, 50, 2);
toolStripStatusLabelLedger.Name = "toolStripStatusLabelLedger"; toolStripStatusLabelLedger.Name = "toolStripStatusLabelLedger";
toolStripStatusLabelLedger.Size = new Size(71, 17); toolStripStatusLabelLedger.Size = new Size(68, 17);
toolStripStatusLabelLedger.Text = "Cold Wallet:"; toolStripStatusLabelLedger.Text = "Cold Wallet";
toolStripStatusLabelLedger.Visible = false; toolStripStatusLabelLedger.Visible = false;
// //
// toolStripSplitButtonlogout // toolStripSplitButtonlogout
@ -459,6 +468,18 @@ namespace FireWallet
panelPortfolio.TabIndex = 7; panelPortfolio.TabIndex = 7;
panelPortfolio.Visible = false; 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
// //
buttonRedeemAll.FlatStyle = FlatStyle.Flat; buttonRedeemAll.FlatStyle = FlatStyle.Flat;
@ -1121,18 +1142,6 @@ 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);
@ -1281,5 +1290,6 @@ namespace FireWallet
private ToolStripMenuItem otherProjectsToolStripMenuItem; private ToolStripMenuItem otherProjectsToolStripMenuItem;
private Button buttonRedeemAll; private Button buttonRedeemAll;
private Button buttonSendAll; private Button buttonSendAll;
private ToolStripStatusLabel toolStripStatusLabelMultisig;
} }
} }

View File

@ -37,6 +37,7 @@ namespace FireWallet
// Batching variables // Batching variables
public bool BatchMode { get; set; } public bool BatchMode { get; set; }
public BatchForm BatchForm { get; set; } public BatchForm BatchForm { get; set; }
public bool multiSig { get; set; }
#endregion #endregion
#region Application #region Application
public MainForm() public MainForm()
@ -767,11 +768,11 @@ namespace FireWallet
if (jObject["watchOnly"].ToString() == "True") if (jObject["watchOnly"].ToString() == "True")
{ {
WatchOnly = true; WatchOnly = true;
toolStripStatusLabelLedger.Text = "Cold Wallet";
toolStripStatusLabelLedger.Visible = true; toolStripStatusLabelLedger.Visible = true;
buttonRevealAll.Visible = false; buttonRevealAll.Visible = false;
buttonRedeemAll.Visible = false; buttonRedeemAll.Visible = false;
buttonSendAll.Visible = false; buttonSendAll.Visible = false;
buttonAddressVerify.Visible = true;
} }
else else
{ {
@ -780,15 +781,38 @@ namespace FireWallet
buttonRevealAll.Visible = true; buttonRevealAll.Visible = true;
buttonRedeemAll.Visible = true; buttonRedeemAll.Visible = true;
buttonSendAll.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 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; return true;
} }
@ -1763,7 +1787,8 @@ namespace FireWallet
{ {
labelSendingError.Show(); labelSendingError.Show();
labelSendingError.Text = "HIP-02 lookup failed"; labelSendingError.Text = "HIP-02 lookup failed";
} else }
else
{ {
labelSendingHIPAddress.Text = address; labelSendingHIPAddress.Text = address;
labelSendingHIPAddress.Show(); labelSendingHIPAddress.Show();
@ -1897,7 +1922,10 @@ namespace FireWallet
{ {
AddLog("Failed:"); AddLog("Failed:");
AddLog(APIresp.ToString()); 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(); notify.ShowDialog();
return; return;
} }

View File

@ -46,9 +46,18 @@
label2 = new Label(); label2 = new Label();
groupBoxSeed = new GroupBox(); groupBoxSeed = new GroupBox();
textBoxSeedPhrase = new TextBox(); textBoxSeedPhrase = new TextBox();
groupBoxMulti = new GroupBox();
numericUpDownM = new NumericUpDown();
numericUpDownN = new NumericUpDown();
label7 = new Label();
label6 = new Label();
checkBoxMulti = new CheckBox();
groupBoxMode.SuspendLayout(); groupBoxMode.SuspendLayout();
groupBoxNew.SuspendLayout(); groupBoxNew.SuspendLayout();
groupBoxSeed.SuspendLayout(); groupBoxSeed.SuspendLayout();
groupBoxMulti.SuspendLayout();
((System.ComponentModel.ISupportInitialize)numericUpDownM).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownN).BeginInit();
SuspendLayout(); SuspendLayout();
// //
// buttonNext // buttonNext
@ -241,11 +250,74 @@
textBoxSeedPhrase.Size = new Size(438, 288); textBoxSeedPhrase.Size = new Size(438, 288);
textBoxSeedPhrase.TabIndex = 0; 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 // NewAccountForm
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(680, 430); ClientSize = new Size(680, 430);
Controls.Add(groupBoxMulti);
Controls.Add(groupBoxSeed); Controls.Add(groupBoxSeed);
Controls.Add(buttonCancel); Controls.Add(buttonCancel);
Controls.Add(buttonNext); Controls.Add(buttonNext);
@ -263,6 +335,10 @@
groupBoxNew.PerformLayout(); groupBoxNew.PerformLayout();
groupBoxSeed.ResumeLayout(false); groupBoxSeed.ResumeLayout(false);
groupBoxSeed.PerformLayout(); groupBoxSeed.PerformLayout();
groupBoxMulti.ResumeLayout(false);
groupBoxMulti.PerformLayout();
((System.ComponentModel.ISupportInitialize)numericUpDownM).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDownN).EndInit();
ResumeLayout(false); ResumeLayout(false);
} }
@ -285,5 +361,11 @@
private Label label5; private Label label5;
private GroupBox groupBoxSeed; private GroupBox groupBoxSeed;
private TextBox textBoxSeedPhrase; private TextBox textBoxSeedPhrase;
private GroupBox groupBoxMulti;
private CheckBox checkBoxMulti;
private NumericUpDown numericUpDownM;
private NumericUpDown numericUpDownN;
private Label label7;
private Label label6;
} }
} }

View File

@ -148,35 +148,26 @@ namespace FireWallet
if (page == 1) if (page == 1)
{ {
// Create new wallet groupBoxMulti.Show();
buttonNext.Enabled = false; page = 6;
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 if (page == 2) else if (page == 2)
{ {
groupBoxSeed.Show(); groupBoxSeed.Show();
buttonNext.Text = "Import";
page = 3; page = 3;
} }
else if (page == 3) else if (page == 3)
{ {
// Create new wallet page = 5;
groupBoxMulti.Show();
buttonNext.Text = "Import";
}
else if (page == 5)
{
if (!checkBoxMulti.Checked)
{
// Import wallet from seed
buttonNext.Enabled = false; buttonNext.Enabled = false;
string path = "wallet/" + textBoxNewName.Text; string path = "wallet/" + textBoxNewName.Text;
string content = "{\"passphrase\":\"" + textBoxNewPass1.Text + "\",\"mnemonic\":\"" + textBoxSeedPhrase.Text + "\"}"; string content = "{\"passphrase\":\"" + textBoxNewPass1.Text + "\",\"mnemonic\":\"" + textBoxSeedPhrase.Text + "\"}";
@ -195,6 +186,73 @@ namespace FireWallet
notify2.Dispose(); notify2.Dispose();
this.Close(); 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) else if (page == 4)
{ {
try try
@ -265,7 +323,8 @@ namespace FireWallet
if (resp.IsSuccessStatusCode) if (resp.IsSuccessStatusCode)
{ {
return await resp.Content.ReadAsStringAsync(); return await resp.Content.ReadAsStringAsync();
} else }
else
{ {
mainForm.AddLog("Put Error: " + await resp.Content.ReadAsStringAsync()); mainForm.AddLog("Put Error: " + await resp.Content.ReadAsStringAsync());
return "Error"; return "Error";