FireWalletCosmos/FireWalletLite/FirstLoginForm.cs

56 lines
1.7 KiB
C#
Raw Normal View History

using FireWallet;
2023-07-05 17:38:25 +10:00
using Newtonsoft.Json.Linq;
2023-07-05 16:44:34 +10:00
2023-07-15 22:17:49 +10:00
namespace FireWalletLite;
public partial class FirstLoginForm : Form
2023-07-05 16:44:34 +10:00
{
2023-07-15 22:17:49 +10:00
private readonly MainForm main;
private string seedPhrase;
public FirstLoginForm(string seedPhrase, MainForm mainForm)
{
InitializeComponent();
this.seedPhrase = seedPhrase;
main = mainForm;
// Theme form
BackColor = ColorTranslator.FromHtml(mainForm.Theme["background"]);
ForeColor = ColorTranslator.FromHtml(mainForm.Theme["foreground"]);
foreach (Control control in Controls) mainForm.ThemeControl(control);
textBoxSeed.Text = seedPhrase;
}
private async void Start_Click(object sender, EventArgs e)
2023-07-05 16:44:34 +10:00
{
2023-07-15 22:17:49 +10:00
if (textBoxPassword.Text.Length < 8)
2023-07-05 16:44:34 +10:00
{
2023-07-15 22:17:49 +10:00
var notifyForm = new NotifyForm("Please choose a longer password!");
notifyForm.ShowDialog();
notifyForm.Dispose();
return;
2023-07-05 16:44:34 +10:00
}
2023-07-05 17:38:25 +10:00
2023-07-15 22:17:49 +10:00
if (textBoxPassword.Text != textBoxPassword2.Text)
2023-07-05 17:38:25 +10:00
{
2023-07-15 22:17:49 +10:00
var notifyForm = new NotifyForm("Passwords do not match!");
notifyForm.ShowDialog();
notifyForm.Dispose();
return;
}
2023-07-05 17:38:25 +10:00
2023-07-15 22:17:49 +10:00
// Encrypt wallet
var content = "{\"method\":\"encryptwallet\",\"params\":[\"" + textBoxPassword.Text + "\"]}";
var response = await main.APIPost("", true, content);
main.AddLog("Encrypt wallet: " + response);
var jObject = JObject.Parse(response);
if (jObject["error"].ToString() != "")
{
var notifyForm = new NotifyForm("Error encrypting wallet: " + jObject["error"]);
notifyForm.ShowDialog();
notifyForm.Dispose();
return;
2023-07-05 17:38:25 +10:00
}
2023-07-15 22:17:49 +10:00
Close();
2023-07-05 16:44:34 +10:00
}
2023-07-15 22:17:49 +10:00
}