main: Added some improvements to hip02 addresses with trailing whitespace

This commit is contained in:
Nathan Woodburn 2023-06-18 19:58:43 +10:00
parent 1a98a6a1c6
commit de7109eddc
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1

View File

@ -1370,7 +1370,6 @@ namespace FireWallet
// Perform the DNS lookup for the specified domain using DNSSec // Perform the DNS lookup for the specified domain using DNSSec
var result = client.Query(domain, QueryType.A); var result = client.Query(domain, QueryType.A);
// Display the DNS lookup results // Display the DNS lookup results
foreach (var record in result.Answers.OfType<ARecord>()) foreach (var record in result.Answers.OfType<ARecord>())
{ {
@ -1381,6 +1380,7 @@ namespace FireWallet
{ {
labelSendingError.Show(); labelSendingError.Show();
labelSendingError.Text = "HIP-02 lookup failed"; labelSendingError.Text = "HIP-02 lookup failed";
AddLog("No IP found");
return; return;
} }
@ -1405,17 +1405,41 @@ namespace FireWallet
// Send a GET request to the specified URL // Send a GET request to the specified URL
HttpResponseMessage response = httpclient.GetAsync(url).Result; HttpResponseMessage response = httpclient.GetAsync(url).Result;
if (response.StatusCode != HttpStatusCode.OK)
{
labelSendingError.Show();
labelSendingError.Text = "HIP-02 lookup failed";
AddLog("HTTPS get failed");
AddLog(response.Content.ReadAsStringAsync().Result);
return;
}
// Response // Response
string address = response.Content.ReadAsStringAsync().Result; string address = response.Content.ReadAsStringAsync().Result;
address = address.Trim();
labelSendingHIPAddress.Text = address;
labelSendingHIPAddress.Show(); if (await ValidAddress(address))
labelHIPArrow.Show(); {
labelSendingHIPAddress.Text = address;
labelSendingHIPAddress.Show();
labelHIPArrow.Show();
}
else
{
labelSendingError.Show();
labelSendingError.Text = "Invalid Address";
AddLog("Invalid Address\n"+address);
}
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
AddLog("HIP-02 lookup error");
AddLog(ex.Message); AddLog(ex.Message);
labelSendingError.Show(); labelSendingError.Show();
labelSendingError.Text = "HIP-02 lookup failed"; labelSendingError.Text = "HIP-02 lookup failed";