mirror of
https://github.com/Nathanwoodburn/FireWallet.git
synced 2024-11-24 08:08:14 +11:00
main: Custom timeouts
This commit is contained in:
parent
af9327a1fa
commit
30c5690c24
@ -43,7 +43,6 @@ namespace FireWallet
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
panelaccount.Visible = true;
|
panelaccount.Visible = true;
|
||||||
httpClient.Timeout = TimeSpan.FromSeconds(10);
|
|
||||||
}
|
}
|
||||||
private async void MainForm_Load(object sender, EventArgs e)
|
private async void MainForm_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
@ -92,7 +91,7 @@ namespace FireWallet
|
|||||||
toolStripDropDownButtonHelp.DropDown.BackColor = ColorTranslator.FromHtml(Theme["background"]);
|
toolStripDropDownButtonHelp.DropDown.BackColor = ColorTranslator.FromHtml(Theme["background"]);
|
||||||
|
|
||||||
// Load node
|
// Load node
|
||||||
if (await LoadNode() != true) this.Close();
|
if (await LoadNode(ss) != true) this.Close();
|
||||||
|
|
||||||
// If node load caused app to close, exit load function
|
// If node load caused app to close, exit load function
|
||||||
if (this.Disposing || this.IsDisposed) return;
|
if (this.Disposing || this.IsDisposed) return;
|
||||||
@ -182,15 +181,17 @@ namespace FireWallet
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region Settings
|
#region Settings
|
||||||
private async Task<bool> LoadNode()
|
private async Task<bool> LoadNode(SplashScreen? ss)
|
||||||
{
|
{
|
||||||
HSD = false;
|
HSD = false;
|
||||||
if (!File.Exists(dir + "node.txt"))
|
if (!File.Exists(dir + "node.txt"))
|
||||||
{
|
{
|
||||||
|
ss.Hide();
|
||||||
NodeForm cf = new NodeForm();
|
NodeForm cf = new NodeForm();
|
||||||
timerNodeStatus.Stop();
|
timerNodeStatus.Stop();
|
||||||
cf.ShowDialog();
|
cf.ShowDialog();
|
||||||
timerNodeStatus.Start();
|
timerNodeStatus.Start();
|
||||||
|
ss.Show();
|
||||||
}
|
}
|
||||||
if (!File.Exists(dir + "node.txt"))
|
if (!File.Exists(dir + "node.txt"))
|
||||||
{
|
{
|
||||||
@ -199,7 +200,7 @@ namespace FireWallet
|
|||||||
await Task.Delay(1000);
|
await Task.Delay(1000);
|
||||||
AddLog("Close Failed");
|
AddLog("Close Failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
StreamReader sr = new StreamReader(dir + "node.txt");
|
StreamReader sr = new StreamReader(dir + "node.txt");
|
||||||
NodeSettings = new Dictionary<string, string>();
|
NodeSettings = new Dictionary<string, string>();
|
||||||
while (!sr.EndOfStream)
|
while (!sr.EndOfStream)
|
||||||
@ -232,6 +233,12 @@ namespace FireWallet
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (NodeSettings.ContainsKey("Timeout"))
|
||||||
|
{
|
||||||
|
int timeout = Convert.ToInt32(NodeSettings["Timeout"]);
|
||||||
|
httpClient.Timeout = TimeSpan.FromSeconds(timeout);
|
||||||
|
} else httpClient.Timeout = TimeSpan.FromSeconds(10);
|
||||||
|
|
||||||
if (NodeSettings.ContainsKey("HSD"))
|
if (NodeSettings.ContainsKey("HSD"))
|
||||||
{
|
{
|
||||||
if (NodeSettings["HSD"].ToLower() == "true")
|
if (NodeSettings["HSD"].ToLower() == "true")
|
||||||
@ -310,6 +317,8 @@ namespace FireWallet
|
|||||||
if (hideScreen)
|
if (hideScreen)
|
||||||
{
|
{
|
||||||
HSDProcess.StartInfo.RedirectStandardError = true;
|
HSDProcess.StartInfo.RedirectStandardError = true;
|
||||||
|
// Send errors to log
|
||||||
|
HSDProcess.ErrorDataReceived += (sender, e) => AddLog("HSD Error: " + e.Data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -760,14 +769,16 @@ namespace FireWallet
|
|||||||
toolStripStatusLabelLedger.Text = "Cold Wallet";
|
toolStripStatusLabelLedger.Text = "Cold Wallet";
|
||||||
toolStripStatusLabelLedger.Visible = true;
|
toolStripStatusLabelLedger.Visible = true;
|
||||||
buttonRevealAll.Visible = false;
|
buttonRevealAll.Visible = false;
|
||||||
|
buttonRedeemAll.Visible = false;
|
||||||
|
buttonSendAll.Visible = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WatchOnly = false;
|
WatchOnly = false;
|
||||||
toolStripStatusLabelLedger.Visible = false;
|
toolStripStatusLabelLedger.Visible = false;
|
||||||
buttonRevealAll.Visible = true;
|
buttonRevealAll.Visible = true;
|
||||||
|
buttonRedeemAll.Visible = true;
|
||||||
|
buttonSendAll.Visible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -853,6 +864,43 @@ namespace FireWallet
|
|||||||
toolStripStatusLabelaccount.Text = "Account: Not Logged In";
|
toolStripStatusLabelaccount.Text = "Account: Not Logged In";
|
||||||
textBoxaccountpassword.Focus();
|
textBoxaccountpassword.Focus();
|
||||||
}
|
}
|
||||||
|
private async void buttonRevealAll_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
buttonRevealAll.Enabled = false;
|
||||||
|
string content = "{\"method\": \"sendreveal\"}";
|
||||||
|
string response = await APIPost("", true, content);
|
||||||
|
AddLog(response);
|
||||||
|
if (response == "Error")
|
||||||
|
{
|
||||||
|
AddLog("Error sending reveal");
|
||||||
|
NotifyForm notifyForm = new NotifyForm("Error sending reveal");
|
||||||
|
notifyForm.ShowDialog();
|
||||||
|
notifyForm.Dispose();
|
||||||
|
buttonRevealAll.Enabled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JObject resp = JObject.Parse(response);
|
||||||
|
if (resp["error"].ToString() != "")
|
||||||
|
{
|
||||||
|
AddLog("Error sending reveal");
|
||||||
|
AddLog(resp["error"].ToString());
|
||||||
|
JObject error = JObject.Parse(resp["error"].ToString());
|
||||||
|
NotifyForm notifyForm = new NotifyForm("Error sending reveal\n" + error["message"].ToString());
|
||||||
|
notifyForm.ShowDialog();
|
||||||
|
notifyForm.Dispose();
|
||||||
|
buttonRevealAll.Enabled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (resp.ContainsKey("result"))
|
||||||
|
{
|
||||||
|
JObject result = JObject.Parse(resp["result"].ToString());
|
||||||
|
string hash = result["hash"].ToString();
|
||||||
|
NotifyForm notifyForm = new NotifyForm("Reveal sent\n" + hash, "Explorer", UserSettings["explorer-tx"] + hash);
|
||||||
|
notifyForm.ShowDialog();
|
||||||
|
notifyForm.Dispose();
|
||||||
|
}
|
||||||
|
buttonRevealAll.Enabled = true;
|
||||||
|
}
|
||||||
private async void buttonRedeemAll_Click(object sender, EventArgs e)
|
private async void buttonRedeemAll_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
buttonRedeemAll.Enabled = false;
|
buttonRedeemAll.Enabled = false;
|
||||||
@ -1086,6 +1134,7 @@ namespace FireWallet
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.Enabled = false;
|
this.Enabled = false;
|
||||||
|
this.Visible = false;
|
||||||
// Show splash
|
// Show splash
|
||||||
SplashScreen ss = new SplashScreen(false);
|
SplashScreen ss = new SplashScreen(false);
|
||||||
bool splash = false;
|
bool splash = false;
|
||||||
@ -1107,7 +1156,6 @@ namespace FireWallet
|
|||||||
// Kill node
|
// Kill node
|
||||||
if (HSDProcess != null)
|
if (HSDProcess != null)
|
||||||
{
|
{
|
||||||
this.Opacity = 0;
|
|
||||||
HSDProcess.Kill();
|
HSDProcess.Kill();
|
||||||
AddLog("Killed HSD");
|
AddLog("Killed HSD");
|
||||||
Thread.Sleep(1000);
|
Thread.Sleep(1000);
|
||||||
@ -1134,10 +1182,12 @@ namespace FireWallet
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
HSDProcess.StartInfo.CreateNoWindow = hideScreen;
|
HSDProcess.StartInfo.CreateNoWindow = hideScreen;
|
||||||
|
|
||||||
if (hideScreen)
|
if (hideScreen)
|
||||||
{
|
{
|
||||||
HSDProcess.StartInfo.RedirectStandardError = true;
|
HSDProcess.StartInfo.RedirectStandardError = true;
|
||||||
|
// Log errors to AddLog
|
||||||
|
HSDProcess.ErrorDataReceived += (sender, e) => AddLog("HSD Error: " + e.Data);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1179,10 +1229,6 @@ namespace FireWallet
|
|||||||
HSDProcess.StartInfo.Arguments = HSDProcess.StartInfo.Arguments + " --prefix " + bobPath;
|
HSDProcess.StartInfo.Arguments = HSDProcess.StartInfo.Arguments + " --prefix " + bobPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
HSDProcess.Start();
|
HSDProcess.Start();
|
||||||
// Wait for HSD to start
|
// Wait for HSD to start
|
||||||
await Task.Delay(2000);
|
await Task.Delay(2000);
|
||||||
@ -1218,6 +1264,7 @@ namespace FireWallet
|
|||||||
ss.CloseSplash();
|
ss.CloseSplash();
|
||||||
}
|
}
|
||||||
this.Enabled = true;
|
this.Enabled = true;
|
||||||
|
this.Visible = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
private async Task<string> GetAddress()
|
private async Task<string> GetAddress()
|
||||||
@ -2337,39 +2384,6 @@ namespace FireWallet
|
|||||||
AddLog(ex.Message);
|
AddLog(ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private async void buttonRevealAll_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
string content = "{\"method\": \"sendreveal\"}";
|
|
||||||
string response = await APIPost("", true, content);
|
|
||||||
AddLog(response);
|
|
||||||
if (response == "Error")
|
|
||||||
{
|
|
||||||
AddLog("Error sending reveal");
|
|
||||||
NotifyForm notifyForm = new NotifyForm("Error sending reveal");
|
|
||||||
notifyForm.ShowDialog();
|
|
||||||
notifyForm.Dispose();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
JObject resp = JObject.Parse(response);
|
|
||||||
if (resp["error"].ToString() != "")
|
|
||||||
{
|
|
||||||
AddLog("Error sending reveal");
|
|
||||||
AddLog(resp["error"].ToString());
|
|
||||||
JObject error = JObject.Parse(resp["error"].ToString());
|
|
||||||
NotifyForm notifyForm = new NotifyForm("Error sending reveal\n" + error["message"].ToString());
|
|
||||||
notifyForm.ShowDialog();
|
|
||||||
notifyForm.Dispose();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (resp.ContainsKey("result"))
|
|
||||||
{
|
|
||||||
JObject result = JObject.Parse(resp["result"].ToString());
|
|
||||||
string hash = result["hash"].ToString();
|
|
||||||
NotifyForm notifyForm = new NotifyForm("Reveal sent\n" + hash, "Explorer", UserSettings["explorer-tx"] + hash);
|
|
||||||
notifyForm.ShowDialog();
|
|
||||||
notifyForm.Dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void textBoxDomainSearch_KeyDown(object sender, KeyEventArgs e)
|
private void textBoxDomainSearch_KeyDown(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.KeyValue == 13)
|
if (e.KeyValue == 13)
|
||||||
|
Loading…
Reference in New Issue
Block a user