diff options
Diffstat (limited to 'main/tollgate_client.c')
| -rw-r--r-- | main/tollgate_client.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/main/tollgate_client.c b/main/tollgate_client.c index a81d16f..73c8370 100644 --- a/main/tollgate_client.c +++ b/main/tollgate_client.c | |||
| @@ -127,15 +127,25 @@ static bool parse_discovery_response(const char *json_str, tollgate_discovery_t | |||
| 127 | if (val && cJSON_IsString(val)) { | 127 | if (val && cJSON_IsString(val)) { |
| 128 | out->step_size_ms = atoi(val->valuestring); | 128 | out->step_size_ms = atoi(val->valuestring); |
| 129 | } | 129 | } |
| 130 | } else if (strcmp(tag_name->valuestring, "price_per_step") == 0 && tag_len >= 6) { | 130 | } else if (strcmp(tag_name->valuestring, "price_per_step") == 0 && tag_len >= 4) { |
| 131 | cJSON *amount = cJSON_GetArrayItem(tag, 2); | 131 | cJSON *payment_type = cJSON_GetArrayItem(tag, 2); |
| 132 | cJSON *mint = cJSON_GetArrayItem(tag, 4); | 132 | |
| 133 | if (cJSON_IsString(payment_type) && strcmp(payment_type->valuestring, "mining") == 0 && tag_len >= 5) { | ||
| 134 | out->mining_available = true; | ||
| 135 | cJSON *port_val = cJSON_GetArrayItem(tag, 3); | ||
| 136 | if (port_val && cJSON_IsString(port_val)) { | ||
| 137 | out->mining_port = (uint16_t)atoi(port_val->valuestring); | ||
| 138 | } | ||
| 139 | } else { | ||
| 140 | cJSON *amount = cJSON_GetArrayItem(tag, 2); | ||
| 141 | cJSON *mint = cJSON_GetArrayItem(tag, 4); | ||
| 133 | 142 | ||
| 134 | if (amount && cJSON_IsString(amount)) { | 143 | if (amount && cJSON_IsString(amount)) { |
| 135 | out->price_per_step = atoi(amount->valuestring); | 144 | out->price_per_step = atoi(amount->valuestring); |
| 136 | } | 145 | } |
| 137 | if (mint && cJSON_IsString(mint)) { | 146 | if (mint && cJSON_IsString(mint)) { |
| 138 | strncpy(out->mint_url, mint->valuestring, sizeof(out->mint_url) - 1); | 147 | strncpy(out->mint_url, mint->valuestring, sizeof(out->mint_url) - 1); |
| 148 | } | ||
| 139 | } | 149 | } |
| 140 | } | 150 | } |
| 141 | } | 151 | } |