diff --git a/README.md b/README.md index e60d13f..4edc705 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,7 @@ After programming, you will only need to setup your Wifi and BTC address. - PASS: MineYourCoins 1. Setup your Wifi Network 1. Add your BTCaddress +1. Change the password if needed #### SD card (if available) @@ -94,7 +95,8 @@ After programming, you will only need to setup your Wifi and BTC address. "SSID": "myWifiSSID", "WifiPW": "myWifiPassword", "PoolUrl": "public-pool.io", - "PoolPort": 21496, + "PoolPort": 21496, + "PoolPassword": "x", "BtcWallet": "walletID", "Timezone": 2, "SaveStats": false diff --git a/src/drivers/storage/SDCard.cpp b/src/drivers/storage/SDCard.cpp index 4e35e5b..4552f8c 100644 --- a/src/drivers/storage/SDCard.cpp +++ b/src/drivers/storage/SDCard.cpp @@ -100,6 +100,7 @@ bool SDCard::loadConfigFile(TSettings* Settings) Settings->WifiSSID = json[JSON_KEY_SSID] | Settings->WifiSSID; Settings->WifiPW = json[JSON_KEY_PASW] | Settings->WifiPW; Settings->PoolAddress = json[JSON_KEY_POOLURL] | Settings->PoolAddress; + strcpy(Settings->PoolPassword, json[JSON_KEY_POOLPASS] | Settings->PoolPassword); strcpy(Settings->BtcWallet, json[JSON_KEY_WALLETID] | Settings->BtcWallet); if (json.containsKey(JSON_KEY_POOLPORT)) Settings->PoolPort = json[JSON_KEY_POOLPORT].as(); diff --git a/src/drivers/storage/nvMemory.cpp b/src/drivers/storage/nvMemory.cpp index e7aca6b..0e88f07 100644 --- a/src/drivers/storage/nvMemory.cpp +++ b/src/drivers/storage/nvMemory.cpp @@ -31,6 +31,7 @@ bool nvMemory::saveConfig(TSettings* Settings) StaticJsonDocument<512> json; json[JSON_SPIFFS_KEY_POOLURL] = Settings->PoolAddress; json[JSON_SPIFFS_KEY_POOLPORT] = Settings->PoolPort; + json[JSON_SPIFFS_KEY_POOLPASS] = Settings->PoolPassword; json[JSON_SPIFFS_KEY_WALLETID] = Settings->BtcWallet; json[JSON_SPIFFS_KEY_TIMEZONE] = Settings->Timezone; json[JSON_SPIFFS_KEY_STATS2NV] = Settings->saveStats; @@ -88,6 +89,7 @@ bool nvMemory::loadConfig(TSettings* Settings) if (!error) { Settings->PoolAddress = json[JSON_SPIFFS_KEY_POOLURL] | Settings->PoolAddress; + strcpy(Settings->PoolPassword, json[JSON_SPIFFS_KEY_POOLPASS] | Settings->PoolPassword); strcpy(Settings->BtcWallet, json[JSON_SPIFFS_KEY_WALLETID] | Settings->BtcWallet); if (json.containsKey(JSON_SPIFFS_KEY_POOLPORT)) Settings->PoolPort = json[JSON_SPIFFS_KEY_POOLPORT].as(); diff --git a/src/drivers/storage/storage.h b/src/drivers/storage/storage.h index 76e80cd..8336847 100644 --- a/src/drivers/storage/storage.h +++ b/src/drivers/storage/storage.h @@ -9,6 +9,7 @@ #define DEFAULT_SSID "NerdMinerAP" #define DEFAULT_WIFIPW "MineYourCoins" #define DEFAULT_POOLURL "public-pool.io" +#define DEFAULT_POOLPASS "x" #define DEFAULT_WALLETID "yourBtcAddress" #define DEFAULT_POOLPORT 21496 #define DEFAULT_TIMEZONE 2 @@ -21,6 +22,7 @@ #define JSON_KEY_SSID "SSID" #define JSON_KEY_PASW "WifiPW" #define JSON_KEY_POOLURL "PoolUrl" +#define JSON_KEY_POOLPASS "PoolPassword" #define JSON_KEY_WALLETID "BtcWallet" #define JSON_KEY_POOLPORT "PoolPort" #define JSON_KEY_TIMEZONE "Timezone" @@ -29,6 +31,7 @@ // JSON config file SPIFFS (different for backward compatibility with existing devices) #define JSON_SPIFFS_KEY_POOLURL "poolString" #define JSON_SPIFFS_KEY_POOLPORT "portNumber" +#define JSON_SPIFFS_KEY_POOLPASS "poolPassword" #define JSON_SPIFFS_KEY_WALLETID "btcString" #define JSON_SPIFFS_KEY_TIMEZONE "gmtZone" #define JSON_SPIFFS_KEY_STATS2NV "saveStatsToNVS" @@ -40,6 +43,7 @@ struct TSettings String WifiPW{ DEFAULT_WIFIPW }; String PoolAddress{ DEFAULT_POOLURL }; char BtcWallet[80]{ DEFAULT_WALLETID }; + char PoolPassword[80]{ DEFAULT_POOLPASS }; int PoolPort{ DEFAULT_POOLPORT }; int Timezone{ DEFAULT_TIMEZONE }; bool saveStats{ DEFAULT_SAVESTATS }; diff --git a/src/mining.cpp b/src/mining.cpp index f8ca70e..5940579 100644 --- a/src/mining.cpp +++ b/src/mining.cpp @@ -167,7 +167,7 @@ void runStratumWorker(void *name) { } strcpy(mWorker.wName, Settings.BtcWallet); - strcpy(mWorker.wPass, "x"); + strcpy(mWorker.wPass, Settings.PoolPassword); // STEP 2: Pool authorize work (Block Info) tx_mining_auth(client, mWorker.wName, mWorker.wPass); //Don't verifies authoritzation, TODO //tx_mining_auth2(client, mWorker.wName, mWorker.wPass); //Don't verifies authoritzation, TODO diff --git a/src/wManager.cpp b/src/wManager.cpp index 41ebff3..f3e8b40 100644 --- a/src/wManager.cpp +++ b/src/wManager.cpp @@ -134,6 +134,9 @@ void init_WifiManager() // Text box (Number) - 7 characters maximum WiFiManagerParameter port_text_box_num("Poolport", "Pool port", convertedValue, 7); + // Text box (String) - 80 characters maximum + WiFiManagerParameter password_text_box("Poolpassword", "Pool password", Settings.PoolPassword, 80); + // Text box (String) - 80 characters maximum WiFiManagerParameter addr_text_box("btcAddress", "Your BTC address", Settings.BtcWallet, 80); @@ -154,6 +157,7 @@ void init_WifiManager() // Add all defined parameters wm.addParameter(&pool_text_box); wm.addParameter(&port_text_box_num); + wm.addParameter(&password_text_box); wm.addParameter(&addr_text_box); wm.addParameter(&time_text_box_num); wm.addParameter(&features_html); @@ -173,6 +177,7 @@ void init_WifiManager() Serial.println("failed to connect and hit timeout"); Settings.PoolAddress = pool_text_box.getValue(); Settings.PoolPort = atoi(port_text_box_num.getValue()); + strncpy(Settings.PoolPassword, password_text_box.getValue(), sizeof(Settings.PoolPassword)); strncpy(Settings.BtcWallet, addr_text_box.getValue(), sizeof(Settings.BtcWallet)); Settings.Timezone = atoi(time_text_box_num.getValue()); Serial.println(save_stats_to_nvs.getValue()); @@ -223,6 +228,11 @@ void init_WifiManager() Serial.print("portNumber: "); Serial.println(Settings.PoolPort); + // Copy the string value + strncpy(Settings.PoolPassword, password_text_box.getValue(), sizeof(Settings.PoolPassword)); + Serial.print("poolPassword: "); + Serial.println(Settings.PoolPassword); + // Copy the string value strncpy(Settings.BtcWallet, addr_text_box.getValue(), sizeof(Settings.BtcWallet)); Serial.print("btcString: ");