Merge pull request #208 from matteocrippa/feature/password

Introduce custom password
This commit is contained in:
BitMaker 2023-11-27 22:37:20 +01:00 committed by GitHub
commit d7b545638f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 32 additions and 10 deletions

View File

@ -97,8 +97,11 @@ After programming, you will only need to setup your Wifi and BTC address.
- PASS: MineYourCoins - PASS: MineYourCoins
1. Setup your Wifi Network 1. Setup your Wifi Network
1. Add your BTCaddress 1. Add your BTCaddress
1. Change the password if needed
- If you are using public-pool.io and you want to set a custom name to your worker you can append a string with format _.yourworkername_ to the address - If you are using public-pool.io and you want to set a custom name to your worker you can append a string with format _.yourworkername_ to the address
#### SD card (if available) #### SD card (if available)
1. Format a SD card using Fat32. 1. Format a SD card using Fat32.
@ -108,10 +111,12 @@ After programming, you will only need to setup your Wifi and BTC address.
"WifiPW": "myWifiPassword", "WifiPW": "myWifiPassword",
"PoolUrl": "public-pool.io", "PoolUrl": "public-pool.io",
"PoolPort": 21496, "PoolPort": 21496,
"PoolPassword": "x",
"BtcWallet": "walletID", "BtcWallet": "walletID",
"Timezone": 2, "Timezone": 2,
"SaveStats": false "SaveStats": false
} }
1. Insert the SD card. 1. Insert the SD card.
1. Hold down the "reset configurations" button as described below to reset the configurations and/or boot without settings in your nvmemory. 1. Hold down the "reset configurations" button as described below to reset the configurations and/or boot without settings in your nvmemory.
1. Power down to remove the SD card. It is not needed for mining. 1. Power down to remove the SD card. It is not needed for mining.

View File

@ -100,6 +100,7 @@ bool SDCard::loadConfigFile(TSettings* Settings)
Settings->WifiSSID = json[JSON_KEY_SSID] | Settings->WifiSSID; Settings->WifiSSID = json[JSON_KEY_SSID] | Settings->WifiSSID;
Settings->WifiPW = json[JSON_KEY_PASW] | Settings->WifiPW; Settings->WifiPW = json[JSON_KEY_PASW] | Settings->WifiPW;
Settings->PoolAddress = json[JSON_KEY_POOLURL] | Settings->PoolAddress; 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); strcpy(Settings->BtcWallet, json[JSON_KEY_WALLETID] | Settings->BtcWallet);
if (json.containsKey(JSON_KEY_POOLPORT)) if (json.containsKey(JSON_KEY_POOLPORT))
Settings->PoolPort = json[JSON_KEY_POOLPORT].as<int>(); Settings->PoolPort = json[JSON_KEY_POOLPORT].as<int>();

View File

