mirror of
https://github.com/Nathanwoodburn/FireWallet.git
synced 2024-11-24 08:08:14 +11:00
multisig: Finished signing for hot wallets
This commit is contained in:
parent
6da345e650
commit
54d5c63db7
35
FireWallet/ImportTXForm.Designer.cs
generated
35
FireWallet/ImportTXForm.Designer.cs
generated
@ -40,6 +40,8 @@
|
|||||||
labelSigsReq = new Label();
|
labelSigsReq = new Label();
|
||||||
labelSigsSigned = new Label();
|
labelSigsSigned = new Label();
|
||||||
labelSigInfo = new Label();
|
labelSigInfo = new Label();
|
||||||
|
buttonExport = new Button();
|
||||||
|
buttonSend = new Button();
|
||||||
groupBoxIn.SuspendLayout();
|
groupBoxIn.SuspendLayout();
|
||||||
groupBoxOut.SuspendLayout();
|
groupBoxOut.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
@ -86,7 +88,7 @@
|
|||||||
//
|
//
|
||||||
buttonSign.FlatStyle = FlatStyle.Flat;
|
buttonSign.FlatStyle = FlatStyle.Flat;
|
||||||
buttonSign.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
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.Name = "buttonSign";
|
||||||
buttonSign.Size = new Size(83, 36);
|
buttonSign.Size = new Size(83, 36);
|
||||||
buttonSign.TabIndex = 2;
|
buttonSign.TabIndex = 2;
|
||||||
@ -98,7 +100,7 @@
|
|||||||
//
|
//
|
||||||
Cancelbutton2.FlatStyle = FlatStyle.Flat;
|
Cancelbutton2.FlatStyle = FlatStyle.Flat;
|
||||||
Cancelbutton2.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
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.Name = "Cancelbutton2";
|
||||||
Cancelbutton2.Size = new Size(83, 36);
|
Cancelbutton2.Size = new Size(83, 36);
|
||||||
Cancelbutton2.TabIndex = 2;
|
Cancelbutton2.TabIndex = 2;
|
||||||
@ -150,6 +152,31 @@
|
|||||||
labelSigInfo.TabIndex = 8;
|
labelSigInfo.TabIndex = 8;
|
||||||
labelSigInfo.Text = "#";
|
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
|
// ImportTXForm
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
@ -162,6 +189,8 @@
|
|||||||
Controls.Add(label1);
|
Controls.Add(label1);
|
||||||
Controls.Add(groupBoxOut);
|
Controls.Add(groupBoxOut);
|
||||||
Controls.Add(groupBoxIn);
|
Controls.Add(groupBoxIn);
|
||||||
|
Controls.Add(buttonSend);
|
||||||
|
Controls.Add(buttonExport);
|
||||||
Controls.Add(Cancelbutton2);
|
Controls.Add(Cancelbutton2);
|
||||||
Controls.Add(buttonSign);
|
Controls.Add(buttonSign);
|
||||||
FormBorderStyle = FormBorderStyle.FixedSingle;
|
FormBorderStyle = FormBorderStyle.FixedSingle;
|
||||||
@ -188,5 +217,7 @@
|
|||||||
private Label labelSigsReq;
|
private Label labelSigsReq;
|
||||||
private Label labelSigsSigned;
|
private Label labelSigsSigned;
|
||||||
private Label labelSigInfo;
|
private Label labelSigInfo;
|
||||||
|
private Button buttonExport;
|
||||||
|
private Button buttonSend;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,6 +9,7 @@ namespace FireWallet
|
|||||||
int totalSigs;
|
int totalSigs;
|
||||||
int reqSigs;
|
int reqSigs;
|
||||||
int sigs;
|
int sigs;
|
||||||
|
string signedTX;
|
||||||
public ImportTXForm(MainForm mainForm)
|
public ImportTXForm(MainForm mainForm)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -18,6 +19,7 @@ namespace FireWallet
|
|||||||
private void ImportTXForm_Load(object sender, EventArgs e)
|
private void ImportTXForm_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
// Default variables
|
// Default variables
|
||||||
|
signedTX = "";
|
||||||
totalSigs = 3;
|
totalSigs = 3;
|
||||||
reqSigs = 2;
|
reqSigs = 2;
|
||||||
sigs = 0;
|
sigs = 0;
|
||||||
@ -109,7 +111,7 @@ namespace FireWallet
|
|||||||
JObject sigGetResult = (JObject)sigGetJson["result"];
|
JObject sigGetResult = (JObject)sigGetJson["result"];
|
||||||
string[] asm = sigGetResult["asm"].ToString().Split(" ");
|
string[] asm = sigGetResult["asm"].ToString().Split(" ");
|
||||||
string totalSigsStr = asm[asm.Length - 2];
|
string totalSigsStr = asm[asm.Length - 2];
|
||||||
totalSigs = int.Parse(totalSigsStr.Replace("OP_",""));
|
totalSigs = int.Parse(totalSigsStr.Replace("OP_", ""));
|
||||||
reqSigs = int.Parse(sigGetResult["reqSigs"].ToString());
|
reqSigs = int.Parse(sigGetResult["reqSigs"].ToString());
|
||||||
sigs = -1;
|
sigs = -1;
|
||||||
for (int i = 0; i < witnesses.Count; i++)
|
for (int i = 0; i < witnesses.Count; i++)
|
||||||
@ -128,7 +130,7 @@ namespace FireWallet
|
|||||||
// Set sig label sizes
|
// Set sig label sizes
|
||||||
labelSigsReq.Width = (labelSigsTotal.Width / totalSigs) * reqSigs;
|
labelSigsReq.Width = (labelSigsTotal.Width / totalSigs) * reqSigs;
|
||||||
labelSigsSigned.Width = (labelSigsTotal.Width / totalSigs) * sigs;
|
labelSigsSigned.Width = (labelSigsTotal.Width / totalSigs) * sigs;
|
||||||
labelSigInfo.Text = "Signed: " + sigs + "\nReq: " + reqSigs + " of "+ totalSigs;
|
labelSigInfo.Text = "Signed: " + sigs + "\nReq: " + reqSigs + " of " + totalSigs;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -266,10 +268,71 @@ namespace FireWallet
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async void buttonSign_Click(object sender, EventArgs e)
|
private async void buttonSign_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!mainForm.WatchOnly)
|
||||||
{
|
{
|
||||||
string content = "{\"tx\":\"" + tx["tx"].ToString() + "\", \"passphrase\":\"" + mainForm.Password + "\"}";
|
string content = "{\"tx\":\"" + tx["tx"].ToString() + "\", \"passphrase\":\"" + mainForm.Password + "\"}";
|
||||||
string response = await mainForm.APIPost("wallet/" + mainForm.Account + "/sign", true, content);
|
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);
|
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();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2699,7 +2699,7 @@ namespace FireWallet
|
|||||||
|
|
||||||
|
|
||||||
#region Multi
|
#region Multi
|
||||||
private void ExportTransaction(string rawTX)
|
public void ExportTransaction(string rawTX)
|
||||||
{
|
{
|
||||||
JObject tx = JObject.Parse(rawTX);
|
JObject tx = JObject.Parse(rawTX);
|
||||||
JObject toExport = new JObject();
|
JObject toExport = new JObject();
|
||||||
|
Loading…
Reference in New Issue
Block a user