diff options
Diffstat (limited to 'main/config.c')
| -rw-r--r-- | main/config.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/main/config.c b/main/config.c index 6753f40..45eb8ff 100644 --- a/main/config.c +++ b/main/config.c | |||
| @@ -58,6 +58,7 @@ esp_err_t tollgate_config_init(void) | |||
| 58 | "]," | 58 | "]," |
| 59 | "\"ap_password\":\"\"," | 59 | "\"ap_password\":\"\"," |
| 60 | "\"mint_url\":\"https://testnut.cashu.space\"," | 60 | "\"mint_url\":\"https://testnut.cashu.space\"," |
| 61 | "\"accepted_mints\":[\"https://testnut.cashu.space\"]," | ||
| 61 | "\"price_per_step\":21," | 62 | "\"price_per_step\":21," |
| 62 | "\"step_size_ms\":60000," | 63 | "\"step_size_ms\":60000," |
| 63 | "\"nostr_geohash\":\"u281w0dfz\"," | 64 | "\"nostr_geohash\":\"u281w0dfz\"," |
| @@ -131,6 +132,20 @@ esp_err_t tollgate_config_init(void) | |||
| 131 | cJSON *mint = cJSON_GetObjectItem(root, "mint_url"); | 132 | cJSON *mint = cJSON_GetObjectItem(root, "mint_url"); |
| 132 | if (mint) strncpy(g_config.mint_url, mint->valuestring, sizeof(g_config.mint_url) - 1); | 133 | if (mint) strncpy(g_config.mint_url, mint->valuestring, sizeof(g_config.mint_url) - 1); |
| 133 | 134 | ||
| 135 | cJSON *acc_mints = cJSON_GetObjectItem(root, "accepted_mints"); | ||
| 136 | if (acc_mints && cJSON_IsArray(acc_mints)) { | ||
| 137 | int mcount = cJSON_GetArraySize(acc_mints); | ||
| 138 | if (mcount > TOLLGATE_MAX_MINT_URLS) mcount = TOLLGATE_MAX_MINT_URLS; | ||
| 139 | for (int i = 0; i < mcount; i++) { | ||
| 140 | cJSON *m = cJSON_GetArrayItem(acc_mints, i); | ||
| 141 | if (m && cJSON_IsString(m)) { | ||
| 142 | strncpy(g_config.accepted_mints[i], m->valuestring, | ||
| 143 | sizeof(g_config.accepted_mints[i]) - 1); | ||
| 144 | g_config.accepted_mint_count++; | ||
| 145 | } | ||
| 146 | } | ||
| 147 | } | ||
| 148 | |||
| 134 | cJSON *lnurl = cJSON_GetObjectItem(root, "lnurl_url"); | 149 | cJSON *lnurl = cJSON_GetObjectItem(root, "lnurl_url"); |
| 135 | if (lnurl) strncpy(g_config.lnurl_url, lnurl->valuestring, sizeof(g_config.lnurl_url) - 1); | 150 | if (lnurl) strncpy(g_config.lnurl_url, lnurl->valuestring, sizeof(g_config.lnurl_url) - 1); |
| 136 | 151 | ||
| @@ -264,15 +279,21 @@ esp_err_t tollgate_config_init(void) | |||
| 264 | 279 | ||
| 265 | cJSON_Delete(root); | 280 | cJSON_Delete(root); |
| 266 | 281 | ||
| 282 | if (g_config.accepted_mint_count == 0 && g_config.mint_url[0] != '\0') { | ||
| 283 | strncpy(g_config.accepted_mints[0], g_config.mint_url, | ||
| 284 | sizeof(g_config.accepted_mints[0]) - 1); | ||
| 285 | g_config.accepted_mint_count = 1; | ||
| 286 | } | ||
| 287 | |||
| 267 | if (g_config.nostr_relay_count == 0) { | 288 | if (g_config.nostr_relay_count == 0) { |
| 268 | strncpy(g_config.nostr_relays[0], "wss://relay.damus.io", sizeof(g_config.nostr_relays[0]) - 1); | 289 | strncpy(g_config.nostr_relays[0], "wss://relay.damus.io", sizeof(g_config.nostr_relays[0]) - 1); |
| 269 | strncpy(g_config.nostr_relays[1], "wss://nos.lol", sizeof(g_config.nostr_relays[1]) - 1); | 290 | strncpy(g_config.nostr_relays[1], "wss://nos.lol", sizeof(g_config.nostr_relays[1]) - 1); |
| 270 | g_config.nostr_relay_count = 2; | 291 | g_config.nostr_relay_count = 2; |
| 271 | } | 292 | } |
| 272 | 293 | ||
| 273 | ESP_LOGI(TAG, "Config loaded: nsec=%s...%s, %d WiFi networks, price=%d sats/%dms", | 294 | ESP_LOGI(TAG, "Config loaded: nsec=%s...%s, %d WiFi networks, %d accepted mints, price=%d sats/%dms", |
| 274 | g_config.nsec, g_config.nsec + 60, g_config.network_count, | 295 | g_config.nsec, g_config.nsec + 60, g_config.network_count, |
| 275 | g_config.price_per_step, g_config.step_size_ms); | 296 | g_config.accepted_mint_count, g_config.price_per_step, g_config.step_size_ms); |
| 276 | return ESP_OK; | 297 | return ESP_OK; |
| 277 | } | 298 | } |
| 278 | 299 | ||