multisig: Finished signing for hot wallets

This commit is contained in:
Nathan Woodburn 2023-06-26 18:48:12 +10:00
parent 6da345e650
commit 54d5c63db7
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
3 changed files with 103 additions and 9 deletions

View File

@ -40,6 +40,8 @@
labelSigsReq = new Label();
labelSigsSigned = new Label();
labelSigInfo = new Label();
buttonExport = new Button();
buttonSend = new Button();
groupBoxIn.SuspendLayout();
groupBoxOut.SuspendLayout();
SuspendLayout();
@ -86,7 +88,7 @@
//
buttonSign.FlatStyle = FlatStyle.Flat;
buttonSign.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
buttonSign.Location = new Point(789, 444);
buttonSign.Location = new Point(700, 444);
buttonSign.Name = "buttonSign";
buttonSign.Size = new Size(83, 36);
buttonSign.TabIndex = 2;
@ -98,7 +100,7 @@
//
Cancelbutton2.FlatStyle = FlatStyle.Flat;
Cancelbutton2.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
Cancelbutton2.Location = new Point(700, 444);
Cancelbutton2.Location = new Point(12, 441);
Cancelbutton2.Name = "Cancelbutton2";
Cancelbutton2.Size = new Size(83, 36);
Cancelbutton2.TabIndex = 2;
@ -150,6 +152,31 @@
labelSigInfo.TabIndex = 8;
labelSigInfo.Text = "#";
//
// buttonExport
//
buttonExport.Enabled = false;
buttonExport.FlatStyle = FlatStyle.Flat;
buttonExport.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
buttonExport.Location = new Point(611, 444);
buttonExport.Name = "buttonExport";
buttonExport.Size = new Size(83, 36);
buttonExport.TabIndex = 2;
buttonExport.Text = "Export";
buttonExport.UseVisualStyleBackColor = true;
buttonExport.Click += buttonExport_Click;
//
// buttonSend
//
buttonSend.FlatStyle = FlatStyle.Flat;
buttonSend.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
buttonSend.Location = new Point(789, 444);
buttonSend.Name = "buttonSend";
buttonSend.Size = new Size(83, 36);
buttonSend.TabIndex = 2;
buttonSend.Text = "Send";
buttonSend.UseVisualStyleBackColor = true;
buttonSend.Click += buttonSend_Click;
//
// ImportTXForm
//
AutoScaleDimensions = new SizeF(7F, 15F);
@ -162,6 +189,8 @@
Controls.Add(label1);
Controls.Add(groupBoxOut);
Controls.Add(groupBoxIn);
Controls.Add(buttonSend);
Controls.Add(buttonExport);
Controls.Add(Cancelbutton2);
Controls.Add(buttonSign);
FormBorderStyle = FormBorderStyle.FixedSingle;
@ -188,5 +217,7 @@
private Label labelSigsReq;
private Label labelSigsSigned;
private Label labelSigInfo;
private Button buttonExport;
private Button buttonSend;
}
}

View File

@ -9,6 +9,7 @@ namespace FireWallet
int totalSigs;
int reqSigs;
int sigs;
string signedTX;
public ImportTXForm(MainForm mainForm)
{
InitializeComponent();
@ -18,6 +19,7 @@ namespace FireWallet
private void ImportTXForm_Load(object sender, EventArgs e)
{
// Default variables
signedTX = "";
totalSigs = 3;
reqSigs = 2;
sigs = 0;
@ -266,10 +268,71 @@ namespace FireWallet
}
private async void buttonSign_Click(object sender, EventArgs e)
{
if (!mainForm.WatchOnly)
{
string content = "{\"tx\":\"" + tx["tx"].ToString() + "\", \"passphrase\":\"" + mainForm.Password + "\"}";
string response = await mainForm.APIPost("wallet/" + mainForm.Account + "/sign", true, content);
if (response == "Error" || response == "")
{
NotifyForm notifyForm = new NotifyForm("Error signing transaction");
notifyForm.ShowDialog();
notifyForm.Dispose();
return;
}
buttonSign.Enabled = false;
buttonExport.Enabled = true;
sigs++;
// Set sig label sizes
labelSigsReq.Width = (labelSigsTotal.Width / totalSigs) * reqSigs;
labelSigsSigned.Width = (labelSigsTotal.Width / totalSigs) * sigs;
labelSigInfo.Text = "Signed: " + sigs + "\nReq: " + reqSigs + " of " + totalSigs;
signedTX = response;
}
}
private void buttonExport_Click(object sender, EventArgs e)
{
mainForm.ExportTransaction(signedTX);
}
private async void buttonSend_Click(object sender, EventArgs e)
{
string content = "";
if (signedTX != "")
{
JObject signed = JObject.Parse(signedTX);
content = "{\"method\":\"sendrawtransaction\", \"params\":[\"" + signed["hex"].ToString() + "\"]}";
}
else
{
content = "{\"method\":\"sendrawtransaction\", \"params\":[\"" + tx["tx"].ToString() + "\"]}";
}
string response = await mainForm.APIPost("", false, content);
if (response == "Error" || response == "")
{
mainForm.AddLog(response);
NotifyForm notifyError = new NotifyForm("Error sending transaction");
notifyError.ShowDialog();
notifyError.Dispose();
return;
}
JObject responseJson = JObject.Parse(response);
if (responseJson["error"].ToString() != "")
{
mainForm.AddLog(response);
JObject error = (JObject)responseJson["error"];
NotifyForm notifyError = new NotifyForm("Error sending transaction\n" + error["message"].ToString());
notifyError.ShowDialog();
notifyError.Dispose();
return;
}
string txHash = responseJson["result"].ToString();
NotifyForm notifyForm = new NotifyForm("Transaction sent\nIf the transaction hasn't been signed it might not be mined", "Explorer", mainForm.UserSettings["explorer-tx"] + txHash);
notifyForm.ShowDialog();
notifyForm.Dispose();
this.Close();
}
}
}

View File

@ -2699,7 +2699,7 @@ namespace FireWallet
#region Multi
private void ExportTransaction(string rawTX)
public void ExportTransaction(string rawTX)
{
JObject tx = JObject.Parse(rawTX);
JObject toExport = new JObject();