Skip to content

Commit

Permalink
Merge pull request #1 from Nathanwoodburn/multisig
Browse files Browse the repository at this point in the history
Add multisig support
  • Loading branch information
Nathanwoodburn authored Jun 27, 2023
2 parents d8efdb9 + ac5cc3f commit 0306b78
Show file tree
Hide file tree
Showing 14 changed files with 2,838 additions and 176 deletions.
61 changes: 54 additions & 7 deletions FireWallet/BatchForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Net;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms.VisualStyles;
using Newtonsoft.Json.Linq;
using ContentAlignment = System.Drawing.ContentAlignment;
using Point = System.Drawing.Point;
Expand Down Expand Up @@ -78,7 +77,6 @@ public void AddBatch(string domain, string operation)
tx.Controls.Add(deleteTX);

panelTXs.Controls.Add(tx);
UpdateTheme();
}
public void AddBatch(string domain, string operation, decimal bid, decimal lockup)
{
Expand Down Expand Up @@ -142,7 +140,6 @@ public void AddBatch(string domain, string operation, decimal bid, decimal locku
tx.Controls.Add(deleteTX);

panelTXs.Controls.Add(tx);
UpdateTheme();
}
public void AddBatch(string domain, string operation, string toAddress)
{
Expand Down Expand Up @@ -202,7 +199,6 @@ public void AddBatch(string domain, string operation, string toAddress)
tx.Controls.Add(deleteTX);

panelTXs.Controls.Add(tx);
UpdateTheme();
}

public void AddBatch(string domain, string operation, DNS[] updateRecords)
Expand Down Expand Up @@ -258,7 +254,6 @@ public void AddBatch(string domain, string operation, DNS[] updateRecords)
tx.Controls.Add(deleteTX);

panelTXs.Controls.Add(tx);
UpdateTheme();
}

private void FixSpacing()
Expand All @@ -278,7 +273,7 @@ public void AddLog(string message)
}
#endregion
#region Theming
private void UpdateTheme()
public void UpdateTheme()
{
// Check if file exists
if (!Directory.Exists(dir))
Expand Down Expand Up @@ -471,7 +466,7 @@ private void buttonCancel_Click(object sender, EventArgs e)
HttpClient httpClient = new HttpClient();
private async void buttonSend_Click(object sender, EventArgs e)
{
if (!mainForm.WatchOnly)
if (!mainForm.WatchOnly && !mainForm.multiSig)
{
string batchTX = "[" + string.Join(", ", batches.Select(batch => batch.ToString())) + "]";
string content = "{\"method\": \"sendbatch\",\"params\":[ " + batchTX + "]}";
Expand Down Expand Up @@ -519,6 +514,58 @@ private async void buttonSend_Click(object sender, EventArgs e)
notifyForm2.Dispose();
this.Close();
}
else if (mainForm.multiSig)
{
string batchTX = "[" + string.Join(", ", batches.Select(batch => batch.ToString())) + "]";
string content = "{\"method\": \"createbatch\",\"params\":[ " + batchTX + "]}";
string responce = await APIPost("", true, content);

if (responce == "Error")
{
AddLog("Error sending batch");
NotifyForm notifyForm = new NotifyForm("Error sending batch");
notifyForm.ShowDialog();
notifyForm.Dispose();
return;
}

JObject jObject = JObject.Parse(responce);
if (jObject["error"].ToString() != "")
{
AddLog("Error: ");
AddLog(jObject["error"].ToString());
if (jObject["error"].ToString().Contains("Batch output addresses would exceed lookahead"))
{
NotifyForm notifyForm = new NotifyForm("Error: \nBatch output addresses would exceed lookahead\nYour batch might have too many TXs.");
notifyForm.ShowDialog();
notifyForm.Dispose();
}
else if (jObject["error"].ToString().Contains("Name is not registered"))
{
NotifyForm notifyForm = new NotifyForm("Error: \nName is not registered\nRemember you can't renew domains in transfer");
notifyForm.ShowDialog();
notifyForm.Dispose();
}
else
{
NotifyForm notifyForm = new NotifyForm("Error: \n" + jObject["error"].ToString());
notifyForm.ShowDialog();
notifyForm.Dispose();
}
return;
}

string[] domains = batches.Select(batch => batch.domain).ToArray();
string tx = await mainForm.ExportTransaction(jObject["result"].ToString(),domains);
if (tx != "Error")
{
ImportTXForm importTXForm = new ImportTXForm(mainForm, tx);
this.Hide();
importTXForm.ShowDialog();
importTXForm.Dispose();
this.Close();
}
}
else // watch only
{
string batchTX = "[" + string.Join(", ", batches.Select(batch => batch.ToString())) + "]";
Expand Down
4 changes: 2 additions & 2 deletions FireWallet/DomainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ private void DomainForm_Load(object sender, EventArgs e)
network = Convert.ToInt32(nodeSettings["Network"]);
GetName();

if (mainForm.WatchOnly)
if (mainForm.WatchOnly || mainForm.multiSig)
{
buttonActionMain.Enabled = false; // Only allow sending in batches for ledger
buttonActionMain.Enabled = false; // Only allow sending in batches for ledger and multisig to prevent confusion
}
}
#region API
Expand Down
3 changes: 2 additions & 1 deletion FireWallet/FireWallet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<PackageIcon>HSDBatcher.png</PackageIcon>
<RepositoryUrl>https://github.com/Nathanwoodburn/FireWallet</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Version>3.4</Version>
<Version>4.0</Version>
</PropertyGroup>

<ItemGroup>
Expand All @@ -29,6 +29,7 @@
<ItemGroup>
<PackageReference Include="DnsClient" Version="1.7.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Portable.BouncyCastle" Version="1.9.0" />
<PackageReference Include="QRCoder" Version="1.4.3" />
</ItemGroup>

Expand Down
223 changes: 223 additions & 0 deletions FireWallet/ImportTXForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0306b78

Please sign in to comment.