main: Added HIP-02 to batch import transfers

This commit is contained in:
Nathan Woodburn 2023-06-24 11:41:05 +10:00
parent ffd1372eca
commit eea79b92d4
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
3 changed files with 35 additions and 7 deletions

View File

@ -737,7 +737,7 @@ namespace FireWallet
} }
if (domains.Length > 0) if (domains.Length > 0)
{ {
BatchImportForm batchImportForm = new BatchImportForm(domains); BatchImportForm batchImportForm = new BatchImportForm(domains,mainForm);
batchImportForm.ShowDialog(); batchImportForm.ShowDialog();
if (batchImportForm.batches != null) if (batchImportForm.batches != null)
{ {

View File

@ -8,12 +8,14 @@ namespace FireWallet
Dictionary<string, string> theme; Dictionary<string, string> theme;
string[] domains; string[] domains;
public Batch[] batches { get; set; } public Batch[] batches { get; set; }
MainForm mainForm;
public BatchImportForm(string[] domains) public BatchImportForm(string[] domains, MainForm mainForm)
{ {
InitializeComponent(); InitializeComponent();
this.domains = domains; this.domains = domains;
comboBoxMode.SelectedIndex = 1; comboBoxMode.SelectedIndex = 1;
this.mainForm = mainForm;
} }
private void BatchImportForm_Load(object sender, EventArgs e) private void BatchImportForm_Load(object sender, EventArgs e)
@ -218,7 +220,7 @@ namespace FireWallet
this.Close(); this.Close();
} }
private void buttonImport_Click(object sender, EventArgs e) private async void buttonImport_Click(object sender, EventArgs e)
{ {
if (comboBoxMode.Text == "BID") if (comboBoxMode.Text == "BID")
{ {
@ -280,6 +282,32 @@ namespace FireWallet
} }
else if (comboBoxMode.Text == "TRANSFER") else if (comboBoxMode.Text == "TRANSFER")
{ {
if (textBoxToAddress.Text == "")
{
MessageBox.Show("Please enter a to address");
return;
}
string address = textBoxToAddress.Text;
if (address.Substring(0,1) == "@")
{
address = await mainForm.HIP02Lookup(address.Substring(1));
if (address == "ERROR")
{
NotifyForm notify = new NotifyForm("Invalid HIP-02 address");
notify.ShowDialog();
notify.Dispose();
return;
}
}
if (!(await mainForm.ValidAddress(address)))
{
NotifyForm notify = new NotifyForm("Invalid address");
notify.ShowDialog();
notify.Dispose();
return;
}
batches = new Batch[0]; batches = new Batch[0];
foreach (string domain in listBoxDomains.Items) foreach (string domain in listBoxDomains.Items)
{ {
@ -287,7 +315,7 @@ namespace FireWallet
{ {
Batch[] newBatch = new Batch[batches.Length + 1]; Batch[] newBatch = new Batch[batches.Length + 1];
Array.Copy(batches, newBatch, batches.Length); Array.Copy(batches, newBatch, batches.Length);
newBatch[newBatch.Length - 1] = new Batch(domain, comboBoxMode.Text, textBoxToAddress.Text); newBatch[newBatch.Length - 1] = new Batch(domain, comboBoxMode.Text, address);
batches = newBatch; batches = newBatch;
} }
} }

View File

@ -51,7 +51,7 @@ namespace FireWallet
string address = ""; string address = "";
private async void buttonTransfer_Click(object sender, EventArgs e) private async void buttonTransfer_Click(object sender, EventArgs e)
{ {
updateAddress(); await updateAddress();
if (!await MainForm.ValidAddress(address)) if (!await MainForm.ValidAddress(address))
{ {
@ -83,7 +83,7 @@ namespace FireWallet
private async void buttonBatch_Click(object sender, EventArgs e) private async void buttonBatch_Click(object sender, EventArgs e)
{ {
updateAddress(); await updateAddress();
if (!await MainForm.ValidAddress(address)) if (!await MainForm.ValidAddress(address))
{ {
@ -95,7 +95,7 @@ namespace FireWallet
this.Close(); this.Close();
} }
private async void updateAddress() private async Task updateAddress()
{ {
labelError.Hide(); labelError.Hide();