From 508500d0c0311611d12af837396c2936b4ed47e7 Mon Sep 17 00:00:00 2001 From: Thomas Farstrike Date: Wed, 27 Nov 2024 08:08:30 +0100 Subject: [PATCH 01/16] Fix copy-paste typo --- lnpos/100_config.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lnpos/100_config.ino b/lnpos/100_config.ino index 5c6cb51..fc39c60 100644 --- a/lnpos/100_config.ino +++ b/lnpos/100_config.ino @@ -164,7 +164,7 @@ void readFiles() secretATM = getValue(lnurlATM, ',', 1); currencyATM = getValue(lnurlATM, ',', 2); Serial.println(""); - Serial.println("lnurlPoS: " + lnurlPoS); + Serial.println("lnurlATM: " + lnurlATM); if (secretATM != "") { menuItemCheck[3] = 1; From 10a4baccbf820d9c953407870e63230d0e15eae9 Mon Sep 17 00:00:00 2001 From: Thomas Farstrike Date: Fri, 6 Dec 2024 15:28:06 +0100 Subject: [PATCH 02/16] Extract various strings (no functionality change) This reduces copy-paste. --- lnpos/lnpos.ino | 48 ++++++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/lnpos/lnpos.ino b/lnpos/lnpos.ino index dbdb14f..2a81282 100644 --- a/lnpos/lnpos.ino +++ b/lnpos/lnpos.ino @@ -22,6 +22,18 @@ fs::SPIFFSFS &FlashFS = SPIFFS; #define KEY_FILE "/thekey.txt" #define USB_POWER 1000 // battery percentage sentinel value to indicate USB power +#define MENU_ITEM_RECEIVE_ONLINE "LNPoS" +#define MENU_ITEM_RECEIVE_OFFLINE "Offline PoS" +#define MENU_ITEM_RECEIVE_ONCHAIN "OnChain" +#define MENU_ITEM_SEND_OFFLINE "ATM" +#define MENU_ITEM_SETTINGS "Settings" + +#define DRAWING_EYES_OPEN "(o.o)" +#define DRAWING_EYES_CLOSED "(-.-)" + +#define FETCHING_FIAT_RATE "FETCHING FIAT RATE" +#define FETCHING_INVOICE "FETCHING INVOICE" + //////////SET TO TRUE TO WIPE MEMORY////////////// bool format = false; @@ -75,7 +87,7 @@ String amountToShow = "0"; String key_val; String selection; -const char menuItems[5][13] = {"LNPoS", "Offline PoS", "OnChain", "ATM", "Settings"}; +const char menuItems[5][13] = {MENU_ITEM_RECEIVE_ONLINE, MENU_ITEM_RECEIVE_OFFLINE, MENU_ITEM_RECEIVE_ONCHAIN, MENU_ITEM_SEND_OFFLINE, MENU_ITEM_SETTINGS}; const char currencyItems[3][5] = {"sat", "USD", "EUR"}; char decimalplacesOutput[20]; int menuItemCheck[5] = {0, 0, 0, 0, 1}; @@ -253,23 +265,23 @@ void loop() menuLoop(); } - if (selection == "LNPoS") + if (selection == MENU_ITEM_RECEIVE_ONLINE) { lnMain(); } - else if (selection == "OnChain") + else if (selection == MENU_ITEM_RECEIVE_ONCHAIN) { onchainMain(); } - else if (selection == "Offline PoS") + else if (selection == MENU_ITEM_RECEIVE_OFFLINE) { lnurlPoSMain(); } - else if (selection == "ATM") + else if (selection == MENU_ITEM_SEND_OFFLINE) { lnurlATMMain(); } - else if (selection == "Settings") + else if (selection == MENU_ITEM_SETTINGS) { accessPoint(); } @@ -455,10 +467,10 @@ void lnMain() currencyLoop(); } - processing("FETCHING FIAT RATE"); + processing(FETCHING_FIAT_RATE); if (!getSats()) { - error("FETCHING FIAT RATE FAILED"); + error(FETCHING_FIAT_RATE " FAILED"); delay(3000); return; } @@ -485,11 +497,11 @@ void lnMain() } // request invoice - processing("FETCHING INVOICE"); + processing(FETCHING_INVOICE); if (!getInvoice()) { unConfirmed = false; - error("ERROR FETCHING INVOICE"); + error("ERROR " FETCHING_INVOICE); delay(3000); break; } @@ -1603,7 +1615,7 @@ bool makeLNURL() float total = amountToShow.toFloat() * multipler; byte payload[51]; // 51 bytes is max one can get with xor-encryption - if (selection == "Offline PoS") + if (selection == MENU_ITEM_RECEIVE_OFFLINE) { size_t payload_len = xor_encrypt(payload, sizeof(payload), (uint8_t *)secretPoS.c_str(), secretPoS.length(), nonce, sizeof(nonce), randomPin, total); preparedURL = baseURLPoS + "?p="; @@ -1872,18 +1884,18 @@ bool isPoweredExternally() */ void sleepAnimation() { - printSleepAnimationFrame("(o.o)", 500); - printSleepAnimationFrame("(-.-)", 500); - printSleepAnimationFrame("(-.-)z", 250); - printSleepAnimationFrame("(-.-)zz", 250); - printSleepAnimationFrame("(-.-)zzz", 250); + printSleepAnimationFrame(DRAWING_EYES_OPEN, 500); + printSleepAnimationFrame(DRAWING_EYES_CLOSED, 500); + printSleepAnimationFrame(DRAWING_EYES_CLOSED "z", 250); + printSleepAnimationFrame(DRAWING_EYES_CLOSED "zz", 250); + printSleepAnimationFrame(DRAWING_EYES_CLOSED "zzz", 250); tft.fillScreen(TFT_BLACK); } void wakeAnimation() { - printSleepAnimationFrame("(-.-)", 100); - printSleepAnimationFrame("(o.o)", 200); + printSleepAnimationFrame(DRAWING_EYES_CLOSED, 100); + printSleepAnimationFrame(DRAWING_EYES_OPEN, 200); tft.fillScreen(TFT_BLACK); } From 3ab56ab549b9358698a00890ff1635864119c816 Mon Sep 17 00:00:00 2001 From: Thomas Farstrike Date: Fri, 6 Dec 2024 15:29:03 +0100 Subject: [PATCH 03/16] Fix typo bnrightness => brightness --- lnpos/lnpos.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lnpos/lnpos.ino b/lnpos/lnpos.ino index 2a81282..e446856 100644 --- a/lnpos/lnpos.ino +++ b/lnpos/lnpos.ino @@ -1839,13 +1839,13 @@ void handleBrightnessAdjust(String keyVal, InvoiceType invoiceType) // Handle screen brighten on QR screen if (keyVal == "1") { - Serial.println("Adjust bnrightness " + invoiceType); + Serial.println("Adjust brightness " + invoiceType); adjustQrBrightness(true, invoiceType); } // Handle screen dim on QR screen else if (keyVal == "4") { - Serial.println("Adjust bnrightness " + invoiceType); + Serial.println("Adjust brightness " + invoiceType); adjustQrBrightness(false, invoiceType); } } From 156ada84a3b1b48c833dfc9919468f2aab639dce Mon Sep 17 00:00:00 2001 From: Thomas Farstrike Date: Fri, 6 Dec 2024 17:12:27 +0100 Subject: [PATCH 04/16] Refactor "*MENU" into ASTERIX_MENU --- lnpos/lnpos.ino | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/lnpos/lnpos.ino b/lnpos/lnpos.ino index e446856..e31f7a9 100644 --- a/lnpos/lnpos.ino +++ b/lnpos/lnpos.ino @@ -28,6 +28,8 @@ fs::SPIFFSFS &FlashFS = SPIFFS; #define MENU_ITEM_SEND_OFFLINE "ATM" #define MENU_ITEM_SETTINGS "Settings" +#define ASTERIX_MENU "*MENU" + #define DRAWING_EYES_OPEN "(o.o)" #define DRAWING_EYES_CLOSED "(-.-)" @@ -417,7 +419,7 @@ void onchainMain() { HDPublicKey hd(masterKey); qrData = hd.derive(String("m/0/") + addressNo).address(); - qrShowCodeOnchain(true, " *MENU #CHECK"); + qrShowCodeOnchain(true, " " ASTERIX_MENU " #CHECK"); while (unConfirmed) { @@ -433,7 +435,7 @@ void onchainMain() while (unConfirmed) { qrData = "https://" + lnurlATMMS + "/address/" + qrData; - qrShowCodeOnchain(false, " *MENU"); + qrShowCodeOnchain(false, " " ASTERIX_MENU); while (unConfirmed) { @@ -604,7 +606,7 @@ void lnurlPoSMain() isLNURLMoneyNumber(true); continue; } - qrShowCodeLNURL(" *MENU #SHOW PIN"); + qrShowCodeLNURL(" " ASTERIX_MENU " #SHOW PIN"); while (unConfirmed) { @@ -691,7 +693,7 @@ void lnurlATMMain() isATMMoneyNumber(true); continue; } - qrShowCodeLNURL(" *MENU"); + qrShowCodeLNURL(" " ASTERIX_MENU); while (unConfirmed) { @@ -796,7 +798,7 @@ void isLNMoneyNumber(bool cleared) tft.println("SAT: "); tft.setCursor(0, 120); tft.setTextSize(2); - tft.println(" *MENU #INVOICE"); + tft.println(" " ASTERIX_MENU " #INVOICE"); if (!cleared) { @@ -834,7 +836,7 @@ void isLNURLMoneyNumber(bool cleared) tft.println(String(currencyPoS) + ": "); tft.setCursor(0, 120); tft.setTextSize(2); - tft.println(" *MENU #INVOICE"); + tft.println(" " ASTERIX_MENU " #INVOICE"); tft.setTextSize(3); if (!cleared) @@ -867,7 +869,7 @@ void isATMMoneyNumber(bool cleared) tft.println(String(currencyATM) + ": "); tft.setCursor(0, 120); tft.setTextSize(2); - tft.println(" *MENU #WITHDRAW"); + tft.println(" " ASTERIX_MENU " #WITHDRAW"); tft.setTextSize(3); if (!cleared) @@ -900,7 +902,7 @@ void isATMMoneyPin(bool cleared) tft.println("PIN:"); tft.setCursor(0, 120); tft.setTextSize(2); - tft.println(" *MENU #CLEAR"); + tft.println(" " ASTERIX_MENU " #CLEAR"); pinToShow = dataIn; String obscuredPinToShow = ""; @@ -933,7 +935,7 @@ void inputScreenOnChain() tft.setTextColor(TFT_WHITE, TFT_BLACK); tft.setTextSize(2); tft.setCursor(0, 120); - tft.println(" *MENU #ADDRESS"); + tft.println(" " ASTERIX_MENU " #ADDRESS"); } void qrShowCodeln() @@ -965,7 +967,7 @@ void qrShowCodeln() tft.setCursor(0, 220); tft.setTextSize(2); tft.setTextColor(TFT_BLACK, TFT_WHITE); - tft.print(" *MENU"); + tft.print(" " ASTERIX_MENU); } void qrShowCodeOnchain(bool anAddress, String message) @@ -1794,13 +1796,13 @@ void adjustQrBrightness(bool shouldMakeBrighter, InvoiceType invoiceType) qrShowCodeln(); break; case LNURLPOS: - qrShowCodeLNURL(" *MENU #SHOW PIN"); + qrShowCodeLNURL(" " ASTERIX_MENU " #SHOW PIN"); break; case ONCHAIN: - qrShowCodeOnchain(true, " *MENU #CHECK"); + qrShowCodeOnchain(true, " " ASTERIX_MENU " #CHECK"); break; case LNURLATM: - qrShowCodeLNURL(" *MENU"); + qrShowCodeLNURL(" " ASTERIX_MENU); break; default: break; From 6b7747dbf79160cc613b2878c081b20b228557ad Mon Sep 17 00:00:00 2001 From: Thomas Farstrike Date: Fri, 6 Dec 2024 17:17:29 +0100 Subject: [PATCH 05/16] Refactor out "#CHECK" and "#INVOICE" To reduce copy-paste. --- lnpos/lnpos.ino | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lnpos/lnpos.ino b/lnpos/lnpos.ino index e31f7a9..d56086e 100644 --- a/lnpos/lnpos.ino +++ b/lnpos/lnpos.ino @@ -29,6 +29,8 @@ fs::SPIFFSFS &FlashFS = SPIFFS; #define MENU_ITEM_SETTINGS "Settings" #define ASTERIX_MENU "*MENU" +#define HASH_CHECK "#CHECK" +#define HASH_INVOICE "#INVOICE" #define DRAWING_EYES_OPEN "(o.o)" #define DRAWING_EYES_CLOSED "(-.-)" @@ -419,7 +421,7 @@ void onchainMain() { HDPublicKey hd(masterKey); qrData = hd.derive(String("m/0/") + addressNo).address(); - qrShowCodeOnchain(true, " " ASTERIX_MENU " #CHECK"); + qrShowCodeOnchain(true, " " ASTERIX_MENU " " HASH_CHECK); while (unConfirmed) { @@ -798,7 +800,7 @@ void isLNMoneyNumber(bool cleared) tft.println("SAT: "); tft.setCursor(0, 120); tft.setTextSize(2); - tft.println(" " ASTERIX_MENU " #INVOICE"); + tft.println(" " ASTERIX_MENU " " HASH_INVOICE); if (!cleared) { @@ -836,7 +838,7 @@ void isLNURLMoneyNumber(bool cleared) tft.println(String(currencyPoS) + ": "); tft.setCursor(0, 120); tft.setTextSize(2); - tft.println(" " ASTERIX_MENU " #INVOICE"); + tft.println(" " ASTERIX_MENU " " HASH_INVOICE); tft.setTextSize(3); if (!cleared) @@ -1799,7 +1801,7 @@ void adjustQrBrightness(bool shouldMakeBrighter, InvoiceType invoiceType) qrShowCodeLNURL(" " ASTERIX_MENU " #SHOW PIN"); break; case ONCHAIN: - qrShowCodeOnchain(true, " " ASTERIX_MENU " #CHECK"); + qrShowCodeOnchain(true, " " ASTERIX_MENU " " HASH_CHECK); break; case LNURLATM: qrShowCodeLNURL(" " ASTERIX_MENU); From d5a889b5970409fe0d6464b85e561f5458a529f6 Mon Sep 17 00:00:00 2001 From: Thomas Farstrike Date: Fri, 6 Dec 2024 17:26:34 +0100 Subject: [PATCH 06/16] Improve some comments --- lnpos/lnpos.ino | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lnpos/lnpos.ino b/lnpos/lnpos.ino index d56086e..8012d00 100644 --- a/lnpos/lnpos.ino +++ b/lnpos/lnpos.ino @@ -22,6 +22,8 @@ fs::SPIFFSFS &FlashFS = SPIFFS; #define KEY_FILE "/thekey.txt" #define USB_POWER 1000 // battery percentage sentinel value to indicate USB power +// Strings that are used more than once are centralized here to avoid copy-paste, +// because they often cause bugs/inconsistencies due to changing one, but not the other(s). #define MENU_ITEM_RECEIVE_ONLINE "LNPoS" #define MENU_ITEM_RECEIVE_OFFLINE "Offline PoS" #define MENU_ITEM_RECEIVE_ONCHAIN "OnChain" @@ -38,9 +40,7 @@ fs::SPIFFSFS &FlashFS = SPIFFS; #define FETCHING_FIAT_RATE "FETCHING FIAT RATE" #define FETCHING_INVOICE "FETCHING INVOICE" -//////////SET TO TRUE TO WIPE MEMORY////////////// - -bool format = false; +bool format = false; // Set to true to wipe memory //////////////////////////////////////////////////////// ////////////LNPOS WILL LOOK FOR DETAILS SET///////////// @@ -48,7 +48,7 @@ bool format = false; ///////////OPTIONALLY SET HARDCODED DETAILS///////////// //////////////////////////////////////////////////////// -bool hardcoded = false; /// Set to true to hardcode +bool hardcoded = false; // Set to true to hardcode String lnurlPoS = "https://legend.lnbits.com/lnurldevice/api/v1/lnurl/WTmei,BzzoY5wbgpym3eMdb9ueXr,USD"; String lnurlATM = "https://legend.lnbits.com/lnurldevice/api/v1/lnurl/W5xu4,XGg4BJ3xCh36JdMKm2kgDw,USD"; From 005a05ff609a8ad8da8fc77657b7d7e94978aa67 Mon Sep 17 00:00:00 2001 From: Thomas Farstrike Date: Sun, 8 Dec 2024 16:48:33 +0100 Subject: [PATCH 07/16] Extract HTTP strings (no functionality change) This reduces copy-paste. --- lnpos/lnpos.ino | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lnpos/lnpos.ino b/lnpos/lnpos.ino index 8012d00..68ef22b 100644 --- a/lnpos/lnpos.ino +++ b/lnpos/lnpos.ino @@ -40,6 +40,10 @@ fs::SPIFFSFS &FlashFS = SPIFFS; #define FETCHING_FIAT_RATE "FETCHING FIAT RATE" #define FETCHING_INVOICE "FETCHING INVOICE" +#define HTTP_USER_AGENT "User-Agent: ESP32" +#define HTTP_CONTENT_TYPE "Content-Type: application/json" +#define HTTP_CONNECTION_CLOSE "Connection: close" + bool format = false; // Set to true to wipe memory //////////////////////////////////////////////////////// @@ -1439,7 +1443,7 @@ bool getSats() const String toPost = "{\"amount\" : 1, \"from\" :\"" + String(lncurrencyChar) + "\"}"; const String url = "/api/v1/conversion"; - client.print(String("POST ") + url + " HTTP/1.1\r\n" + "Host: " + String(lnbitsServerChar) + "\r\n" + "User-Agent: ESP32\r\n" + "X-Api-Key: " + String(invoiceChar) + " \r\n" + "Content-Type: application/json\r\n" + "Connection: close\r\n" + "Content-Length: " + toPost.length() + "\r\n" + "\r\n" + toPost + "\n"); + client.print(String("POST ") + url + " HTTP/1.1\r\n" + "Host: " + String(lnbitsServerChar) + "\r\n" HTTP_USER_AGENT "\r\n" "X-Api-Key: " + String(invoiceChar) + " \r\n" HTTP_CONTENT_TYPE "\r\n" HTTP_CONNECTION_CLOSE "\r\n" + "Content-Length: " + toPost.length() + "\r\n" + "\r\n" + toPost + "\n"); while (client.connected()) { @@ -1487,7 +1491,7 @@ bool getInvoice() const String toPost = "{\"out\": false,\"amount\" : " + String(noSats.toInt()) + ", \"memo\" :\"LNPoS-" + String(random(1, 1000)) + "\"}"; const String url = "/api/v1/payments"; - client.print(String("POST ") + url + " HTTP/1.1\r\n" + "Host: " + lnbitsServerChar + "\r\n" + "User-Agent: ESP32\r\n" + "X-Api-Key: " + invoiceChar + " \r\n" + "Content-Type: application/json\r\n" + "Connection: close\r\n" + "Content-Length: " + toPost.length() + "\r\n" + "\r\n" + toPost + "\n"); + client.print(String("POST ") + url + " HTTP/1.1\r\n" + "Host: " + lnbitsServerChar + "\r\n" HTTP_USER_AGENT "\r\n" "X-Api-Key: " + invoiceChar + " \r\n" HTTP_CONTENT_TYPE "\r\n" + HTTP_CONNECTION_CLOSE "\r\n" + "Content-Length: " + toPost.length() + "\r\n" + "\r\n" + toPost + "\n"); while (client.connected()) { @@ -1533,7 +1537,7 @@ bool checkInvoice() } const String url = "/api/v1/payments/"; - client.print(String("GET ") + url + dataId + " HTTP/1.1\r\n" + "Host: " + lnbitsServerChar + "\r\n" + "User-Agent: ESP32\r\n" + "Content-Type: application/json\r\n" + "Connection: close\r\n\r\n"); + client.print(String("GET ") + url + dataId + " HTTP/1.1\r\n" + "Host: " + lnbitsServerChar + "\r\n" HTTP_USER_AGENT "\r\n" + HTTP_CONTENT_TYPE "\r\n" + HTTP_CONNECTION_CLOSE "\r\n\r\n"); while (client.connected()) { const String line = client.readStringUntil('\n'); From 1d895d43760b48a27549418ecb453920ddea0968 Mon Sep 17 00:00:00 2001 From: Thomas Farstrike Date: Sun, 8 Dec 2024 16:49:20 +0100 Subject: [PATCH 08/16] Fix LNBits conversion API call It was always returning "sats": 1 and it turned out that's because it should be "from_" (and not "from") as stated in the docs. --- lnpos/lnpos.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lnpos/lnpos.ino b/lnpos/lnpos.ino index 68ef22b..d1a8c93 100644 --- a/lnpos/lnpos.ino +++ b/lnpos/lnpos.ino @@ -1441,7 +1441,7 @@ bool getSats() return false; } - const String toPost = "{\"amount\" : 1, \"from\" :\"" + String(lncurrencyChar) + "\"}"; + const String toPost = "{\"amount\" : 1, \"from_\" :\"" + String(lncurrencyChar) + "\", \"to\": \"sats\"}"; const String url = "/api/v1/conversion"; client.print(String("POST ") + url + " HTTP/1.1\r\n" + "Host: " + String(lnbitsServerChar) + "\r\n" HTTP_USER_AGENT "\r\n" "X-Api-Key: " + String(invoiceChar) + " \r\n" HTTP_CONTENT_TYPE "\r\n" HTTP_CONNECTION_CLOSE "\r\n" + "Content-Length: " + toPost.length() + "\r\n" + "\r\n" + toPost + "\n"); @@ -1455,6 +1455,7 @@ bool getSats() } const String line = client.readString(); + Serial.println("POST of " + toPost + " to /api/v1/conversion returned: " + line); StaticJsonDocument<150> doc; DeserializationError error = deserializeJson(doc, line); if (error) From 35face5e0d3aec7b0d578599892be66a0c78b528 Mon Sep 17 00:00:00 2001 From: Thomas Farstrike Date: Sun, 8 Dec 2024 16:55:03 +0100 Subject: [PATCH 09/16] Improve menu spacing layout --- lnpos/lnpos.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lnpos/lnpos.ino b/lnpos/lnpos.ino index d1a8c93..052d22e 100644 --- a/lnpos/lnpos.ino +++ b/lnpos/lnpos.ino @@ -1298,7 +1298,7 @@ void menuLoop() menuItemNo++; } - tft.setCursor(0, 40); + tft.setCursor(0, 30); tft.setTextSize(2); int current = 0; From 62105660bbd63926ff180141fc4767594f763aee Mon Sep 17 00:00:00 2001 From: Thomas Farstrike Date: Sun, 8 Dec 2024 16:55:42 +0100 Subject: [PATCH 10/16] Remove 2 unnecessary casts --- lnpos/lnpos.ino | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lnpos/lnpos.ino b/lnpos/lnpos.ino index 052d22e..12f57e3 100644 --- a/lnpos/lnpos.ino +++ b/lnpos/lnpos.ino @@ -1432,7 +1432,6 @@ bool getSats() } const char *lnbitsServerChar = lnbitsServer.c_str(); const char *invoiceChar = invoice.c_str(); - const char *lncurrencyChar = lncurrency.c_str(); Serial.println("connecting to LNbits server " + lnbitsServer); if (!client.connect(lnbitsServerChar, 443)) @@ -1441,7 +1440,7 @@ bool getSats() return false; } - const String toPost = "{\"amount\" : 1, \"from_\" :\"" + String(lncurrencyChar) + "\", \"to\": \"sats\"}"; + const String toPost = "{\"amount\" : 1, \"from_\" :\"" + lncurrency + "\", \"to\": \"sats\"}"; const String url = "/api/v1/conversion"; client.print(String("POST ") + url + " HTTP/1.1\r\n" + "Host: " + String(lnbitsServerChar) + "\r\n" HTTP_USER_AGENT "\r\n" "X-Api-Key: " + String(invoiceChar) + " \r\n" HTTP_CONTENT_TYPE "\r\n" HTTP_CONNECTION_CLOSE "\r\n" + "Content-Length: " + toPost.length() + "\r\n" + "\r\n" + toPost + "\n"); From e0061267cc37d61799d59473ccd3f5cdc9ad1d55 Mon Sep 17 00:00:00 2001 From: Thomas Farstrike Date: Sun, 8 Dec 2024 17:09:01 +0100 Subject: [PATCH 11/16] Add FIXME --- lnpos/lnpos.ino | 1 + 1 file changed, 1 insertion(+) diff --git a/lnpos/lnpos.ino b/lnpos/lnpos.ino index 12f57e3..54a54aa 100644 --- a/lnpos/lnpos.ino +++ b/lnpos/lnpos.ino @@ -1274,6 +1274,7 @@ void currencyLoop() void menuLoop() { // footer/header + // FIXME: after a "pretend sleep", this 'header' isn't drawn tft.fillScreen(TFT_BLACK); tft.setTextSize(2); tft.setCursor(0, 10); From 12f721ab83dedfe47c6924153b701f0a059cb4db Mon Sep 17 00:00:00 2001 From: Thomas Farstrike Date: Sun, 8 Dec 2024 17:11:15 +0100 Subject: [PATCH 12/16] Move variable up --- lnpos/lnpos.ino | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lnpos/lnpos.ino b/lnpos/lnpos.ino index 54a54aa..cf92a7c 100644 --- a/lnpos/lnpos.ino +++ b/lnpos/lnpos.ino @@ -22,6 +22,10 @@ fs::SPIFFSFS &FlashFS = SPIFFS; #define KEY_FILE "/thekey.txt" #define USB_POWER 1000 // battery percentage sentinel value to indicate USB power +//////////SET TO TRUE TO WIPE MEMORY////////////// + +bool format = false; + // Strings that are used more than once are centralized here to avoid copy-paste, // because they often cause bugs/inconsistencies due to changing one, but not the other(s). #define MENU_ITEM_RECEIVE_ONLINE "LNPoS" From b58007e513ef84c431803c65c573bff8919aa946 Mon Sep 17 00:00:00 2001 From: Thomas Farstrike Date: Sun, 8 Dec 2024 17:15:32 +0100 Subject: [PATCH 13/16] Minimize diff --- lnpos/lnpos.ino | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lnpos/lnpos.ino b/lnpos/lnpos.ino index cf92a7c..bb06d3e 100644 --- a/lnpos/lnpos.ino +++ b/lnpos/lnpos.ino @@ -48,15 +48,14 @@ bool format = false; #define HTTP_CONTENT_TYPE "Content-Type: application/json" #define HTTP_CONNECTION_CLOSE "Connection: close" -bool format = false; // Set to true to wipe memory - //////////////////////////////////////////////////////// ////////////LNPOS WILL LOOK FOR DETAILS SET///////////// ////////OVER THE WEBINSTALLER CONFIG, HOWEVER/////////// ///////////OPTIONALLY SET HARDCODED DETAILS///////////// //////////////////////////////////////////////////////// -bool hardcoded = false; // Set to true to hardcode + +bool hardcoded = false; /// Set to true to hardcode String lnurlPoS = "https://legend.lnbits.com/lnurldevice/api/v1/lnurl/WTmei,BzzoY5wbgpym3eMdb9ueXr,USD"; String lnurlATM = "https://legend.lnbits.com/lnurldevice/api/v1/lnurl/W5xu4,XGg4BJ3xCh36JdMKm2kgDw,USD"; From 09282a9798f04fd7446f966a8c14ec93e2a130eb Mon Sep 17 00:00:00 2001 From: Thomas Farstrike Date: Sun, 8 Dec 2024 17:22:35 +0100 Subject: [PATCH 14/16] Improve menu items for clarity Notice users that just want to receive payments don't know the difference between the old menu items: LNPoS vs Offline PoS vs OnChain... In the case of non-native English speakers, they don't even know what a PoS is. Replacing these with "Receive Online", "Receive Offline" and "Receive OnChain" makes it much clearer of what they will do and how they will do it. --- lnpos/lnpos.ino | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lnpos/lnpos.ino b/lnpos/lnpos.ino index bb06d3e..cc115c8 100644 --- a/lnpos/lnpos.ino +++ b/lnpos/lnpos.ino @@ -28,9 +28,9 @@ bool format = false; // Strings that are used more than once are centralized here to avoid copy-paste, // because they often cause bugs/inconsistencies due to changing one, but not the other(s). -#define MENU_ITEM_RECEIVE_ONLINE "LNPoS" -#define MENU_ITEM_RECEIVE_OFFLINE "Offline PoS" -#define MENU_ITEM_RECEIVE_ONCHAIN "OnChain" +#define MENU_ITEM_RECEIVE_ONLINE "Receive Online" +#define MENU_ITEM_RECEIVE_OFFLINE "Receive Offline" +#define MENU_ITEM_RECEIVE_ONCHAIN "Receive OnChain" #define MENU_ITEM_SEND_OFFLINE "ATM" #define MENU_ITEM_SETTINGS "Settings" @@ -98,7 +98,7 @@ String amountToShow = "0"; String key_val; String selection; -const char menuItems[5][13] = {MENU_ITEM_RECEIVE_ONLINE, MENU_ITEM_RECEIVE_OFFLINE, MENU_ITEM_RECEIVE_ONCHAIN, MENU_ITEM_SEND_OFFLINE, MENU_ITEM_SETTINGS}; +const char menuItems[5][16] = {MENU_ITEM_RECEIVE_ONLINE, MENU_ITEM_RECEIVE_OFFLINE, MENU_ITEM_RECEIVE_ONCHAIN, MENU_ITEM_SEND_OFFLINE, MENU_ITEM_SETTINGS}; const char currencyItems[3][5] = {"sat", "USD", "EUR"}; char decimalplacesOutput[20]; int menuItemCheck[5] = {0, 0, 0, 0, 1}; From f79356e42596c17377f83df2d6e49d5a75004cdb Mon Sep 17 00:00:00 2001 From: Thomas Farstrike Date: Tue, 10 Dec 2024 15:03:14 +0100 Subject: [PATCH 15/16] Rename "ATM" to more explicit "Send Offline" This menu option is used to send Bitcoin over the Lightning network in an offline manner, using LNURL-withdraw. Only US English speakers use the expression "ATM", as Canadians use "ABM", while the British call them cashpoints or cash machines. Non-English speakers also use different names, such as 'geldautomaat' in Flanders or 'pinautomaat' in the Netherlands. The "Send Offline" functionality *can* be used to sell Bitcoin, not unlike Automated Teller Machine, although in this case it's the opposite of automated, as it's very much human operated. But this functionality might just as well be used to withdraw funds from the device, or to refund a customer. Therefore, it's more clear and in line with the other menu items to rename "ATM" to simply "Send Offline". --- lnpos/lnpos.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lnpos/lnpos.ino b/lnpos/lnpos.ino index cc115c8..4de372f 100644 --- a/lnpos/lnpos.ino +++ b/lnpos/lnpos.ino @@ -31,7 +31,7 @@ bool format = false; #define MENU_ITEM_RECEIVE_ONLINE "Receive Online" #define MENU_ITEM_RECEIVE_OFFLINE "Receive Offline" #define MENU_ITEM_RECEIVE_ONCHAIN "Receive OnChain" -#define MENU_ITEM_SEND_OFFLINE "ATM" +#define MENU_ITEM_SEND_OFFLINE "Send Offline" #define MENU_ITEM_SETTINGS "Settings" #define ASTERIX_MENU "*MENU" From 518f084d80d741724bf428d0b8c39a8efd153aa4 Mon Sep 17 00:00:00 2001 From: Thomas Farstrike Date: Tue, 10 Dec 2024 15:32:49 +0100 Subject: [PATCH 16/16] Update CHANGELOG.md --- lnpos/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lnpos/CHANGELOG.md b/lnpos/CHANGELOG.md index c00f84e..f4ceaec 100644 --- a/lnpos/CHANGELOG.md +++ b/lnpos/CHANGELOG.md @@ -5,3 +5,5 @@ - Show a little "arrow" in front of the selected menu item to avoid ambiguity when only 2 menu items are present (or when the user is color blind) - Make "USB" indicator blue so it looks better and is easier to distinguish - Show firmware version at boot to allow the user to easily check which version is running (handy for troubleshooting) +- Fix fiat conversion API call compatibility with LNBits +- Change "LNPoS", "Offline PoS", "OnChain" and "ATM" menu items to more explicit "Receive Online", "Receive Offline", "Receive OnChain" and "Send Offline"