From eea79b92d48958e46d55a462f1324e72c34a679c Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Sat, 24 Jun 2023 11:41:05 +1000 Subject: [PATCH] main: Added HIP-02 to batch import transfers --- FireWallet/BatchForm.cs | 2 +- FireWallet/BatchImportForm.cs | 34 +++++++++++++++++++++++++++++++--- FireWallet/TransferForm.cs | 6 +++--- 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/FireWallet/BatchForm.cs b/FireWallet/BatchForm.cs index 58de35a..ea1a0e1 100644 --- a/FireWallet/BatchForm.cs +++ b/FireWallet/BatchForm.cs @@ -737,7 +737,7 @@ namespace FireWallet } if (domains.Length > 0) { - BatchImportForm batchImportForm = new BatchImportForm(domains); + BatchImportForm batchImportForm = new BatchImportForm(domains,mainForm); batchImportForm.ShowDialog(); if (batchImportForm.batches != null) { diff --git a/FireWallet/BatchImportForm.cs b/FireWallet/BatchImportForm.cs index b41ee35..7b18ab3 100644 --- a/FireWallet/BatchImportForm.cs +++ b/FireWallet/BatchImportForm.cs @@ -8,12 +8,14 @@ namespace FireWallet Dictionary theme; string[] domains; public Batch[] batches { get; set; } + MainForm mainForm; - public BatchImportForm(string[] domains) + public BatchImportForm(string[] domains, MainForm mainForm) { InitializeComponent(); this.domains = domains; comboBoxMode.SelectedIndex = 1; + this.mainForm = mainForm; } private void BatchImportForm_Load(object sender, EventArgs e) @@ -218,7 +220,7 @@ namespace FireWallet this.Close(); } - private void buttonImport_Click(object sender, EventArgs e) + private async void buttonImport_Click(object sender, EventArgs e) { if (comboBoxMode.Text == "BID") { @@ -280,6 +282,32 @@ namespace FireWallet } 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]; foreach (string domain in listBoxDomains.Items) { @@ -287,7 +315,7 @@ namespace FireWallet { Batch[] newBatch = new Batch[batches.Length + 1]; 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; } } diff --git a/FireWallet/TransferForm.cs b/FireWallet/TransferForm.cs index 11d43a0..e2b4a40 100644 --- a/FireWallet/TransferForm.cs +++ b/FireWallet/TransferForm.cs @@ -51,7 +51,7 @@ namespace FireWallet string address = ""; private async void buttonTransfer_Click(object sender, EventArgs e) { - updateAddress(); + await updateAddress(); if (!await MainForm.ValidAddress(address)) { @@ -83,7 +83,7 @@ namespace FireWallet private async void buttonBatch_Click(object sender, EventArgs e) { - updateAddress(); + await updateAddress(); if (!await MainForm.ValidAddress(address)) { @@ -95,7 +95,7 @@ namespace FireWallet this.Close(); } - private async void updateAddress() + private async Task updateAddress() { labelError.Hide();