├── .gitignore ├── LICENSE.md ├── NHB3.sln ├── NHB3 ├── Api.cs ├── ApiConnect.cs ├── ApiForm.Designer.cs ├── ApiForm.cs ├── ApiForm.resx ├── App.config ├── BotForm.Designer.cs ├── BotForm.cs ├── BotForm.resx ├── Home.Designer.cs ├── Home.cs ├── Home.resx ├── NHB3.csproj ├── OrderForm.Designer.cs ├── OrderForm.cs ├── OrderForm.resx ├── PoolForm.Designer.cs ├── PoolForm.cs ├── PoolForm.resx ├── PoolsForm.Designer.cs ├── PoolsForm.cs ├── PoolsForm.resx ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings └── packages.config ├── README.md └── screenshots ├── 00nhb3.png ├── 01api.png ├── 02pools.png ├── 03pool.png ├── 04order_create.png ├── 05order_refill.png ├── 06order_edit.png ├── 07bot_settings.png ├── 08bot_run.png └── 09_order.png /.gitignore: -------------------------------------------------------------------------------- 1 | .vs 2 | packages 3 | NHB3/bin 4 | NHB3/obj -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2020 NiceHash.com 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /NHB3.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29806.167 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NHB3", "NHB3\NHB3.csproj", "{544DB7FC-334D-4C5D-A298-61508693EB31}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {544DB7FC-334D-4C5D-A298-61508693EB31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {544DB7FC-334D-4C5D-A298-61508693EB31}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {544DB7FC-334D-4C5D-A298-61508693EB31}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {544DB7FC-334D-4C5D-A298-61508693EB31}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {ACE18268-A609-422C-8625-55B261915EF9} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /NHB3/Api.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Linq; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Net; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace NHB3 11 | { 12 | class Api 13 | { 14 | private string urlRoot; 15 | private string orgId; 16 | private string apiKey; 17 | private string apiSecret; 18 | 19 | public string time; 20 | 21 | public Api(string urlRoot, string orgId, string apiKey, string apiSecret) 22 | { 23 | this.urlRoot = urlRoot; 24 | this.orgId = orgId; 25 | this.apiKey = apiKey; 26 | this.apiSecret = apiSecret; 27 | } 28 | 29 | private static string HashBySegments(string key, string apiKey, string time, string nonce, string orgId, string method, string encodedPath, string query, string bodyStr) 30 | { 31 | List segments = new List(); 32 | segments.Add(apiKey); 33 | segments.Add(time); 34 | segments.Add(nonce); 35 | segments.Add(null); 36 | segments.Add(orgId); 37 | segments.Add(null); 38 | segments.Add(method); 39 | segments.Add(encodedPath == null ? null : encodedPath); 40 | segments.Add(query == null ? null : query); 41 | 42 | if (bodyStr != null && bodyStr.Length > 0) 43 | { 44 | segments.Add(bodyStr); 45 | } 46 | return Api.CalcHMACSHA256Hash(Api.JoinSegments(segments), key); 47 | } 48 | private static string getPath(string url) 49 | { 50 | var arrSplit = url.Split('?'); 51 | return arrSplit[0]; 52 | } 53 | private static string getQuery(string url) 54 | { 55 | var arrSplit = url.Split('?'); 56 | 57 | if (arrSplit.Length == 1) 58 | { 59 | return null; 60 | } 61 | else 62 | { 63 | return arrSplit[1]; 64 | } 65 | } 66 | 67 | private static string JoinSegments(List segments) 68 | { 69 | var sb = new System.Text.StringBuilder(); 70 | bool first = true; 71 | foreach (var segment in segments) 72 | { 73 | if (!first) 74 | { 75 | sb.Append("\x00"); 76 | } 77 | else 78 | { 79 | first = false; 80 | } 81 | 82 | if (segment != null) 83 | { 84 | sb.Append(segment); 85 | } 86 | } 87 | Console.ForegroundColor = ConsoleColor.DarkGray; 88 | Console.Out.WriteLine("req: [" + sb.ToString() + "]"); 89 | return sb.ToString(); 90 | } 91 | 92 | private static string CalcHMACSHA256Hash(string plaintext, string salt) 93 | { 94 | string result = ""; 95 | var enc = Encoding.Default; 96 | byte[] 97 | baText2BeHashed = enc.GetBytes(plaintext), 98 | baSalt = enc.GetBytes(salt); 99 | System.Security.Cryptography.HMACSHA256 hasher = new System.Security.Cryptography.HMACSHA256(baSalt); 100 | byte[] baHashedText = hasher.ComputeHash(baText2BeHashed); 101 | result = string.Join("", baHashedText.ToList().Select(b => b.ToString("x2")).ToArray()); 102 | return result; 103 | } 104 | 105 | private string srvrTime() 106 | { 107 | string timeResponse = this.get("/api/v2/time", false); 108 | JObject timeObject = JsonConvert.DeserializeObject(timeResponse); 109 | 110 | if (timeObject["error_id"] == null) 111 | { 112 | this.time = "" + timeObject["serverTime"]; 113 | return this.time; 114 | } 115 | return "0"; 116 | } 117 | 118 | public string get(string url, bool auth) 119 | { 120 | var client = new RestSharp.RestClient(this.urlRoot); 121 | var request = new RestSharp.RestRequest(url); 122 | 123 | if (auth) 124 | { 125 | string time = this.srvrTime(); 126 | string nonce = Guid.NewGuid().ToString(); 127 | string digest = Api.HashBySegments(this.apiSecret, this.apiKey, time, nonce, this.orgId, "GET", getPath(url), getQuery(url), null); 128 | 129 | request.AddHeader("X-Time", time); 130 | request.AddHeader("X-Nonce", nonce); 131 | request.AddHeader("X-Auth", this.apiKey + ":" + digest); 132 | request.AddHeader("X-Organization-Id", this.orgId); 133 | } 134 | 135 | var response = client.Execute(request, RestSharp.Method.GET); 136 | Console.Out.WriteLine("res: [" + response.Content + "]"); 137 | 138 | if (response.StatusCode != HttpStatusCode.OK) 139 | { 140 | return "{error_id: -1}"; 141 | } 142 | return response.Content; 143 | } 144 | 145 | public string post(string url, string payload, bool requestId) 146 | { 147 | string time = this.srvrTime(); 148 | var client = new RestSharp.RestClient(this.urlRoot); 149 | var request = new RestSharp.RestRequest(url); 150 | request.AddHeader("Accept", "application/json"); 151 | request.AddHeader("Content-type", "application/json"); 152 | 153 | string nonce = Guid.NewGuid().ToString(); 154 | string digest = Api.HashBySegments(this.apiSecret, this.apiKey, time, nonce, this.orgId, "POST", getPath(url), getQuery(url), payload); 155 | 156 | if (payload != null) 157 | { 158 | request.AddJsonBody(payload); 159 | } 160 | 161 | request.AddHeader("X-Time", time); 162 | request.AddHeader("X-Nonce", nonce); 163 | request.AddHeader("X-Auth", this.apiKey + ":" + digest); 164 | request.AddHeader("X-Organization-Id", this.orgId); 165 | 166 | if (requestId) 167 | { 168 | request.AddHeader("X-Request-Id", Guid.NewGuid().ToString()); 169 | } 170 | 171 | var response = client.Execute(request, RestSharp.Method.POST); 172 | Console.ForegroundColor = ConsoleColor.DarkGray; 173 | Console.Out.WriteLine("res: [" + response.Content + "]"); 174 | 175 | if (response.StatusCode != HttpStatusCode.OK) 176 | { 177 | return "{error_id: -1}"; 178 | } 179 | return response.Content; 180 | } 181 | 182 | public string delete(string url, bool requestId) 183 | { 184 | string time = this.srvrTime(); 185 | var client = new RestSharp.RestClient(this.urlRoot); 186 | var request = new RestSharp.RestRequest(url); 187 | 188 | string nonce = Guid.NewGuid().ToString(); 189 | string digest = Api.HashBySegments(this.apiSecret, this.apiKey, time, nonce, this.orgId, "DELETE", getPath(url), getQuery(url), null); 190 | 191 | request.AddHeader("X-Time", time); 192 | request.AddHeader("X-Nonce", nonce); 193 | request.AddHeader("X-Auth", this.apiKey + ":" + digest); 194 | request.AddHeader("X-Organization-Id", this.orgId); 195 | 196 | if (requestId) 197 | { 198 | request.AddHeader("X-Request-Id", Guid.NewGuid().ToString()); 199 | } 200 | 201 | var response = client.Execute(request, RestSharp.Method.DELETE); 202 | Console.ForegroundColor = ConsoleColor.DarkGray; 203 | Console.Out.WriteLine("res: [" + response.Content + "]"); 204 | 205 | if (response.StatusCode != HttpStatusCode.OK) 206 | { 207 | return "{error_id: -1}"; 208 | } 209 | return response.Content; 210 | } 211 | } 212 | } -------------------------------------------------------------------------------- /NHB3/ApiConnect.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Linq; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Data; 6 | using System.IO; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace NHB3 12 | { 13 | public class ApiConnect 14 | { 15 | Api api; 16 | public JArray algorithms; //hold algo settings 17 | public JArray buy; //hold buy settings 18 | public JArray pools = new JArray(); 19 | public bool connected = false; 20 | public string currency; 21 | 22 | public void setup(ApiSettings settings) { 23 | this.api = new Api(getApiUrl(settings.Enviorment), settings.OrganizationID, settings.ApiID, settings.ApiSecret); 24 | this.connected = true; 25 | 26 | //read algo settings 27 | string algosResponse = api.get("/main/api/v2/mining/algorithms", false); 28 | 29 | JObject algosObject = JsonConvert.DeserializeObject(algosResponse); 30 | if (algosObject["error_id"] == null) 31 | { 32 | algorithms = algosObject["miningAlgorithms"] as JArray; 33 | } 34 | 35 | //read buy settings 36 | string buyResponse = api.get("/main/api/v2/public/buy/info", false); 37 | 38 | JObject buyObject = JsonConvert.DeserializeObject(buyResponse); 39 | if (buyObject["error_id"] == null) 40 | { 41 | buy = buyObject["miningAlgorithms"] as JArray; 42 | } 43 | } 44 | 45 | public JArray getMarket() { 46 | string marketResponse = api.get("/main/api/v2/public/orders/active2", false); 47 | if (String.IsNullOrEmpty(marketResponse)) { 48 | return new JArray(); 49 | } 50 | 51 | JObject marektObject = JsonConvert.DeserializeObject(marketResponse); 52 | if (marektObject["error_id"] == null) 53 | { 54 | return marektObject["list"] as JArray; 55 | } 56 | return new JArray(); 57 | } 58 | 59 | public JArray getMarketForAlgo(String algorithm) 60 | { 61 | string marketResponse = api.get("/main/api/v2/public/orders/active2?algorithm="+algorithm, false); 62 | if (String.IsNullOrEmpty(marketResponse)) 63 | { 64 | return new JArray(); 65 | } 66 | 67 | JObject marektObject = JsonConvert.DeserializeObject(marketResponse); 68 | if (marektObject["error_id"] == null) 69 | { 70 | return marektObject["list"] as JArray; 71 | } 72 | return new JArray(); 73 | } 74 | 75 | public bool settingsOk() { 76 | string accountsResponse = api.get("/main/api/v2/accounting/accounts2", true); 77 | 78 | JObject accountsObject = JsonConvert.DeserializeObject(accountsResponse); 79 | if (accountsObject["error_id"] == null) 80 | { 81 | return true; 82 | } 83 | return false; 84 | } 85 | 86 | public JObject getBalance(string currency) { 87 | string accountsResponse = api.get("/main/api/v2/accounting/accounts2", true); 88 | 89 | JObject accountsObject = JsonConvert.DeserializeObject(accountsResponse); 90 | 91 | if (accountsObject["error_id"] != null) 92 | { 93 | //api call failed 94 | Console.WriteLine("Error reading API ... {0}", accountsObject); 95 | return null; 96 | } 97 | 98 | JArray currencies = accountsObject["currencies"] as JArray; 99 | foreach (JObject obj in currencies) 100 | { 101 | string curr = obj["currency"].ToString(); 102 | if (curr.Equals(currency)) { 103 | return obj; 104 | } 105 | } 106 | return null; 107 | } 108 | 109 | public JArray getPools(bool force) { 110 | if (force) 111 | { 112 | string poolsResponse = api.get("/main/api/v2/pools?size=1000", true); 113 | JObject poolsObject = JsonConvert.DeserializeObject(poolsResponse); 114 | 115 | if (poolsObject["error_id"] == null) 116 | { 117 | this.pools = poolsObject["list"] as JArray; 118 | } 119 | } 120 | return this.pools; 121 | } 122 | 123 | public void deletePool(string id) { 124 | api.delete("/main/api/v2/pool/"+id, false); 125 | } 126 | 127 | public void editPool(string name, string algorithm, string url, string port, string username, string password, string id) { 128 | Dictionary pool = new Dictionary 129 | { 130 | { "id", id }, 131 | { "algorithm", algorithm }, 132 | { "name", name }, 133 | { "username", username }, 134 | { "password", password }, 135 | { "stratumHostname", url }, 136 | { "stratumPort", port } 137 | }; 138 | api.post("/main/api/v2/pool", JsonConvert.SerializeObject(pool), false); 139 | } 140 | 141 | public void addPool(string name, string algorithm, string url, string port, string username, string password) { 142 | Dictionary pool = new Dictionary 143 | { 144 | { "algorithm", algorithm }, 145 | { "name", name }, 146 | { "username", username }, 147 | { "password", password }, 148 | { "stratumHostname", url }, 149 | { "stratumPort", port } 150 | }; 151 | api.post("/main/api/v2/pool", JsonConvert.SerializeObject(pool), false); 152 | } 153 | 154 | public JArray getOrders() { 155 | long ts = Convert.ToInt64(api.time) + (24 * 60 * 1000); //in case of stratum "refresh" 156 | 157 | string ordersResponse = api.get("/main/api/v2/hashpower/myOrders?active=true&op=LE&limit=1000&ts="+ts, true); 158 | JObject ordersObject = JsonConvert.DeserializeObject(ordersResponse); 159 | 160 | if (ordersObject["error_id"] == null) 161 | { 162 | return ordersObject["list"] as JArray; 163 | } 164 | return new JArray(); 165 | } 166 | 167 | public JObject getFixedPrice(string algo, string limit, string market) { 168 | Dictionary reqParams = new Dictionary 169 | { 170 | { "algorithm", algo }, 171 | { "limit", limit }, 172 | { "market", market } 173 | }; 174 | string fixedResponse = api.post("/main/api/v2/hashpower/orders/fixedPrice", JsonConvert.SerializeObject(reqParams), false); 175 | JObject fixedObject = JsonConvert.DeserializeObject(fixedResponse); 176 | 177 | if (fixedObject["error_id"] == null) 178 | { 179 | return fixedObject; 180 | } 181 | return new JObject(); 182 | } 183 | 184 | public JObject createOrder(string algo, string market, string type, string pool, string price, string limit, string amount) { 185 | JObject selAlgo = getAlgo(algo); 186 | 187 | Dictionary order = new Dictionary { 188 | { "algorithm", algo }, 189 | { "amount", amount }, 190 | { "displayMarketFactor", (string)selAlgo["displayMarketFactor"] }, 191 | { "displayPriceFactor", (string)selAlgo["displayPriceFactor"] }, 192 | { "limit", limit }, 193 | { "market", market }, 194 | { "marketFactor", (string)selAlgo["marketFactor"] }, 195 | { "poolId", pool }, 196 | { "price", price }, 197 | { "priceFactor", (string)selAlgo["priceFactor"] }, 198 | { "type", type } 199 | }; 200 | string newOrderResponse = api.post("/main/api/v2/hashpower/order", JsonConvert.SerializeObject(order), true); 201 | JObject orderObject = JsonConvert.DeserializeObject(newOrderResponse); 202 | 203 | if (orderObject["error_id"] == null) 204 | { 205 | return orderObject; 206 | } 207 | return new JObject(); 208 | } 209 | 210 | public JObject refillOrder(string id, string amount) { 211 | Dictionary order = new Dictionary { 212 | { "amount", amount } 213 | }; 214 | 215 | string refillOrderResponse = api.post("/main/api/v2/hashpower/order/"+id+"/refill", JsonConvert.SerializeObject(order), true); 216 | JObject orderObject = JsonConvert.DeserializeObject(refillOrderResponse); 217 | 218 | if (orderObject["error_id"] == null) 219 | { 220 | return orderObject; 221 | } 222 | return new JObject(); 223 | } 224 | 225 | public JObject updateOrder(string algo, string id, string price, string limit) 226 | { 227 | JObject selAlgo = getAlgo(algo); 228 | Dictionary order = new Dictionary { 229 | { "price", price }, 230 | { "limit", limit }, 231 | { "displayMarketFactor", (string)selAlgo["displayMarketFactor"] }, 232 | { "marketFactor", (string)selAlgo["marketFactor"] }, 233 | { "displayPriceFactor", (string)selAlgo["displayPriceFactor"] }, 234 | { "priceFactor", (string)selAlgo["priceFactor"] } 235 | }; 236 | 237 | string editOrderResponse = api.post("/main/api/v2/hashpower/order/" + id + "/updatePriceAndLimit", JsonConvert.SerializeObject(order), true); 238 | JObject orderObject = JsonConvert.DeserializeObject(editOrderResponse); 239 | 240 | if (orderObject["error_id"] == null) 241 | { 242 | return orderObject; 243 | } 244 | return new JObject(); 245 | } 246 | 247 | public JObject cancelOrder(string id) 248 | { 249 | string deleteOrderResponse = api.delete("/main/api/v2/hashpower/order/" + id, true); 250 | JObject orderObject = JsonConvert.DeserializeObject(deleteOrderResponse); 251 | 252 | if (orderObject["error_id"] == null) 253 | { 254 | return orderObject; 255 | } 256 | return new JObject(); 257 | } 258 | 259 | public ApiSettings readSettings() { 260 | String fileName = Path.Combine(Directory.GetCurrentDirectory(), "settings.json"); 261 | if (File.Exists(fileName)) 262 | { 263 | ApiSettings saved = JsonConvert.DeserializeObject(File.ReadAllText(@fileName)); 264 | return saved; 265 | } 266 | return new ApiSettings(); 267 | } 268 | 269 | public JObject getAlgo(string algo) { 270 | foreach (JObject obj in algorithms) 271 | { 272 | if (algo.Equals(""+obj["algorithm"])) 273 | { 274 | return obj; 275 | } 276 | } 277 | return new JObject(); 278 | } 279 | 280 | private string getApiUrl(int Enviorment) 281 | { 282 | if (Enviorment == 1) 283 | { 284 | return "https://api2.nicehash.com"; 285 | } else if (Enviorment == 99) 286 | { 287 | return "https://api-test-dev.nicehash.com"; 288 | } 289 | return "https://api-test.nicehash.com"; 290 | } 291 | 292 | public class ApiSettings 293 | { 294 | public string OrganizationID { get; set; } 295 | 296 | public string ApiID { get; set; } 297 | 298 | public string ApiSecret { get; set; } 299 | 300 | public int Enviorment { get; set; } 301 | } 302 | } 303 | } 304 | -------------------------------------------------------------------------------- /NHB3/ApiForm.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace NHB3 2 | { 3 | partial class ApiForm 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.label1 = new System.Windows.Forms.Label(); 32 | this.label2 = new System.Windows.Forms.Label(); 33 | this.textBox1 = new System.Windows.Forms.TextBox(); 34 | this.textBox2 = new System.Windows.Forms.TextBox(); 35 | this.label3 = new System.Windows.Forms.Label(); 36 | this.textBox3 = new System.Windows.Forms.TextBox(); 37 | this.label4 = new System.Windows.Forms.Label(); 38 | this.radioButton1 = new System.Windows.Forms.RadioButton(); 39 | this.radioButton2 = new System.Windows.Forms.RadioButton(); 40 | this.linkLabel1 = new System.Windows.Forms.LinkLabel(); 41 | this.button1 = new System.Windows.Forms.Button(); 42 | this.button2 = new System.Windows.Forms.Button(); 43 | this.label5 = new System.Windows.Forms.Label(); 44 | this.label6 = new System.Windows.Forms.Label(); 45 | this.SuspendLayout(); 46 | // 47 | // label1 48 | // 49 | this.label1.AutoSize = true; 50 | this.label1.Location = new System.Drawing.Point(13, 13); 51 | this.label1.Name = "label1"; 52 | this.label1.Size = new System.Drawing.Size(116, 20); 53 | this.label1.TabIndex = 0; 54 | this.label1.Text = "OrganizationID"; 55 | // 56 | // label2 57 | // 58 | this.label2.AutoSize = true; 59 | this.label2.Location = new System.Drawing.Point(13, 46); 60 | this.label2.Name = "label2"; 61 | this.label2.Size = new System.Drawing.Size(49, 20); 62 | this.label2.TabIndex = 1; 63 | this.label2.Text = "ApiID"; 64 | // 65 | // textBox1 66 | // 67 | this.textBox1.Location = new System.Drawing.Point(135, 10); 68 | this.textBox1.Name = "textBox1"; 69 | this.textBox1.Size = new System.Drawing.Size(653, 26); 70 | this.textBox1.TabIndex = 2; 71 | // 72 | // textBox2 73 | // 74 | this.textBox2.Location = new System.Drawing.Point(135, 43); 75 | this.textBox2.Name = "textBox2"; 76 | this.textBox2.Size = new System.Drawing.Size(653, 26); 77 | this.textBox2.TabIndex = 3; 78 | // 79 | // label3 80 | // 81 | this.label3.AutoSize = true; 82 | this.label3.Location = new System.Drawing.Point(13, 82); 83 | this.label3.Name = "label3"; 84 | this.label3.Size = new System.Drawing.Size(79, 20); 85 | this.label3.TabIndex = 4; 86 | this.label3.Text = "ApiSecret"; 87 | // 88 | // textBox3 89 | // 90 | this.textBox3.Location = new System.Drawing.Point(135, 76); 91 | this.textBox3.Name = "textBox3"; 92 | this.textBox3.Size = new System.Drawing.Size(653, 26); 93 | this.textBox3.TabIndex = 5; 94 | // 95 | // label4 96 | // 97 | this.label4.AutoSize = true; 98 | this.label4.Location = new System.Drawing.Point(13, 113); 99 | this.label4.Name = "label4"; 100 | this.label4.Size = new System.Drawing.Size(89, 20); 101 | this.label4.TabIndex = 6; 102 | this.label4.Text = "Enviorment"; 103 | // 104 | // radioButton1 105 | // 106 | this.radioButton1.AutoSize = true; 107 | this.radioButton1.Location = new System.Drawing.Point(135, 111); 108 | this.radioButton1.Name = "radioButton1"; 109 | this.radioButton1.Size = new System.Drawing.Size(61, 24); 110 | this.radioButton1.TabIndex = 7; 111 | this.radioButton1.TabStop = true; 112 | this.radioButton1.Text = "test"; 113 | this.radioButton1.UseVisualStyleBackColor = true; 114 | // 115 | // radioButton2 116 | // 117 | this.radioButton2.AutoSize = true; 118 | this.radioButton2.Location = new System.Drawing.Point(203, 111); 119 | this.radioButton2.Name = "radioButton2"; 120 | this.radioButton2.Size = new System.Drawing.Size(109, 24); 121 | this.radioButton2.TabIndex = 8; 122 | this.radioButton2.TabStop = true; 123 | this.radioButton2.Text = "production"; 124 | this.radioButton2.UseVisualStyleBackColor = true; 125 | // 126 | // linkLabel1 127 | // 128 | this.linkLabel1.AutoSize = true; 129 | this.linkLabel1.Location = new System.Drawing.Point(642, 113); 130 | this.linkLabel1.Name = "linkLabel1"; 131 | this.linkLabel1.Size = new System.Drawing.Size(146, 20); 132 | this.linkLabel1.TabIndex = 9; 133 | this.linkLabel1.TabStop = true; 134 | this.linkLabel1.Text = "How to get API Key"; 135 | this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked); 136 | // 137 | // button1 138 | // 139 | this.button1.Location = new System.Drawing.Point(500, 158); 140 | this.button1.Name = "button1"; 141 | this.button1.Size = new System.Drawing.Size(141, 39); 142 | this.button1.TabIndex = 10; 143 | this.button1.Text = "Test credentials"; 144 | this.button1.UseVisualStyleBackColor = true; 145 | this.button1.Click += new System.EventHandler(this.button1_Click); 146 | // 147 | // button2 148 | // 149 | this.button2.Enabled = false; 150 | this.button2.Location = new System.Drawing.Point(647, 158); 151 | this.button2.Name = "button2"; 152 | this.button2.Size = new System.Drawing.Size(141, 39); 153 | this.button2.TabIndex = 11; 154 | this.button2.Text = "Save credentials"; 155 | this.button2.UseVisualStyleBackColor = true; 156 | this.button2.Click += new System.EventHandler(this.button2_Click); 157 | // 158 | // label5 159 | // 160 | this.label5.AutoSize = true; 161 | this.label5.ForeColor = System.Drawing.Color.Firebrick; 162 | this.label5.Location = new System.Drawing.Point(13, 176); 163 | this.label5.Name = "label5"; 164 | this.label5.Size = new System.Drawing.Size(44, 20); 165 | this.label5.TabIndex = 12; 166 | this.label5.Text = "Error"; 167 | this.label5.Visible = false; 168 | // 169 | // label6 170 | // 171 | this.label6.AutoSize = true; 172 | this.label6.ForeColor = System.Drawing.Color.Green; 173 | this.label6.Location = new System.Drawing.Point(18, 177); 174 | this.label6.Name = "label6"; 175 | this.label6.Size = new System.Drawing.Size(70, 20); 176 | this.label6.TabIndex = 13; 177 | this.label6.Text = "Success"; 178 | this.label6.Visible = false; 179 | // 180 | // ApiForm 181 | // 182 | this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); 183 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 184 | this.ClientSize = new System.Drawing.Size(800, 210); 185 | this.Controls.Add(this.label6); 186 | this.Controls.Add(this.label5); 187 | this.Controls.Add(this.button2); 188 | this.Controls.Add(this.button1); 189 | this.Controls.Add(this.linkLabel1); 190 | this.Controls.Add(this.radioButton2); 191 | this.Controls.Add(this.radioButton1); 192 | this.Controls.Add(this.label4); 193 | this.Controls.Add(this.textBox3); 194 | this.Controls.Add(this.label3); 195 | this.Controls.Add(this.textBox2); 196 | this.Controls.Add(this.textBox1); 197 | this.Controls.Add(this.label2); 198 | this.Controls.Add(this.label1); 199 | this.Name = "ApiForm"; 200 | this.Text = "Api settings"; 201 | this.ResumeLayout(false); 202 | this.PerformLayout(); 203 | 204 | } 205 | 206 | #endregion 207 | 208 | private System.Windows.Forms.Label label1; 209 | private System.Windows.Forms.Label label2; 210 | private System.Windows.Forms.TextBox textBox1; 211 | private System.Windows.Forms.TextBox textBox2; 212 | private System.Windows.Forms.Label label3; 213 | private System.Windows.Forms.TextBox textBox3; 214 | private System.Windows.Forms.Label label4; 215 | private System.Windows.Forms.RadioButton radioButton1; 216 | private System.Windows.Forms.RadioButton radioButton2; 217 | private System.Windows.Forms.LinkLabel linkLabel1; 218 | private System.Windows.Forms.Button button1; 219 | private System.Windows.Forms.Button button2; 220 | private System.Windows.Forms.Label label5; 221 | private System.Windows.Forms.Label label6; 222 | } 223 | } -------------------------------------------------------------------------------- /NHB3/ApiForm.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Linq; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.ComponentModel; 6 | using System.Data; 7 | using System.Drawing; 8 | using System.IO; 9 | using System.Linq; 10 | using System.Text; 11 | using System.Threading.Tasks; 12 | using System.Windows.Forms; 13 | using static NHB3.ApiConnect; 14 | 15 | namespace NHB3 16 | { 17 | public partial class ApiForm : Form 18 | { 19 | ApiConnect ac; 20 | 21 | public ApiForm(ApiConnect ac) 22 | { 23 | InitializeComponent(); 24 | this.Show(); 25 | this.ac = ac; 26 | 27 | //load current settings 28 | ApiSettings saved = this.ac.readSettings(); 29 | this.textBox1.Text = saved.OrganizationID; 30 | this.textBox2.Text = saved.ApiID; 31 | this.textBox3.Text = saved.ApiSecret; 32 | 33 | if (saved.Enviorment == 0) 34 | { 35 | this.radioButton1.Checked = true; 36 | } 37 | else if (saved.Enviorment == 1) 38 | { 39 | this.radioButton2.Checked = true; 40 | } 41 | } 42 | 43 | private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 44 | { 45 | System.Diagnostics.Process.Start("https://github.com/nicehash/rest-clients-demo"); 46 | } 47 | 48 | private void button1_Click(object sender, EventArgs e) 49 | { 50 | this.button2.Enabled = false; 51 | this.label5.Visible = false; //error 52 | this.label6.Visible = false; //success 53 | 54 | ApiSettings current = formSettings(); 55 | ac.setup(current); 56 | if (ac.settingsOk()) { 57 | this.label6.Visible = true; 58 | this.button2.Enabled = true; 59 | } else { 60 | this.label5.Visible = true; 61 | } 62 | } 63 | 64 | private void button2_Click(object sender, EventArgs e) 65 | { 66 | String fileName = Path.Combine(Directory.GetCurrentDirectory(), "settings.json"); 67 | ApiSettings current = formSettings(); 68 | File.WriteAllText(fileName, JsonConvert.SerializeObject(current)); 69 | this.Close(); 70 | } 71 | 72 | private ApiSettings formSettings() { 73 | ApiSettings current = new ApiSettings(); 74 | 75 | current.OrganizationID = this.textBox1.Text; 76 | current.ApiID = this.textBox2.Text; 77 | current.ApiSecret = this.textBox3.Text; 78 | 79 | if (this.radioButton1.Checked == true) 80 | { 81 | current.Enviorment = 0; 82 | } 83 | else if (this.radioButton2.Checked == true) 84 | { 85 | current.Enviorment = 1; 86 | } 87 | return current; 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /NHB3/ApiForm.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /NHB3/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /NHB3/BotForm.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace NHB3 2 | { 3 | partial class BotForm 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.checkBox1 = new System.Windows.Forms.CheckBox(); 32 | this.checkBox2 = new System.Windows.Forms.CheckBox(); 33 | this.checkBox3 = new System.Windows.Forms.CheckBox(); 34 | this.button1 = new System.Windows.Forms.Button(); 35 | this.SuspendLayout(); 36 | // 37 | // checkBox1 38 | // 39 | this.checkBox1.AutoSize = true; 40 | this.checkBox1.Location = new System.Drawing.Point(13, 13); 41 | this.checkBox1.Name = "checkBox1"; 42 | this.checkBox1.Size = new System.Drawing.Size(254, 24); 43 | this.checkBox1.TabIndex = 0; 44 | this.checkBox1.Text = "Refill order when spent hit 90%"; 45 | this.checkBox1.UseVisualStyleBackColor = true; 46 | // 47 | // checkBox2 48 | // 49 | this.checkBox2.AutoSize = true; 50 | this.checkBox2.Location = new System.Drawing.Point(13, 44); 51 | this.checkBox2.Name = "checkBox2"; 52 | this.checkBox2.Size = new System.Drawing.Size(467, 24); 53 | this.checkBox2.TabIndex = 1; 54 | this.checkBox2.Text = "Lower order price for one step if cheaper hashpower available"; 55 | this.checkBox2.UseVisualStyleBackColor = true; 56 | // 57 | // checkBox3 58 | // 59 | this.checkBox3.AutoSize = true; 60 | this.checkBox3.Location = new System.Drawing.Point(13, 75); 61 | this.checkBox3.Name = "checkBox3"; 62 | this.checkBox3.Size = new System.Drawing.Size(441, 24); 63 | this.checkBox3.TabIndex = 2; 64 | this.checkBox3.Text = "Increase order price for one step if order run out of miners"; 65 | this.checkBox3.UseVisualStyleBackColor = true; 66 | // 67 | // button1 68 | // 69 | this.button1.Location = new System.Drawing.Point(485, 105); 70 | this.button1.Name = "button1"; 71 | this.button1.Size = new System.Drawing.Size(75, 32); 72 | this.button1.TabIndex = 3; 73 | this.button1.Text = "Save"; 74 | this.button1.UseVisualStyleBackColor = true; 75 | this.button1.Click += new System.EventHandler(this.button1_Click); 76 | // 77 | // BotForm 78 | // 79 | this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); 80 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 81 | this.ClientSize = new System.Drawing.Size(581, 151); 82 | this.Controls.Add(this.button1); 83 | this.Controls.Add(this.checkBox3); 84 | this.Controls.Add(this.checkBox2); 85 | this.Controls.Add(this.checkBox1); 86 | this.Name = "BotForm"; 87 | this.Text = "Bot settings"; 88 | this.ResumeLayout(false); 89 | this.PerformLayout(); 90 | 91 | } 92 | 93 | #endregion 94 | 95 | private System.Windows.Forms.CheckBox checkBox1; 96 | private System.Windows.Forms.CheckBox checkBox2; 97 | private System.Windows.Forms.CheckBox checkBox3; 98 | private System.Windows.Forms.Button button1; 99 | } 100 | } -------------------------------------------------------------------------------- /NHB3/BotForm.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel; 5 | using System.Data; 6 | using System.Drawing; 7 | using System.IO; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | using System.Windows.Forms; 12 | 13 | namespace NHB3 14 | { 15 | public partial class BotForm : Form 16 | { 17 | 18 | public bool refill; 19 | public bool lower; 20 | public bool increase; 21 | 22 | public BotForm() 23 | { 24 | InitializeComponent(); 25 | this.Show(); 26 | loadSettings(); 27 | } 28 | 29 | public void loadSettings() { 30 | String fileName = Path.Combine(Directory.GetCurrentDirectory(), "bot.json"); 31 | if (File.Exists(fileName)) 32 | { 33 | BotSettings saved = JsonConvert.DeserializeObject(File.ReadAllText(@fileName)); 34 | this.checkBox1.Checked = saved.reffilOrder; 35 | this.checkBox2.Checked = saved.lowerPrice; 36 | this.checkBox3.Checked = saved.increasePrice; 37 | } 38 | } 39 | 40 | private void button1_Click(object sender, EventArgs e) 41 | { 42 | String fileName = Path.Combine(Directory.GetCurrentDirectory(), "bot.json"); 43 | BotSettings current = formSettings(); 44 | File.WriteAllText(fileName, JsonConvert.SerializeObject(current)); 45 | this.Close(); 46 | } 47 | 48 | private BotSettings formSettings() 49 | { 50 | BotSettings current = new BotSettings(); 51 | 52 | current.reffilOrder = false; 53 | current.lowerPrice = false; 54 | current.increasePrice = false; 55 | 56 | if (this.checkBox1.Checked) current.reffilOrder = true; 57 | if (this.checkBox2.Checked) current.lowerPrice = true; 58 | if (this.checkBox3.Checked) current.increasePrice = true; 59 | 60 | return current; 61 | } 62 | } 63 | 64 | public class BotSettings 65 | { 66 | public bool reffilOrder { get; set; } 67 | 68 | public bool lowerPrice { get; set; } 69 | 70 | public bool increasePrice { get; set; } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /NHB3/BotForm.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /NHB3/Home.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace NHB3 2 | { 3 | partial class Home 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Home)); 32 | this.menuStrip1 = new System.Windows.Forms.MenuStrip(); 33 | this.refreshToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 34 | this.newOrderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 35 | this.editSelectedOrderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 36 | this.ordersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 37 | this.balanceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 38 | this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); 39 | this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem(); 40 | this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem(); 41 | this.botToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 42 | this.statusStrip1 = new System.Windows.Forms.StatusStrip(); 43 | this.toolStripSplitButton1 = new System.Windows.Forms.ToolStripSplitButton(); 44 | this.autoPilotOffToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 45 | this.autoPilotONToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 46 | this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); 47 | this.toolStripStatusLabel2 = new System.Windows.Forms.ToolStripStatusLabel(); 48 | this.dataGridView1 = new System.Windows.Forms.DataGridView(); 49 | this.menuStrip1.SuspendLayout(); 50 | this.statusStrip1.SuspendLayout(); 51 | ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); 52 | this.SuspendLayout(); 53 | // 54 | // menuStrip1 55 | // 56 | this.menuStrip1.ImageScalingSize = new System.Drawing.Size(24, 24); 57 | this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 58 | this.refreshToolStripMenuItem, 59 | this.toolStripMenuItem1}); 60 | this.menuStrip1.Location = new System.Drawing.Point(0, 0); 61 | this.menuStrip1.Name = "menuStrip1"; 62 | this.menuStrip1.Size = new System.Drawing.Size(1406, 36); 63 | this.menuStrip1.TabIndex = 0; 64 | this.menuStrip1.Text = "menuStrip1"; 65 | // 66 | // refreshToolStripMenuItem 67 | // 68 | this.refreshToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { 69 | this.newOrderToolStripMenuItem, 70 | this.editSelectedOrderToolStripMenuItem, 71 | this.ordersToolStripMenuItem, 72 | this.balanceToolStripMenuItem}); 73 | this.refreshToolStripMenuItem.Name = "refreshToolStripMenuItem"; 74 | this.refreshToolStripMenuItem.Size = new System.Drawing.Size(87, 32); 75 | this.refreshToolStripMenuItem.Text = "Actions"; 76 | // 77 | // newOrderToolStripMenuItem 78 | // 79 | this.newOrderToolStripMenuItem.Name = "newOrderToolStripMenuItem"; 80 | this.newOrderToolStripMenuItem.Size = new System.Drawing.Size(261, 34); 81 | this.newOrderToolStripMenuItem.Text = "New order"; 82 | this.newOrderToolStripMenuItem.Click += new System.EventHandler(this.newOrderToolStripMenuItem_Click); 83 | // 84 | // editSelectedOrderToolStripMenuItem 85 | // 86 | this.editSelectedOrderToolStripMenuItem.Name = "editSelectedOrderToolStripMenuItem"; 87 | this.editSelectedOrderToolStripMenuItem.Size = new System.Drawing.Size(261, 34); 88 | this.editSelectedOrderToolStripMenuItem.Text = "Edit selected order"; 89 | this.editSelectedOrderToolStripMenuItem.Click += new System.EventHandler(this.editSelectedOrderToolStripMenuItem_Click); 90 | // 91 | // ordersToolStripMenuItem 92 | // 93 | this.ordersToolStripMenuItem.Name = "ordersToolStripMenuItem"; 94 | this.ordersToolStripMenuItem.Size = new System.Drawing.Size(261, 34); 95 | this.ordersToolStripMenuItem.Text = "Refresh orders"; 96 | this.ordersToolStripMenuItem.Click += new System.EventHandler(this.ordersToolStripMenuItem_Click); 97 | // 98 | // balanceToolStripMenuItem 99 | // 100 | this.balanceToolStripMenuItem.Name = "balanceToolStripMenuItem"; 101 | this.balanceToolStripMenuItem.Size = new System.Drawing.Size(261, 34); 102 | this.balanceToolStripMenuItem.Text = "Refresh balance"; 103 | this.balanceToolStripMenuItem.Click += new System.EventHandler(this.balanceToolStripMenuItem_Click); 104 | // 105 | // toolStripMenuItem1 106 | // 107 | this.toolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { 108 | this.toolStripMenuItem2, 109 | this.toolStripMenuItem3, 110 | this.botToolStripMenuItem}); 111 | this.toolStripMenuItem1.Name = "toolStripMenuItem1"; 112 | this.toolStripMenuItem1.Size = new System.Drawing.Size(92, 32); 113 | this.toolStripMenuItem1.Text = "Settings"; 114 | // 115 | // toolStripMenuItem2 116 | // 117 | this.toolStripMenuItem2.Name = "toolStripMenuItem2"; 118 | this.toolStripMenuItem2.Size = new System.Drawing.Size(157, 34); 119 | this.toolStripMenuItem2.Text = "API"; 120 | this.toolStripMenuItem2.Click += new System.EventHandler(this.api_Click); 121 | // 122 | // toolStripMenuItem3 123 | // 124 | this.toolStripMenuItem3.Name = "toolStripMenuItem3"; 125 | this.toolStripMenuItem3.Size = new System.Drawing.Size(157, 34); 126 | this.toolStripMenuItem3.Text = "Pools"; 127 | this.toolStripMenuItem3.Click += new System.EventHandler(this.pools_Click); 128 | // 129 | // botToolStripMenuItem 130 | // 131 | this.botToolStripMenuItem.Name = "botToolStripMenuItem"; 132 | this.botToolStripMenuItem.Size = new System.Drawing.Size(157, 34); 133 | this.botToolStripMenuItem.Text = "Bot"; 134 | this.botToolStripMenuItem.Click += new System.EventHandler(this.botToolStripMenuItem_Click); 135 | // 136 | // statusStrip1 137 | // 138 | this.statusStrip1.ImageScalingSize = new System.Drawing.Size(24, 24); 139 | this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 140 | this.toolStripSplitButton1, 141 | this.toolStripStatusLabel1, 142 | this.toolStripStatusLabel2}); 143 | this.statusStrip1.Location = new System.Drawing.Point(0, 693); 144 | this.statusStrip1.Name = "statusStrip1"; 145 | this.statusStrip1.Size = new System.Drawing.Size(1406, 32); 146 | this.statusStrip1.TabIndex = 1; 147 | this.statusStrip1.Text = "statusStrip1"; 148 | // 149 | // toolStripSplitButton1 150 | // 151 | this.toolStripSplitButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; 152 | this.toolStripSplitButton1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { 153 | this.autoPilotOffToolStripMenuItem, 154 | this.autoPilotONToolStripMenuItem}); 155 | this.toolStripSplitButton1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripSplitButton1.Image"))); 156 | this.toolStripSplitButton1.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; 157 | this.toolStripSplitButton1.ImageTransparentColor = System.Drawing.Color.Magenta; 158 | this.toolStripSplitButton1.Name = "toolStripSplitButton1"; 159 | this.toolStripSplitButton1.Size = new System.Drawing.Size(37, 29); 160 | this.toolStripSplitButton1.Text = "toolStripSplitButton1"; 161 | // 162 | // autoPilotOffToolStripMenuItem 163 | // 164 | this.autoPilotOffToolStripMenuItem.Name = "autoPilotOffToolStripMenuItem"; 165 | this.autoPilotOffToolStripMenuItem.Size = new System.Drawing.Size(172, 34); 166 | this.autoPilotOffToolStripMenuItem.Text = "Bot Off"; 167 | this.autoPilotOffToolStripMenuItem.Click += new System.EventHandler(this.autoPilotOffToolStripMenuItem_Click); 168 | // 169 | // autoPilotONToolStripMenuItem 170 | // 171 | this.autoPilotONToolStripMenuItem.Name = "autoPilotONToolStripMenuItem"; 172 | this.autoPilotONToolStripMenuItem.Size = new System.Drawing.Size(172, 34); 173 | this.autoPilotONToolStripMenuItem.Text = "Bot On"; 174 | this.autoPilotONToolStripMenuItem.Click += new System.EventHandler(this.autoPilotONToolStripMenuItem_Click); 175 | // 176 | // toolStripStatusLabel1 177 | // 178 | this.toolStripStatusLabel1.Name = "toolStripStatusLabel1"; 179 | this.toolStripStatusLabel1.Size = new System.Drawing.Size(80, 25); 180 | this.toolStripStatusLabel1.Text = "Stopped"; 181 | // 182 | // toolStripStatusLabel2 183 | // 184 | this.toolStripStatusLabel2.Name = "toolStripStatusLabel2"; 185 | this.toolStripStatusLabel2.Size = new System.Drawing.Size(75, 25); 186 | this.toolStripStatusLabel2.Text = "Balance:"; 187 | // 188 | // dataGridView1 189 | // 190 | this.dataGridView1.AllowUserToAddRows = false; 191 | this.dataGridView1.AllowUserToDeleteRows = false; 192 | this.dataGridView1.AllowUserToOrderColumns = true; 193 | this.dataGridView1.AllowUserToResizeRows = false; 194 | this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 195 | | System.Windows.Forms.AnchorStyles.Left) 196 | | System.Windows.Forms.AnchorStyles.Right))); 197 | this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; 198 | this.dataGridView1.Location = new System.Drawing.Point(12, 36); 199 | this.dataGridView1.Name = "dataGridView1"; 200 | this.dataGridView1.RowHeadersWidth = 62; 201 | this.dataGridView1.RowTemplate.Height = 20; 202 | this.dataGridView1.Size = new System.Drawing.Size(1382, 645); 203 | this.dataGridView1.TabIndex = 2; 204 | // 205 | // Home 206 | // 207 | this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); 208 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 209 | this.ClientSize = new System.Drawing.Size(1406, 725); 210 | this.Controls.Add(this.dataGridView1); 211 | this.Controls.Add(this.statusStrip1); 212 | this.Controls.Add(this.menuStrip1); 213 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 214 | this.MainMenuStrip = this.menuStrip1; 215 | this.Name = "Home"; 216 | this.Text = "NHB3"; 217 | this.menuStrip1.ResumeLayout(false); 218 | this.menuStrip1.PerformLayout(); 219 | this.statusStrip1.ResumeLayout(false); 220 | this.statusStrip1.PerformLayout(); 221 | ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); 222 | this.ResumeLayout(false); 223 | this.PerformLayout(); 224 | 225 | } 226 | 227 | #endregion 228 | 229 | private System.Windows.Forms.MenuStrip menuStrip1; 230 | private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1; 231 | private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2; 232 | private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem3; 233 | private System.Windows.Forms.StatusStrip statusStrip1; 234 | private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1; 235 | private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel2; 236 | private System.Windows.Forms.ToolStripMenuItem refreshToolStripMenuItem; 237 | private System.Windows.Forms.ToolStripMenuItem balanceToolStripMenuItem; 238 | private System.Windows.Forms.ToolStripMenuItem ordersToolStripMenuItem; 239 | private System.Windows.Forms.DataGridView dataGridView1; 240 | private System.Windows.Forms.ToolStripMenuItem newOrderToolStripMenuItem; 241 | private System.Windows.Forms.ToolStripMenuItem editSelectedOrderToolStripMenuItem; 242 | private System.Windows.Forms.ToolStripSplitButton toolStripSplitButton1; 243 | private System.Windows.Forms.ToolStripMenuItem autoPilotOffToolStripMenuItem; 244 | private System.Windows.Forms.ToolStripMenuItem autoPilotONToolStripMenuItem; 245 | private System.Windows.Forms.ToolStripMenuItem botToolStripMenuItem; 246 | } 247 | } 248 | 249 | -------------------------------------------------------------------------------- /NHB3/Home.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Linq; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.ComponentModel; 6 | using System.Data; 7 | using System.Drawing; 8 | using System.Globalization; 9 | using System.IO; 10 | using System.Linq; 11 | using System.Text; 12 | using System.Threading.Tasks; 13 | using System.Windows.Forms; 14 | using static NHB3.ApiConnect; 15 | 16 | namespace NHB3 17 | { 18 | public partial class Home : Form 19 | { 20 | ApiConnect ac; 21 | string currency = "TBTC"; 22 | bool botRunning = false; 23 | JArray orders; 24 | JObject market; 25 | 26 | System.Threading.Timer timer; 27 | 28 | public Home() 29 | { 30 | InitializeComponent(); 31 | ac = new ApiConnect(); 32 | 33 | ApiSettings saved = ac.readSettings(); 34 | 35 | if (saved.OrganizationID != null) { 36 | ac.setup(saved); 37 | 38 | if (saved.Enviorment == 1) { 39 | currency = "BTC"; 40 | } 41 | ac.currency = currency; 42 | refreshBalance(); 43 | refreshOrders(false); 44 | ac.getPools(true); 45 | 46 | timer = new System.Threading.Timer( 47 | e => runBot(), 48 | null, 49 | TimeSpan.Zero, 50 | TimeSpan.FromSeconds(60)); 51 | } 52 | } 53 | 54 | private void api_Click(object sender, EventArgs e) 55 | { 56 | ApiForm af = new ApiForm(ac); 57 | af.FormBorderStyle = FormBorderStyle.FixedSingle; 58 | } 59 | 60 | private void pools_Click(object sender, EventArgs e) 61 | { 62 | PoolsForm pf = new PoolsForm(ac); 63 | pf.FormBorderStyle = FormBorderStyle.FixedSingle; 64 | } 65 | 66 | private void botToolStripMenuItem_Click(object sender, EventArgs e) 67 | { 68 | BotForm bf = new BotForm(); 69 | bf.FormBorderStyle = FormBorderStyle.FixedSingle; 70 | } 71 | 72 | private void newOrderToolStripMenuItem_Click(object sender, EventArgs e) 73 | { 74 | OrderForm of = new OrderForm(ac); 75 | of.FormBorderStyle = FormBorderStyle.FixedSingle; 76 | of.FormClosed += new FormClosedEventHandler(f_FormClosed); //refresh orders 77 | } 78 | 79 | private void ordersToolStripMenuItem_Click(object sender, EventArgs e) 80 | { 81 | refreshOrders(false); 82 | } 83 | 84 | private void balanceToolStripMenuItem_Click(object sender, EventArgs e) 85 | { 86 | refreshBalance(); 87 | } 88 | 89 | private void refreshBalance() { 90 | if (ac.connected) 91 | { 92 | JObject balance = ac.getBalance(currency); 93 | if (balance != null) 94 | { 95 | this.toolStripStatusLabel2.Text = "Balance: " + balance["available"] + " " + currency; 96 | } 97 | } else { 98 | this.toolStripStatusLabel2.Text = "Balance: N/A " + currency; 99 | } 100 | } 101 | 102 | private void refreshOrders(bool fromThread) 103 | { 104 | if (ac.connected) 105 | { 106 | orders = ac.getOrders(); 107 | 108 | //filter out data 109 | JArray cleanOrders = new JArray(); 110 | foreach (JObject order in orders) 111 | { 112 | JObject cleanOrder = new JObject(); 113 | cleanOrder.Add("id", ""+order["id"]); 114 | cleanOrder.Add("market", "" + order["market"]); 115 | cleanOrder.Add("pool", "" + order["pool"]["name"]); 116 | cleanOrder.Add("type", (""+order["type"]["code"]).Equals("STANDARD") ? "standard" : "fixed"); 117 | cleanOrder.Add("algorithm", "" + order["algorithm"]["algorithm"]); 118 | cleanOrder.Add("amount", "" + order["amount"]); 119 | cleanOrder.Add("payedAmount", "" + order["payedAmount"]); 120 | cleanOrder.Add("availableAmount", "" + order["availableAmount"]); 121 | 122 | float payed = float.Parse("" + order["payedAmount"], CultureInfo.InvariantCulture); 123 | float available = float.Parse("" + order["availableAmount"], CultureInfo.InvariantCulture); 124 | float spent_factor = payed / available * 100; 125 | 126 | cleanOrder.Add("spentPercent", "" + spent_factor.ToString("0.00")+ "%"); 127 | cleanOrder.Add("limit", "" + order["limit"]); 128 | cleanOrder.Add("price", "" + order["price"]); 129 | 130 | cleanOrder.Add("rigsCount", "" + order["rigsCount"]); 131 | cleanOrder.Add("acceptedCurrentSpeed", "" + order["acceptedCurrentSpeed"]); 132 | cleanOrders.Add(cleanOrder); 133 | } 134 | 135 | if (fromThread) 136 | { 137 | dataGridView1.Invoke((MethodInvoker)delegate 138 | { 139 | dataGridView1.DataSource = cleanOrders; 140 | }); 141 | } else 142 | { 143 | dataGridView1.DataSource = cleanOrders; 144 | } 145 | 146 | dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; 147 | dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None; 148 | dataGridView1.AllowUserToOrderColumns = true; 149 | dataGridView1.AllowUserToResizeColumns = true; 150 | } 151 | } 152 | 153 | private void refreshMarket() { 154 | if (ac.connected) 155 | { 156 | market = new JObject(); //flush 157 | //market = ac.getMarket(); 158 | } 159 | } 160 | 161 | private void autoPilotOffToolStripMenuItem_Click(object sender, EventArgs e) 162 | { 163 | toolStripStatusLabel1.Text = "Stopped"; 164 | botRunning = false; 165 | } 166 | 167 | private void autoPilotONToolStripMenuItem_Click(object sender, EventArgs e) 168 | { 169 | toolStripStatusLabel1.Text = "Idle"; 170 | botRunning = true; 171 | runBot(); 172 | } 173 | 174 | private void editSelectedOrderToolStripMenuItem_Click(object sender, EventArgs e) 175 | { 176 | if (dataGridView1.Rows.GetRowCount(DataGridViewElementStates.Selected) == 1) 177 | { 178 | OrderForm of = new OrderForm(ac); 179 | of.FormBorderStyle = FormBorderStyle.FixedSingle; 180 | of.setEditMode((JObject)orders[dataGridView1.SelectedRows[0].Index]); 181 | of.FormClosed += new FormClosedEventHandler(f_FormClosed); //refresh orders 182 | } 183 | } 184 | 185 | private void f_FormClosed(object sender, FormClosedEventArgs e) 186 | { 187 | refreshOrders(false); 188 | } 189 | 190 | private void runBot() { 191 | if (!botRunning) { 192 | return; 193 | } 194 | 195 | //read needed data 196 | String fileName = Path.Combine(Directory.GetCurrentDirectory(), "bot.json"); 197 | if (!File.Exists(fileName)) 198 | { 199 | return; 200 | } 201 | 202 | toolStripStatusLabel1.Text = "Working"; 203 | 204 | BotSettings saved = JsonConvert.DeserializeObject(File.ReadAllText(@fileName)); 205 | Console.ForegroundColor = ConsoleColor.Green; 206 | Console.WriteLine("bot iteration tasks {0} {1} {2}", saved.reffilOrder, saved.lowerPrice, saved.increasePrice); 207 | 208 | Control.CheckForIllegalCrossThreadCalls = false; 209 | refreshOrders(true); 210 | 211 | if (saved.lowerPrice || saved.increasePrice) { 212 | refreshMarket(); 213 | } 214 | 215 | Console.ForegroundColor = ConsoleColor.White; 216 | Console.WriteLine("orders to process: {0}", orders.Count); 217 | 218 | //do refill?? 219 | if (saved.reffilOrder) { 220 | foreach (JObject order in orders) 221 | { 222 | float payed = float.Parse("" + order["payedAmount"], CultureInfo.InvariantCulture); 223 | float available = float.Parse("" + order["availableAmount"], CultureInfo.InvariantCulture); 224 | float spent_factor = payed/available*100; 225 | Console.ForegroundColor = ConsoleColor.Cyan; 226 | Console.WriteLine("?refill?; order {0}, payed {1}, available {2}, percent {3}", order["id"], payed, available, spent_factor.ToString("0.00")); 227 | 228 | if (spent_factor > 90) 229 | { 230 | JObject algo = ac.getAlgo(""+order["algorithm"]["algorithm"]); 231 | Console.ForegroundColor = ConsoleColor.Cyan; 232 | Console.WriteLine("===> refill order for {0}", algo["minimalOrderAmount"]); 233 | ac.refillOrder(""+order["id"], ""+algo["minimalOrderAmount"]); 234 | } 235 | } 236 | } 237 | 238 | //do speed adjust?? 239 | if (saved.lowerPrice || saved.increasePrice) { 240 | foreach (JObject order in orders) { 241 | string order_type = "" + order["type"]["code"]; 242 | if (order_type.Equals("STANDARD")) 243 | { 244 | JObject algo = ac.getAlgo("" + order["algorithm"]["algorithm"]); 245 | float order_speed = float.Parse("" + order["acceptedCurrentSpeed"], CultureInfo.InvariantCulture); 246 | float rigs_count = float.Parse("" + order["rigsCount"], CultureInfo.InvariantCulture); 247 | float order_price = float.Parse("" + order["price"], CultureInfo.InvariantCulture); 248 | float price_step_down = float.Parse("" + algo["priceDownStep"], CultureInfo.InvariantCulture); 249 | 250 | Console.ForegroundColor = ConsoleColor.Green; 251 | Console.WriteLine("?adjust price?; order {0}, speed {1}, rigs {2}, price {3}, step_down {4}", order["id"], order_speed, rigs_count, order_price, price_step_down); 252 | 253 | if (saved.increasePrice && (order_speed == 0 || rigs_count == 0)) { 254 | float new_price = (float)Math.Round(order_price + (price_step_down * -1), 4); 255 | Console.ForegroundColor = ConsoleColor.Yellow; 256 | Console.WriteLine("===> price up order to {0}", new_price); 257 | ac.updateOrder("" + order["algorithm"]["algorithm"], "" + order["id"], new_price.ToString(new CultureInfo("en-US")), "" + order["limit"]); 258 | } else if (saved.lowerPrice && (order_speed > 0 || rigs_count > 0)) { 259 | Dictionary market = getOrderPriceRangesForAlgoAndMarket("" + order["algorithm"]["algorithm"], "" + order["market"]); 260 | var list = market.Keys.ToList(); 261 | list.Sort(); 262 | 263 | int idx = 0; 264 | foreach (var key in list) 265 | { 266 | float curr_tier_price = float.Parse(key, CultureInfo.InvariantCulture); 267 | if (key.Equals(""+order_price)) { 268 | break; 269 | } 270 | idx++; 271 | } 272 | 273 | if (idx > 1) { 274 | float new_price = (float)Math.Round(order_price + price_step_down, 4); 275 | Console.ForegroundColor = ConsoleColor.Yellow; 276 | Console.WriteLine("===> price down order to {0}", new_price); 277 | ac.updateOrder("" + order["algorithm"]["algorithm"], "" + order["id"], new_price.ToString(new CultureInfo("en-US")), "" + order["limit"]); 278 | } 279 | } 280 | } 281 | } 282 | } 283 | toolStripStatusLabel1.Text = "Idle"; 284 | } 285 | 286 | private Dictionary getOrderPriceRangesForAlgoAndMarket(string oa, string om) 287 | { 288 | var prices = new Dictionary(); 289 | 290 | //simple cache 291 | if (market[oa] == null) 292 | { 293 | market[oa] = ac.getMarketForAlgo(oa); 294 | } 295 | 296 | foreach (JObject order in market[oa]) 297 | { 298 | string order_type = "" + order["type"]; 299 | string order_algo = "" + order["algorithm"]; 300 | string order_market = "" + order["market"]; 301 | float order_speed = float.Parse("" + order["acceptedCurrentSpeed"], CultureInfo.InvariantCulture); 302 | string order_price = "" + order["price"]; 303 | 304 | if (order_type.Equals("STANDARD") && order_algo.Equals(oa) && order_market.Equals(om) && order_speed > 0) { 305 | if (prices.ContainsKey(order_price)) 306 | { 307 | prices[order_price] = prices[order_price] + order_speed; 308 | } 309 | else 310 | { 311 | prices[order_price] = order_speed; 312 | } 313 | } 314 | } 315 | return prices; 316 | } 317 | } 318 | } 319 | -------------------------------------------------------------------------------- /NHB3/NHB3.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {544DB7FC-334D-4C5D-A298-61508693EB31} 8 | Exe 9 | NHB3 10 | NHB3 11 | v4.7.2 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | NHB3.Program 37 | 38 | 39 | 40 | ..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll 41 | 42 | 43 | ..\packages\RestSharp.106.10.1\lib\net452\RestSharp.dll 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | Form 61 | 62 | 63 | ApiForm.cs 64 | 65 | 66 | 67 | 68 | Form 69 | 70 | 71 | BotForm.cs 72 | 73 | 74 | Form 75 | 76 | 77 | OrderForm.cs 78 | 79 | 80 | Form 81 | 82 | 83 | PoolForm.cs 84 | 85 | 86 | Form 87 | 88 | 89 | PoolsForm.cs 90 | 91 | 92 | Form 93 | 94 | 95 | Home.cs 96 | 97 | 98 | 99 | 100 | ApiForm.cs 101 | 102 | 103 | BotForm.cs 104 | 105 | 106 | Home.cs 107 | 108 | 109 | OrderForm.cs 110 | 111 | 112 | PoolForm.cs 113 | 114 | 115 | PoolsForm.cs 116 | 117 | 118 | ResXFileCodeGenerator 119 | Resources.Designer.cs 120 | Designer 121 | 122 | 123 | True 124 | Resources.resx 125 | 126 | 127 | 128 | SettingsSingleFileGenerator 129 | Settings.Designer.cs 130 | 131 | 132 | True 133 | Settings.settings 134 | True 135 | 136 | 137 | 138 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /NHB3/OrderForm.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace NHB3 2 | { 3 | partial class OrderForm 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.label2 = new System.Windows.Forms.Label(); 32 | this.comboAlgorithm = new System.Windows.Forms.ComboBox(); 33 | this.rbStd = new System.Windows.Forms.RadioButton(); 34 | this.rbFixed = new System.Windows.Forms.RadioButton(); 35 | this.label3 = new System.Windows.Forms.Label(); 36 | this.comboPools = new System.Windows.Forms.ComboBox(); 37 | this.label4 = new System.Windows.Forms.Label(); 38 | this.tbPrice = new System.Windows.Forms.TextBox(); 39 | this.priceLbl = new System.Windows.Forms.Label(); 40 | this.label6 = new System.Windows.Forms.Label(); 41 | this.tbLimit = new System.Windows.Forms.TextBox(); 42 | this.limitLbl = new System.Windows.Forms.Label(); 43 | this.tbAmount = new System.Windows.Forms.TextBox(); 44 | this.label8 = new System.Windows.Forms.Label(); 45 | this.currencyLbl = new System.Windows.Forms.Label(); 46 | this.priceDetailsLbl = new System.Windows.Forms.Label(); 47 | this.limitDetailsLbl = new System.Windows.Forms.Label(); 48 | this.amountDetailsLbl = new System.Windows.Forms.Label(); 49 | this.btnCreate = new System.Windows.Forms.Button(); 50 | this.rbUSA = new System.Windows.Forms.RadioButton(); 51 | this.rbEU = new System.Windows.Forms.RadioButton(); 52 | this.label14 = new System.Windows.Forms.Label(); 53 | this.tbNewAmount = new System.Windows.Forms.TextBox(); 54 | this.btnRefill = new System.Windows.Forms.Button(); 55 | this.label15 = new System.Windows.Forms.Label(); 56 | this.tbNewPrice = new System.Windows.Forms.TextBox(); 57 | this.tbNewLimit = new System.Windows.Forms.TextBox(); 58 | this.label16 = new System.Windows.Forms.Label(); 59 | this.tabControl1 = new System.Windows.Forms.TabControl(); 60 | this.tabPage1 = new System.Windows.Forms.TabPage(); 61 | this.tbId = new System.Windows.Forms.TextBox(); 62 | this.amountDetailsLbl2 = new System.Windows.Forms.Label(); 63 | this.tbAvailableAmount = new System.Windows.Forms.TextBox(); 64 | this.label1 = new System.Windows.Forms.Label(); 65 | this.tabPage2 = new System.Windows.Forms.TabPage(); 66 | this.limitDetailsLbl2 = new System.Windows.Forms.Label(); 67 | this.priceDetailsLbl2 = new System.Windows.Forms.Label(); 68 | this.btnCancel = new System.Windows.Forms.Button(); 69 | this.btnUpdate = new System.Windows.Forms.Button(); 70 | this.groupBox1 = new System.Windows.Forms.GroupBox(); 71 | this.lblCreate = new System.Windows.Forms.Label(); 72 | this.lblPool = new System.Windows.Forms.Label(); 73 | this.groupBox2 = new System.Windows.Forms.GroupBox(); 74 | this.lblErrorCreate = new System.Windows.Forms.Label(); 75 | this.rbEUN = new System.Windows.Forms.RadioButton(); 76 | this.rbUSAE = new System.Windows.Forms.RadioButton(); 77 | this.rbSA = new System.Windows.Forms.RadioButton(); 78 | this.rbASIA = new System.Windows.Forms.RadioButton(); 79 | this.tabControl1.SuspendLayout(); 80 | this.tabPage1.SuspendLayout(); 81 | this.tabPage2.SuspendLayout(); 82 | this.groupBox1.SuspendLayout(); 83 | this.groupBox2.SuspendLayout(); 84 | this.SuspendLayout(); 85 | // 86 | // label2 87 | // 88 | this.label2.AutoSize = true; 89 | this.label2.Location = new System.Drawing.Point(8, 8); 90 | this.label2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); 91 | this.label2.Name = "label2"; 92 | this.label2.Size = new System.Drawing.Size(50, 13); 93 | this.label2.TabIndex = 3; 94 | this.label2.Text = "Algorithm"; 95 | // 96 | // comboAlgorithm 97 | // 98 | this.comboAlgorithm.FormattingEnabled = true; 99 | this.comboAlgorithm.Location = new System.Drawing.Point(67, 6); 100 | this.comboAlgorithm.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); 101 | this.comboAlgorithm.Name = "comboAlgorithm"; 102 | this.comboAlgorithm.Size = new System.Drawing.Size(341, 21); 103 | this.comboAlgorithm.TabIndex = 4; 104 | this.comboAlgorithm.SelectedIndexChanged += new System.EventHandler(this.comboAlgorithm_SelectedIndexChanged); 105 | // 106 | // rbStd 107 | // 108 | this.rbStd.AutoSize = true; 109 | this.rbStd.Checked = true; 110 | this.rbStd.Location = new System.Drawing.Point(57, 9); 111 | this.rbStd.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); 112 | this.rbStd.Name = "rbStd"; 113 | this.rbStd.Size = new System.Drawing.Size(66, 17); 114 | this.rbStd.TabIndex = 5; 115 | this.rbStd.TabStop = true; 116 | this.rbStd.Text = "standard"; 117 | this.rbStd.UseVisualStyleBackColor = true; 118 | this.rbStd.CheckedChanged += new System.EventHandler(this.formChanged); 119 | // 120 | // rbFixed 121 | // 122 | this.rbFixed.AutoSize = true; 123 | this.rbFixed.Location = new System.Drawing.Point(125, 9); 124 | this.rbFixed.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); 125 | this.rbFixed.Name = "rbFixed"; 126 | this.rbFixed.Size = new System.Drawing.Size(47, 17); 127 | this.rbFixed.TabIndex = 6; 128 | this.rbFixed.Text = "fixed"; 129 | this.rbFixed.UseVisualStyleBackColor = true; 130 | this.rbFixed.Visible = false; 131 | this.rbFixed.CheckedChanged += new System.EventHandler(this.formChanged); 132 | // 133 | // label3 134 | // 135 | this.label3.AutoSize = true; 136 | this.label3.Location = new System.Drawing.Point(8, 93); 137 | this.label3.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); 138 | this.label3.Name = "label3"; 139 | this.label3.Size = new System.Drawing.Size(28, 13); 140 | this.label3.TabIndex = 7; 141 | this.label3.Text = "Pool"; 142 | // 143 | // comboPools 144 | // 145 | this.comboPools.FormattingEnabled = true; 146 | this.comboPools.Location = new System.Drawing.Point(67, 91); 147 | this.comboPools.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); 148 | this.comboPools.Name = "comboPools"; 149 | this.comboPools.Size = new System.Drawing.Size(341, 21); 150 | this.comboPools.TabIndex = 8; 151 | this.comboPools.SelectedIndexChanged += new System.EventHandler(this.formChanged); 152 | // 153 | // label4 154 | // 155 | this.label4.AutoSize = true; 156 | this.label4.Location = new System.Drawing.Point(8, 116); 157 | this.label4.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); 158 | this.label4.Name = "label4"; 159 | this.label4.Size = new System.Drawing.Size(31, 13); 160 | this.label4.TabIndex = 9; 161 | this.label4.Text = "Price"; 162 | // 163 | // tbPrice 164 | // 165 | this.tbPrice.Location = new System.Drawing.Point(67, 114); 166 | this.tbPrice.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); 167 | this.tbPrice.Name = "tbPrice"; 168 | this.tbPrice.Size = new System.Drawing.Size(207, 20); 169 | this.tbPrice.TabIndex = 10; 170 | // 171 | // priceLbl 172 | // 173 | this.priceLbl.AutoSize = true; 174 | this.priceLbl.Location = new System.Drawing.Point(277, 116); 175 | this.priceLbl.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); 176 | this.priceLbl.Name = "priceLbl"; 177 | this.priceLbl.Size = new System.Drawing.Size(104, 13); 178 | this.priceLbl.TabIndex = 11; 179 | this.priceLbl.Text = "currency/speed/day"; 180 | // 181 | // label6 182 | // 183 | this.label6.AutoSize = true; 184 | this.label6.Location = new System.Drawing.Point(8, 151); 185 | this.label6.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); 186 | this.label6.Name = "label6"; 187 | this.label6.Size = new System.Drawing.Size(28, 13); 188 | this.label6.TabIndex = 12; 189 | this.label6.Text = "Limit"; 190 | // 191 | // tbLimit 192 | // 193 | this.tbLimit.Location = new System.Drawing.Point(67, 151); 194 | this.tbLimit.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); 195 | this.tbLimit.Name = "tbLimit"; 196 | this.tbLimit.Size = new System.Drawing.Size(207, 20); 197 | this.tbLimit.TabIndex = 13; 198 | this.tbLimit.TextChanged += new System.EventHandler(this.formChanged); 199 | // 200 | // limitLbl 201 | // 202 | this.limitLbl.AutoSize = true; 203 | this.limitLbl.Location = new System.Drawing.Point(277, 151); 204 | this.limitLbl.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); 205 | this.limitLbl.Name = "limitLbl"; 206 | this.limitLbl.Size = new System.Drawing.Size(76, 13); 207 | this.limitLbl.TabIndex = 14; 208 | this.limitLbl.Text = "speed/second"; 209 | // 210 | // tbAmount 211 | // 212 | this.tbAmount.Location = new System.Drawing.Point(67, 188); 213 | this.tbAmount.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); 214 | this.tbAmount.Name = "tbAmount"; 215 | this.tbAmount.Size = new System.Drawing.Size(207, 20); 216 | this.tbAmount.TabIndex = 15; 217 | // 218 | // label8 219 | // 220 | this.label8.AutoSize = true; 221 | this.label8.Location = new System.Drawing.Point(8, 187); 222 | this.label8.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); 223 | this.label8.Name = "label8"; 224 | this.label8.Size = new System.Drawing.Size(43, 13); 225 | this.label8.TabIndex = 16; 226 | this.label8.Text = "Amount"; 227 | // 228 | // currencyLbl 229 | // 230 | this.currencyLbl.AutoSize = true; 231 | this.currencyLbl.Location = new System.Drawing.Point(277, 187); 232 | this.currencyLbl.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); 233 | this.currencyLbl.Name = "currencyLbl"; 234 | this.currencyLbl.Size = new System.Drawing.Size(48, 13); 235 | this.currencyLbl.TabIndex = 17; 236 | this.currencyLbl.Text = "currency"; 237 | // 238 | // priceDetailsLbl 239 | // 240 | this.priceDetailsLbl.AutoSize = true; 241 | this.priceDetailsLbl.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 242 | this.priceDetailsLbl.ForeColor = System.Drawing.SystemColors.ControlDarkDark; 243 | this.priceDetailsLbl.Location = new System.Drawing.Point(66, 134); 244 | this.priceDetailsLbl.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); 245 | this.priceDetailsLbl.Name = "priceDetailsLbl"; 246 | this.priceDetailsLbl.Size = new System.Drawing.Size(35, 13); 247 | this.priceDetailsLbl.TabIndex = 18; 248 | this.priceDetailsLbl.Text = "[price]"; 249 | // 250 | // limitDetailsLbl 251 | // 252 | this.limitDetailsLbl.AutoSize = true; 253 | this.limitDetailsLbl.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 254 | this.limitDetailsLbl.ForeColor = System.Drawing.SystemColors.ControlDarkDark; 255 | this.limitDetailsLbl.Location = new System.Drawing.Point(66, 171); 256 | this.limitDetailsLbl.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); 257 | this.limitDetailsLbl.Name = "limitDetailsLbl"; 258 | this.limitDetailsLbl.Size = new System.Drawing.Size(42, 13); 259 | this.limitDetailsLbl.TabIndex = 19; 260 | this.limitDetailsLbl.Text = "[speed]"; 261 | // 262 | // amountDetailsLbl 263 | // 264 | this.amountDetailsLbl.AutoSize = true; 265 | this.amountDetailsLbl.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 266 | this.amountDetailsLbl.ForeColor = System.Drawing.SystemColors.ControlDarkDark; 267 | this.amountDetailsLbl.Location = new System.Drawing.Point(66, 208); 268 | this.amountDetailsLbl.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); 269 | this.amountDetailsLbl.Name = "amountDetailsLbl"; 270 | this.amountDetailsLbl.Size = new System.Drawing.Size(48, 13); 271 | this.amountDetailsLbl.TabIndex = 20; 272 | this.amountDetailsLbl.Text = "[amount]"; 273 | // 274 | // btnCreate 275 | // 276 | this.btnCreate.Location = new System.Drawing.Point(8, 226); 277 | this.btnCreate.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); 278 | this.btnCreate.Name = "btnCreate"; 279 | this.btnCreate.Size = new System.Drawing.Size(93, 21); 280 | this.btnCreate.TabIndex = 21; 281 | this.btnCreate.Text = "Create"; 282 | this.btnCreate.UseVisualStyleBackColor = true; 283 | this.btnCreate.Click += new System.EventHandler(this.btnCreate_Click); 284 | // 285 | // rbUSA 286 | // 287 | this.rbUSA.AutoSize = true; 288 | this.rbUSA.Enabled = false; 289 | this.rbUSA.Location = new System.Drawing.Point(170, 9); 290 | this.rbUSA.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); 291 | this.rbUSA.Name = "rbUSA"; 292 | this.rbUSA.Size = new System.Drawing.Size(61, 17); 293 | this.rbUSA.TabIndex = 23; 294 | this.rbUSA.Text = "USA-W"; 295 | this.rbUSA.UseVisualStyleBackColor = true; 296 | this.rbUSA.CheckedChanged += new System.EventHandler(this.formChanged); 297 | // 298 | // rbEU 299 | // 300 | this.rbEU.AutoSize = true; 301 | this.rbEU.Checked = true; 302 | this.rbEU.Enabled = false; 303 | this.rbEU.Location = new System.Drawing.Point(57, 9); 304 | this.rbEU.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); 305 | this.rbEU.Name = "rbEU"; 306 | this.rbEU.Size = new System.Drawing.Size(54, 17); 307 | this.rbEU.TabIndex = 22; 308 | this.rbEU.Text = "EU-W"; 309 | this.rbEU.UseVisualStyleBackColor = true; 310 | this.rbEU.CheckedChanged += new System.EventHandler(this.formChanged); 311 | // 312 | // label14 313 | // 314 | this.label14.AutoSize = true; 315 | this.label14.Location = new System.Drawing.Point(4, 6); 316 | this.label14.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); 317 | this.label14.Name = "label14"; 318 | this.label14.Size = new System.Drawing.Size(68, 13); 319 | this.label14.TabIndex = 26; 320 | this.label14.Text = "Refill amount"; 321 | // 322 | // tbNewAmount 323 | // 324 | this.tbNewAmount.Location = new System.Drawing.Point(95, 4); 325 | this.tbNewAmount.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); 326 | this.tbNewAmount.Name = "tbNewAmount"; 327 | this.tbNewAmount.Size = new System.Drawing.Size(169, 20); 328 | this.tbNewAmount.TabIndex = 26; 329 | // 330 | // btnRefill 331 | // 332 | this.btnRefill.Location = new System.Drawing.Point(7, 47); 333 | this.btnRefill.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); 334 | this.btnRefill.Name = "btnRefill"; 335 | this.btnRefill.Size = new System.Drawing.Size(93, 21); 336 | this.btnRefill.TabIndex = 26; 337 | this.btnRefill.Text = "Refill"; 338 | this.btnRefill.UseVisualStyleBackColor = true; 339 | this.btnRefill.Click += new System.EventHandler(this.btnRefill_Click); 340 | // 341 | // label15 342 | // 343 | this.label15.AutoSize = true; 344 | this.label15.Location = new System.Drawing.Point(4, 6); 345 | this.label15.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); 346 | this.label15.Name = "label15"; 347 | this.label15.Size = new System.Drawing.Size(55, 13); 348 | this.label15.TabIndex = 27; 349 | this.label15.Text = "New price"; 350 | // 351 | // tbNewPrice 352 | // 353 | this.tbNewPrice.Location = new System.Drawing.Point(95, 4); 354 | this.tbNewPrice.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); 355 | this.tbNewPrice.Name = "tbNewPrice"; 356 | this.tbNewPrice.Size = new System.Drawing.Size(169, 20); 357 | this.tbNewPrice.TabIndex = 28; 358 | // 359 | // tbNewLimit 360 | // 361 | this.tbNewLimit.Location = new System.Drawing.Point(95, 25); 362 | this.tbNewLimit.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); 363 | this.tbNewLimit.Name = "tbNewLimit"; 364 | this.tbNewLimit.Size = new System.Drawing.Size(169, 20); 365 | this.tbNewLimit.TabIndex = 29; 366 | // 367 | // label16 368 | // 369 | this.label16.AutoSize = true; 370 | this.label16.Location = new System.Drawing.Point(4, 27); 371 | this.label16.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); 372 | this.label16.Name = "label16"; 373 | this.label16.Size = new System.Drawing.Size(49, 13); 374 | this.label16.TabIndex = 30; 375 | this.label16.Text = "New limit"; 376 | // 377 | // tabControl1 378 | // 379 | this.tabControl1.Controls.Add(this.tabPage1); 380 | this.tabControl1.Controls.Add(this.tabPage2); 381 | this.tabControl1.Enabled = false; 382 | this.tabControl1.Location = new System.Drawing.Point(8, 255); 383 | this.tabControl1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); 384 | this.tabControl1.Name = "tabControl1"; 385 | this.tabControl1.SelectedIndex = 0; 386 | this.tabControl1.Size = new System.Drawing.Size(407, 96); 387 | this.tabControl1.TabIndex = 26; 388 | // 389 | // tabPage1 390 | // 391 | this.tabPage1.Controls.Add(this.tbId); 392 | this.tabPage1.Controls.Add(this.amountDetailsLbl2); 393 | this.tabPage1.Controls.Add(this.tbAvailableAmount); 394 | this.tabPage1.Controls.Add(this.label1); 395 | this.tabPage1.Controls.Add(this.label14); 396 | this.tabPage1.Controls.Add(this.tbNewAmount); 397 | this.tabPage1.Controls.Add(this.btnRefill); 398 | this.tabPage1.Location = new System.Drawing.Point(4, 22); 399 | this.tabPage1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); 400 | this.tabPage1.Name = "tabPage1"; 401 | this.tabPage1.Padding = new System.Windows.Forms.Padding(2, 2, 2, 2); 402 | this.tabPage1.Size = new System.Drawing.Size(399, 70); 403 | this.tabPage1.TabIndex = 0; 404 | this.tabPage1.Text = "Refill order"; 405 | this.tabPage1.UseVisualStyleBackColor = true; 406 | // 407 | // tbId 408 | // 409 | this.tbId.Location = new System.Drawing.Point(104, 49); 410 | this.tbId.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); 411 | this.tbId.Name = "tbId"; 412 | this.tbId.Size = new System.Drawing.Size(159, 20); 413 | this.tbId.TabIndex = 32; 414 | this.tbId.Visible = false; 415 | // 416 | // amountDetailsLbl2 417 | // 418 | this.amountDetailsLbl2.AutoSize = true; 419 | this.amountDetailsLbl2.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 420 | this.amountDetailsLbl2.ForeColor = System.Drawing.SystemColors.ControlDarkDark; 421 | this.amountDetailsLbl2.Location = new System.Drawing.Point(266, 7); 422 | this.amountDetailsLbl2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); 423 | this.amountDetailsLbl2.Name = "amountDetailsLbl2"; 424 | this.amountDetailsLbl2.Size = new System.Drawing.Size(48, 13); 425 | this.amountDetailsLbl2.TabIndex = 31; 426 | this.amountDetailsLbl2.Text = "[amount]"; 427 | // 428 | // tbAvailableAmount 429 | // 430 | this.tbAvailableAmount.Enabled = false; 431 | this.tbAvailableAmount.Location = new System.Drawing.Point(95, 25); 432 | this.tbAvailableAmount.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); 433 | this.tbAvailableAmount.Name = "tbAvailableAmount"; 434 | this.tbAvailableAmount.Size = new System.Drawing.Size(169, 20); 435 | this.tbAvailableAmount.TabIndex = 28; 436 | // 437 | // label1 438 | // 439 | this.label1.AutoSize = true; 440 | this.label1.Location = new System.Drawing.Point(4, 27); 441 | this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); 442 | this.label1.Name = "label1"; 443 | this.label1.Size = new System.Drawing.Size(88, 13); 444 | this.label1.TabIndex = 27; 445 | this.label1.Text = "Available amount"; 446 | // 447 | // tabPage2 448 | // 449 | this.tabPage2.Controls.Add(this.limitDetailsLbl2); 450 | this.tabPage2.Controls.Add(this.priceDetailsLbl2); 451 | this.tabPage2.Controls.Add(this.btnCancel); 452 | this.tabPage2.Controls.Add(this.btnUpdate); 453 | this.tabPage2.Controls.Add(this.label15); 454 | this.tabPage2.Controls.Add(this.label16); 455 | this.tabPage2.Controls.Add(this.tbNewPrice); 456 | this.tabPage2.Controls.Add(this.tbNewLimit); 457 | this.tabPage2.Location = new System.Drawing.Point(4, 22); 458 | this.tabPage2.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); 459 | this.tabPage2.Name = "tabPage2"; 460 | this.tabPage2.Padding = new System.Windows.Forms.Padding(2, 2, 2, 2); 461 | this.tabPage2.Size = new System.Drawing.Size(399, 70); 462 | this.tabPage2.TabIndex = 1; 463 | this.tabPage2.Text = "Edit order"; 464 | this.tabPage2.UseVisualStyleBackColor = true; 465 | // 466 | // limitDetailsLbl2 467 | // 468 | this.limitDetailsLbl2.AutoSize = true; 469 | this.limitDetailsLbl2.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 470 | this.limitDetailsLbl2.ForeColor = System.Drawing.SystemColors.ControlDarkDark; 471 | this.limitDetailsLbl2.Location = new System.Drawing.Point(266, 28); 472 | this.limitDetailsLbl2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); 473 | this.limitDetailsLbl2.Name = "limitDetailsLbl2"; 474 | this.limitDetailsLbl2.Size = new System.Drawing.Size(42, 13); 475 | this.limitDetailsLbl2.TabIndex = 31; 476 | this.limitDetailsLbl2.Text = "[speed]"; 477 | // 478 | // priceDetailsLbl2 479 | // 480 | this.priceDetailsLbl2.AutoSize = true; 481 | this.priceDetailsLbl2.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 482 | this.priceDetailsLbl2.ForeColor = System.Drawing.SystemColors.ControlDarkDark; 483 | this.priceDetailsLbl2.Location = new System.Drawing.Point(266, 7); 484 | this.priceDetailsLbl2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); 485 | this.priceDetailsLbl2.Name = "priceDetailsLbl2"; 486 | this.priceDetailsLbl2.Size = new System.Drawing.Size(35, 13); 487 | this.priceDetailsLbl2.TabIndex = 31; 488 | this.priceDetailsLbl2.Text = "[price]"; 489 | // 490 | // btnCancel 491 | // 492 | this.btnCancel.ForeColor = System.Drawing.Color.DarkRed; 493 | this.btnCancel.Location = new System.Drawing.Point(303, 47); 494 | this.btnCancel.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); 495 | this.btnCancel.Name = "btnCancel"; 496 | this.btnCancel.Size = new System.Drawing.Size(93, 21); 497 | this.btnCancel.TabIndex = 32; 498 | this.btnCancel.Text = "Cancel Order"; 499 | this.btnCancel.UseVisualStyleBackColor = true; 500 | this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); 501 | // 502 | // btnUpdate 503 | // 504 | this.btnUpdate.Location = new System.Drawing.Point(7, 47); 505 | this.btnUpdate.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); 506 | this.btnUpdate.Name = "btnUpdate"; 507 | this.btnUpdate.Size = new System.Drawing.Size(93, 21); 508 | this.btnUpdate.TabIndex = 31; 509 | this.btnUpdate.Text = "Update"; 510 | this.btnUpdate.UseVisualStyleBackColor = true; 511 | this.btnUpdate.Click += new System.EventHandler(this.btnUpdate_Click); 512 | // 513 | // groupBox1 514 | // 515 | this.groupBox1.Controls.Add(this.rbASIA); 516 | this.groupBox1.Controls.Add(this.rbSA); 517 | this.groupBox1.Controls.Add(this.rbUSAE); 518 | this.groupBox1.Controls.Add(this.rbEUN); 519 | this.groupBox1.Controls.Add(this.rbEU); 520 | this.groupBox1.Controls.Add(this.rbUSA); 521 | this.groupBox1.Location = new System.Drawing.Point(11, 28); 522 | this.groupBox1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); 523 | this.groupBox1.Name = "groupBox1"; 524 | this.groupBox1.Padding = new System.Windows.Forms.Padding(2, 2, 2, 2); 525 | this.groupBox1.Size = new System.Drawing.Size(396, 29); 526 | this.groupBox1.TabIndex = 27; 527 | this.groupBox1.TabStop = false; 528 | this.groupBox1.Text = "Market"; 529 | // 530 | // lblCreate 531 | // 532 | this.lblCreate.AutoSize = true; 533 | this.lblCreate.ForeColor = System.Drawing.Color.DarkRed; 534 | this.lblCreate.Location = new System.Drawing.Point(105, 229); 535 | this.lblCreate.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); 536 | this.lblCreate.Name = "lblCreate"; 537 | this.lblCreate.Size = new System.Drawing.Size(120, 13); 538 | this.lblCreate.TabIndex = 28; 539 | this.lblCreate.Text = "Fixed order params error"; 540 | this.lblCreate.Visible = false; 541 | // 542 | // lblPool 543 | // 544 | this.lblPool.AutoSize = true; 545 | this.lblPool.ForeColor = System.Drawing.Color.DarkRed; 546 | this.lblPool.Location = new System.Drawing.Point(105, 229); 547 | this.lblPool.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); 548 | this.lblPool.Name = "lblPool"; 549 | this.lblPool.Size = new System.Drawing.Size(87, 13); 550 | this.lblPool.TabIndex = 29; 551 | this.lblPool.Text = "No selected pool"; 552 | this.lblPool.Visible = false; 553 | // 554 | // groupBox2 555 | // 556 | this.groupBox2.Controls.Add(this.rbFixed); 557 | this.groupBox2.Controls.Add(this.rbStd); 558 | this.groupBox2.Location = new System.Drawing.Point(11, 58); 559 | this.groupBox2.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); 560 | this.groupBox2.Name = "groupBox2"; 561 | this.groupBox2.Padding = new System.Windows.Forms.Padding(2, 2, 2, 2); 562 | this.groupBox2.Size = new System.Drawing.Size(396, 29); 563 | this.groupBox2.TabIndex = 28; 564 | this.groupBox2.TabStop = false; 565 | this.groupBox2.Text = "Type"; 566 | // 567 | // lblErrorCreate 568 | // 569 | this.lblErrorCreate.AutoSize = true; 570 | this.lblErrorCreate.ForeColor = System.Drawing.Color.DarkRed; 571 | this.lblErrorCreate.Location = new System.Drawing.Point(309, 229); 572 | this.lblErrorCreate.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); 573 | this.lblErrorCreate.Name = "lblErrorCreate"; 574 | this.lblErrorCreate.Size = new System.Drawing.Size(97, 13); 575 | this.lblErrorCreate.TabIndex = 30; 576 | this.lblErrorCreate.Text = "Error creating order"; 577 | this.lblErrorCreate.Visible = false; 578 | // 579 | // rbEUN 580 | // 581 | this.rbEUN.AutoSize = true; 582 | this.rbEUN.Enabled = false; 583 | this.rbEUN.Location = new System.Drawing.Point(115, 9); 584 | this.rbEUN.Margin = new System.Windows.Forms.Padding(2); 585 | this.rbEUN.Name = "rbEUN"; 586 | this.rbEUN.Size = new System.Drawing.Size(51, 17); 587 | this.rbEUN.TabIndex = 24; 588 | this.rbEUN.Text = "EU-N"; 589 | this.rbEUN.UseVisualStyleBackColor = true; 590 | // 591 | // rbUSAE 592 | // 593 | this.rbUSAE.AutoSize = true; 594 | this.rbUSAE.Enabled = false; 595 | this.rbUSAE.Location = new System.Drawing.Point(235, 8); 596 | this.rbUSAE.Margin = new System.Windows.Forms.Padding(2); 597 | this.rbUSAE.Name = "rbUSAE"; 598 | this.rbUSAE.Size = new System.Drawing.Size(57, 17); 599 | this.rbUSAE.TabIndex = 25; 600 | this.rbUSAE.Text = "USA-E"; 601 | this.rbUSAE.UseVisualStyleBackColor = true; 602 | // 603 | // rbSA 604 | // 605 | this.rbSA.AutoSize = true; 606 | this.rbSA.Enabled = false; 607 | this.rbSA.Location = new System.Drawing.Point(296, 8); 608 | this.rbSA.Margin = new System.Windows.Forms.Padding(2); 609 | this.rbSA.Name = "rbSA"; 610 | this.rbSA.Size = new System.Drawing.Size(39, 17); 611 | this.rbSA.TabIndex = 26; 612 | this.rbSA.Text = "SA"; 613 | this.rbSA.UseVisualStyleBackColor = true; 614 | // 615 | // rbASIA 616 | // 617 | this.rbASIA.AutoSize = true; 618 | this.rbASIA.Enabled = false; 619 | this.rbASIA.Location = new System.Drawing.Point(339, 8); 620 | this.rbASIA.Margin = new System.Windows.Forms.Padding(2); 621 | this.rbASIA.Name = "rbASIA"; 622 | this.rbASIA.Size = new System.Drawing.Size(49, 17); 623 | this.rbASIA.TabIndex = 27; 624 | this.rbASIA.Text = "ASIA"; 625 | this.rbASIA.UseVisualStyleBackColor = true; 626 | // 627 | // OrderForm 628 | // 629 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 630 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 631 | this.ClientSize = new System.Drawing.Size(419, 353); 632 | this.Controls.Add(this.lblErrorCreate); 633 | this.Controls.Add(this.groupBox2); 634 | this.Controls.Add(this.lblPool); 635 | this.Controls.Add(this.lblCreate); 636 | this.Controls.Add(this.groupBox1); 637 | this.Controls.Add(this.tabControl1); 638 | this.Controls.Add(this.btnCreate); 639 | this.Controls.Add(this.amountDetailsLbl); 640 | this.Controls.Add(this.limitDetailsLbl); 641 | this.Controls.Add(this.priceDetailsLbl); 642 | this.Controls.Add(this.currencyLbl); 643 | this.Controls.Add(this.label8); 644 | this.Controls.Add(this.tbAmount); 645 | this.Controls.Add(this.limitLbl); 646 | this.Controls.Add(this.tbLimit); 647 | this.Controls.Add(this.label6); 648 | this.Controls.Add(this.priceLbl); 649 | this.Controls.Add(this.tbPrice); 650 | this.Controls.Add(this.label4); 651 | this.Controls.Add(this.comboPools); 652 | this.Controls.Add(this.label3); 653 | this.Controls.Add(this.comboAlgorithm); 654 | this.Controls.Add(this.label2); 655 | this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); 656 | this.Name = "OrderForm"; 657 | this.Text = "Order"; 658 | this.tabControl1.ResumeLayout(false); 659 | this.tabPage1.ResumeLayout(false); 660 | this.tabPage1.PerformLayout(); 661 | this.tabPage2.ResumeLayout(false); 662 | this.tabPage2.PerformLayout(); 663 | this.groupBox1.ResumeLayout(false); 664 | this.groupBox1.PerformLayout(); 665 | this.groupBox2.ResumeLayout(false); 666 | this.groupBox2.PerformLayout(); 667 | this.ResumeLayout(false); 668 | this.PerformLayout(); 669 | 670 | } 671 | 672 | #endregion 673 | private System.Windows.Forms.Label label2; 674 | private System.Windows.Forms.ComboBox comboAlgorithm; 675 | private System.Windows.Forms.RadioButton rbStd; 676 | private System.Windows.Forms.RadioButton rbFixed; 677 | private System.Windows.Forms.Label label3; 678 | private System.Windows.Forms.ComboBox comboPools; 679 | private System.Windows.Forms.Label label4; 680 | private System.Windows.Forms.TextBox tbPrice; 681 | private System.Windows.Forms.Label priceLbl; 682 | private System.Windows.Forms.Label label6; 683 | private System.Windows.Forms.TextBox tbLimit; 684 | private System.Windows.Forms.Label limitLbl; 685 | private System.Windows.Forms.TextBox tbAmount; 686 | private System.Windows.Forms.Label label8; 687 | private System.Windows.Forms.Label currencyLbl; 688 | private System.Windows.Forms.Label priceDetailsLbl; 689 | private System.Windows.Forms.Label limitDetailsLbl; 690 | private System.Windows.Forms.Label amountDetailsLbl; 691 | private System.Windows.Forms.Button btnCreate; 692 | private System.Windows.Forms.RadioButton rbUSA; 693 | private System.Windows.Forms.RadioButton rbEU; 694 | private System.Windows.Forms.Label label14; 695 | private System.Windows.Forms.TextBox tbNewAmount; 696 | private System.Windows.Forms.Button btnRefill; 697 | private System.Windows.Forms.Label label15; 698 | private System.Windows.Forms.TextBox tbNewPrice; 699 | private System.Windows.Forms.TextBox tbNewLimit; 700 | private System.Windows.Forms.Label label16; 701 | private System.Windows.Forms.TabControl tabControl1; 702 | private System.Windows.Forms.TabPage tabPage1; 703 | private System.Windows.Forms.TabPage tabPage2; 704 | private System.Windows.Forms.Button btnUpdate; 705 | private System.Windows.Forms.Button btnCancel; 706 | private System.Windows.Forms.GroupBox groupBox1; 707 | private System.Windows.Forms.Label lblCreate; 708 | private System.Windows.Forms.Label lblPool; 709 | private System.Windows.Forms.GroupBox groupBox2; 710 | private System.Windows.Forms.Label lblErrorCreate; 711 | private System.Windows.Forms.TextBox tbAvailableAmount; 712 | private System.Windows.Forms.Label label1; 713 | private System.Windows.Forms.Label amountDetailsLbl2; 714 | private System.Windows.Forms.Label limitDetailsLbl2; 715 | private System.Windows.Forms.Label priceDetailsLbl2; 716 | private System.Windows.Forms.TextBox tbId; 717 | private System.Windows.Forms.RadioButton rbUSAE; 718 | private System.Windows.Forms.RadioButton rbEUN; 719 | private System.Windows.Forms.RadioButton rbASIA; 720 | private System.Windows.Forms.RadioButton rbSA; 721 | } 722 | } -------------------------------------------------------------------------------- /NHB3/OrderForm.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Linq; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.ComponentModel; 6 | using System.Data; 7 | using System.Drawing; 8 | using System.Globalization; 9 | using System.IO; 10 | using System.Linq; 11 | using System.Text; 12 | using System.Threading.Tasks; 13 | using System.Windows.Forms; 14 | 15 | namespace NHB3 16 | { 17 | public partial class OrderForm : Form 18 | { 19 | ApiConnect ac; 20 | JObject algo; 21 | JObject buy; 22 | 23 | string lastFixedAlgo = ""; 24 | string lastFixedMarket = ""; 25 | string lastFixedLimit = ""; 26 | bool edit = false; 27 | 28 | public OrderForm(ApiConnect ac) 29 | { 30 | InitializeComponent(); 31 | this.Show(); 32 | this.ac = ac; 33 | 34 | this.currencyLbl.Text = ac.currency; 35 | 36 | //pools dropdown 37 | this.comboPools.DisplayMember = "name"; 38 | this.comboPools.ValueMember = "id"; 39 | 40 | foreach (JObject obj in ac.algorithms) 41 | { 42 | this.comboAlgorithm.Items.Add(obj["algorithm"]); 43 | } 44 | this.comboAlgorithm.SelectedIndex = 0; 45 | } 46 | 47 | private void comboAlgorithm_SelectedIndexChanged(object sender, EventArgs e) 48 | { 49 | //get algo settings 50 | foreach (JObject obj in ac.algorithms) 51 | { 52 | if (this.comboAlgorithm.SelectedItem.Equals(obj["algorithm"])) 53 | { 54 | this.algo = obj; 55 | break; 56 | } 57 | } 58 | 59 | //get algo settings 60 | foreach (JObject obj in ac.buy) 61 | { 62 | if (this.algo["order"].Equals(obj["algo"])) 63 | { 64 | this.buy = obj; 65 | break; 66 | } 67 | } 68 | 69 | JArray markets = JArray.Parse(this.buy["enabledHashpowerMarkets"].ToString()); 70 | this.rbEU.Enabled = false; 71 | this.rbEUN.Enabled = false; 72 | this.rbUSA.Enabled = false; 73 | this.rbUSAE.Enabled = false; 74 | this.rbSA.Enabled = false; 75 | this.rbASIA.Enabled = false; 76 | 77 | foreach (String market in markets) { 78 | if (market.Equals("EU")) { 79 | this.rbEU.Enabled = true; 80 | } 81 | else if (market.Equals("EU_N")) 82 | { 83 | this.rbEUN.Enabled = true; 84 | } 85 | else if (market.Equals("USA")) 86 | { 87 | this.rbUSA.Enabled = true; 88 | } 89 | else if (market.Equals("USA_E")) 90 | { 91 | this.rbUSAE.Enabled = true; 92 | } 93 | else if (market.Equals("SA")) 94 | { 95 | this.rbSA.Enabled = true; 96 | } 97 | else if (market.Equals("ASIA")) 98 | { 99 | this.rbASIA.Enabled = true; 100 | } 101 | } 102 | 103 | //set lbls 104 | this.priceLbl.Text = ac.currency + "/" + this.algo["displayMarketFactor"] + "/day"; 105 | this.limitLbl.Text = this.algo["displayMarketFactor"] + "/second"; 106 | this.priceDetailsLbl.Text = "> 0"; 107 | this.limitDetailsLbl.Text = "> " + this.algo["minSpeedLimit"] + " AND < " + this.algo["maxSpeedLimit"] + " OR 0 // no speed limit"; 108 | this.amountDetailsLbl.Text = "> " + this.algo["minimalOrderAmount"]; 109 | 110 | this.tbLimit.Text = "" + this.algo["minSpeedLimit"]; 111 | this.tbAmount.Text = "" + this.algo["minimalOrderAmount"]; 112 | 113 | //filter pools 114 | this.comboPools.Items.Clear(); 115 | this.comboPools.ResetText(); 116 | this.comboPools.SelectedIndex = -1; 117 | 118 | foreach (JObject pool in ac.getPools(false)) 119 | { 120 | if (this.comboAlgorithm.SelectedItem.Equals(pool["algorithm"])) 121 | { 122 | this.comboPools.Items.Add(pool); 123 | } 124 | } 125 | 126 | if (!edit) 127 | { 128 | formDataUpdate(); 129 | } 130 | } 131 | 132 | private void formChanged(object sender, EventArgs e) 133 | { 134 | if (!edit) 135 | { 136 | formDataUpdate(); 137 | } 138 | } 139 | 140 | private void formDataUpdate() 141 | { 142 | this.tbPrice.Enabled = true; 143 | this.btnCreate.Enabled = true; 144 | this.lblPool.Visible = false; 145 | this.lblCreate.Visible = false; 146 | this.lblErrorCreate.Visible = false; 147 | 148 | if (this.comboPools.SelectedItem == null) 149 | { 150 | this.btnCreate.Enabled = false; 151 | this.lblPool.Visible = true; 152 | return; 153 | } 154 | 155 | string algo = "" + this.comboAlgorithm.SelectedItem; 156 | string limit = "" + this.tbLimit.Text; 157 | string market = "EU"; 158 | if (this.rbUSA.Checked) 159 | { 160 | market = "USA"; 161 | } 162 | 163 | if (this.rbFixed.Checked) 164 | { 165 | JObject response = ac.getFixedPrice(algo, limit, market); 166 | 167 | this.btnCreate.Enabled = false; 168 | this.lblCreate.Visible = true; 169 | 170 | if (response["fixedMax"] != null && response["fixedPrice"] != null) 171 | { 172 | this.tbPrice.Text = "" + response["fixedPrice"]; 173 | this.tbPrice.Enabled = false; 174 | this.limitDetailsLbl.Text = "> " + this.algo["minSpeedLimit"] + " AND < " + response["fixedMax"]; 175 | 176 | this.btnCreate.Enabled = true; 177 | this.lblCreate.Visible = false; 178 | } 179 | } 180 | } 181 | 182 | private void btnCreate_Click(object sender, EventArgs e) 183 | { 184 | string algo = "" + this.comboAlgorithm.SelectedItem; 185 | string market = "EU"; 186 | if (this.rbUSA.Checked) 187 | { 188 | market = "USA"; 189 | } 190 | string type = "STANDARD"; 191 | if (this.rbFixed.Checked) 192 | { 193 | type = "FIXED"; 194 | } 195 | JObject pool = (JObject)this.comboPools.SelectedItem; 196 | 197 | string price = "" + this.tbPrice.Text; 198 | string limit = "" + this.tbLimit.Text; 199 | string amount = "" + this.tbAmount.Text; 200 | 201 | JObject order = ac.createOrder(algo, market, type, "" + pool["id"], price, limit, amount); 202 | if (order["id"] != null) 203 | { 204 | this.lblErrorCreate.Visible = false; 205 | setEditMode(order); 206 | } 207 | else 208 | { 209 | this.lblErrorCreate.Visible = true; 210 | } 211 | } 212 | 213 | public void setEditMode(JObject order) 214 | { 215 | edit = true; 216 | 217 | this.Text = "Edit order " + order["id"]; 218 | this.tabControl1.Enabled = true; 219 | 220 | this.lblErrorCreate.Visible = false; 221 | this.lblPool.Visible = false; 222 | this.lblCreate.Visible = false; 223 | 224 | this.btnCreate.Visible = false; 225 | this.comboAlgorithm.Enabled = false; 226 | this.comboPools.Enabled = false; 227 | this.rbEU.Enabled = false; 228 | this.rbUSA.Enabled = false; 229 | this.rbStd.Enabled = false; 230 | this.rbFixed.Enabled = false; 231 | this.tbPrice.Enabled = false; 232 | this.tbLimit.Enabled = false; 233 | this.tbAmount.Enabled = false; 234 | 235 | if (order["type"]["code"].Equals("FIXED")) 236 | { 237 | this.tbNewLimit.Enabled = false; 238 | this.tbNewPrice.Enabled = false; 239 | this.btnUpdate.Enabled = false; 240 | } 241 | else 242 | { 243 | this.tbNewLimit.Enabled = true; 244 | this.tbNewPrice.Enabled = true; 245 | this.btnUpdate.Enabled = true; 246 | } 247 | 248 | //set values 249 | this.tbId.Text = "" + order["id"]; 250 | this.comboAlgorithm.SelectedItem = order["algorithm"]["algorithm"]; 251 | if (("" + order["market"]).Equals("EU")) 252 | { 253 | this.rbEU.Checked = true; 254 | this.rbUSA.Checked = false; 255 | } 256 | else 257 | { 258 | this.rbEU.Checked = false; 259 | this.rbUSA.Checked = true; 260 | } 261 | 262 | if (("" + order["type"]["code"]).Equals("STANDARD")) 263 | { 264 | this.rbStd.Checked = true; 265 | this.rbFixed.Checked = false; 266 | } 267 | else 268 | { 269 | this.rbStd.Checked = false; 270 | this.rbFixed.Checked = true; 271 | } 272 | 273 | int idx = 0; 274 | foreach (JObject pool in this.comboPools.Items) 275 | { 276 | if (order["pool"]["id"].Equals(pool["id"])) 277 | { 278 | break; 279 | } 280 | idx++; 281 | } 282 | this.comboPools.SelectedIndex = idx; 283 | 284 | this.tbPrice.Text = "" + order["price"]; 285 | this.tbLimit.Text = "" + order["limit"]; 286 | this.tbAmount.Text = "" + order["amount"]; 287 | 288 | this.tbNewAmount.Text = "" + this.algo["minimalOrderAmount"]; 289 | this.tbAvailableAmount.Text = "" + order["availableAmount"]; 290 | this.tbNewPrice.Text = "" + order["price"]; 291 | this.tbNewLimit.Text = "" + order["limit"]; 292 | 293 | this.priceDetailsLbl2.Text = "step down < " + this.algo["priceDownStep"]; 294 | this.amountDetailsLbl2.Text = "> " + this.algo["minimalOrderAmount"]; 295 | this.limitDetailsLbl2.Text = "> " + this.algo["minSpeedLimit"] + " AND < " + this.algo["maxSpeedLimit"] + " OR 0"; 296 | } 297 | 298 | private void btnRefill_Click(object sender, EventArgs e) 299 | { 300 | string amount = "" + this.tbNewAmount.Text; 301 | string id = "" + this.tbId.Text; 302 | 303 | JObject order = ac.refillOrder(id, amount); 304 | if (order["id"] != null) 305 | { 306 | this.lblErrorCreate.Visible = false; 307 | setEditMode(order); 308 | } 309 | } 310 | 311 | private void btnUpdate_Click(object sender, EventArgs e) 312 | { 313 | string algo = "" + this.comboAlgorithm.SelectedItem; 314 | string price = "" + this.tbNewPrice.Text; 315 | string limit = "" + this.tbNewLimit.Text; 316 | string id = "" + this.tbId.Text; 317 | 318 | JObject order = ac.updateOrder(algo, id, price, limit); 319 | if (order["id"] != null) 320 | { 321 | this.lblErrorCreate.Visible = false; 322 | setEditMode(order); 323 | } 324 | } 325 | 326 | private void btnCancel_Click(object sender, EventArgs e) 327 | { 328 | string id = "" + this.tbId.Text; 329 | 330 | JObject order = ac.cancelOrder(id); 331 | if (order["id"] != null) 332 | { 333 | this.Close(); 334 | } 335 | } 336 | } 337 | } 338 | -------------------------------------------------------------------------------- /NHB3/OrderForm.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /NHB3/PoolForm.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace NHB3 2 | { 3 | partial class PoolForm 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.label1 = new System.Windows.Forms.Label(); 32 | this.textName = new System.Windows.Forms.TextBox(); 33 | this.label2 = new System.Windows.Forms.Label(); 34 | this.comboAlgorithm = new System.Windows.Forms.ComboBox(); 35 | this.label3 = new System.Windows.Forms.Label(); 36 | this.textUrl = new System.Windows.Forms.TextBox(); 37 | this.label4 = new System.Windows.Forms.Label(); 38 | this.textPort = new System.Windows.Forms.TextBox(); 39 | this.label5 = new System.Windows.Forms.Label(); 40 | this.textUsername = new System.Windows.Forms.TextBox(); 41 | this.label6 = new System.Windows.Forms.Label(); 42 | this.textPassword = new System.Windows.Forms.TextBox(); 43 | this.buttonAdd = new System.Windows.Forms.Button(); 44 | this.buttonEdit = new System.Windows.Forms.Button(); 45 | this.buttonDelete = new System.Windows.Forms.Button(); 46 | this.textId = new System.Windows.Forms.TextBox(); 47 | this.SuspendLayout(); 48 | // 49 | // label1 50 | // 51 | this.label1.AutoSize = true; 52 | this.label1.Location = new System.Drawing.Point(12, 12); 53 | this.label1.Name = "label1"; 54 | this.label1.Size = new System.Drawing.Size(51, 20); 55 | this.label1.TabIndex = 0; 56 | this.label1.Text = "Name"; 57 | // 58 | // textName 59 | // 60 | this.textName.Location = new System.Drawing.Point(121, 6); 61 | this.textName.Name = "textName"; 62 | this.textName.Size = new System.Drawing.Size(667, 26); 63 | this.textName.TabIndex = 1; 64 | // 65 | // label2 66 | // 67 | this.label2.AutoSize = true; 68 | this.label2.Location = new System.Drawing.Point(12, 41); 69 | this.label2.Name = "label2"; 70 | this.label2.Size = new System.Drawing.Size(76, 20); 71 | this.label2.TabIndex = 2; 72 | this.label2.Text = "Algorithm"; 73 | // 74 | // comboAlgorithm 75 | // 76 | this.comboAlgorithm.FormattingEnabled = true; 77 | this.comboAlgorithm.Location = new System.Drawing.Point(121, 38); 78 | this.comboAlgorithm.Name = "comboAlgorithm"; 79 | this.comboAlgorithm.Size = new System.Drawing.Size(667, 28); 80 | this.comboAlgorithm.TabIndex = 3; 81 | // 82 | // label3 83 | // 84 | this.label3.AutoSize = true; 85 | this.label3.Location = new System.Drawing.Point(12, 76); 86 | this.label3.Name = "label3"; 87 | this.label3.Size = new System.Drawing.Size(83, 20); 88 | this.label3.TabIndex = 4; 89 | this.label3.Text = "Hostname"; 90 | // 91 | // textUrl 92 | // 93 | this.textUrl.Location = new System.Drawing.Point(121, 73); 94 | this.textUrl.Name = "textUrl"; 95 | this.textUrl.Size = new System.Drawing.Size(424, 26); 96 | this.textUrl.TabIndex = 5; 97 | // 98 | // label4 99 | // 100 | this.label4.AutoSize = true; 101 | this.label4.Location = new System.Drawing.Point(551, 76); 102 | this.label4.Name = "label4"; 103 | this.label4.Size = new System.Drawing.Size(38, 20); 104 | this.label4.TabIndex = 6; 105 | this.label4.Text = "Port"; 106 | // 107 | // textPort 108 | // 109 | this.textPort.Location = new System.Drawing.Point(595, 73); 110 | this.textPort.Name = "textPort"; 111 | this.textPort.Size = new System.Drawing.Size(193, 26); 112 | this.textPort.TabIndex = 7; 113 | // 114 | // label5 115 | // 116 | this.label5.AutoSize = true; 117 | this.label5.Location = new System.Drawing.Point(12, 108); 118 | this.label5.Name = "label5"; 119 | this.label5.Size = new System.Drawing.Size(83, 20); 120 | this.label5.TabIndex = 8; 121 | this.label5.Text = "Username"; 122 | // 123 | // textUsername 124 | // 125 | this.textUsername.Location = new System.Drawing.Point(121, 105); 126 | this.textUsername.Name = "textUsername"; 127 | this.textUsername.Size = new System.Drawing.Size(667, 26); 128 | this.textUsername.TabIndex = 9; 129 | // 130 | // label6 131 | // 132 | this.label6.AutoSize = true; 133 | this.label6.Location = new System.Drawing.Point(12, 140); 134 | this.label6.Name = "label6"; 135 | this.label6.Size = new System.Drawing.Size(78, 20); 136 | this.label6.TabIndex = 10; 137 | this.label6.Text = "Password"; 138 | // 139 | // textPassword 140 | // 141 | this.textPassword.Location = new System.Drawing.Point(121, 137); 142 | this.textPassword.Name = "textPassword"; 143 | this.textPassword.Size = new System.Drawing.Size(667, 26); 144 | this.textPassword.TabIndex = 11; 145 | // 146 | // buttonAdd 147 | // 148 | this.buttonAdd.Location = new System.Drawing.Point(712, 170); 149 | this.buttonAdd.Name = "buttonAdd"; 150 | this.buttonAdd.Size = new System.Drawing.Size(75, 32); 151 | this.buttonAdd.TabIndex = 12; 152 | this.buttonAdd.Text = "Add"; 153 | this.buttonAdd.UseVisualStyleBackColor = true; 154 | this.buttonAdd.Visible = false; 155 | this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click); 156 | // 157 | // buttonEdit 158 | // 159 | this.buttonEdit.Location = new System.Drawing.Point(712, 170); 160 | this.buttonEdit.Name = "buttonEdit"; 161 | this.buttonEdit.Size = new System.Drawing.Size(75, 32); 162 | this.buttonEdit.TabIndex = 13; 163 | this.buttonEdit.Text = "Save"; 164 | this.buttonEdit.UseVisualStyleBackColor = true; 165 | this.buttonEdit.Visible = false; 166 | this.buttonEdit.Click += new System.EventHandler(this.buttonEdit_Click); 167 | // 168 | // buttonDelete 169 | // 170 | this.buttonDelete.ForeColor = System.Drawing.Color.DarkRed; 171 | this.buttonDelete.Location = new System.Drawing.Point(712, 170); 172 | this.buttonDelete.Name = "buttonDelete"; 173 | this.buttonDelete.Size = new System.Drawing.Size(75, 32); 174 | this.buttonDelete.TabIndex = 14; 175 | this.buttonDelete.Text = "Delete"; 176 | this.buttonDelete.UseVisualStyleBackColor = true; 177 | this.buttonDelete.Visible = false; 178 | this.buttonDelete.Click += new System.EventHandler(this.buttonDelete_Click); 179 | // 180 | // textId 181 | // 182 | this.textId.Location = new System.Drawing.Point(121, 169); 183 | this.textId.Name = "textId"; 184 | this.textId.Size = new System.Drawing.Size(100, 26); 185 | this.textId.TabIndex = 15; 186 | this.textId.Visible = false; 187 | // 188 | // PoolForm 189 | // 190 | this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); 191 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 192 | this.ClientSize = new System.Drawing.Size(800, 210); 193 | this.Controls.Add(this.textId); 194 | this.Controls.Add(this.buttonDelete); 195 | this.Controls.Add(this.buttonEdit); 196 | this.Controls.Add(this.buttonAdd); 197 | this.Controls.Add(this.textPassword); 198 | this.Controls.Add(this.label6); 199 | this.Controls.Add(this.textUsername); 200 | this.Controls.Add(this.label5); 201 | this.Controls.Add(this.textPort); 202 | this.Controls.Add(this.label4); 203 | this.Controls.Add(this.textUrl); 204 | this.Controls.Add(this.label3); 205 | this.Controls.Add(this.comboAlgorithm); 206 | this.Controls.Add(this.label2); 207 | this.Controls.Add(this.textName); 208 | this.Controls.Add(this.label1); 209 | this.Name = "PoolForm"; 210 | this.Text = "Pool"; 211 | this.ResumeLayout(false); 212 | this.PerformLayout(); 213 | 214 | } 215 | 216 | #endregion 217 | 218 | private System.Windows.Forms.Label label1; 219 | private System.Windows.Forms.TextBox textName; 220 | private System.Windows.Forms.Label label2; 221 | private System.Windows.Forms.ComboBox comboAlgorithm; 222 | private System.Windows.Forms.Label label3; 223 | private System.Windows.Forms.TextBox textUrl; 224 | private System.Windows.Forms.Label label4; 225 | private System.Windows.Forms.TextBox textPort; 226 | private System.Windows.Forms.Label label5; 227 | private System.Windows.Forms.TextBox textUsername; 228 | private System.Windows.Forms.Label label6; 229 | private System.Windows.Forms.TextBox textPassword; 230 | private System.Windows.Forms.Button buttonAdd; 231 | private System.Windows.Forms.Button buttonEdit; 232 | private System.Windows.Forms.Button buttonDelete; 233 | private System.Windows.Forms.TextBox textId; 234 | } 235 | } -------------------------------------------------------------------------------- /NHB3/PoolForm.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json.Linq; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel; 5 | using System.Data; 6 | using System.Drawing; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | using System.Windows.Forms; 11 | 12 | namespace NHB3 13 | { 14 | public partial class PoolForm : Form 15 | { 16 | ApiConnect ac; 17 | 18 | public PoolForm(ApiConnect ac, int mode, JToken pool) 19 | { 20 | InitializeComponent(); 21 | this.Show(); 22 | this.ac = ac; 23 | 24 | if (mode == 1) 25 | { 26 | this.Text = "Add pool"; 27 | this.buttonAdd.Visible = true; 28 | } 29 | else if (mode == 2) 30 | { 31 | this.Text = "Edit pool " + pool["id"]; 32 | this.buttonEdit.Visible = true; 33 | } 34 | else if (mode == 3) 35 | { 36 | this.Text = "Delete pool" + pool["id"]; 37 | this.buttonDelete.Visible = true; 38 | } 39 | 40 | foreach (JObject obj in ac.algorithms) 41 | { 42 | this.comboAlgorithm.Items.Add(obj["algorithm"]); 43 | } 44 | this.comboAlgorithm.SelectedIndex = 0; 45 | 46 | if (mode == 2 || mode == 3) { 47 | this.textName.Text = "" + pool["name"]; 48 | this.comboAlgorithm.SelectedItem = pool["algorithm"]; 49 | this.textUrl.Text = "" + pool["stratumHostname"]; 50 | this.textPort.Text = "" + pool["stratumPort"]; 51 | this.textUsername.Text = "" + pool["username"]; 52 | this.textPassword.Text = "" + pool["password"]; 53 | this.textId.Text = "" + pool["id"]; 54 | } 55 | } 56 | 57 | private void buttonDelete_Click(object sender, EventArgs e) 58 | { 59 | ac.deletePool(this.textId.Text); 60 | this.Close(); 61 | } 62 | 63 | private void buttonEdit_Click(object sender, EventArgs e) 64 | { 65 | ac.editPool(this.textName.Text, ""+this.comboAlgorithm.SelectedItem, this.textUrl.Text, this.textPort.Text, this.textUsername.Text, this.textPassword.Text, this.textId.Text); 66 | this.Close(); 67 | } 68 | 69 | private void buttonAdd_Click(object sender, EventArgs e) 70 | { 71 | ac.addPool(this.textName.Text, ""+this.comboAlgorithm.SelectedItem, this.textUrl.Text, this.textPort.Text, this.textUsername.Text, this.textPassword.Text); 72 | this.Close(); 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /NHB3/PoolForm.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /NHB3/PoolsForm.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace NHB3 2 | { 3 | partial class PoolsForm 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.dataGridView1 = new System.Windows.Forms.DataGridView(); 32 | this.label1 = new System.Windows.Forms.Label(); 33 | this.buttonAdd = new System.Windows.Forms.Button(); 34 | this.buttonDelete = new System.Windows.Forms.Button(); 35 | this.buttonEdit = new System.Windows.Forms.Button(); 36 | ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); 37 | this.SuspendLayout(); 38 | // 39 | // dataGridView1 40 | // 41 | this.dataGridView1.AllowUserToAddRows = false; 42 | this.dataGridView1.AllowUserToDeleteRows = false; 43 | this.dataGridView1.AllowUserToOrderColumns = true; 44 | this.dataGridView1.AllowUserToResizeRows = false; 45 | this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; 46 | this.dataGridView1.Location = new System.Drawing.Point(12, 36); 47 | this.dataGridView1.Name = "dataGridView1"; 48 | this.dataGridView1.RowHeadersWidth = 62; 49 | this.dataGridView1.RowTemplate.Height = 20; 50 | this.dataGridView1.Size = new System.Drawing.Size(1322, 466); 51 | this.dataGridView1.TabIndex = 0; 52 | // 53 | // label1 54 | // 55 | this.label1.AutoSize = true; 56 | this.label1.Location = new System.Drawing.Point(13, 13); 57 | this.label1.Name = "label1"; 58 | this.label1.Size = new System.Drawing.Size(72, 20); 59 | this.label1.TabIndex = 1; 60 | this.label1.Text = "My Pools"; 61 | // 62 | // buttonAdd 63 | // 64 | this.buttonAdd.Location = new System.Drawing.Point(12, 509); 65 | this.buttonAdd.Name = "buttonAdd"; 66 | this.buttonAdd.Size = new System.Drawing.Size(200, 32); 67 | this.buttonAdd.TabIndex = 2; 68 | this.buttonAdd.Text = "Add new pool"; 69 | this.buttonAdd.UseVisualStyleBackColor = true; 70 | this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click); 71 | // 72 | // buttonDelete 73 | // 74 | this.buttonDelete.ForeColor = System.Drawing.Color.DarkRed; 75 | this.buttonDelete.Location = new System.Drawing.Point(1134, 508); 76 | this.buttonDelete.Name = "buttonDelete"; 77 | this.buttonDelete.Size = new System.Drawing.Size(200, 32); 78 | this.buttonDelete.TabIndex = 4; 79 | this.buttonDelete.Text = "Delete selected pool"; 80 | this.buttonDelete.UseVisualStyleBackColor = true; 81 | this.buttonDelete.Click += new System.EventHandler(this.buttonDelete_Click); 82 | // 83 | // buttonEdit 84 | // 85 | this.buttonEdit.Location = new System.Drawing.Point(928, 508); 86 | this.buttonEdit.Name = "buttonEdit"; 87 | this.buttonEdit.Size = new System.Drawing.Size(200, 32); 88 | this.buttonEdit.TabIndex = 3; 89 | this.buttonEdit.Text = "Edit selected pool"; 90 | this.buttonEdit.UseVisualStyleBackColor = true; 91 | this.buttonEdit.Click += new System.EventHandler(this.buttonEdit_Click); 92 | // 93 | // PoolsForm 94 | // 95 | this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); 96 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 97 | this.ClientSize = new System.Drawing.Size(1346, 552); 98 | this.Controls.Add(this.buttonEdit); 99 | this.Controls.Add(this.buttonDelete); 100 | this.Controls.Add(this.buttonAdd); 101 | this.Controls.Add(this.label1); 102 | this.Controls.Add(this.dataGridView1); 103 | this.Name = "PoolsForm"; 104 | this.Text = "Pools"; 105 | ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); 106 | this.ResumeLayout(false); 107 | this.PerformLayout(); 108 | 109 | } 110 | 111 | #endregion 112 | 113 | private System.Windows.Forms.DataGridView dataGridView1; 114 | private System.Windows.Forms.Label label1; 115 | private System.Windows.Forms.Button buttonAdd; 116 | private System.Windows.Forms.Button buttonDelete; 117 | private System.Windows.Forms.Button buttonEdit; 118 | } 119 | } -------------------------------------------------------------------------------- /NHB3/PoolsForm.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Linq; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.ComponentModel; 6 | using System.Data; 7 | using System.Drawing; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | using System.Web.UI.WebControls; 12 | using System.Windows.Forms; 13 | 14 | namespace NHB3 15 | { 16 | public partial class PoolsForm : Form 17 | { 18 | ApiConnect ac; 19 | JArray pools; 20 | 21 | public PoolsForm(ApiConnect ac) 22 | { 23 | InitializeComponent(); 24 | this.Show(); 25 | this.ac = ac; 26 | 27 | loadPools(true); 28 | } 29 | 30 | private void loadPools(bool force) { 31 | if (ac.connected) { 32 | pools = ac.getPools(force); 33 | dataGridView1.DataSource = pools; 34 | 35 | dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; 36 | dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None; 37 | dataGridView1.AllowUserToOrderColumns = true; 38 | dataGridView1.AllowUserToResizeColumns = true; 39 | } 40 | } 41 | 42 | private void buttonAdd_Click(object sender, EventArgs e) 43 | { 44 | PoolForm pf = new PoolForm(ac, 1, null); 45 | pf.FormBorderStyle = FormBorderStyle.FixedSingle; 46 | pf.FormClosed += new FormClosedEventHandler(f_FormClosed); 47 | } 48 | 49 | private void buttonEdit_Click(object sender, EventArgs e) 50 | { 51 | if (dataGridView1.Rows.GetRowCount(DataGridViewElementStates.Selected) == 1) { 52 | PoolForm pf = new PoolForm(ac, 2, pools[dataGridView1.SelectedRows[0].Index]); 53 | pf.FormBorderStyle = FormBorderStyle.FixedSingle; 54 | pf.FormClosed += new FormClosedEventHandler(f_FormClosed); 55 | } 56 | } 57 | 58 | private void buttonDelete_Click(object sender, EventArgs e) 59 | { 60 | if (dataGridView1.Rows.GetRowCount(DataGridViewElementStates.Selected) == 1) { 61 | PoolForm pf = new PoolForm(ac, 3, pools[dataGridView1.SelectedRows[0].Index]); 62 | pf.FormBorderStyle = FormBorderStyle.FixedSingle; 63 | pf.FormClosed += new FormClosedEventHandler(f_FormClosed); 64 | } 65 | } 66 | 67 | private void f_FormClosed(object sender, FormClosedEventArgs e) 68 | { 69 | loadPools(true); //refresh 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /NHB3/PoolsForm.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /NHB3/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace NHB3 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// The main entry point for the application. 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new Home()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /NHB3/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("NHB3")] 9 | [assembly: AssemblyDescription("NiceHash BOT 3")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("NHB3")] 13 | [assembly: AssemblyCopyright("Copyright © 2020")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("544db7fc-334d-4c5d-a298-61508693eb31")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("0.9.9.0")] 36 | [assembly: AssemblyFileVersion("0.9.9.0")] 37 | -------------------------------------------------------------------------------- /NHB3/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace NHB3.Properties 12 | { 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources 26 | { 27 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// Returns the cached ResourceManager instance used by this class. 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if ((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("NHB3.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// Overrides the current thread's CurrentUICulture property for all 56 | /// resource lookups using this strongly typed resource class. 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /NHB3/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /NHB3/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace NHB3.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /NHB3/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /NHB3/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NiceHashBot 2 | NHB3 bot for automatic order management. 3 | 4 | - [Features](#features) 5 | - [How to run?](#run) 6 | - [How to compile?](#compile) 7 | - [Tips for programmers](#tips) 8 | 9 | ![](https://raw.githubusercontent.com/nicehash/NiceHashBot/master/screenshots/00nhb3.png) 10 | 11 | # Features 12 | 13 | - Run on **test** and **production** environment (instructions on how to obtain API keys https://github.com/nicehash/rest-clients-demo/blob/master/README.md) 14 | - Manage pools (create/edit/delete) 15 | - Manage orders (create/refill/edit/delete) 16 | - Automatically manage orders for **(Bot On mode)**: 17 | * **price adjustment** - keep price as low as possible (increase and decrease prices) 18 | * **refilling** - automatically refill order when 90% of available money is consumed 19 | - Console window showing important events, API calls and errors 20 | 21 | # Instructions on how to run 22 | 23 | - Download binaries from here: https://github.com/nicehash/NiceHashBot/releases 24 | - Extract zip archive 25 | - Run NHB3.exe 26 | - Note: .NET Framework 4.7 or higher is required. You can also run multiple instances of NHB3 - each in own folder with different API credentials. 27 | 28 | # Instructions on how to compile 29 | 30 | - Use Visual Studio 2019 or later 31 | - Open project in Visual Studio 32 | - Rebuild & run 33 | 34 | # Tips for programmers 35 | 36 | NHB3 is proof of concept (but working) application. It is some how extension of rest-clients-demo (https://github.com/nicehash/rest-clients-demo) and can be used *as is* or upgraded for further improvements in usability and functionality. 37 | Main purpose is to demonstrate interaction with new NiceHash platform. 38 | 39 | NHB3 uses two classes for interaction with NiceHash platform **Api.cs** that prepares all required request headers (authorization - as described here - https://docs.nicehash.com/) and executes remote calls and **ApiConnect.cs** that exposes methods for actions used by NHB3. 40 | 41 | Majority of BOT logic is in function **runBot()** inside Home.cs class witch is executed once per minute and then check if order needs some sort of interaction (refill, increase speed or decrease speed). 42 | 43 | 44 | -------------------------------------------------------------------------------- /screenshots/00nhb3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nicehash/NiceHashBot/ab8bbe1f05c6065b5820bf2fc6d891940dc3f68f/screenshots/00nhb3.png -------------------------------------------------------------------------------- /screenshots/01api.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nicehash/NiceHashBot/ab8bbe1f05c6065b5820bf2fc6d891940dc3f68f/screenshots/01api.png -------------------------------------------------------------------------------- /screenshots/02pools.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nicehash/NiceHashBot/ab8bbe1f05c6065b5820bf2fc6d891940dc3f68f/screenshots/02pools.png -------------------------------------------------------------------------------- /screenshots/03pool.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nicehash/NiceHashBot/ab8bbe1f05c6065b5820bf2fc6d891940dc3f68f/screenshots/03pool.png -------------------------------------------------------------------------------- /screenshots/04order_create.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nicehash/NiceHashBot/ab8bbe1f05c6065b5820bf2fc6d891940dc3f68f/screenshots/04order_create.png -------------------------------------------------------------------------------- /screenshots/05order_refill.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nicehash/NiceHashBot/ab8bbe1f05c6065b5820bf2fc6d891940dc3f68f/screenshots/05order_refill.png -------------------------------------------------------------------------------- /screenshots/06order_edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nicehash/NiceHashBot/ab8bbe1f05c6065b5820bf2fc6d891940dc3f68f/screenshots/06order_edit.png -------------------------------------------------------------------------------- /screenshots/07bot_settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nicehash/NiceHashBot/ab8bbe1f05c6065b5820bf2fc6d891940dc3f68f/screenshots/07bot_settings.png -------------------------------------------------------------------------------- /screenshots/08bot_run.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nicehash/NiceHashBot/ab8bbe1f05c6065b5820bf2fc6d891940dc3f68f/screenshots/08bot_run.png -------------------------------------------------------------------------------- /screenshots/09_order.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nicehash/NiceHashBot/ab8bbe1f05c6065b5820bf2fc6d891940dc3f68f/screenshots/09_order.png --------------------------------------------------------------------------------