aboutsummaryrefslogtreecommitdiff
path: root/src/lib/exchange_api_management_post_keys.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/exchange_api_management_post_keys.c')
-rw-r--r--src/lib/exchange_api_management_post_keys.c90
1 files changed, 31 insertions, 59 deletions
diff --git a/src/lib/exchange_api_management_post_keys.c b/src/lib/exchange_api_management_post_keys.c
index 6273299a3..e956cfd55 100644
--- a/src/lib/exchange_api_management_post_keys.c
+++ b/src/lib/exchange_api_management_post_keys.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of TALER 2 This file is part of TALER
3 Copyright (C) 2015-2020 Taler Systems SA 3 Copyright (C) 2015-2021 Taler Systems SA
4 4
5 TALER is free software; you can redistribute it and/or modify it under the 5 TALER is free software; you can redistribute it and/or modify it under the
6 terms of the GNU General Public License as published by the Free Software 6 terms of the GNU General Public License as published by the Free Software
@@ -149,72 +149,44 @@ TALER_EXCHANGE_post_management_keys (
149 return NULL; 149 return NULL;
150 } 150 }
151 denom_sigs = json_array (); 151 denom_sigs = json_array ();
152 if (NULL == denom_sigs) 152 GNUNET_assert (NULL != denom_sigs);
153 {
154 GNUNET_free (ph->url);
155 GNUNET_free (ph);
156 return NULL;
157 }
158 for (unsigned int i = 0; i<pkd->num_denom_sigs; i++) 153 for (unsigned int i = 0; i<pkd->num_denom_sigs; i++)
159 { 154 {
160 if (0 != 155 const struct TALER_EXCHANGE_DenominationKeySignature *dks
161 json_array_append_new ( 156 = &pkd->denom_sigs[i];
162 denom_sigs, 157
163 json_pack ("{s:o, s:o}", 158 GNUNET_assert (0 ==
164 "h_denom_pub", 159 json_array_append_new (
165 GNUNET_JSON_from_data_auto ( 160 denom_sigs,
166 &pkd->denom_sigs[i].h_denom_pub), 161 GNUNET_JSON_PACK (
167 "master_sig", 162 GNUNET_JSON_pack_data_auto ("h_denom_pub",
168 GNUNET_JSON_from_data_auto ( 163 &dks->h_denom_pub),
169 &pkd->denom_sigs[i].master_sig)))) 164 GNUNET_JSON_pack_data_auto ("master_sig",
170 { 165 &dks->master_sig))));
171 json_decref (denom_sigs);
172 GNUNET_free (ph->url);
173 GNUNET_free (ph);
174 return NULL;
175 }
176 } 166 }
177 signkey_sigs = json_array (); 167 signkey_sigs = json_array ();
178 if (NULL == signkey_sigs) 168 GNUNET_assert (NULL != signkey_sigs);
179 {
180 json_decref (denom_sigs);
181 GNUNET_free (ph->url);
182 GNUNET_free (ph);
183 return NULL;
184 }
185 for (unsigned int i = 0; i<pkd->num_sign_sigs; i++) 169 for (unsigned int i = 0; i<pkd->num_sign_sigs; i++)
186 { 170 {
187 if (0 != 171 const struct TALER_EXCHANGE_SigningKeySignature *sks
188 json_array_append_new ( 172 = &pkd->sign_sigs[i];
189 signkey_sigs, 173
190 json_pack ("{s:o, s:o}", 174 GNUNET_assert (0 ==
191 "exchange_pub", 175 json_array_append_new (
192 GNUNET_JSON_from_data_auto ( 176 signkey_sigs,
193 &pkd->sign_sigs[i].exchange_pub), 177 GNUNET_JSON_PACK (
194 "master_sig", 178 GNUNET_JSON_pack_data_auto ("exchange_pub",
195 GNUNET_JSON_from_data_auto ( 179 &sks->exchange_pub),
196 &pkd->sign_sigs[i].master_sig)))) 180 GNUNET_JSON_pack_data_auto ("master_sig",
197 { 181 &sks->master_sig))));
198 json_decref (signkey_sigs);
199 json_decref (denom_sigs);
200 GNUNET_free (ph->url);
201 GNUNET_free (ph);
202 return NULL;
203 }
204 }
205 body = json_pack ("{s:o, s:o}",
206 "denom_sigs",
207 denom_sigs,
208 "signkey_sigs",
209 signkey_sigs);
210 if (NULL == body)
211 {
212 GNUNET_break (0);
213 GNUNET_free (ph->url);
214 GNUNET_free (ph);
215 return NULL;
216 } 182 }
183 body = GNUNET_JSON_PACK (
184 GNUNET_JSON_pack_array_steal ("denom_sigs",
185 denom_sigs),
186 GNUNET_JSON_pack_array_steal ("signkey_sigs",
187 signkey_sigs));
217 eh = curl_easy_init (); 188 eh = curl_easy_init ();
189 GNUNET_assert (NULL != eh);
218 if (GNUNET_OK != 190 if (GNUNET_OK !=
219 TALER_curl_easy_post (&ph->post_ctx, 191 TALER_curl_easy_post (&ph->post_ctx,
220 eh, 192 eh,