diff --git a/src/NiceHashBot/FormMain.Designer.cs b/src/NiceHashBot/FormMain.Designer.cs
index 00ad833..3d93063 100644
--- a/src/NiceHashBot/FormMain.Designer.cs
+++ b/src/NiceHashBot/FormMain.Designer.cs
@@ -68,7 +68,7 @@ private void InitializeComponent()
this.settingsToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
- this.menuStrip1.Size = new System.Drawing.Size(687, 24);
+ this.menuStrip1.Size = new System.Drawing.Size(770, 24);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
@@ -82,6 +82,7 @@ private void InitializeComponent()
//
// createNewToolStripMenuItem
//
+ this.createNewToolStripMenuItem.Enabled = false;
this.createNewToolStripMenuItem.Name = "createNewToolStripMenuItem";
this.createNewToolStripMenuItem.Size = new System.Drawing.Size(133, 22);
this.createNewToolStripMenuItem.Text = "Create new";
@@ -103,9 +104,9 @@ private void InitializeComponent()
//
// statusStrip1
//
- this.statusStrip1.Location = new System.Drawing.Point(0, 486);
+ this.statusStrip1.Location = new System.Drawing.Point(0, 327);
this.statusStrip1.Name = "statusStrip1";
- this.statusStrip1.Size = new System.Drawing.Size(687, 22);
+ this.statusStrip1.Size = new System.Drawing.Size(770, 22);
this.statusStrip1.TabIndex = 1;
this.statusStrip1.Text = "statusStrip1";
//
@@ -116,7 +117,7 @@ private void InitializeComponent()
this.toolStripLabel2});
this.toolStrip1.Location = new System.Drawing.Point(0, 24);
this.toolStrip1.Name = "toolStrip1";
- this.toolStrip1.Size = new System.Drawing.Size(687, 25);
+ this.toolStrip1.Size = new System.Drawing.Size(770, 25);
this.toolStrip1.TabIndex = 4;
this.toolStrip1.Text = "toolStrip1";
//
@@ -150,7 +151,7 @@ private void InitializeComponent()
this.listView1.Location = new System.Drawing.Point(0, 49);
this.listView1.MultiSelect = false;
this.listView1.Name = "listView1";
- this.listView1.Size = new System.Drawing.Size(687, 437);
+ this.listView1.Size = new System.Drawing.Size(770, 278);
this.listView1.TabIndex = 2;
this.listView1.UseCompatibleStateImageBehavior = false;
this.listView1.View = System.Windows.Forms.View.Details;
@@ -158,12 +159,12 @@ private void InitializeComponent()
// columnHeader1
//
this.columnHeader1.Text = "Location";
- this.columnHeader1.Width = 63;
+ this.columnHeader1.Width = 117;
//
// columnHeader2
//
this.columnHeader2.Text = "Algorithm";
- this.columnHeader2.Width = 75;
+ this.columnHeader2.Width = 93;
//
// columnHeader3
//
@@ -240,7 +241,7 @@ private void InitializeComponent()
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(687, 508);
+ this.ClientSize = new System.Drawing.Size(770, 349);
this.Controls.Add(this.listView1);
this.Controls.Add(this.toolStrip1);
this.Controls.Add(this.statusStrip1);
diff --git a/src/NiceHashBot/FormMain.cs b/src/NiceHashBot/FormMain.cs
index bd5d634..9676c4c 100644
--- a/src/NiceHashBot/FormMain.cs
+++ b/src/NiceHashBot/FormMain.cs
@@ -62,24 +62,18 @@ private void TimerRefresh_Tick(object sender, EventArgs e)
listView1.Items.Clear();
for (int i = 0; i < Orders.Length; i++)
{
+ int Algorithm = Orders[i].Algorithm;
ListViewItem LVI = new ListViewItem(APIWrapper.SERVICE_NAME[Orders[i].ServiceLocation]);
- LVI.SubItems.Add(APIWrapper.ALGORITHM_NAME[Orders[i].Algorithm]);
+ LVI.SubItems.Add(APIWrapper.ALGORITHM_NAME[Algorithm]);
if (Orders[i].OrderStats != null)
{
LVI.SubItems.Add("#" + Orders[i].OrderStats.ID.ToString());
string PriceText = Orders[i].OrderStats.Price.ToString("F4") + " (" + Orders[i].MaxPrice.ToString("F4") + ")";
- if (Orders[i].Algorithm == 1)
- PriceText += " BTC/TH/Day";
- else
- PriceText += " BTC/GH/Day";
+ PriceText += " BTC/" + APIWrapper.SPEED_TEXT[Algorithm] + "/Day";
LVI.SubItems.Add(PriceText);
LVI.SubItems.Add(Orders[i].OrderStats.BTCAvailable.ToString("F8"));
LVI.SubItems.Add(Orders[i].OrderStats.Workers.ToString());
- string SpeedText = "";
- if (Orders[i].Algorithm == 1)
- SpeedText = (Orders[i].OrderStats.Speed * 0.001).ToString("F4") + " (" + Orders[i].Limit.ToString("F2") + ") TH/s";
- else
- SpeedText = Orders[i].OrderStats.Speed.ToString("F4") + " (" + Orders[i].Limit.ToString("F2") + ") GH/s";
+ string SpeedText = (Orders[i].OrderStats.Speed * APIWrapper.ALGORITHM_MULTIPLIER[Algorithm]).ToString("F4") + " (" + Orders[i].Limit.ToString("F2") + ") " + APIWrapper.SPEED_TEXT[Algorithm] + "/s";
LVI.SubItems.Add(SpeedText);
if (!Orders[i].OrderStats.Alive)
LVI.BackColor = Color.PaleVioletRed;
@@ -150,8 +144,13 @@ private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
if (APIWrapper.Initialize(SettingsContainer.Settings.APIID.ToString(), SettingsContainer.Settings.APIKey))
{
+ createNewToolStripMenuItem.Enabled = true;
BalanceRefresh_Tick(sender, e);
}
+ else
+ {
+ createNewToolStripMenuItem.Enabled = false;
+ }
}
}
diff --git a/src/NiceHashBot/FormNewOrder.cs b/src/NiceHashBot/FormNewOrder.cs
index da2cdb7..c9894ef 100644
--- a/src/NiceHashBot/FormNewOrder.cs
+++ b/src/NiceHashBot/FormNewOrder.cs
@@ -55,18 +55,10 @@ private void FormNewOrder_FormClosing(object sender, FormClosingEventArgs e)
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
{
- if (comboBox2.SelectedIndex == 1)
- {
- label5.Text = "TH/s";
- label8.Text = "BTC/TH/Day";
- label11.Text = "BTC/TH/Day";
- }
- else
- {
- label5.Text = "GH/s";
- label8.Text = "BTC/GH/Day";
- label11.Text = "BTC/GH/Day";
- }
+ int index = comboBox2.SelectedIndex;
+ label5.Text = APIWrapper.SPEED_TEXT[index] + "/s";
+ label8.Text = "BTC/" + APIWrapper.SPEED_TEXT[index] + "/Day";
+ label11.Text = "BTC/" + APIWrapper.SPEED_TEXT[index] + "/Day";
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
@@ -102,7 +94,12 @@ private void button2_Click(object sender, EventArgs e)
if (AdvancedOptionsShown)
{
- OrderContainer.Add(comboBox1.SelectedIndex, comboBox2.SelectedIndex, MaxPrice, Limit, Pools[comboBox3.SelectedIndex], OrderID, StartPrice, StartAmount, textBox1.Text);
+ if (!OrderContainer.Add(comboBox1.SelectedIndex, comboBox2.SelectedIndex, MaxPrice, Limit, Pools[comboBox3.SelectedIndex], OrderID, StartPrice, StartAmount, textBox1.Text))
+ {
+ MessageBox.Show("Order already in list!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ numericUpDown3.Focus();
+ return;
+ }
}
else
{
diff --git a/src/NiceHashBot/FormSettings.Designer.cs b/src/NiceHashBot/FormSettings.Designer.cs
index d90428b..3ba8391 100644
--- a/src/NiceHashBot/FormSettings.Designer.cs
+++ b/src/NiceHashBot/FormSettings.Designer.cs
@@ -167,8 +167,9 @@ private void InitializeComponent()
this.Name = "FormSettings";
this.ShowIcon = false;
this.ShowInTaskbar = false;
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Settings";
+ this.TopMost = true;
this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.tabPage1.PerformLayout();
diff --git a/src/NiceHashBot/OrderContainer.cs b/src/NiceHashBot/OrderContainer.cs
index b3ea442..bc0c163 100644
--- a/src/NiceHashBot/OrderContainer.cs
+++ b/src/NiceHashBot/OrderContainer.cs
@@ -193,12 +193,17 @@ public static void Add(int SL, int Algo, double Price, double SpeedLimit, Pool P
}
- public static void Add(int SL, int Algo, double Price, double SpeedLimit, Pool PoolInfo, int OrderID, double StartPrice, double StartAmount, string HandlerFile)
+ public static bool Add(int SL, int Algo, double Price, double SpeedLimit, Pool PoolInfo, int OrderID, double StartPrice, double StartAmount, string HandlerFile)
{
+ foreach (OrderContainer OC_ in OrderList)
+ if (OC_.ID == OrderID) return false;
+
OrderContainer OC = new OrderContainer(SL, Algo, Price, SpeedLimit, PoolInfo, OrderID, StartPrice, StartAmount, HandlerFile);
OC.Launch();
OrderList.Add(OC);
Commit();
+
+ return true;
}
diff --git a/src/NiceHashBot/Properties/AssemblyInfo.cs b/src/NiceHashBot/Properties/AssemblyInfo.cs
index 9199746..673c693 100644
--- a/src/NiceHashBot/Properties/AssemblyInfo.cs
+++ b/src/NiceHashBot/Properties/AssemblyInfo.cs
@@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.2.0")]
-[assembly: AssemblyFileVersion("1.0.2.0")]
+[assembly: AssemblyVersion("1.0.3.0")]
+[assembly: AssemblyFileVersion("1.0.3.0")]
diff --git a/src/NiceHashBotLib/APIBuyInfo.cs b/src/NiceHashBotLib/APIBuyInfo.cs
new file mode 100644
index 0000000..81fc6af
--- /dev/null
+++ b/src/NiceHashBotLib/APIBuyInfo.cs
@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Newtonsoft.Json;
+
+namespace NiceHashBotLib
+{
+ class APIAlgorithmInfo
+ {
+ [JsonProperty(PropertyName = "algo")]
+ public int ID;
+
+ [JsonProperty(PropertyName = "name")]
+ public string Name;
+
+ [JsonProperty(PropertyName = "min_limit")]
+ public double MinimalLimit;
+
+ [JsonProperty(PropertyName = "down_step")]
+ public double PriceDownStep;
+
+ [JsonProperty(PropertyName = "multi")]
+ public double Multiplier;
+
+ [JsonProperty(PropertyName = "speed_text")]
+ public string SpeedText;
+ }
+
+ class APIBuyInfo
+ {
+ [JsonProperty(PropertyName = "algorithms")]
+ public APIAlgorithmInfo[] Algorithms;
+
+ [JsonProperty(PropertyName = "down_time")]
+ public int DownStepTime;
+ }
+}
diff --git a/src/NiceHashBotLib/APIWrapper.cs b/src/NiceHashBotLib/APIWrapper.cs
index b9c6501..74ad00f 100644
--- a/src/NiceHashBotLib/APIWrapper.cs
+++ b/src/NiceHashBotLib/APIWrapper.cs
@@ -13,7 +13,7 @@ public class APIWrapper
///
/// API Version compatible with.
///
- public readonly static string API_VERSION_COMPATIBLE = "1.2.0";
+ public readonly static string API_VERSION_COMPATIBLE = "1.2.2";
///
/// URLs for NiceHash services.
@@ -23,27 +23,42 @@ public class APIWrapper
///
/// Names for NiceHash services.
///
- public readonly static string[] SERVICE_NAME = { "Europe (NiceHash)", " USA (WestHash)" };
+ public readonly static string[] SERVICE_NAME = { "Europe (NiceHash)", "USA (WestHash)" };
///
/// Names for algorithms.
///
- public readonly static string[] ALGORITHM_NAME = { "Scrypt", "SHA256", "Scrypt-A.-Nf.", "X11", "X13", "Keccak", "X15", "Nist5", "NeoScrypt", "Lyra2RE", "WhirlpoolX", "Qubit", "Quark" };
+ public static string[] ALGORITHM_NAME;
///
/// Total number of algorithms.
///
- public readonly static int NUMBER_OF_ALGORITHMS = ALGORITHM_NAME.Length;
+ public static int NUMBER_OF_ALGORITHMS;
///
/// Price decrease steps for all algorithms.
///
- public readonly static double[] PRICE_DECREASE_STEP = { -0.001, -0.0001, -0.002, -0.001, -0.001, -0.0001, -0.001, -0.001, -0.01, -0.002, -0.0001, -0.0005, -0.001 };
+ public static double[] PRICE_DECREASE_STEP;
///
- /// Price decrase interval - it is 10 minutes.
+ /// Minimal speed limit for order.
///
- public readonly static TimeSpan PRICE_DECREASE_INTERVAL = new TimeSpan(0, 10, 1);
+ public static double[] MINIMAL_LIMIT;
+
+ ///
+ /// Algorithm multiplier used for limit (to get GH/s speed).
+ ///
+ public static double[] ALGORITHM_MULTIPLIER;
+
+ ///
+ /// Algorithm speed text.
+ ///
+ public static string[] SPEED_TEXT;
+
+ ///
+ /// Price decrase interval.
+ ///
+ public static TimeSpan PRICE_DECREASE_INTERVAL;
///
/// API ID.
@@ -70,8 +85,8 @@ public class APIWrapper
#region PRIVATE_PROPERTIES
private static object CacheLock = new object();
- private static CachedOrderList[,] CachedOList = new CachedOrderList[SERVICE_LOCATION.Length, NUMBER_OF_ALGORITHMS];
- private static CachedStats[,] CachedSList = new CachedStats[SERVICE_LOCATION.Length, NUMBER_OF_ALGORITHMS];
+ private static CachedOrderList[,] CachedOList;
+ private static CachedStats[,] CachedSList;
#endregion
@@ -120,7 +135,38 @@ public static bool Initialize(string ID, string Key)
LibConsole.WriteLine(LibConsole.TEXT_TYPE.INFO, "Provided ID and Key are correct!");
+
+ Result R = Request>(0, "buy.info", false, null);
+ if (R == null)
+ {
+ LibConsole.WriteLine(LibConsole.TEXT_TYPE.ERROR, "Unable to get buy information. Service unavailable.");
+ return false;
+ }
+
+ PRICE_DECREASE_INTERVAL = new TimeSpan(0, 0, R.Data.DownStepTime);
+ ALGORITHM_NAME = new string[R.Data.Algorithms.Length];
+ PRICE_DECREASE_STEP = new double[R.Data.Algorithms.Length];
+ ALGORITHM_MULTIPLIER = new double[R.Data.Algorithms.Length];
+ MINIMAL_LIMIT = new double[R.Data.Algorithms.Length];
+ SPEED_TEXT = new string[R.Data.Algorithms.Length];
+ for (int i = 0; i < R.Data.Algorithms.Length; i++)
+ {
+ ALGORITHM_NAME[i] = R.Data.Algorithms[i].Name;
+ PRICE_DECREASE_STEP[i] = R.Data.Algorithms[i].PriceDownStep;
+ ALGORITHM_MULTIPLIER[i] = R.Data.Algorithms[i].Multiplier;
+ MINIMAL_LIMIT[i] = R.Data.Algorithms[i].MinimalLimit;
+ SPEED_TEXT[i] = R.Data.Algorithms[i].SpeedText;
+ }
+
+ NUMBER_OF_ALGORITHMS = ALGORITHM_NAME.Length;
+
+ CachedOList = new CachedOrderList[SERVICE_LOCATION.Length, NUMBER_OF_ALGORITHMS];
+ CachedSList = new CachedStats[SERVICE_LOCATION.Length, NUMBER_OF_ALGORITHMS];
+
+ LibConsole.WriteLine(LibConsole.TEXT_TYPE.INFO, "Buy information loaded.");
+
ValidAuthorization = true;
+
return true;
}
diff --git a/src/NiceHashBotLib/NiceHashBotLib.csproj b/src/NiceHashBotLib/NiceHashBotLib.csproj
index 311c4d6..fa8612b 100644
--- a/src/NiceHashBotLib/NiceHashBotLib.csproj
+++ b/src/NiceHashBotLib/NiceHashBotLib.csproj
@@ -41,6 +41,7 @@
+
diff --git a/src/NiceHashBotLib/OrderInstance.cs b/src/NiceHashBotLib/OrderInstance.cs
index 1abd67c..0c9e650 100644
--- a/src/NiceHashBotLib/OrderInstance.cs
+++ b/src/NiceHashBotLib/OrderInstance.cs
@@ -246,7 +246,7 @@ private bool IncreasePrice(Order MyOrder, Order[] AllOrders, double MinimalPrice
}
// Do not increase price, if we already have price higher or equal compared to minimal price.
- if (MyOrder.Price >= MinimalPrice) return false;
+ if (MyOrder.Price >= (MinimalPrice - 0.00001)) return false;
if (MaxPrice >= MinimalPrice)
{