upleb.uk

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

summaryrefslogtreecommitdiff
path: root/main/tollgate_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'main/tollgate_api.c')
-rw-r--r--main/tollgate_api.c25
1 files changed, 3 insertions, 22 deletions
diff --git a/main/tollgate_api.c b/main/tollgate_api.c
index 25e7dd2..650b0f3 100644
--- a/main/tollgate_api.c
+++ b/main/tollgate_api.c
@@ -224,20 +224,6 @@ static esp_err_t api_post_payment(httpd_req_t *req)
224 return ESP_OK; 224 return ESP_OK;
225 } 225 }
226 226
227 for (int i = 0; i < token->proof_count; i++) {
228 if (session_is_secret_spent(token->proofs[i].secret)) {
229 free(token);
230 cJSON *notice = create_notice("error", "payment-error-token-spent", "Token already spent");
231 char *json = cJSON_PrintUnformatted(notice);
232 httpd_resp_set_status(req, "402 Payment Required");
233 httpd_resp_set_type(req, "application/json");
234 httpd_resp_send(req, json, strlen(json));
235 cJSON_free(json);
236 cJSON_Delete(notice);
237 return ESP_OK;
238 }
239 }
240
241 cashu_proof_state_t *states = malloc(CASHU_MAX_PROOFS * sizeof(cashu_proof_state_t)); 227 cashu_proof_state_t *states = malloc(CASHU_MAX_PROOFS * sizeof(cashu_proof_state_t));
242 if (!states) { 228 if (!states) {
243 free(token); 229 free(token);
@@ -299,16 +285,11 @@ static esp_err_t api_post_payment(httpd_req_t *req)
299 return ESP_OK; 285 return ESP_OK;
300 } 286 }
301 287
302 int secret_count = token->proof_count > 5 ? 5 : token->proof_count;
303 const char *secrets[5];
304 for (int i = 0; i < secret_count; i++) {
305 secrets[i] = token->proofs[i].secret;
306 }
307 session_t *session; 288 session_t *session;
308 if (is_bytes) { 289 if (is_bytes) {
309 session = session_create_bytes(client_ip, allotment, secrets, secret_count); 290 session = session_create_bytes(client_ip, allotment);
310 } else { 291 } else {
311 session = session_create(client_ip, allotment, secrets, secret_count); 292 session = session_create(client_ip, allotment);
312 } 293 }
313 if (!session) { 294 if (!session) {
314 free(states); 295 free(states);
@@ -498,7 +479,7 @@ esp_err_t tollgate_api_start(void)
498 config.server_port = 2121; 479 config.server_port = 2121;
499 config.ctrl_port = 32769; 480 config.ctrl_port = 32769;
500 config.max_uri_handlers = 10; 481 config.max_uri_handlers = 10;
501 config.stack_size = 32768; 482 config.stack_size = 16384;
502 483
503 esp_err_t ret = httpd_start(&s_api_server, &config); 484 esp_err_t ret = httpd_start(&s_api_server, &config);
504 if (ret != ESP_OK) { 485 if (ret != ESP_OK) {