upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYour Name <you@example.com>2026-05-19 04:12:32 +0530
committerYour Name <you@example.com>2026-05-19 04:12:32 +0530
commit3aa372ccc3e11c837458b00088ffb6cbe99ff6ca (patch)
treed0cea8925e1908c4ea5e90096f4d48b9cfee2ce7
parentd0a99d8a92b762187d3d638c9a705d4b891f6ead (diff)
fix: merge readiness — display_enabled config, real pubkey, probe interval, dedup services
- Add display_enabled config field (default true, parsed from config.json) - Guard display_init/display_update behind display_enabled check - Fix discovery pubkey: replace hardcoded all-zeros with identity_get()->npub_hex - Revert MINT_HEALTH_PROBE_INTERVAL_S from 30 (testing) to 300 (production) - Remove duplicate services_start_task call in IP event handler - Fix UTF-8 arrow in STA auth threshold log message - Gitignore compiled test binaries (test_mcp_handler, test_mint_health, etc.) - Remove tracked test binaries from git Verified on Board B (stable): - make test-discovery-b: pubkey=d6bfe100..., metric=milliseconds, price_per_step tags - make test-mints-b: 4 mints listed with reachable field - Wallet: 40 sats balance with 4 proofs from previous payment - All API endpoints responding (discovery, mints, wallet, whoami, portal) - 75/75 unit tests passing
-rw-r--r--.gitignore7
-rw-r--r--main/config.c6
-rw-r--r--main/config.h1
-rw-r--r--main/mint_health.h2
-rw-r--r--main/tollgate_api.c9
-rw-r--r--main/tollgate_main.c20
-rwxr-xr-xtests/unit/test_cvm_serverbin45728 -> 0 bytes
-rwxr-xr-xtests/unit/test_lightning_payoutbin20560 -> 0 bytes
-rwxr-xr-xtests/unit/test_lnurl_paybin21312 -> 0 bytes
-rwxr-xr-xtests/unit/test_mcp_handlerbin63056 -> 0 bytes
-rwxr-xr-xtests/unit/test_mint_healthbin36792 -> 0 bytes
-rwxr-xr-xtests/unit/test_nip04bin298792 -> 0 bytes
-rwxr-xr-xtests/unit/test_tollgate_clientbin52072 -> 0 bytes
13 files changed, 32 insertions, 13 deletions
diff --git a/.gitignore b/.gitignore
index b2f1400..80cd5ed 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,4 +19,11 @@ tests/unit/test_identity
19tests/unit/test_nostr_event 19tests/unit/test_nostr_event
20tests/unit/test_cashu 20tests/unit/test_cashu
21tests/unit/test_session 21tests/unit/test_session
22tests/unit/test_mcp_handler
23tests/unit/test_mint_health
24tests/unit/test_tollgate_client
25tests/unit/test_cvm_server
26tests/unit/test_lnurl_pay
27tests/unit/test_lightning_payout
28tests/unit/test_nip04
22interop/routers.env 29interop/routers.env
diff --git a/main/config.c b/main/config.c
index fe0ceba..22b26da 100644
--- a/main/config.c
+++ b/main/config.c
@@ -36,6 +36,7 @@ esp_err_t tollgate_config_init(void)
36 g_config.cvm_enabled = true; 36 g_config.cvm_enabled = true;
37 strncpy(g_config.cvm_relays, "wss://relay.primal.net", sizeof(g_config.cvm_relays) - 1); 37 strncpy(g_config.cvm_relays, "wss://relay.primal.net", sizeof(g_config.cvm_relays) - 1);
38 strncpy(g_config.wifi_auth_mode, "WPA2", sizeof(g_config.wifi_auth_mode) - 1); 38 strncpy(g_config.wifi_auth_mode, "WPA2", sizeof(g_config.wifi_auth_mode) - 1);
39 g_config.display_enabled = true;
39 40
40 esp_vfs_spiffs_conf_t conf = { 41 esp_vfs_spiffs_conf_t conf = {
41 .base_path = "/spiffs", 42 .base_path = "/spiffs",
@@ -278,6 +279,9 @@ esp_err_t tollgate_config_init(void)
278 strncpy(g_config.wifi_auth_mode, auth_mode->valuestring, sizeof(g_config.wifi_auth_mode) - 1); 279 strncpy(g_config.wifi_auth_mode, auth_mode->valuestring, sizeof(g_config.wifi_auth_mode) - 1);
279 } 280 }
280 281
282 cJSON *disp_en = cJSON_GetObjectItem(root, "display_enabled");
283 if (disp_en && cJSON_IsBool(disp_en)) g_config.display_enabled = cJSON_IsTrue(disp_en);
284
281 if (g_config.payout.mint_count == 0 && g_config.mint_url[0] != '\0') { 285 if (g_config.payout.mint_count == 0 && g_config.mint_url[0] != '\0') {
282 strncpy(g_config.payout.mints[0].url, g_config.mint_url, 286 strncpy(g_config.payout.mints[0].url, g_config.mint_url,
283 sizeof(g_config.payout.mints[0].url) - 1); 287 sizeof(g_config.payout.mints[0].url) - 1);
@@ -331,7 +335,7 @@ esp_err_t tollgate_config_get_wifi(wifi_config_t *wifi_config)
331 } else if (strstr(g_config.wifi_auth_mode, "WPA2")) { 335 } else if (strstr(g_config.wifi_auth_mode, "WPA2")) {
332 wifi_config->sta.threshold.authmode = WIFI_AUTH_WPA2_PSK; 336 wifi_config->sta.threshold.authmode = WIFI_AUTH_WPA2_PSK;
333 } 337 }
334 ESP_LOGI(TAG, "STA auth threshold: %s %d", g_config.wifi_auth_mode, wifi_config->sta.threshold.authmode); 338 ESP_LOGI(TAG, "STA auth threshold: %s -> %d", g_config.wifi_auth_mode, wifi_config->sta.threshold.authmode);
335 return ESP_OK; 339 return ESP_OK;
336} 340}
337 341
diff --git a/main/config.h b/main/config.h
index 1a32cc2..18dfc66 100644
--- a/main/config.h
+++ b/main/config.h
@@ -67,6 +67,7 @@ typedef struct {
67 char cvm_relays[256]; 67 char cvm_relays[256];
68 68
69 char wifi_auth_mode[16]; 69 char wifi_auth_mode[16];
70 bool display_enabled;
70} tollgate_config_t; 71} tollgate_config_t;
71 72
72void tollgate_config_derive_unique(tollgate_config_t *cfg); 73void tollgate_config_derive_unique(tollgate_config_t *cfg);
diff --git a/main/mint_health.h b/main/mint_health.h
index 4e9a5a7..f047d6a 100644
--- a/main/mint_health.h
+++ b/main/mint_health.h
@@ -6,7 +6,7 @@
6#include <stdbool.h> 6#include <stdbool.h>
7 7
8#define MINT_HEALTH_MAX 8 8#define MINT_HEALTH_MAX 8
9#define MINT_HEALTH_PROBE_INTERVAL_S 30 9#define MINT_HEALTH_PROBE_INTERVAL_S 300
10#define MINT_HEALTH_PROBE_TIMEOUT_MS 15000 10#define MINT_HEALTH_PROBE_TIMEOUT_MS 15000
11#define MINT_HEALTH_RECOVERY_THRESHOLD 3 11#define MINT_HEALTH_RECOVERY_THRESHOLD 3
12 12
diff --git a/main/tollgate_api.c b/main/tollgate_api.c
index 997dd09..0120003 100644
--- a/main/tollgate_api.c
+++ b/main/tollgate_api.c
@@ -1,6 +1,7 @@
1#include "tollgate_api.h" 1#include "tollgate_api.h"
2#include "cashu.h" 2#include "cashu.h"
3#include "config.h" 3#include "config.h"
4#include "identity.h"
4#include "session.h" 5#include "session.h"
5#include "firewall.h" 6#include "firewall.h"
6#include "nucula_wallet.h" 7#include "nucula_wallet.h"
@@ -16,8 +17,6 @@
16static const char *TAG = "tollgate_api"; 17static const char *TAG = "tollgate_api";
17static httpd_handle_t s_api_server = NULL; 18static httpd_handle_t s_api_server = NULL;
18 19
19static const char *TOLLGATE_PUBKEY = "0000000000000000000000000000000000000000000000000000000000000000";
20
21static esp_err_t get_client_ip(httpd_req_t *req, uint32_t *ip_out) 20static esp_err_t get_client_ip(httpd_req_t *req, uint32_t *ip_out)
22{ 21{
23 int sockfd = httpd_req_to_sockfd(req); 22 int sockfd = httpd_req_to_sockfd(req);
@@ -34,7 +33,7 @@ static cJSON *create_notice(const char *level, const char *code, const char *con
34{ 33{
35 cJSON *root = cJSON_CreateObject(); 34 cJSON *root = cJSON_CreateObject();
36 cJSON_AddNumberToObject(root, "kind", 21023); 35 cJSON_AddNumberToObject(root, "kind", 21023);
37 cJSON_AddStringToObject(root, "pubkey", TOLLGATE_PUBKEY); 36 cJSON_AddStringToObject(root, "pubkey", identity_get()->npub_hex);
38 cJSON *tags = cJSON_CreateArray(); 37 cJSON *tags = cJSON_CreateArray();
39 cJSON *level_tag = cJSON_CreateArray(); 38 cJSON *level_tag = cJSON_CreateArray();
40 cJSON_AddItemToArray(level_tag, cJSON_CreateString("level")); 39 cJSON_AddItemToArray(level_tag, cJSON_CreateString("level"));
@@ -53,7 +52,7 @@ static cJSON *create_session_event(uint32_t client_ip, uint64_t allotment_ms)
53{ 52{
54 cJSON *root = cJSON_CreateObject(); 53 cJSON *root = cJSON_CreateObject();
55 cJSON_AddNumberToObject(root, "kind", 1022); 54 cJSON_AddNumberToObject(root, "kind", 1022);
56 cJSON_AddStringToObject(root, "pubkey", TOLLGATE_PUBKEY); 55 cJSON_AddStringToObject(root, "pubkey", identity_get()->npub_hex);
57 56
58 cJSON *tags = cJSON_CreateArray(); 57 cJSON *tags = cJSON_CreateArray();
59 58
@@ -95,7 +94,7 @@ static esp_err_t api_get_discovery(httpd_req_t *req)
95 94
96 cJSON *root = cJSON_CreateObject(); 95 cJSON *root = cJSON_CreateObject();
97 cJSON_AddNumberToObject(root, "kind", 10021); 96 cJSON_AddNumberToObject(root, "kind", 10021);
98 cJSON_AddStringToObject(root, "pubkey", TOLLGATE_PUBKEY); 97 cJSON_AddStringToObject(root, "pubkey", identity_get()->npub_hex);
99 98
100 cJSON *tags = cJSON_CreateArray(); 99 cJSON *tags = cJSON_CreateArray();
101 100
diff --git a/main/tollgate_main.c b/main/tollgate_main.c
index e81ba7b..15791a3 100644
--- a/main/tollgate_main.c
+++ b/main/tollgate_main.c
@@ -108,8 +108,6 @@ static void ip_event_handler(void *arg, esp_event_base_t event_base,
108 char gw_ip_str[16]; 108 char gw_ip_str[16];
109 snprintf(gw_ip_str, sizeof(gw_ip_str), IPSTR, IP2STR(&event->ip_info.gw)); 109 snprintf(gw_ip_str, sizeof(gw_ip_str), IPSTR, IP2STR(&event->ip_info.gw));
110 tollgate_client_on_sta_connected(gw_ip_str); 110 tollgate_client_on_sta_connected(gw_ip_str);
111
112 xTaskCreate(services_start_task, "svc_start", 32768, NULL, 5, NULL);
113 } else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_LOST_IP) { 111 } else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_LOST_IP) {
114 ESP_LOGW(TAG, "Lost IP address"); 112 ESP_LOGW(TAG, "Lost IP address");
115 xEventGroupClearBits(s_wifi_event_group, WIFI_CONNECTED_BIT); 113 xEventGroupClearBits(s_wifi_event_group, WIFI_CONNECTED_BIT);
@@ -178,6 +176,13 @@ static void start_services(void)
178 s_services_running = true; 176 s_services_running = true;
179 if (s_services_mutex) xSemaphoreGive(s_services_mutex); 177 if (s_services_mutex) xSemaphoreGive(s_services_mutex);
180 ESP_LOGI(TAG, "=== TollGate services started ==="); 178 ESP_LOGI(TAG, "=== TollGate services started ===");
179
180 if (cfg->display_enabled) {
181 display_set_state(DISPLAY_READY);
182 char portal_url[128];
183 snprintf(portal_url, sizeof(portal_url), "http://%s/", cfg->ap_ip_str);
184 display_update(cfg->ap_ssid, 0, 0, portal_url);
185 }
181} 186}
182 187
183static void stop_services(void) 188static void stop_services(void)
@@ -259,9 +264,6 @@ void app_main(void)
259{ 264{
260 ESP_LOGI(TAG, "=== TollGate ESP32 Starting ==="); 265 ESP_LOGI(TAG, "=== TollGate ESP32 Starting ===");
261 266
262 ESP_LOGW(TAG, "Display disabled for stability testing");
263
264
265 esp_err_t ret = nvs_flash_init(); 267 esp_err_t ret = nvs_flash_init();
266 if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) { 268 if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
267 ESP_ERROR_CHECK(nvs_flash_erase()); 269 ESP_ERROR_CHECK(nvs_flash_erase());
@@ -271,7 +273,13 @@ void app_main(void)
271 273
272 ESP_ERROR_CHECK(tollgate_config_init()); 274 ESP_ERROR_CHECK(tollgate_config_init());
273 275
274 ESP_ERROR_CHECK(identity_init(tollgate_config_get()->nsec)); 276 const tollgate_config_t *init_cfg = tollgate_config_get();
277 if (init_cfg->display_enabled) {
278 display_init();
279 display_set_state(DISPLAY_BOOT);
280 }
281
282 ESP_ERROR_CHECK(identity_init(init_cfg->nsec));
275 283
276 tollgate_config_derive_unique((tollgate_config_t *)tollgate_config_get()); 284 tollgate_config_derive_unique((tollgate_config_t *)tollgate_config_get());
277 285
diff --git a/tests/unit/test_cvm_server b/tests/unit/test_cvm_server
deleted file mode 100755
index 8f0b605..0000000
--- a/tests/unit/test_cvm_server
+++ /dev/null
Binary files differ
diff --git a/tests/unit/test_lightning_payout b/tests/unit/test_lightning_payout
deleted file mode 100755
index c6aaa5f..0000000
--- a/tests/unit/test_lightning_payout
+++ /dev/null
Binary files differ
diff --git a/tests/unit/test_lnurl_pay b/tests/unit/test_lnurl_pay
deleted file mode 100755
index 61c9743..0000000
--- a/tests/unit/test_lnurl_pay
+++ /dev/null
Binary files differ
diff --git a/tests/unit/test_mcp_handler b/tests/unit/test_mcp_handler
deleted file mode 100755
index a001641..0000000
--- a/tests/unit/test_mcp_handler
+++ /dev/null
Binary files differ
diff --git a/tests/unit/test_mint_health b/tests/unit/test_mint_health
deleted file mode 100755
index 2a48ad2..0000000
--- a/tests/unit/test_mint_health
+++ /dev/null
Binary files differ
diff --git a/tests/unit/test_nip04 b/tests/unit/test_nip04
deleted file mode 100755
index cbf4c80..0000000
--- a/tests/unit/test_nip04
+++ /dev/null
Binary files differ
diff --git a/tests/unit/test_tollgate_client b/tests/unit/test_tollgate_client
deleted file mode 100755
index 8077223..0000000
--- a/tests/unit/test_tollgate_client
+++ /dev/null
Binary files differ