diff options
Diffstat (limited to 'src/lib/exchange_api_recoup.c')
-rw-r--r-- | src/lib/exchange_api_recoup.c | 55 |
1 files changed, 13 insertions, 42 deletions
diff --git a/src/lib/exchange_api_recoup.c b/src/lib/exchange_api_recoup.c index e4093a018..09d99b236 100644 --- a/src/lib/exchange_api_recoup.c +++ b/src/lib/exchange_api_recoup.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of TALER | 2 | This file is part of TALER |
3 | Copyright (C) 2017-2020 Taler Systems SA | 3 | Copyright (C) 2017-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 |
@@ -300,28 +300,12 @@ handle_recoup_finished (void *cls, | |||
300 | } | 300 | } |
301 | 301 | ||
302 | 302 | ||
303 | /** | ||
304 | * Ask the exchange to pay back a coin due to the exchange triggering | ||
305 | * the emergency recoup protocol for a given denomination. The value | ||
306 | * of the coin will be refunded to the original customer (without fees). | ||
307 | * | ||
308 | * @param exchange the exchange handle; the exchange must be ready to operate | ||
309 | * @param pk kind of coin to pay back | ||
310 | * @param denom_sig signature over the coin by the exchange using @a pk | ||
311 | * @param ps secret internals of the original planchet | ||
312 | * @param was_refreshed #GNUNET_YES if the coin in @a ps was refreshed | ||
313 | * @param recoup_cb the callback to call when the final result for this request is available | ||
314 | * @param recoup_cb_cls closure for @a recoup_cb | ||
315 | * @return NULL | ||
316 | * if the inputs are invalid (i.e. denomination key not with this exchange). | ||
317 | * In this case, the callback is not called. | ||
318 | */ | ||
319 | struct TALER_EXCHANGE_RecoupHandle * | 303 | struct TALER_EXCHANGE_RecoupHandle * |
320 | TALER_EXCHANGE_recoup (struct TALER_EXCHANGE_Handle *exchange, | 304 | TALER_EXCHANGE_recoup (struct TALER_EXCHANGE_Handle *exchange, |
321 | const struct TALER_EXCHANGE_DenomPublicKey *pk, | 305 | const struct TALER_EXCHANGE_DenomPublicKey *pk, |
322 | const struct TALER_DenominationSignature *denom_sig, | 306 | const struct TALER_DenominationSignature *denom_sig, |
323 | const struct TALER_PlanchetSecretsP *ps, | 307 | const struct TALER_PlanchetSecretsP *ps, |
324 | int was_refreshed, | 308 | bool was_refreshed, |
325 | TALER_EXCHANGE_RecoupResultCallback recoup_cb, | 309 | TALER_EXCHANGE_RecoupResultCallback recoup_cb, |
326 | void *recoup_cb_cls) | 310 | void *recoup_cb_cls) |
327 | { | 311 | { |
@@ -347,24 +331,17 @@ TALER_EXCHANGE_recoup (struct TALER_EXCHANGE_Handle *exchange, | |||
347 | GNUNET_CRYPTO_eddsa_sign (&ps->coin_priv.eddsa_priv, | 331 | GNUNET_CRYPTO_eddsa_sign (&ps->coin_priv.eddsa_priv, |
348 | &pr, | 332 | &pr, |
349 | &coin_sig.eddsa_signature); | 333 | &coin_sig.eddsa_signature); |
350 | recoup_obj = json_pack ("{s:o, s:o," /* denom pub/sig */ | 334 | recoup_obj = GNUNET_JSON_PACK ( |
351 | " s:o," /* sig */ | 335 | GNUNET_JSON_pack_data_auto ("denom_pub_hash", |
352 | " s:o, s:o}", /* coin_bks */ | 336 | &h_denom_pub), |
353 | "denom_pub_hash", GNUNET_JSON_from_data_auto ( | 337 | TALER_JSON_pack_denomination_signature ("denom_sig", |
354 | &h_denom_pub), | 338 | denom_sig), |
355 | "denom_sig", GNUNET_JSON_from_rsa_signature ( | 339 | GNUNET_JSON_pack_data_auto ("coin_sig", |
356 | denom_sig->rsa_signature), | 340 | &coin_sig), |
357 | "coin_sig", GNUNET_JSON_from_data_auto (&coin_sig), | 341 | GNUNET_JSON_pack_data_auto ("coin_blind_key_secret", |
358 | "coin_blind_key_secret", GNUNET_JSON_from_data_auto ( | 342 | &ps->blinding_key), |
359 | &ps->blinding_key), | 343 | GNUNET_JSON_pack_bool ("refreshed", |
360 | "refreshed", json_boolean (was_refreshed) | 344 | was_refreshed)); |
361 | ); | ||
362 | if (NULL == recoup_obj) | ||
363 | { | ||
364 | GNUNET_break (0); | ||
365 | return NULL; | ||
366 | } | ||
367 | |||
368 | { | 345 | { |
369 | char pub_str[sizeof (struct TALER_CoinSpendPublicKeyP) * 2]; | 346 | char pub_str[sizeof (struct TALER_CoinSpendPublicKeyP) * 2]; |
370 | char *end; | 347 | char *end; |
@@ -426,12 +403,6 @@ TALER_EXCHANGE_recoup (struct TALER_EXCHANGE_Handle *exchange, | |||
426 | } | 403 | } |
427 | 404 | ||
428 | 405 | ||
429 | /** | ||
430 | * Cancel a recoup request. This function cannot be used on a | ||
431 | * request handle if the callback was already invoked. | ||
432 | * | ||
433 | * @param ph the recoup handle | ||
434 | */ | ||
435 | void | 406 | void |
436 | TALER_EXCHANGE_recoup_cancel (struct TALER_EXCHANGE_RecoupHandle *ph) | 407 | TALER_EXCHANGE_recoup_cancel (struct TALER_EXCHANGE_RecoupHandle *ph) |
437 | { | 408 | { |