diff --git a/BidderGUI/Form1.Designer.cs b/BidderGUI/Form1.Designer.cs index de64c2f..074e824 100644 --- a/BidderGUI/Form1.Designer.cs +++ b/BidderGUI/Form1.Designer.cs @@ -98,6 +98,9 @@ private void InitializeComponent() buttonDeleteDNS = new Button(); dnslistBox = new ListBox(); buttonAddDNS = new Button(); + groupBoxTransfer = new GroupBox(); + textBoxAddress = new TextBox(); + label18 = new Label(); ((System.ComponentModel.ISupportInitialize)bidnumericUpDown).BeginInit(); ((System.ComponentModel.ISupportInitialize)blindnumericUpDown).BeginInit(); ((System.ComponentModel.ISupportInitialize)intervalnumericUpDown).BeginInit(); @@ -111,6 +114,7 @@ private void InitializeComponent() groupBox1.SuspendLayout(); ledgergroupBox.SuspendLayout(); updategroupBox.SuspendLayout(); + groupBoxTransfer.SuspendLayout(); SuspendLayout(); // // button1 @@ -359,12 +363,13 @@ private void InitializeComponent() modecomboBox.FlatStyle = FlatStyle.Flat; modecomboBox.ForeColor = Color.White; modecomboBox.FormattingEnabled = true; - modecomboBox.Items.AddRange(new object[] { "OPEN", "BID", "REVEAL", "REDEEM", "REGISTER", "UPDATE", "RENEW" }); + modecomboBox.Items.AddRange(new object[] { "OPEN", "BID", "REVEAL", "REDEEM", "REGISTER", "UPDATE", "RENEW", "TRANSFER" }); modecomboBox.Location = new Point(88, 75); modecomboBox.Name = "modecomboBox"; modecomboBox.Size = new Size(141, 23); modecomboBox.TabIndex = 3; modecomboBox.Text = "BID"; + modecomboBox.SelectedIndexChanged += modecomboBox_SelectedIndexChanged; // // label11 // @@ -901,12 +906,42 @@ private void InitializeComponent() buttonAddDNS.UseVisualStyleBackColor = false; buttonAddDNS.Click += addDNS; // + // groupBoxTransfer + // + groupBoxTransfer.Controls.Add(label18); + groupBoxTransfer.Controls.Add(textBoxAddress); + groupBoxTransfer.ForeColor = Color.FromArgb(142, 5, 194); + groupBoxTransfer.Location = new Point(383, 368); + groupBoxTransfer.Name = "groupBoxTransfer"; + groupBoxTransfer.Size = new Size(713, 197); + groupBoxTransfer.TabIndex = 32; + groupBoxTransfer.TabStop = false; + groupBoxTransfer.Text = "Transfer"; + groupBoxTransfer.Visible = false; + // + // textBoxAddress + // + textBoxAddress.Location = new Point(66, 21); + textBoxAddress.Name = "textBoxAddress"; + textBoxAddress.Size = new Size(189, 23); + textBoxAddress.TabIndex = 0; + // + // label18 + // + label18.AutoSize = true; + label18.Location = new Point(10, 24); + label18.Name = "label18"; + label18.Size = new Size(50, 15); + label18.TabIndex = 1; + label18.Text = "Send to:"; + // // Form1 // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; BackColor = Color.Black; ClientSize = new Size(1108, 789); + Controls.Add(groupBoxTransfer); Controls.Add(updategroupBox); Controls.Add(ledgergroupBox); Controls.Add(groupBox1); @@ -947,6 +982,8 @@ private void InitializeComponent() ledgergroupBox.PerformLayout(); updategroupBox.ResumeLayout(false); updategroupBox.PerformLayout(); + groupBoxTransfer.ResumeLayout(false); + groupBoxTransfer.PerformLayout(); ResumeLayout(false); PerformLayout(); } @@ -1020,5 +1057,8 @@ private void InitializeComponent() private TextBox dns2textBox; private Label totalcostlabel; private Label perbidcostlabel; + private GroupBox groupBoxTransfer; + private Label label18; + private TextBox textBoxAddress; } } \ No newline at end of file diff --git a/BidderGUI/Form1.cs b/BidderGUI/Form1.cs index edc1963..a68d3e1 100644 --- a/BidderGUI/Form1.cs +++ b/BidderGUI/Form1.cs @@ -25,7 +25,6 @@ private void Form1_Load(object sender, EventArgs e) addlog("For help contact Nathan.Woodburn/ or go to https://l.woodburn.au/discord"); addlog("If this application helps, please consider supporting me to help pay for costs in developing other projects"); addlog("https://l.woodburn.au/support"); - UpdateTheme(); GetSettings(); } @@ -129,131 +128,134 @@ async void sendtransaction() // Send a batch of transactions // Check the selected mode is legit - string[] modes = { "OPEN", "BID", "REVEAL", "REDEEM", "REGISTER", "RENEW", "UPDATE" }; + string[] modes = { "OPEN", "BID", "REVEAL", "REDEEM", "REGISTER", "RENEW", "UPDATE", "TRANSFER" }; - if (modes.Contains(modecomboBox.Text)) + // If the mode is not in the list + if (!modes.Contains(modecomboBox.Text)) { - // If there is only 1 domain left in the list - // Send a single transaction - if (domainslistBox.Items.Count == 1) - { - // Get domain - string domain = domainslistBox.Items[0].ToString(); - // Log transaction attempt - addlog("Sending " + modecomboBox.Text + " for: " + domain); + addlog("Invalid Mode. Cancelled Sending"); + stopbutton.PerformClick(); + } + // If there is only 1 domain left in the list + // Send a single transaction + if (domainslistBox.Items.Count == 1) + { + // Get domain + string domain = domainslistBox.Items[0].ToString(); + // Log transaction attempt + addlog("Sending " + modecomboBox.Text + " for: " + domain); - // Select mode - if (modecomboBox.Text == "BID") - { - // Create API call - HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "http://" + ipporttextBox.Text + "/wallet/" + wallettextBox.Text + "/bid"); - request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes("x:" + apitextBox.Text))); - string curltext = "{\"passphrase\":\"" + passtextBox.Text + "\",\"name\":\"" + domain + "\",\"broadcast\":true,\"sign\":true,\"bid\":" + getbid(true) + ",\"lockup\":" + getblind(true) + "}"; - request.Content = new StringContent(curltext); + // Select mode + if (modecomboBox.Text == "BID") + { + // Create API call + HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "http://" + ipporttextBox.Text + "/wallet/" + wallettextBox.Text + "/bid"); + request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes("x:" + apitextBox.Text))); + string curltext = "{\"passphrase\":\"" + passtextBox.Text + "\",\"name\":\"" + domain + "\",\"broadcast\":true,\"sign\":true,\"bid\":" + getbid(true) + ",\"lockup\":" + getblind(true) + "}"; + request.Content = new StringContent(curltext); - // Send request - sendapicall(request, domain); + // Send request + sendapicall(request, domain); - } - else if (modecomboBox.Text == "REGISTER") - { - // Use UPDATE for REGISTER + } + else if (modecomboBox.Text == "REGISTER") + { + // Use UPDATE for REGISTER - // Create API call - HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "http://" + ipporttextBox.Text + "/wallet/" + wallettextBox.Text + "/update"); - request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes("x:" + apitextBox.Text))); - string curltext = "{\"passphrase\":\"" + passtextBox.Text + "\",\"name\":\"" + domain + "\",\"broadcast\":true,\"sign\":true,\"data\": {\"records\":[]}}"; - request.Content = new StringContent(curltext); + // Create API call + HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "http://" + ipporttextBox.Text + "/wallet/" + wallettextBox.Text + "/update"); + request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes("x:" + apitextBox.Text))); + string curltext = "{\"passphrase\":\"" + passtextBox.Text + "\",\"name\":\"" + domain + "\",\"broadcast\":true,\"sign\":true,\"data\": {\"records\":[]}}"; + request.Content = new StringContent(curltext); - // Send request - sendapicall(request, domain); + // Send request + sendapicall(request, domain); - } - else - { - // Create API call - HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "http://" + ipporttextBox.Text + "/wallet/" + wallettextBox.Text + "/" + modecomboBox.Text.ToLower()); - request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes("x:" + apitextBox.Text))); - string curltext = "{\"passphrase\":\"" + passtextBox.Text + "\",\"name\":\"" + domain + "\",\"broadcast\":true,\"sign\":true}"; - request.Content = new StringContent(curltext); - - // Send request - sendapicall(request, domain); - } } - // If there is more than 1 domain left in the list - // Send a batch of transactions - else if (domainslistBox.Items.Count > 1) + else if (modecomboBox.Text == "TRANSFER") { - // Get the top batch of domains - string[] domains = domainslistBox.Items.OfType().ToArray(); - domains = domains.Take((int)batchsizenumericud.Value).ToArray(); + HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "http://" + ipporttextBox.Text + "/wallet/" + wallettextBox.Text + "/transfer"); + request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes("x:" + apitextBox.Text))); + string curltext = "{\"passphrase\":\"" + passtextBox.Text + "\",\"name\":\"" + domain + "\",\"broadcast\":true,\"sign\":true,\"address\":\"" + textBoxAddress.Text + "\"}"; + request.Content = new StringContent(curltext); + sendapicall(request, domain); + } + else + { + // Create API call + HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "http://" + ipporttextBox.Text + "/wallet/" + wallettextBox.Text + "/" + modecomboBox.Text.ToLower()); + request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes("x:" + apitextBox.Text))); + string curltext = "{\"passphrase\":\"" + passtextBox.Text + "\",\"name\":\"" + domain + "\",\"broadcast\":true,\"sign\":true}"; + request.Content = new StringContent(curltext); - // Select mode - if (modecomboBox.Text == "BID") - { - // Send API call - sendbatchbid(domains); - } - else if (modecomboBox.Text == "REGISTER") - { - // Send API call - sendbatchupdate(domains); - } - else if (modecomboBox.Text == "UPDATE") + // Send request + sendapicall(request, domain); + } + } + // If there is more than 1 domain left in the list + // Send a batch of transactions + else if (domainslistBox.Items.Count > 1) + { + // Get the top batch of domains + string[] domains = domainslistBox.Items.OfType().ToArray(); + domains = domains.Take((int)batchsizenumericud.Value).ToArray(); + + // Select mode + if (modecomboBox.Text == "BID") + { + // Send API call + sendbatchbid(domains); + } + else if (modecomboBox.Text == "REGISTER") + { + // Send API call + sendbatchupdate(domains); + } + else if (modecomboBox.Text == "UPDATE") + { + // Generate records + string records = ""; + string TXTs = ""; + foreach (string record in dnslistBox.Items.OfType().ToArray()) { - // Generate records - string records = ""; - string TXTs = ""; - foreach (string record in dnslistBox.Items.OfType().ToArray()) + if (record.Contains("{")) // Is not a TXT record { - if (record.Contains("{")) // Is not a TXT record - { - records = records + record + ","; - } - else - { - TXTs = TXTs + "\"" + record + "\","; - } + records = records + record + ","; } - if (records != "") - { - records = records.Substring(0, records.Length - 1); - } - if (TXTs != "") + else { - records = records + ",{\"type\": \"TXT\",\"txt\": [" + TXTs.Substring(0, TXTs.Length - 1) + "]}"; + TXTs = TXTs + "\"" + record + "\","; } - - - // Send API call - sendbatchupdate(domains, records); } - else + if (records != "") { - // Send API call - sendbatch(domains, modecomboBox.Text); + records = records.Substring(0, records.Length - 1); } + if (TXTs != "") + { + records = records + ",{\"type\": \"TXT\",\"txt\": [" + TXTs.Substring(0, TXTs.Length - 1) + "]}"; + } + + // Send API call + sendbatchupdate(domains, records); } - // If there are no domains left in the list else { - // Log error - addlog("No Domains Found. Cancelled Sending"); - // Stop timers - stopbutton.PerformClick(); - + // Send API call + sendbatch(domains, modecomboBox.Text); } + } - // If the selected mode is not legit + // If there are no domains left in the list else { // Log error - addlog("Invalid Mode. Cancelled Sending"); + addlog("No Domains Found. Cancelled Sending"); // Stop timers stopbutton.PerformClick(); + } } @@ -341,9 +343,19 @@ async void sendbatch(string[] domains, string method) { // Create the batch for the API call string batch = "["; - foreach (string domain in domains) + if (modecomboBox.Text == "TRANSFER") + { + foreach (string domain in domains) + { + batch = batch + "[\"TRANSFER\", \"" + domain + "\", \""+textBoxAddress.Text+"\"], "; + } + } + else { - batch = batch + "[\"" + method + "\", \"" + domain + "\"], "; + foreach (string domain in domains) + { + batch = batch + "[\"" + method + "\", \"" + domain + "\"], "; + } } // Finish the JSON by removing the last comma and adding a closing bracket batch = batch.Substring(0, batch.Length - 2) + "]"; @@ -1001,89 +1013,29 @@ private void UpdateTheme() // Foreground this.ForeColor = ColorTranslator.FromHtml(theme["foreground"]); // Need to specify this for each groupbox to override the black text - walletgroupBox.ForeColor = ColorTranslator.FromHtml(theme["foreground"]); - groupBox1.ForeColor = ColorTranslator.FromHtml(theme["foreground"]); - groupBox2.ForeColor = ColorTranslator.FromHtml(theme["foreground"]); - groupBox3.ForeColor = ColorTranslator.FromHtml(theme["foreground"]); - settingsgroupBox.ForeColor = ColorTranslator.FromHtml(theme["foreground"]); - ledgergroupBox.ForeColor = ColorTranslator.FromHtml(theme["foreground"]); - biddinggroupBox.ForeColor = ColorTranslator.FromHtml(theme["foreground"]); - updategroupBox.ForeColor = ColorTranslator.FromHtml(theme["foreground"]); - - - // background-alt - apitextBox.BackColor = ColorTranslator.FromHtml(theme["background-alt"]); - wallettextBox.BackColor = ColorTranslator.FromHtml(theme["background-alt"]); - dns1textBox.BackColor = ColorTranslator.FromHtml(theme["background-alt"]); - dns2textBox.BackColor = ColorTranslator.FromHtml(theme["background-alt"]); - dns3textBox.BackColor = ColorTranslator.FromHtml(theme["background-alt"]); - dns4textBox.BackColor = ColorTranslator.FromHtml(theme["background-alt"]); - domainslistBox.BackColor = ColorTranslator.FromHtml(theme["background-alt"]); - dnslistBox.BackColor = ColorTranslator.FromHtml(theme["background-alt"]); - logtextBox.BackColor = ColorTranslator.FromHtml(theme["background-alt"]); - passtextBox.BackColor = ColorTranslator.FromHtml(theme["background-alt"]); - ipporttextBox.BackColor = ColorTranslator.FromHtml(theme["background-alt"]); - loglinesnumeric.BackColor = ColorTranslator.FromHtml(theme["background-alt"]); - bidnumericUpDown.BackColor = ColorTranslator.FromHtml(theme["background-alt"]); - blindnumericUpDown.BackColor = ColorTranslator.FromHtml(theme["background-alt"]); - batchsizenumericud.BackColor = ColorTranslator.FromHtml(theme["background-alt"]); - intervalnumericUpDown.BackColor = ColorTranslator.FromHtml(theme["background-alt"]); - regtestbutton.BackColor = ColorTranslator.FromHtml(theme["background-alt"]); - mainnetbutton.BackColor = ColorTranslator.FromHtml(theme["background-alt"]); - button1.BackColor = ColorTranslator.FromHtml(theme["background-alt"]); - buttonAddDNS.BackColor = ColorTranslator.FromHtml(theme["background-alt"]); - button3.BackColor = ColorTranslator.FromHtml(theme["background-alt"]); - button4.BackColor = ColorTranslator.FromHtml(theme["background-alt"]); - buttonDeleteDNS.BackColor = ColorTranslator.FromHtml(theme["background-alt"]); - button8.BackColor = ColorTranslator.FromHtml(theme["background-alt"]); - buttoncleardomains.BackColor = ColorTranslator.FromHtml(theme["background-alt"]); - modecomboBox.BackColor = ColorTranslator.FromHtml(theme["background-alt"]); - domaintextBox.BackColor = ColorTranslator.FromHtml(theme["background-alt"]); - removebutton.BackColor = ColorTranslator.FromHtml(theme["background-alt"]); - dnstypecomboBox.BackColor = ColorTranslator.FromHtml(theme["background-alt"]); - startbutton.BackColor = ColorTranslator.FromHtml(theme["background-alt"]); - stopbutton.BackColor = ColorTranslator.FromHtml(theme["background-alt"]); - addbutton.BackColor = ColorTranslator.FromHtml(theme["background-alt"]); - - // Foreground-alt - apitextBox.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]); - wallettextBox.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]); - dns1textBox.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]); - dns2textBox.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]); - dns3textBox.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]); - dns4textBox.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]); - domainslistBox.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]); - dnslistBox.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]); - logtextBox.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]); - passtextBox.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]); - ipporttextBox.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]); - loglinesnumeric.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]); - bidnumericUpDown.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]); - blindnumericUpDown.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]); - batchsizenumericud.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]); - intervalnumericUpDown.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]); - regtestbutton.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]); - mainnetbutton.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]); - button1.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]); - buttonAddDNS.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]); - button3.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]); - button4.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]); - buttonDeleteDNS.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]); - button8.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]); - buttoncleardomains.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]); - modecomboBox.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]); - domaintextBox.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]); - removebutton.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]); - dnstypecomboBox.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]); - startbutton.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]); - stopbutton.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]); - addbutton.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]); + foreach (Control c in this.Controls) + { + if (c is GroupBox) + { + c.ForeColor = ColorTranslator.FromHtml(theme["foreground"]); + foreach (Control c1 in c.Controls) + { + if (c1 is TextBox || c1 is ListBox || c1 is NumericUpDown || c1 is Button || c1 is ComboBox) + { + c1.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]); + c1.BackColor = ColorTranslator.FromHtml(theme["background-alt"]); + } + } + } else if (c is TextBox || c is ListBox || c is NumericUpDown || c is Button || c is ComboBox) + { + c.ForeColor = ColorTranslator.FromHtml(theme["foreground-alt"]); + c.BackColor = ColorTranslator.FromHtml(theme["background-alt"]); + } + } // Transparancy applyTransparency(theme); - - } private void applyTransparency(Dictionary theme) @@ -1308,5 +1260,16 @@ private void SaveSettings() } #endregion + private void modecomboBox_SelectedIndexChanged(object sender, EventArgs e) + { + if (modecomboBox.Text == "TRANSFER") + { + groupBoxTransfer.Show(); + } + else + { + groupBoxTransfer.Hide(); + } + } } } \ No newline at end of file