diff --git a/api.c b/api.c index e71db958..d2893fa3 100644 --- a/api.c +++ b/api.c @@ -2112,7 +2112,8 @@ static void copyadvanceafter(char ch, char **param, char **buf) *(dst_b++) = '\0'; } -static bool pooldetails(char *param, char **url, char **user, char **pass) +static bool pooldetails(char *param, char **url, char **user, char **pass, + char **name, char **desc, char **algo) { char *ptr, *buf; @@ -2121,24 +2122,31 @@ static bool pooldetails(char *param, char **url, char **user, char **pass) quit(1, "Failed to malloc pooldetails buf"); *url = buf; - - // copy url copyadvanceafter(',', ¶m, &buf); - if (!(*param)) // missing user goto exitsama; *user = buf; - - // copy user copyadvanceafter(',', ¶m, &buf); - if (!*param) // missing pass goto exitsama; *pass = buf; + copyadvanceafter(',', ¶m, &buf); + if (!*param) // missing name + goto exitsama; + + *name = buf; + copyadvanceafter(',', ¶m, &buf); + if (!*param) // missing desc + goto exitsama; + + *desc = buf; + copyadvanceafter(',', ¶m, &buf); + if (!*param) // missing algo + goto exitsama; - // copy pass + *algo = buf; copyadvanceafter(',', ¶m, &buf); return true; @@ -2151,6 +2159,7 @@ exitsama: static void addpool(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group) { char *url, *user, *pass; + char *name, *desc, *algo; struct pool *pool; char *ptr; @@ -2159,7 +2168,8 @@ static void addpool(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char * return; } - if (!pooldetails(param, &url, &user, &pass)) { + if (!pooldetails(param, &url, &user, &pass, + &name, &desc, &algo)) { ptr = escape_string(param, isjson); message(io_data, MSG_INVPDP, 0, ptr, isjson); if (ptr != param) @@ -2170,7 +2180,7 @@ static void addpool(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char * pool = add_pool(); detect_stratum(pool, url); - add_pool_details(pool, true, url, user, pass); + add_pool_details(pool, true, url, user, pass, name, desc, algo); ptr = escape_string(url, isjson); message(io_data, MSG_ADDPOOL, 0, ptr, isjson); diff --git a/miner.h b/miner.h index 1b89d01f..7db088fd 100644 --- a/miner.h +++ b/miner.h @@ -1053,7 +1053,7 @@ extern bool detect_stratum(struct pool *pool, char *url); extern void print_summary(void); extern void adjust_quota_gcd(void); extern struct pool *add_pool(void); -extern bool add_pool_details(struct pool *pool, bool live, char *url, char *user, char *pass); +extern bool add_pool_details(struct pool *pool, bool live, char *url, char *user, char *pass, char *name, char *desc, char *algo); #define MAX_GPUDEVICES 16 #define MAX_DEVICES 4096 diff --git a/sgminer.c b/sgminer.c index 66735da8..52ee9dc1 100644 --- a/sgminer.c +++ b/sgminer.c @@ -7515,7 +7515,7 @@ static void *test_pool_thread(void *arg) /* Always returns true that the pool details were added unless we are not * live, implying this is the only pool being added, so if no pools are * active it returns false. */ -bool add_pool_details(struct pool *pool, bool live, char *url, char *user, char *pass) +bool add_pool_details(struct pool *pool, bool live, char *url, char *user, char *pass, char *name, char *desc, char *algo) { size_t siz; @@ -7524,6 +7524,10 @@ bool add_pool_details(struct pool *pool, bool live, char *url, char *user, char pool->rpc_url = url; pool->rpc_user = user; pool->rpc_pass = pass; + pool->name = name; + pool->description = desc; + strcpy(pool->algorithm.name, algo); + siz = strlen(pool->rpc_user) + strlen(pool->rpc_pass) + 2; pool->rpc_userpass = (char *)malloc(siz); if (!pool->rpc_userpass) @@ -7547,23 +7551,26 @@ bool add_pool_details(struct pool *pool, bool live, char *url, char *user, char static bool input_pool(bool live) { char *url = NULL, *user = NULL, *pass = NULL; + char *name = NULL, *desc = NULL, *algo = NULL; struct pool *pool; bool ret = false; immedok(logwin, true); wlogprint("Input server details.\n"); + /* Get user input */ url = curses_input("URL"); - if (!url) - goto out; - - user = curses_input("Username"); - if (!user) - goto out; - + if (!url) goto out; + user = curses_input("User name"); + if (!user) goto out; pass = curses_input("Password"); - if (!pass) - goto out; + if (!pass) goto out; + name = curses_input("Pool name (optional)"); + if (strcmp(name, "-1") == 0) strcpy(name, ""); + desc = curses_input("Description (optional)"); + if (strcmp(desc, "-1") == 0) strcpy(desc, ""); + algo = curses_input("Algorithm (optional)"); + if (strcmp(name, "-1") == 0) strcpy(algo, ""); pool = add_pool(); @@ -7580,7 +7587,8 @@ static bool input_pool(bool live) url = httpinput; } - ret = add_pool_details(pool, live, url, user, pass); + ret = add_pool_details(pool, live, url, user, pass, + name, desc, algo); out: immedok(logwin, false); @@ -7591,6 +7599,12 @@ out: free(user); if (pass) free(pass); + if (name) + free(name); + if (desc) + free(desc); + if (algo) + free(algo); } return ret; }