FireWalletCosmos/FireWalletLite/FirstLoginForm.cs

69 lines
2.2 KiB
C#
Raw Normal View History

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