2023-06-09 14:43:02 +10:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
2023-06-15 13:55:51 +10:00
|
|
|
|
using DnsClient.Protocol;
|
|
|
|
|
using DnsClient;
|
2023-06-09 14:43:02 +10:00
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
|
|
|
|
|
namespace FireWallet
|
|
|
|
|
{
|
|
|
|
|
public partial class TransferForm : Form
|
|
|
|
|
{
|
|
|
|
|
MainForm MainForm;
|
|
|
|
|
string Domain;
|
|
|
|
|
public TransferForm(MainForm main, string domain)
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
MainForm = main;
|
|
|
|
|
Domain = domain;
|
|
|
|
|
this.Text = "Transfer " + Domain + " | FireWallet";
|
|
|
|
|
label1.Text = "Transfer " + Domain;
|
2023-06-17 15:24:13 +10:00
|
|
|
|
if (MainForm.Theme.ContainsKey("error"))
|
2023-06-09 14:43:02 +10:00
|
|
|
|
{
|
2023-06-17 15:24:13 +10:00
|
|
|
|
labelError.ForeColor = ColorTranslator.FromHtml(MainForm.Theme["error"]);
|
2023-06-09 14:43:02 +10:00
|
|
|
|
}
|
2023-06-17 15:24:13 +10:00
|
|
|
|
if (MainForm.WatchOnly)
|
2023-06-09 14:43:02 +10:00
|
|
|
|
{
|
|
|
|
|
buttonTransfer.Enabled = false; // watch only wallet only batch
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Theme
|
2023-06-17 15:24:13 +10:00
|
|
|
|
this.BackColor = ColorTranslator.FromHtml(MainForm.Theme["background"]);
|
|
|
|
|
this.ForeColor = ColorTranslator.FromHtml(MainForm.Theme["foreground"]);
|
2023-06-09 14:43:02 +10:00
|
|
|
|
foreach (Control c in Controls)
|
|
|
|
|
{
|
|
|
|
|
MainForm.ThemeControl(c);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonCancel_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-15 13:55:51 +10:00
|
|
|
|
string address = "";
|
2023-06-09 14:43:02 +10:00
|
|
|
|
private async void buttonTransfer_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2023-06-24 11:41:05 +10:00
|
|
|
|
await updateAddress();
|
2023-06-15 13:55:51 +10:00
|
|
|
|
|
|
|
|
|
if (!await MainForm.ValidAddress(address))
|
2023-06-09 14:43:02 +10:00
|
|
|
|
{
|
|
|
|
|
labelError.Show();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string content = "{\"method\": \"sendtransfer\",\"params\": [ \"" + Domain + "\", \"" +
|
2023-06-15 13:55:51 +10:00
|
|
|
|
address + "\"]}";
|
2023-06-09 14:43:02 +10:00
|
|
|
|
string output = await MainForm.APIPost("", true, content);
|
|
|
|
|
JObject APIresp = JObject.Parse(output);
|
|
|
|
|
if (APIresp["error"].ToString() != "")
|
|
|
|
|
{
|
|
|
|
|
MainForm.AddLog("Failed:");
|
|
|
|
|
MainForm.AddLog(APIresp.ToString());
|
|
|
|
|
NotifyForm notify = new NotifyForm("Error Transaction Failed");
|
|
|
|
|
notify.ShowDialog();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
JObject result = JObject.Parse(APIresp["result"].ToString());
|
|
|
|
|
string hash = result["hash"].ToString();
|
2023-06-17 15:24:13 +10:00
|
|
|
|
string link = MainForm.UserSettings["explorer-tx"] + hash;
|
2023-06-09 14:43:02 +10:00
|
|
|
|
NotifyForm notifySuccess = new NotifyForm("Transaction Sent\nThis transaction could take up to 20 minutes to mine",
|
|
|
|
|
"Explorer", link);
|
|
|
|
|
notifySuccess.ShowDialog();
|
|
|
|
|
notifySuccess.Dispose();
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async void buttonBatch_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2023-06-24 11:41:05 +10:00
|
|
|
|
await updateAddress();
|
2023-06-15 13:55:51 +10:00
|
|
|
|
|
|
|
|
|
if (!await MainForm.ValidAddress(address))
|
2023-06-09 14:43:02 +10:00
|
|
|
|
{
|
|
|
|
|
labelError.Show();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-15 13:55:51 +10:00
|
|
|
|
MainForm.AddBatch(Domain, "TRANSFER", address);
|
2023-06-09 14:43:02 +10:00
|
|
|
|
this.Close();
|
|
|
|
|
}
|
2023-06-15 13:55:51 +10:00
|
|
|
|
|
2023-06-24 11:41:05 +10:00
|
|
|
|
private async Task updateAddress()
|
2023-06-15 13:55:51 +10:00
|
|
|
|
{
|
|
|
|
|
labelError.Hide();
|
|
|
|
|
|
|
|
|
|
if (textBoxAddress.Text.Length < 1)
|
|
|
|
|
{
|
|
|
|
|
address = "";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (textBoxAddress.Text.Substring(0, 1) == "@")
|
|
|
|
|
{
|
|
|
|
|
string domain = textBoxAddress.Text.Substring(1);
|
|
|
|
|
|
2023-06-24 11:34:02 +10:00
|
|
|
|
string address = await MainForm.HIP02Lookup(domain);
|
|
|
|
|
if (address == "ERROR")
|
2023-06-15 13:55:51 +10:00
|
|
|
|
{
|
|
|
|
|
labelError.Show();
|
|
|
|
|
labelError.Text = "HIP-02 lookup failed";
|
2023-06-24 11:34:02 +10:00
|
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
labelSendingHIPAddress.Text = address;
|
|
|
|
|
this.address = address;
|
|
|
|
|
labelSendingHIPAddress.Show();
|
|
|
|
|
labelHIPArrow.Show();
|
2023-06-15 13:55:51 +10:00
|
|
|
|
}
|
|
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
address = textBoxAddress.Text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2023-06-09 14:43:02 +10:00
|
|
|
|
}
|
|
|
|
|
}
|