batch: Fixed batch form flashing when it imports

This commit is contained in:
Nathan Woodburn 2023-06-26 21:21:03 +10:00
parent 54d5c63db7
commit db5934bf4a
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1

View File

@ -78,7 +78,6 @@ namespace FireWallet
tx.Controls.Add(deleteTX); tx.Controls.Add(deleteTX);
panelTXs.Controls.Add(tx); panelTXs.Controls.Add(tx);
UpdateTheme();
} }
public void AddBatch(string domain, string operation, decimal bid, decimal lockup) public void AddBatch(string domain, string operation, decimal bid, decimal lockup)
{ {
@ -142,7 +141,6 @@ namespace FireWallet
tx.Controls.Add(deleteTX); tx.Controls.Add(deleteTX);
panelTXs.Controls.Add(tx); panelTXs.Controls.Add(tx);
UpdateTheme();
} }
public void AddBatch(string domain, string operation, string toAddress) public void AddBatch(string domain, string operation, string toAddress)
{ {
@ -202,7 +200,6 @@ namespace FireWallet
tx.Controls.Add(deleteTX); tx.Controls.Add(deleteTX);
panelTXs.Controls.Add(tx); panelTXs.Controls.Add(tx);
UpdateTheme();
} }
public void AddBatch(string domain, string operation, DNS[] updateRecords) public void AddBatch(string domain, string operation, DNS[] updateRecords)
@ -258,7 +255,6 @@ namespace FireWallet
tx.Controls.Add(deleteTX); tx.Controls.Add(deleteTX);
panelTXs.Controls.Add(tx); panelTXs.Controls.Add(tx);
UpdateTheme();
} }
private void FixSpacing() private void FixSpacing()
@ -278,7 +274,7 @@ namespace FireWallet
} }
#endregion #endregion
#region Theming #region Theming
private void UpdateTheme() public void UpdateTheme()
{ {
// Check if file exists // Check if file exists
if (!Directory.Exists(dir)) if (!Directory.Exists(dir))
@ -471,7 +467,7 @@ namespace FireWallet
HttpClient httpClient = new HttpClient(); HttpClient httpClient = new HttpClient();
private async void buttonSend_Click(object sender, EventArgs e) 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 batchTX = "[" + string.Join(", ", batches.Select(batch => batch.ToString())) + "]";
string content = "{\"method\": \"sendbatch\",\"params\":[ " + batchTX + "]}"; string content = "{\"method\": \"sendbatch\",\"params\":[ " + batchTX + "]}";
@ -519,6 +515,58 @@ namespace FireWallet
notifyForm2.Dispose(); notifyForm2.Dispose();
this.Close(); this.Close();
} }
else if (!mainForm.WatchOnly)
{
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 else // watch only
{ {
string batchTX = "[" + string.Join(", ", batches.Select(batch => batch.ToString())) + "]"; string batchTX = "[" + string.Join(", ", batches.Select(batch => batch.ToString())) + "]";