mirror of
https://github.com/Nathanwoodburn/FireWallet.git
synced 2024-11-24 08:08:14 +11:00
main: Initial send multisig to address
This commit is contained in:
parent
cefd2d18c7
commit
b1d21289ab
16
FireWallet/MainForm.Designer.cs
generated
16
FireWallet/MainForm.Designer.cs
generated
@ -129,6 +129,7 @@ namespace FireWallet
|
|||||||
textBoxExAddr = new TextBox();
|
textBoxExAddr = new TextBox();
|
||||||
labelSettings4 = new Label();
|
labelSettings4 = new Label();
|
||||||
textBoxExTX = new TextBox();
|
textBoxExTX = new TextBox();
|
||||||
|
buttonMultiSign = new Button();
|
||||||
statusStripmain.SuspendLayout();
|
statusStripmain.SuspendLayout();
|
||||||
panelaccount.SuspendLayout();
|
panelaccount.SuspendLayout();
|
||||||
groupBoxaccount.SuspendLayout();
|
groupBoxaccount.SuspendLayout();
|
||||||
@ -365,6 +366,7 @@ namespace FireWallet
|
|||||||
// panelNav
|
// panelNav
|
||||||
//
|
//
|
||||||
panelNav.Controls.Add(buttonNavSettings);
|
panelNav.Controls.Add(buttonNavSettings);
|
||||||
|
panelNav.Controls.Add(buttonMultiSign);
|
||||||
panelNav.Controls.Add(buttonBatch);
|
panelNav.Controls.Add(buttonBatch);
|
||||||
panelNav.Controls.Add(buttonNavDomains);
|
panelNav.Controls.Add(buttonNavDomains);
|
||||||
panelNav.Controls.Add(buttonNavReceive);
|
panelNav.Controls.Add(buttonNavReceive);
|
||||||
@ -1142,6 +1144,19 @@ namespace FireWallet
|
|||||||
textBoxExTX.Size = new Size(307, 29);
|
textBoxExTX.Size = new Size(307, 29);
|
||||||
textBoxExTX.TabIndex = 1;
|
textBoxExTX.TabIndex = 1;
|
||||||
//
|
//
|
||||||
|
// buttonMultiSign
|
||||||
|
//
|
||||||
|
buttonMultiSign.FlatStyle = FlatStyle.Flat;
|
||||||
|
buttonMultiSign.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
|
||||||
|
buttonMultiSign.Location = new Point(12, 301);
|
||||||
|
buttonMultiSign.Name = "buttonMultiSign";
|
||||||
|
buttonMultiSign.Size = new Size(89, 30);
|
||||||
|
buttonMultiSign.TabIndex = 3;
|
||||||
|
buttonMultiSign.TabStop = false;
|
||||||
|
buttonMultiSign.Text = "Import TX";
|
||||||
|
buttonMultiSign.UseVisualStyleBackColor = true;
|
||||||
|
buttonMultiSign.Click += buttonMultiSign_Click;
|
||||||
|
//
|
||||||
// MainForm
|
// MainForm
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
@ -1291,5 +1306,6 @@ namespace FireWallet
|
|||||||
private Button buttonRedeemAll;
|
private Button buttonRedeemAll;
|
||||||
private Button buttonSendAll;
|
private Button buttonSendAll;
|
||||||
private ToolStripStatusLabel toolStripStatusLabelMultisig;
|
private ToolStripStatusLabel toolStripStatusLabelMultisig;
|
||||||
|
private Button buttonMultiSign;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,17 +1,17 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using Point = System.Drawing.Point;
|
|
||||||
using Size = System.Drawing.Size;
|
|
||||||
using QRCoder;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using System.Security.Cryptography;
|
|
||||||
using System.Text;
|
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using System.Net.Security;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Security.Cryptography.X509Certificates;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using DnsClient;
|
using DnsClient;
|
||||||
using DnsClient.Protocol;
|
using DnsClient.Protocol;
|
||||||
using System.Security.Cryptography.X509Certificates;
|
using Newtonsoft.Json.Linq;
|
||||||
using System.Net.Security;
|
using QRCoder;
|
||||||
|
using Point = System.Drawing.Point;
|
||||||
|
using Size = System.Drawing.Size;
|
||||||
|
|
||||||
namespace FireWallet
|
namespace FireWallet
|
||||||
{
|
{
|
||||||
@ -1519,6 +1519,12 @@ namespace FireWallet
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region Nav
|
#region Nav
|
||||||
|
private void buttonMultiSign_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
ImportTXForm importTXForm = new ImportTXForm(this);
|
||||||
|
importTXForm.ShowDialog();
|
||||||
|
importTXForm.Dispose();
|
||||||
|
}
|
||||||
private async void PortfolioPanel_Click(object sender, EventArgs e)
|
private async void PortfolioPanel_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
hidePages();
|
hidePages();
|
||||||
@ -1912,7 +1918,7 @@ namespace FireWallet
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!WatchOnly)
|
if (!WatchOnly && !multiSig)
|
||||||
{
|
{
|
||||||
string content = "{\"method\": \"sendtoaddress\",\"params\": [ \"" + address + "\", " +
|
string content = "{\"method\": \"sendtoaddress\",\"params\": [ \"" + address + "\", " +
|
||||||
amount.ToString() + ", \"\", \"\", " + subtractFee + " ]}";
|
amount.ToString() + ", \"\", \"\", " + subtractFee + " ]}";
|
||||||
@ -1940,7 +1946,46 @@ namespace FireWallet
|
|||||||
labelSendingError.Text = "";
|
labelSendingError.Text = "";
|
||||||
buttonNavPortfolio.PerformClick();
|
buttonNavPortfolio.PerformClick();
|
||||||
}
|
}
|
||||||
else // Cold wallet signing
|
else // Cold or multisig wallet signing
|
||||||
|
{
|
||||||
|
if (multiSig)
|
||||||
|
{
|
||||||
|
if (!WatchOnly)
|
||||||
|
{
|
||||||
|
string content = "{\"method\": \"createsendtoaddress\",\"params\": [ \"" + address + "\", " +
|
||||||
|
amount.ToString() + ", \"\", \"\", " + subtractFee + " ]}";
|
||||||
|
string output = await APIPost("", true, content);
|
||||||
|
JObject APIresp = JObject.Parse(output);
|
||||||
|
if (APIresp["error"].ToString() != "")
|
||||||
|
{
|
||||||
|
AddLog("Failed:");
|
||||||
|
AddLog(APIresp.ToString());
|
||||||
|
JObject error = JObject.Parse(APIresp["error"].ToString());
|
||||||
|
string ErrorMessage = error["message"].ToString();
|
||||||
|
|
||||||
|
NotifyForm notify = new NotifyForm("Error Transaction Failed\n" + ErrorMessage);
|
||||||
|
notify.ShowDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JObject result = JObject.Parse(APIresp["result"].ToString());
|
||||||
|
string hex = result["hex"].ToString();
|
||||||
|
|
||||||
|
content = "{\"tx\": \"" + hex + "\",\"passphrase\":\"" + Password + "\"}";
|
||||||
|
output = await APIPost("wallet/" + Account + "/sign", true, content);
|
||||||
|
if (!output.Contains("hex"))
|
||||||
|
{
|
||||||
|
AddLog("Failed:");
|
||||||
|
AddLog(APIresp.ToString());
|
||||||
|
NotifyForm notify = new NotifyForm("Error Transaction Failed\nCheck the logs");
|
||||||
|
notify.ShowDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ExportTransaction(output);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else // Cold wallet non multisig
|
||||||
{
|
{
|
||||||
AddLog("Sending CW " + amount.ToString() + " HNS to " + address);
|
AddLog("Sending CW " + amount.ToString() + " HNS to " + address);
|
||||||
|
|
||||||
@ -2031,6 +2076,7 @@ namespace FireWallet
|
|||||||
notifyError.ShowDialog();
|
notifyError.ShowDialog();
|
||||||
notifyError.Dispose();
|
notifyError.Dispose();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2042,6 +2088,7 @@ namespace FireWallet
|
|||||||
labelSendingError.Text = ex.Message;
|
labelSendingError.Text = ex.Message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CloneRepository(string repositoryUrl, string destinationPath)
|
public void CloneRepository(string repositoryUrl, string destinationPath)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -2650,5 +2697,64 @@ namespace FireWallet
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region Multi
|
||||||
|
private void ExportTransaction(string rawTX)
|
||||||
|
{
|
||||||
|
JObject tx = JObject.Parse(rawTX);
|
||||||
|
JObject toExport = new JObject();
|
||||||
|
toExport["version"] = 1;
|
||||||
|
toExport["tx"] = tx["hex"];
|
||||||
|
JArray inputsParsed = new JArray();
|
||||||
|
JArray outputsParsed = new JArray();
|
||||||
|
JArray inputs = JArray.Parse(tx["inputs"].ToString());
|
||||||
|
JArray outputs = JArray.Parse(tx["outputs"].ToString());
|
||||||
|
foreach (JObject input in inputs)
|
||||||
|
{
|
||||||
|
JObject coin = JObject.Parse(input["coin"].ToString());
|
||||||
|
JObject covenant = JObject.Parse(coin["covenant"].ToString());
|
||||||
|
string type = covenant["type"].ToString();
|
||||||
|
JObject data = new JObject();
|
||||||
|
if (type == "0")
|
||||||
|
{
|
||||||
|
inputsParsed.Add(data);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddLog("Not supported yet");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (JObject output in outputs)
|
||||||
|
{
|
||||||
|
JObject covenant = JObject.Parse(output["covenant"].ToString());
|
||||||
|
string type = covenant["type"].ToString();
|
||||||
|
JObject data = new JObject();
|
||||||
|
if (type == "0")
|
||||||
|
{
|
||||||
|
outputsParsed.Add(data);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddLog("Not supported yet");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
JObject metadata = new JObject();
|
||||||
|
metadata["inputs"] = inputsParsed;
|
||||||
|
metadata["outputs"] = outputsParsed;
|
||||||
|
toExport["metadata"] = metadata;
|
||||||
|
|
||||||
|
SaveFileDialog saveFileDialog = new SaveFileDialog
|
||||||
|
{
|
||||||
|
Filter = "JSON file (*.json)|*.json",
|
||||||
|
Title = "Save transaction as JSON"
|
||||||
|
};
|
||||||
|
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
StreamWriter sw = new StreamWriter(saveFileDialog.FileName);
|
||||||
|
sw.Write(toExport.ToString());
|
||||||
|
sw.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user