From beb73a2eeacf7dbe5e292ce6e26a95a933808267 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 19 May 2026 04:13:11 +0530 Subject: feat(mining): integrate mining subsystem into existing modules - CMakeLists.txt: add 6 mining sources + tcp_transport dependency - config.h/c: mining_payout_mode_t enum, mining config fields, JSON parsing - tollgate_main.c: mining init in start_services(), stratum_client_tick in main loop - tollgate_api.c: GET /mining/job, POST /mining/share, GET /mining/stats endpoints - session.h/c: payment_method_t enum (CASHU/MINING/BYTES) - firewall.h/c: sandbox allowlist for mining port + mint URLs - tollgate_client.h/c: TG_CLIENT_MINING state, mining discovery tag parsing - captive_portal.c: tabbed UI with Cashu/Mine tabs, live hashrate polling --- main/tollgate_client.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'main/tollgate_client.c') diff --git a/main/tollgate_client.c b/main/tollgate_client.c index ac8dcfe..33b108e 100644 --- a/main/tollgate_client.c +++ b/main/tollgate_client.c @@ -126,15 +126,25 @@ static bool parse_discovery_response(const char *json_str, tollgate_discovery_t if (val && cJSON_IsString(val)) { out->step_size_ms = atoi(val->valuestring); } - } else if (strcmp(tag_name->valuestring, "price_per_step") == 0 && tag_len >= 6) { - cJSON *amount = cJSON_GetArrayItem(tag, 2); - cJSON *mint = cJSON_GetArrayItem(tag, 4); + } else if (strcmp(tag_name->valuestring, "price_per_step") == 0 && tag_len >= 4) { + cJSON *payment_type = cJSON_GetArrayItem(tag, 2); + + if (cJSON_IsString(payment_type) && strcmp(payment_type->valuestring, "mining") == 0 && tag_len >= 5) { + out->mining_available = true; + cJSON *port_val = cJSON_GetArrayItem(tag, 3); + if (port_val && cJSON_IsString(port_val)) { + out->mining_port = (uint16_t)atoi(port_val->valuestring); + } + } else { + cJSON *amount = cJSON_GetArrayItem(tag, 2); + cJSON *mint = cJSON_GetArrayItem(tag, 4); - if (amount && cJSON_IsString(amount)) { - out->price_per_step = atoi(amount->valuestring); - } - if (mint && cJSON_IsString(mint)) { - strncpy(out->mint_url, mint->valuestring, sizeof(out->mint_url) - 1); + if (amount && cJSON_IsString(amount)) { + out->price_per_step = atoi(amount->valuestring); + } + if (mint && cJSON_IsString(mint)) { + strncpy(out->mint_url, mint->valuestring, sizeof(out->mint_url) - 1); + } } } } -- cgit v1.2.3