@ -31,6 +31,7 @@ bool nvMemory::saveConfig(TSettings* Settings)
StaticJsonDocument<512> json; StaticJsonDocument<512> json;
json[JSON_SPIFFS_KEY_POOLURL] = Settings->PoolAddress; json[JSON_SPIFFS_KEY_POOLURL] = Settings->PoolAddress;
json[JSON_SPIFFS_KEY_POOLPORT] = Settings->PoolPort; 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_WALLETID] = Settings->BtcWallet;
json[JSON_SPIFFS_KEY_TIMEZONE] = Settings->Timezone; json[JSON_SPIFFS_KEY_TIMEZONE] = Settings->Timezone;
json[JSON_SPIFFS_KEY_STATS2NV] = Settings->saveStats; json[JSON_SPIFFS_KEY_STATS2NV] = Settings->saveStats;
@ -88,6 +89,7 @@ bool nvMemory::loadConfig(TSettings* Settings)
if (!error) if (!error)
{ {
Settings->PoolAddress = json[JSON_SPIFFS_KEY_POOLURL] | Settings->PoolAddress; 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); strcpy(Settings->BtcWallet, json[JSON_SPIFFS_KEY_WALLETID] | Settings->BtcWallet);
if (json.containsKey(JSON_SPIFFS_KEY_POOLPORT)) if (json.containsKey(JSON_SPIFFS_KEY_POOLPORT))
Settings->PoolPort = json[JSON_SPIFFS_KEY_POOLPORT].as<int>(); Settings->PoolPort = json[JSON_SPIFFS_KEY_POOLPORT].as<int>();

View File

@ -9,6 +9,7 @@
#define DEFAULT_SSID "NerdMinerAP" #define DEFAULT_SSID "NerdMinerAP"
#define DEFAULT_WIFIPW "MineYourCoins" #define DEFAULT_WIFIPW "MineYourCoins"
#define DEFAULT_POOLURL "public-pool.io" #define DEFAULT_POOLURL "public-pool.io"
#define DEFAULT_POOLPASS "x"
#define DEFAULT_WALLETID "yourBtcAddress" #define DEFAULT_WALLETID "yourBtcAddress"
#define DEFAULT_POOLPORT 21496 #define DEFAULT_POOLPORT 21496
#define DEFAULT_TIMEZONE 2 #define DEFAULT_TIMEZONE 2
@ -21,6 +22,7 @@
#define JSON_KEY_SSID "SSID" #define JSON_KEY_SSID "SSID"
#define JSON_KEY_PASW "WifiPW" #define JSON_KEY_PASW "WifiPW"
#define JSON_KEY_POOLURL "PoolUrl" #define JSON_KEY_POOLURL "PoolUrl"
#define JSON_KEY_POOLPASS "PoolPassword"
#define JSON_KEY_WALLETID "BtcWallet" #define JSON_KEY_WALLETID "BtcWallet"
#define JSON_KEY_POOLPORT "PoolPort" #define JSON_KEY_POOLPORT "PoolPort"
#define JSON_KEY_TIMEZONE "Timezone" #define JSON_KEY_TIMEZONE "Timezone"
@ -29,6 +31,7 @@
// JSON config file SPIFFS (different for backward compatibility with existing devices) // JSON config file SPIFFS (different for backward compatibility with existing devices)
#define JSON_SPIFFS_KEY_POOLURL "poolString" #define JSON_SPIFFS_KEY_POOLURL "poolString"
#define JSON_SPIFFS_KEY_POOLPORT "portNumber" #define JSON_SPIFFS_KEY_POOLPORT "portNumber"
#define JSON_SPIFFS_KEY_POOLPASS "poolPassword"
#define JSON_SPIFFS_KEY_WALLETID "btcString" #define JSON_SPIFFS_KEY_WALLETID "btcString"
#define JSON_SPIFFS_KEY_TIMEZONE "gmtZone" #define JSON_SPIFFS_KEY_TIMEZONE "gmtZone"
#define JSON_SPIFFS_KEY_STATS2NV "saveStatsToNVS" #define JSON_SPIFFS_KEY_STATS2NV "saveStatsToNVS"
@ -40,6 +43,7 @@ struct TSettings
String WifiPW{ DEFAULT_WIFIPW }; String WifiPW{ DEFAULT_WIFIPW };
String PoolAddress{ DEFAULT_POOLURL }; String PoolAddress{ DEFAULT_POOLURL };
char BtcWallet[80]{ DEFAULT_WALLETID }; char BtcWallet[80]{ DEFAULT_WALLETID };
char PoolPassword[80]{ DEFAULT_POOLPASS };
int PoolPort{ DEFAULT_POOLPORT }; int PoolPort{ DEFAULT_POOLPORT };
int Timezone{ DEFAULT_TIMEZONE }; int Timezone{ DEFAULT_TIMEZONE };
bool saveStats{ DEFAULT_SAVESTATS }; bool saveStats{ DEFAULT_SAVESTATS };

View File

@ -167,7 +167,7 @@ void runStratumWorker(void *name) {
} }
strcpy(mWorker.wName, Settings.BtcWallet); strcpy(mWorker.wName, Settings.BtcWallet);
strcpy(mWorker.wPass, "x"); strcpy(mWorker.wPass, Settings.PoolPassword);
// STEP 2: Pool authorize work (Block Info) // STEP 2: Pool authorize work (Block Info)
tx_mining_auth(client, mWorker.wName, mWorker.wPass); //Don't verifies authoritzation, TODO 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 //tx_mining_auth2(client, mWorker.wName, mWorker.wPass); //Don't verifies authoritzation, TODO

View File

@ -134,6 +134,9 @@ void init_WifiManager()
// Text box (Number) - 7 characters maximum // Text box (Number) - 7 characters maximum
WiFiManagerParameter port_text_box_num("Poolport", "Pool port", convertedValue, 7); 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 // Text box (String) - 80 characters maximum
WiFiManagerParameter addr_text_box("btcAddress", "Your BTC address", Settings.BtcWallet, 80); WiFiManagerParameter addr_text_box("btcAddress", "Your BTC address", Settings.BtcWallet, 80);
@ -154,6 +157,7 @@ void init_WifiManager()
// Add all defined parameters // Add all defined parameters
wm.addParameter(&pool_text_box); wm.addParameter(&pool_text_box);
wm.addParameter(&port_text_box_num); wm.addParameter(&port_text_box_num);
wm.addParameter(&password_text_box);
wm.addParameter(&addr_text_box); wm.addParameter(&addr_text_box);
wm.addParameter(&time_text_box_num); wm.addParameter(&time_text_box_num);
wm.addParameter(&features_html); wm.addParameter(&features_html);
@ -173,6 +177,7 @@ void init_WifiManager()
Serial.println("failed to connect and hit timeout"); Serial.println("failed to connect and hit timeout");
Settings.PoolAddress = pool_text_box.getValue(); Settings.PoolAddress = pool_text_box.getValue();
Settings.PoolPort = atoi(port_text_box_num.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)); strncpy(Settings.BtcWallet, addr_text_box.getValue(), sizeof(Settings.BtcWallet));
Settings.Timezone = atoi(time_text_box_num.getValue()); Settings.Timezone = atoi(time_text_box_num.getValue());
Serial.println(save_stats_to_nvs.getValue()); Serial.println(save_stats_to_nvs.getValue());
@ -223,6 +228,11 @@ void init_WifiManager()
Serial.print("portNumber: "); Serial.print("portNumber: ");
Serial.println(Settings.PoolPort); 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 // Copy the string value
strncpy(Settings.BtcWallet, addr_text_box.getValue(), sizeof(Settings.BtcWallet)); strncpy(Settings.BtcWallet, addr_text_box.getValue(), sizeof(Settings.BtcWallet));
Serial.print("btcString: "); Serial.print("btcString: ");