diff --git a/FireWallet/TransferForm.cs b/FireWallet/TransferForm.cs index 6ef2da4..11d43a0 100644 --- a/FireWallet/TransferForm.cs +++ b/FireWallet/TransferForm.cs @@ -95,7 +95,7 @@ namespace FireWallet this.Close(); } - private void updateAddress() + private async void updateAddress() { labelError.Hide(); @@ -108,82 +108,17 @@ namespace FireWallet { string domain = textBoxAddress.Text.Substring(1); - try + string address = await MainForm.HIP02Lookup(domain); + if (address == "ERROR") { - IPAddress iPAddress = null; - - - // Create an instance of LookupClient using the custom options - NameServer nameServer = new NameServer(IPAddress.Parse("127.0.0.1"), 5350); - var options = new LookupClientOptions(nameServer); - options.EnableAuditTrail = true; - options.UseTcpOnly = true; - options.Recursion = true; - options.UseCache = false; - options.RequestDnsSecRecords = true; - options.Timeout = TimeSpan.FromSeconds(5); - - - var client = new LookupClient(options); - - - // Perform the DNS lookup for the specified domain using DNSSec - - var result = client.Query(domain, QueryType.A); - - - - - - // Display the DNS lookup results - foreach (var record in result.Answers.OfType()) - { - iPAddress = record.Address; - } - - if (iPAddress == null) - { - labelError.Show(); - labelError.Text = "HIP-02 lookup failed"; - return; - } - - // Get TLSA record - var resultTLSA = client.Query("_443._tcp." + domain, QueryType.TLSA); - foreach (var record in resultTLSA.Answers.OfType()) - { - MainForm.TLSA = record.CertificateAssociationDataAsString; - } - - - - string url = "https://" + iPAddress.ToString() + "/.well-known/wallets/HNS"; - var handler = new HttpClientHandler(); - - handler.ServerCertificateCustomValidationCallback = MainForm.ValidateServerCertificate; - - // Create an instance of HttpClient with the custom handler - using (var httpclient = new HttpClient(handler)) - { - httpclient.DefaultRequestHeaders.Add("Host", domain); - // Send a GET request to the specified URL - HttpResponseMessage response = httpclient.GetAsync(url).Result; - - // Response - string address = response.Content.ReadAsStringAsync().Result; - - labelSendingHIPAddress.Text = address; - this.address = address; - labelSendingHIPAddress.Show(); - labelHIPArrow.Show(); - } - - } - catch (Exception ex) - { - MainForm.AddLog(ex.Message); labelError.Show(); labelError.Text = "HIP-02 lookup failed"; + } else + { + labelSendingHIPAddress.Text = address; + this.address = address; + labelSendingHIPAddress.Show(); + labelHIPArrow.Show(); } } else {