upleb.uk

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

summaryrefslogtreecommitdiff
path: root/main/config.c
diff options
context:
space:
mode:
authorYour Name <you@example.com>2026-05-17 04:21:39 +0530
committerYour Name <you@example.com>2026-05-17 04:21:39 +0530
commit78dd599277b8e8b2ddc39a4ae710ec91d737272e (patch)
tree9fbd89695cede00b8ff3b12ce428e96a2aa70e9b /main/config.c
parentb0d7394e089f00a9ffa67a2b33a502e47b778a93 (diff)
Phase 4: TollGate client detection + auto-payment
- New tollgate_client.c/h: detect upstream TollGate (kind=10021), auto-pay via nucula wallet, session monitoring with 20% renewal - State machine: IDLE→DETECTING→NEEDS_PAY→PAYING→PAID→RENEWING - Blocking: upstream payment before local services start - Synchronous wallet init (was async task) - Client config: enabled, steps_to_buy, renewal_threshold_pct - Updated PLAN.md with Phases 4-7 (client, payout, bytes, CVM) - Updated CHECKLIST.md with all new phase items - 30 new unit tests (all passing), 116 total
Diffstat (limited to 'main/config.c')
-rw-r--r--main/config.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/main/config.c b/main/config.c
index 47d631f..c074410 100644
--- a/main/config.c
+++ b/main/config.c
@@ -22,6 +22,10 @@ esp_err_t tollgate_config_init(void)
22 g_config.step_size_ms = 60000; 22 g_config.step_size_ms = 60000;
23 g_config.persist_threshold_sats = 1; 23 g_config.persist_threshold_sats = 1;
24 g_config.nostr_publish_interval_s = 21600; 24 g_config.nostr_publish_interval_s = 21600;
25 g_config.client_enabled = false;
26 g_config.client_steps_to_buy = 1;
27 g_config.client_renewal_threshold_pct = 20;
28 g_config.client_retry_interval_ms = 30000;
25 29
26 esp_vfs_spiffs_conf_t conf = { 30 esp_vfs_spiffs_conf_t conf = {
27 .base_path = "/spiffs", 31 .base_path = "/spiffs",
@@ -49,7 +53,11 @@ esp_err_t tollgate_config_init(void)
49 "\"step_size_ms\":60000," 53 "\"step_size_ms\":60000,"
50 "\"nostr_geohash\":\"u281w0dfz\"," 54 "\"nostr_geohash\":\"u281w0dfz\","
51 "\"nostr_relays\":[\"wss://relay.damus.io\",\"wss://nos.lol\"]," 55 "\"nostr_relays\":[\"wss://relay.damus.io\",\"wss://nos.lol\"],"
52 "\"nostr_publish_interval_s\":21600" 56 "\"nostr_publish_interval_s\":21600,"
57 "\"client_enabled\":false,"
58 "\"client_steps_to_buy\":1,"
59 "\"client_renewal_threshold_pct\":20,"
60 "\"client_retry_interval_ms\":30000"
53 "}"; 61 "}";
54 f = fopen("/spiffs/config.json", "w"); 62 f = fopen("/spiffs/config.json", "w");
55 if (f) { 63 if (f) {
@@ -146,6 +154,18 @@ esp_err_t tollgate_config_init(void)
146 cJSON *pub_interval = cJSON_GetObjectItem(root, "nostr_publish_interval_s"); 154 cJSON *pub_interval = cJSON_GetObjectItem(root, "nostr_publish_interval_s");
147 if (pub_interval) g_config.nostr_publish_interval_s = pub_interval->valueint; 155 if (pub_interval) g_config.nostr_publish_interval_s = pub_interval->valueint;
148 156
157 cJSON *client_enabled = cJSON_GetObjectItem(root, "client_enabled");
158 if (client_enabled && cJSON_IsBool(client_enabled)) g_config.client_enabled = cJSON_IsTrue(client_enabled);
159
160 cJSON *client_steps = cJSON_GetObjectItem(root, "client_steps_to_buy");
161 if (client_steps) g_config.client_steps_to_buy = client_steps->valueint;
162
163 cJSON *client_renewal = cJSON_GetObjectItem(root, "client_renewal_threshold_pct");
164 if (client_renewal) g_config.client_renewal_threshold_pct = client_renewal->valueint;
165
166 cJSON *client_retry = cJSON_GetObjectItem(root, "client_retry_interval_ms");
167 if (client_retry) g_config.client_retry_interval_ms = client_retry->valueint;
168
149 cJSON_Delete(root); 169 cJSON_Delete(root);
150 170
151 if (g_config.nostr_relay_count == 0) { 171 if (g_config.nostr_relay_count == 0) {