upleb.uk

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

summaryrefslogtreecommitdiff
path: root/main/tollgate_client.c
diff options
context:
space:
mode:
authorYour Name <you@example.com>2026-05-19 04:13:11 +0530
committerYour Name <you@example.com>2026-05-19 04:13:11 +0530
commitbeb73a2eeacf7dbe5e292ce6e26a95a933808267 (patch)
tree3a9b711e1475c09ed544b96358587df3e5362555 /main/tollgate_client.c
parentc75230e551a778408b2e370b208aff76b74c6560 (diff)
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
Diffstat (limited to 'main/tollgate_client.c')
-rw-r--r--main/tollgate_client.c26
1 files changed, 18 insertions, 8 deletions
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
126 if (val && cJSON_IsString(val)) { 126 if (val && cJSON_IsString(val)) {
127 out->step_size_ms = atoi(val->valuestring); 127 out->step_size_ms = atoi(val->valuestring);
128 } 128 }
129 } else if (strcmp(tag_name->valuestring, "price_per_step") == 0 && tag_len >= 6) { 129 } else if (strcmp(tag_name->valuestring, "price_per_step") == 0 && tag_len >= 4) {
130 cJSON *amount = cJSON_GetArrayItem(tag, 2); 130 cJSON *payment_type = cJSON_GetArrayItem(tag, 2);
131 cJSON *mint = cJSON_GetArrayItem(tag, 4); 131
132 if (cJSON_IsString(payment_type) && strcmp(payment_type->valuestring, "mining") == 0 && tag_len >= 5) {
133 out->mining_available = true;
134 cJSON *port_val = cJSON_GetArrayItem(tag, 3);
135 if (port_val && cJSON_IsString(port_val)) {
136 out->mining_port = (uint16_t)atoi(port_val->valuestring);
137 }
138 } else {
139 cJSON *amount = cJSON_GetArrayItem(tag, 2);
140 cJSON *mint = cJSON_GetArrayItem(tag, 4);
132 141
133 if (amount && cJSON_IsString(amount)) { 142 if (amount && cJSON_IsString(amount)) {
134 out->price_per_step = atoi(amount->valuestring); 143 out->price_per_step = atoi(amount->valuestring);
135 } 144 }
136 if (mint && cJSON_IsString(mint)) { 145 if (mint && cJSON_IsString(mint)) {
137 strncpy(out->mint_url, mint->valuestring, sizeof(out->mint_url) - 1); 146 strncpy(out->mint_url, mint->valuestring, sizeof(out->mint_url) - 1);
147 }
138 } 148 }
139 } 149 }
140 } 150 }