From 1d54400a025ff62ad15b77ab117ea5188884b1a1 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 31 Jul 2021 20:27:16 +0200 Subject: -more eliminations of json_pack --- src/include/taler_exchange_service.h | 8 +- src/include/taler_json_lib.h | 12 +- src/lib/auditor_api_deposit_confirmation.c | 62 +++--- src/lib/exchange_api_auditor_add_denomination.c | 14 +- src/lib/exchange_api_deposit.c | 57 +++-- src/lib/exchange_api_handle.c | 232 ++++++++------------- src/lib/exchange_api_management_auditor_disable.c | 20 +- src/lib/exchange_api_management_auditor_enable.c | 32 ++- src/lib/exchange_api_management_post_keys.c | 90 +++----- ...change_api_management_revoke_denomination_key.c | 6 +- .../exchange_api_management_revoke_signing_key.c | 16 +- src/lib/exchange_api_management_set_wire_fee.c | 36 ++-- src/lib/exchange_api_management_wire_disable.c | 24 +-- src/lib/exchange_api_management_wire_enable.c | 28 +-- src/lib/exchange_api_melt.c | 62 ++---- src/lib/exchange_api_recoup.c | 55 ++--- src/lib/exchange_api_refreshes_reveal.c | 58 ++---- src/lib/exchange_api_refund.c | 67 ++---- src/lib/exchange_api_withdraw2.c | 49 +---- 19 files changed, 305 insertions(+), 623 deletions(-) diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h index a344771cf..3fc5f353b 100644 --- a/src/include/taler_exchange_service.h +++ b/src/include/taler_exchange_service.h @@ -155,10 +155,10 @@ struct TALER_EXCHANGE_DenomPublicKey struct TALER_Amount fee_refund; /** - * Set to #GNUNET_YES if this denomination key has been + * Set to true if this denomination key has been * revoked by the exchange. */ - int revoked; + bool revoked; }; @@ -1869,7 +1869,7 @@ typedef void * @param pk kind of coin to pay back * @param denom_sig signature over the coin by the exchange using @a pk * @param ps secret internals of the original planchet - * @param was_refreshed #GNUNET_YES if the coin in @a ps was refreshed + * @param was_refreshed true if the coin in @a ps was refreshed * @param recoup_cb the callback to call when the final result for this request is available * @param recoup_cb_cls closure for @a recoup_cb * @return NULL @@ -1881,7 +1881,7 @@ TALER_EXCHANGE_recoup (struct TALER_EXCHANGE_Handle *exchange, const struct TALER_EXCHANGE_DenomPublicKey *pk, const struct TALER_DenominationSignature *denom_sig, const struct TALER_PlanchetSecretsP *ps, - int was_refreshed, + bool was_refreshed, TALER_EXCHANGE_RecoupResultCallback recoup_cb, void *recoup_cb_cls); diff --git a/src/include/taler_json_lib.h b/src/include/taler_json_lib.h index 4ed259b21..0cbeba082 100644 --- a/src/include/taler_json_lib.h +++ b/src/include/taler_json_lib.h @@ -103,9 +103,9 @@ TALER_JSON_pack_time_rel_nbo (const char *name, * @return json pack specification */ struct GNUNET_JSON_PackSpec -TALER_JSON_pack_denomination_public_key (const char *name, - const struct - TALER_DenominationPublicKey *pk); +TALER_JSON_pack_denomination_public_key ( + const char *name, + const struct TALER_DenominationPublicKey *pk); /** @@ -117,9 +117,9 @@ TALER_JSON_pack_denomination_public_key (const char *name, * @return json pack specification */ struct GNUNET_JSON_PackSpec -TALER_JSON_pack_denomination_signature (const char *name, - const struct - TALER_DenominationSignature *sig); +TALER_JSON_pack_denomination_signature ( + const char *name, + const struct TALER_DenominationSignature *sig); /** diff --git a/src/lib/auditor_api_deposit_confirmation.c b/src/lib/auditor_api_deposit_confirmation.c index eb84aeadc..2afbfd1e9 100644 --- a/src/lib/auditor_api_deposit_confirmation.c +++ b/src/lib/auditor_api_deposit_confirmation.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2020 Taler Systems SA + Copyright (C) 2014-2021 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -323,37 +323,35 @@ TALER_AUDITOR_deposit_confirmation ( } deposit_confirmation_obj - = json_pack ("{s:o, s:o," /* h_wire, h_contract_terms */ - " s:o, s:o," /* timestamp, refund_deadline */ - " s:o, s:o," /* amount_without_fees, coin_pub */ - " s:o, s:o," /* merchant_pub, exchange_sig */ - " s:o, s:o," /* master_pub, ep_start */ - " s:o, s:o," /* ep_expire, ep_end */ - " s:o, s:o}", /* master_sig, exchange_pub */ - "h_wire", GNUNET_JSON_from_data_auto (h_wire), - "h_contract_terms", GNUNET_JSON_from_data_auto ( - h_contract_terms), - "exchange_timestamp", GNUNET_JSON_from_time_abs ( - exchange_timestamp), - "refund_deadline", GNUNET_JSON_from_time_abs (refund_deadline), - "amount_without_fee", TALER_JSON_from_amount ( - amount_without_fee), - "coin_pub", GNUNET_JSON_from_data_auto (coin_pub), - "merchant_pub", GNUNET_JSON_from_data_auto (merchant_pub), - "exchange_sig", GNUNET_JSON_from_data_auto (exchange_sig), - "master_pub", GNUNET_JSON_from_data_auto (master_pub), - "ep_start", GNUNET_JSON_from_time_abs (ep_start), - "ep_expire", GNUNET_JSON_from_time_abs (ep_expire), - "ep_end", GNUNET_JSON_from_time_abs (ep_end), - "master_sig", GNUNET_JSON_from_data_auto (master_sig), - "exchange_pub", GNUNET_JSON_from_data_auto (exchange_pub)); - - if (NULL == deposit_confirmation_obj) - { - GNUNET_break (0); - return NULL; - } - + = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_data_auto ("h_wire", + h_wire), + GNUNET_JSON_pack_data_auto ("h_contract_terms", + h_contract_terms), + GNUNET_JSON_pack_time_abs ("exchange_timestamp", + exchange_timestamp), + GNUNET_JSON_pack_time_abs ("refund_deadline", + refund_deadline), + TALER_JSON_pack_amount ("amount_without_fee", + amount_without_fee), + GNUNET_JSON_pack_data_auto ("coin_pub", + coin_pub), + GNUNET_JSON_pack_data_auto ("merchant_pub", + merchant_pub), + GNUNET_JSON_pack_data_auto ("exchange_sig", + exchange_sig), + GNUNET_JSON_pack_data_auto ("master_pub", + master_pub), + GNUNET_JSON_pack_time_abs ("ep_start", + ep_start), + GNUNET_JSON_pack_time_abs ("ep_expire", + ep_expire), + GNUNET_JSON_pack_time_abs ("ep_end", + ep_end), + GNUNET_JSON_pack_data_auto ("master_sig", + master_sig), + GNUNET_JSON_pack_data_auto ("exchange_pub", + exchange_pub)); dh = GNUNET_new (struct TALER_AUDITOR_DepositConfirmationHandle); dh->auditor = auditor; dh->cb = cb; diff --git a/src/lib/exchange_api_auditor_add_denomination.c b/src/lib/exchange_api_auditor_add_denomination.c index 50bffd974..8952cd2fc 100644 --- a/src/lib/exchange_api_auditor_add_denomination.c +++ b/src/lib/exchange_api_auditor_add_denomination.c @@ -187,17 +187,11 @@ TALER_EXCHANGE_add_auditor_denomination ( GNUNET_free (ah); return NULL; } - body = json_pack ("{s:o}", - "auditor_sig", - GNUNET_JSON_from_data_auto (auditor_sig)); - if (NULL == body) - { - GNUNET_break (0); - GNUNET_free (ah->url); - GNUNET_free (ah); - return NULL; - } + body = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_data_auto ("auditor_sig", + auditor_sig)); eh = curl_easy_init (); + GNUNET_assert (NULL != eh); if (GNUNET_OK != TALER_curl_easy_post (&ah->post_ctx, eh, diff --git a/src/lib/exchange_api_deposit.c b/src/lib/exchange_api_deposit.c index 792920c17..f22ae0df7 100644 --- a/src/lib/exchange_api_deposit.c +++ b/src/lib/exchange_api_deposit.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2020 Taler Systems SA + Copyright (C) 2014-2021 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -663,38 +663,29 @@ TALER_EXCHANGE_deposit (struct TALER_EXCHANGE_Handle *exchange, return NULL; } - deposit_obj = json_pack ("{s:o, s:O," /* f/wire */ - " s:o, s:o," /* h_wire, h_contract_terms */ - " s:o," /* denom_pub */ - " s:o, s:o," /* ub_sig, timestamp */ - " s:o," /* merchant_pub */ - " s:o, s:o," /* refund_deadline, wire_deadline */ - " s:o}", /* coin_sig */ - "contribution", TALER_JSON_from_amount (amount), - "wire", wire_details, - "h_wire", GNUNET_JSON_from_data_auto (&h_wire), - "h_contract_terms", GNUNET_JSON_from_data_auto ( - h_contract_terms), - "denom_pub_hash", GNUNET_JSON_from_data_auto ( - &denom_pub_hash), - "ub_sig", GNUNET_JSON_from_rsa_signature ( - denom_sig->rsa_signature), - "timestamp", GNUNET_JSON_from_time_abs (timestamp), - "merchant_pub", GNUNET_JSON_from_data_auto ( - merchant_pub), - "refund_deadline", GNUNET_JSON_from_time_abs ( - refund_deadline), - "wire_transfer_deadline", GNUNET_JSON_from_time_abs ( - wire_deadline), - "coin_sig", GNUNET_JSON_from_data_auto (coin_sig) - ); - if (NULL == deposit_obj) - { - *ec = TALER_EC_GENERIC_JSON_ALLOCATION_FAILURE; - GNUNET_break (0); - return NULL; - } - + deposit_obj = GNUNET_JSON_PACK ( + TALER_JSON_pack_amount ("contribution", + amount), + GNUNET_JSON_pack_object_incref ("wire", + wire_details), + GNUNET_JSON_pack_data_auto ("h_wire", + &h_wire), + GNUNET_JSON_pack_data_auto ("h_contract_terms", + h_contract_terms), + GNUNET_JSON_pack_data_auto ("denom_pub_hash", + &denom_pub_hash), + TALER_JSON_pack_denomination_signature ("ub_sig", + denom_sig), + GNUNET_JSON_pack_time_abs ("timestamp", + timestamp), + GNUNET_JSON_pack_data_auto ("merchant_pub", + merchant_pub), + GNUNET_JSON_pack_time_abs ("refund_deadline", + refund_deadline), + GNUNET_JSON_pack_time_abs ("wire_transfer_deadline", + wire_deadline), + GNUNET_JSON_pack_data_auto ("coin_sig", + coin_sig)); dh = GNUNET_new (struct TALER_EXCHANGE_DepositHandle); dh->auditor_chance = AUDITOR_CHANCE; dh->exchange = exchange; diff --git a/src/lib/exchange_api_handle.c b/src/lib/exchange_api_handle.c index 43eac97a7..615239723 100644 --- a/src/lib/exchange_api_handle.c +++ b/src/lib/exchange_api_handle.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2018 Taler Systems SA + Copyright (C) 2014-2021 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -1612,22 +1612,17 @@ TALER_EXCHANGE_serialize_data (struct TALER_EXCHANGE_Handle *exchange) if (now.abs_value_us > sk->valid_until.abs_value_us) continue; /* skip keys that have expired */ - signkey = json_pack ("{s:o, s:o, s:o, s:o, s:o}", - "key", - GNUNET_JSON_from_data_auto - (&sk->key), - "master_sig", - GNUNET_JSON_from_data_auto - (&sk->master_sig), - "stamp_start", - GNUNET_JSON_from_time_abs - (sk->valid_from), - "stamp_expire", - GNUNET_JSON_from_time_abs - (sk->valid_until), - "stamp_end", - GNUNET_JSON_from_time_abs - (sk->valid_legal)); + signkey = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_data_auto ("key", + &sk->key), + GNUNET_JSON_pack_data_auto ("master_sig", + &sk->master_sig), + GNUNET_JSON_pack_time_abs ("stamp_start", + sk->valid_from), + GNUNET_JSON_pack_time_abs ("stamp_expire", + sk->valid_until), + GNUNET_JSON_pack_time_abs ("stamp_end", + sk->valid_legal)); if (NULL == signkey) { GNUNET_break (0); @@ -1656,57 +1651,35 @@ TALER_EXCHANGE_serialize_data (struct TALER_EXCHANGE_Handle *exchange) if (now.abs_value_us > dk->expire_deposit.abs_value_us) continue; /* skip keys that have expired */ - denom = json_pack ("{s:o, s:o, s:o, s:o, s:o " - ",s:o, s:o, s:o, s:o, s:o " - ",s:o}", - "stamp_expire_deposit", - GNUNET_JSON_from_time_abs (dk->expire_deposit), - "stamp_expire_withdraw", - GNUNET_JSON_from_time_abs (dk->withdraw_valid_until), - "stamp_start", - GNUNET_JSON_from_time_abs (dk->valid_from), - "stamp_expire_legal", - GNUNET_JSON_from_time_abs (dk->expire_legal), - "value", - TALER_JSON_from_amount (&dk->value), - "fee_withdraw", - /* #6 */ - TALER_JSON_from_amount (&dk->fee_withdraw), - "fee_deposit", - TALER_JSON_from_amount (&dk->fee_deposit), - "fee_refresh", - TALER_JSON_from_amount (&dk->fee_refresh), - "fee_refund", - TALER_JSON_from_amount (&dk->fee_refund), - "master_sig", - GNUNET_JSON_from_data_auto (&dk->master_sig), - /* #10 */ - "denom_pub", - GNUNET_JSON_from_rsa_public_key ( - dk->key.rsa_public_key)); - if (NULL == denom) - { - GNUNET_break (0); - continue; - } - if (0 != json_array_append_new (denoms, - denom)) - { - GNUNET_break (0); - json_decref (denom); - json_decref (denoms); - json_decref (signkeys); - return NULL; - } + denom = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_time_abs ("stamp_expire_deposit", + dk->expire_deposit), + GNUNET_JSON_pack_time_abs ("stamp_expire_withdraw", + dk->withdraw_valid_until), + GNUNET_JSON_pack_time_abs ("stamp_start", + dk->valid_from), + GNUNET_JSON_pack_time_abs ("stamp_expire_legal", + dk->expire_legal), + TALER_JSON_pack_amount ("value", + &dk->value), + TALER_JSON_pack_amount ("fee_withdraw", + &dk->fee_withdraw), + TALER_JSON_pack_amount ("fee_deposit", + &dk->fee_deposit), + TALER_JSON_pack_amount ("fee_refresh", + &dk->fee_refresh), + TALER_JSON_pack_amount ("fee_refund", + &dk->fee_refund), + GNUNET_JSON_pack_data_auto ("master_sig", + &dk->master_sig), + TALER_JSON_pack_denomination_public_key ("denom_pub", + &dk->key)); + GNUNET_assert (0 == + json_array_append_new (denoms, + denom)); } auditors = json_array (); - if (NULL == auditors) - { - GNUNET_break (0); - json_decref (denoms); - json_decref (signkeys); - return NULL; - } + GNUNET_assert (NULL != auditors); for (unsigned int i = 0; inum_auditors; i++) { const struct TALER_EXCHANGE_AuditorInformation *ai = &kd->auditors[i]; @@ -1733,92 +1706,53 @@ TALER_EXCHANGE_serialize_data (struct TALER_EXCHANGE_Handle *exchange) if (now.abs_value_us > dk->expire_deposit.abs_value_us) continue; /* skip auditor signatures for denomination keys that have expired */ GNUNET_assert (adi->denom_key_offset < kd->num_denom_keys); - k = json_pack ("{s:o, s:o}", - "denom_pub_h", - GNUNET_JSON_from_data_auto (&dk->h_key), - "auditor_sig", - GNUNET_JSON_from_data_auto (&adi->auditor_sig)); - if (NULL == k) - { - GNUNET_break (0); - json_decref (adenoms); - json_decref (denoms); - json_decref (signkeys); - json_decref (auditors); - return NULL; - } - if (0 != json_array_append_new (adenoms, - k)) - { - GNUNET_break (0); - json_decref (k); - json_decref (adenoms); - json_decref (denoms); - json_decref (signkeys); - json_decref (auditors); - return NULL; - } + k = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_data_auto ("denom_pub_h", + &dk->h_key), + GNUNET_JSON_pack_data_auto ("auditor_sig", + &adi->auditor_sig)); + GNUNET_assert (0 == + json_array_append_new (adenoms, + k)); } - a = json_pack ("{s:o, s:s, s:o}", - "auditor_pub", - GNUNET_JSON_from_data_auto (&ai->auditor_pub), - "auditor_url", - ai->auditor_url, - "denomination_keys", - adenoms); - if (NULL == a) - { - json_decref (adenoms); - json_decref (denoms); - json_decref (signkeys); - json_decref (auditors); - return NULL; - } - if (0 != json_array_append_new (auditors, - a)) - { - json_decref (a); - json_decref (denoms); - json_decref (signkeys); - json_decref (auditors); - return NULL; - } - } - keys = json_pack ("{s:s, s:s, s:o, s:o, s:o, s:o" - ",s:o, s:o}", - /* 1 */ - "version", - kd->version, - "currency", - kd->currency, - "master_public_key", - GNUNET_JSON_from_data_auto (&kd->master_pub), - "reserve_closing_delay", - GNUNET_JSON_from_time_rel (kd->reserve_closing_delay), - "list_issue_date", - GNUNET_JSON_from_time_abs (kd->list_issue_date), - "signkeys", - signkeys, - /* #7 */ - "denoms", - denoms, - "auditors", - auditors); - if (NULL == keys) - { - GNUNET_break (0); - return NULL; + a = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_data_auto ("auditor_pub", + &ai->auditor_pub), + GNUNET_JSON_pack_string ("auditor_url", + ai->auditor_url), + GNUNET_JSON_pack_array_steal ("denomination_keys", + adenoms)); + GNUNET_assert (0 == + json_array_append_new (auditors, + a)); } - return json_pack ("{s:I, s:o, s:s, s:o}", - "version", - (json_int_t) EXCHANGE_SERIALIZATION_FORMAT_VERSION, - "expire", - GNUNET_JSON_from_time_abs (exchange->key_data_expiration), - "exchange_url", - exchange->url, - "keys", - keys); + keys = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_string ("version", + kd->version), + GNUNET_JSON_pack_string ("currency", + kd->currency), + GNUNET_JSON_pack_data_auto ("master_public_key", + &kd->master_pub), + GNUNET_JSON_pack_time_rel ("reserve_closing_delay", + kd->reserve_closing_delay), + GNUNET_JSON_pack_time_abs ("list_issue_date", + kd->list_issue_date), + GNUNET_JSON_pack_array_steal ("signkeys", + signkeys), + GNUNET_JSON_pack_array_steal ("denoms", + denoms), + GNUNET_JSON_pack_array_steal ("auditors", + auditors)); + return GNUNET_JSON_PACK ( + GNUNET_JSON_pack_uint64 ("version", + EXCHANGE_SERIALIZATION_FORMAT_VERSION), + GNUNET_JSON_pack_time_abs ("expire", + exchange->key_data_expiration), + GNUNET_JSON_pack_string ("exchange_url", + exchange->url), + GNUNET_JSON_pack_object_steal ("keys", + keys)); } diff --git a/src/lib/exchange_api_management_auditor_disable.c b/src/lib/exchange_api_management_auditor_disable.c index 1ae657742..fb68ad6d3 100644 --- a/src/lib/exchange_api_management_auditor_disable.c +++ b/src/lib/exchange_api_management_auditor_disable.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2015-2020 Taler Systems SA + Copyright (C) 2015-2021 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -166,19 +166,13 @@ TALER_EXCHANGE_management_disable_auditor ( GNUNET_free (ah); return NULL; } - body = json_pack ("{s:o, s:o}", - "master_sig", - GNUNET_JSON_from_data_auto (master_sig), - "validity_end", - GNUNET_JSON_from_time_abs (validity_end)); - if (NULL == body) - { - GNUNET_break (0); - GNUNET_free (ah->url); - GNUNET_free (ah); - return NULL; - } + body = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_data_auto ("master_sig", + master_sig), + GNUNET_JSON_pack_time_abs ("validity_end", + validity_end)); eh = curl_easy_init (); + GNUNET_assert (NULL != eh); if (GNUNET_OK != TALER_curl_easy_post (&ah->post_ctx, eh, diff --git a/src/lib/exchange_api_management_auditor_enable.c b/src/lib/exchange_api_management_auditor_enable.c index 8bad2026c..1f53cb120 100644 --- a/src/lib/exchange_api_management_auditor_enable.c +++ b/src/lib/exchange_api_management_auditor_enable.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2015-2020 Taler Systems SA + Copyright (C) 2015-2021 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -150,25 +150,19 @@ TALER_EXCHANGE_management_enable_auditor ( GNUNET_free (ah); return NULL; } - body = json_pack ("{s:s, s:s, s:o, s:o, s:o}", - "auditor_url", - auditor_url, - "auditor_name", - auditor_name, - "auditor_pub", - GNUNET_JSON_from_data_auto (auditor_pub), - "master_sig", - GNUNET_JSON_from_data_auto (master_sig), - "validity_start", - GNUNET_JSON_from_time_abs (validity_start)); - if (NULL == body) - { - GNUNET_break (0); - GNUNET_free (ah->url); - GNUNET_free (ah); - return NULL; - } + body = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_string ("auditor_url", + auditor_url), + GNUNET_JSON_pack_string ("auditor_name", + auditor_name), + GNUNET_JSON_pack_data_auto ("auditor_pub", + auditor_pub), + GNUNET_JSON_pack_data_auto ("master_sig", + master_sig), + GNUNET_JSON_pack_time_abs ("validity_start", + validity_start)); eh = curl_easy_init (); + GNUNET_assert (NULL != eh); if (GNUNET_OK != TALER_curl_easy_post (&ah->post_ctx, eh, 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 @@ /* This file is part of TALER - Copyright (C) 2015-2020 Taler Systems SA + Copyright (C) 2015-2021 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -149,72 +149,44 @@ TALER_EXCHANGE_post_management_keys ( return NULL; } denom_sigs = json_array (); - if (NULL == denom_sigs) - { - GNUNET_free (ph->url); - GNUNET_free (ph); - return NULL; - } + GNUNET_assert (NULL != denom_sigs); for (unsigned int i = 0; inum_denom_sigs; i++) { - if (0 != - json_array_append_new ( - denom_sigs, - json_pack ("{s:o, s:o}", - "h_denom_pub", - GNUNET_JSON_from_data_auto ( - &pkd->denom_sigs[i].h_denom_pub), - "master_sig", - GNUNET_JSON_from_data_auto ( - &pkd->denom_sigs[i].master_sig)))) - { - json_decref (denom_sigs); - GNUNET_free (ph->url); - GNUNET_free (ph); - return NULL; - } + const struct TALER_EXCHANGE_DenominationKeySignature *dks + = &pkd->denom_sigs[i]; + + GNUNET_assert (0 == + json_array_append_new ( + denom_sigs, + GNUNET_JSON_PACK ( + GNUNET_JSON_pack_data_auto ("h_denom_pub", + &dks->h_denom_pub), + GNUNET_JSON_pack_data_auto ("master_sig", + &dks->master_sig)))); } signkey_sigs = json_array (); - if (NULL == signkey_sigs) - { - json_decref (denom_sigs); - GNUNET_free (ph->url); - GNUNET_free (ph); - return NULL; - } + GNUNET_assert (NULL != signkey_sigs); for (unsigned int i = 0; inum_sign_sigs; i++) { - if (0 != - json_array_append_new ( - signkey_sigs, - json_pack ("{s:o, s:o}", - "exchange_pub", - GNUNET_JSON_from_data_auto ( - &pkd->sign_sigs[i].exchange_pub), - "master_sig", - GNUNET_JSON_from_data_auto ( - &pkd->sign_sigs[i].master_sig)))) - { - json_decref (signkey_sigs); - json_decref (denom_sigs); - GNUNET_free (ph->url); - GNUNET_free (ph); - return NULL; - } - } - body = json_pack ("{s:o, s:o}", - "denom_sigs", - denom_sigs, - "signkey_sigs", - signkey_sigs); - if (NULL == body) - { - GNUNET_break (0); - GNUNET_free (ph->url); - GNUNET_free (ph); - return NULL; + const struct TALER_EXCHANGE_SigningKeySignature *sks + = &pkd->sign_sigs[i]; + + GNUNET_assert (0 == + json_array_append_new ( + signkey_sigs, + GNUNET_JSON_PACK ( + GNUNET_JSON_pack_data_auto ("exchange_pub", + &sks->exchange_pub), + GNUNET_JSON_pack_data_auto ("master_sig", + &sks->master_sig)))); } + body = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_array_steal ("denom_sigs", + denom_sigs), + GNUNET_JSON_pack_array_steal ("signkey_sigs", + signkey_sigs)); eh = curl_easy_init (); + GNUNET_assert (NULL != eh); if (GNUNET_OK != TALER_curl_easy_post (&ph->post_ctx, eh, diff --git a/src/lib/exchange_api_management_revoke_denomination_key.c b/src/lib/exchange_api_management_revoke_denomination_key.c index 492ece7ef..b9e2a556a 100644 --- a/src/lib/exchange_api_management_revoke_denomination_key.c +++ b/src/lib/exchange_api_management_revoke_denomination_key.c @@ -163,9 +163,9 @@ TALER_EXCHANGE_management_revoke_denomination_key ( GNUNET_free (rh); return NULL; } - body = json_pack ("{s:o}", - "master_sig", - GNUNET_JSON_from_data_auto (master_sig)); + body = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_data_auto ("master_sig", + master_sig)); if (NULL == body) { GNUNET_break (0); diff --git a/src/lib/exchange_api_management_revoke_signing_key.c b/src/lib/exchange_api_management_revoke_signing_key.c index f403cee28..f43a46c40 100644 --- a/src/lib/exchange_api_management_revoke_signing_key.c +++ b/src/lib/exchange_api_management_revoke_signing_key.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2015-2020 Taler Systems SA + Copyright (C) 2015-2021 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -160,17 +160,11 @@ TALER_EXCHANGE_management_revoke_signing_key ( GNUNET_free (rh); return NULL; } - body = json_pack ("{s:o}", - "master_sig", - GNUNET_JSON_from_data_auto (master_sig)); - if (NULL == body) - { - GNUNET_break (0); - GNUNET_free (rh->url); - GNUNET_free (rh); - return NULL; - } + body = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_data_auto ("master_sig", + master_sig)); eh = curl_easy_init (); + GNUNET_assert (NULL != eh); if (GNUNET_OK != TALER_curl_easy_post (&rh->post_ctx, eh, diff --git a/src/lib/exchange_api_management_set_wire_fee.c b/src/lib/exchange_api_management_set_wire_fee.c index 6048bf657..075dbbbba 100644 --- a/src/lib/exchange_api_management_set_wire_fee.c +++ b/src/lib/exchange_api_management_set_wire_fee.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2020 Taler Systems SA + Copyright (C) 2020-2021 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -152,27 +152,21 @@ TALER_EXCHANGE_management_set_wire_fees ( GNUNET_free (swfh); return NULL; } - body = json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o}", - "wire_method", - wire_method, - "master_sig", - GNUNET_JSON_from_data_auto (master_sig), - "fee_start", - GNUNET_JSON_from_time_abs (validity_start), - "fee_end", - GNUNET_JSON_from_time_abs (validity_end), - "closing_fee", - TALER_JSON_from_amount (closing_fee), - "wire_fee", - TALER_JSON_from_amount (wire_fee)); - if (NULL == body) - { - GNUNET_break (0); - GNUNET_free (swfh->url); - GNUNET_free (swfh); - return NULL; - } + body = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_string ("wire_method", + wire_method), + GNUNET_JSON_pack_data_auto ("master_sig", + master_sig), + GNUNET_JSON_pack_time_abs ("fee_start", + validity_start), + GNUNET_JSON_pack_time_abs ("fee_end", + validity_end), + TALER_JSON_pack_amount ("closing_fee", + closing_fee), + TALER_JSON_pack_amount ("wire_fee", + wire_fee)); eh = curl_easy_init (); + GNUNET_assert (NULL != eh); if (GNUNET_OK != TALER_curl_easy_post (&swfh->post_ctx, eh, diff --git a/src/lib/exchange_api_management_wire_disable.c b/src/lib/exchange_api_management_wire_disable.c index 613358fdd..fbc6626ad 100644 --- a/src/lib/exchange_api_management_wire_disable.c +++ b/src/lib/exchange_api_management_wire_disable.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2015-2020 Taler Systems SA + Copyright (C) 2015-2021 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -154,21 +154,15 @@ TALER_EXCHANGE_management_disable_wire ( GNUNET_free (wh); return NULL; } - body = json_pack ("{s:s, s:o, s:o}", - "payto_uri", - payto_uri, - "master_sig_del", - GNUNET_JSON_from_data_auto (master_sig), - "validity_end", - GNUNET_JSON_from_time_abs (validity_end)); - if (NULL == body) - { - GNUNET_break (0); - GNUNET_free (wh->url); - GNUNET_free (wh); - return NULL; - } + body = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_string ("payto_uri", + payto_uri), + GNUNET_JSON_pack_data_auto ("master_sig_del", + master_sig), + GNUNET_JSON_pack_time_abs ("validity_end", + validity_end)); eh = curl_easy_init (); + GNUNET_assert (NULL != eh); if (GNUNET_OK != TALER_curl_easy_post (&wh->post_ctx, eh, diff --git a/src/lib/exchange_api_management_wire_enable.c b/src/lib/exchange_api_management_wire_enable.c index a45762963..43eb2ce97 100644 --- a/src/lib/exchange_api_management_wire_enable.c +++ b/src/lib/exchange_api_management_wire_enable.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2015-2020 Taler Systems SA + Copyright (C) 2015-2021 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -151,23 +151,17 @@ TALER_EXCHANGE_management_enable_wire ( GNUNET_free (wh); return NULL; } - body = json_pack ("{s:s, s:o, s:o, s:o}", - "payto_uri", - payto_uri, - "master_sig_add", - GNUNET_JSON_from_data_auto (master_sig1), - "master_sig_wire", - GNUNET_JSON_from_data_auto (master_sig2), - "validity_start", - GNUNET_JSON_from_time_abs (validity_start)); - if (NULL == body) - { - GNUNET_break (0); - GNUNET_free (wh->url); - GNUNET_free (wh); - return NULL; - } + body = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_string ("payto_uri", + payto_uri), + GNUNET_JSON_pack_data_auto ("master_sig_add", + master_sig1), + GNUNET_JSON_pack_data_auto ("master_sig_wire", + master_sig2), + GNUNET_JSON_pack_time_abs ("validity_start", + validity_start)); eh = curl_easy_init (); + GNUNET_assert (NULL != eh); if (GNUNET_OK != TALER_curl_easy_post (&wh->post_ctx, eh, diff --git a/src/lib/exchange_api_melt.c b/src/lib/exchange_api_melt.c index 1f369c11b..dcee66a8b 100644 --- a/src/lib/exchange_api_melt.c +++ b/src/lib/exchange_api_melt.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2015-2020 Taler Systems SA + Copyright (C) 2015-2021 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -449,26 +449,6 @@ handle_melt_finished (void *cls, } -/** - * Submit a melt request to the exchange and get the exchange's - * response. - * - * This API is typically used by a wallet. Note that to ensure that - * no money is lost in case of hardware failures, the provided - * argument should have been constructed using - * #TALER_EXCHANGE_refresh_prepare and committed to persistent storage - * prior to calling this function. - * - * @param exchange the exchange handle; the exchange must be ready to operate - * @param refresh_data_length size of the @a refresh_data (returned - * in the `res_size` argument from #TALER_EXCHANGE_refresh_prepare()) - * @param refresh_data the refresh data as returned from - #TALER_EXCHANGE_refresh_prepare()) - * @param melt_cb the callback to call with the result - * @param melt_cb_cls closure for @a melt_cb - * @return a handle for this request; NULL if the argument was invalid. - * In this case, neither callback will be called. - */ struct TALER_EXCHANGE_MeltHandle * TALER_EXCHANGE_melt (struct TALER_EXCHANGE_Handle *exchange, size_t refresh_data_length, @@ -511,27 +491,19 @@ TALER_EXCHANGE_melt (struct TALER_EXCHANGE_Handle *exchange, GNUNET_CRYPTO_eddsa_sign (&md->melted_coin.coin_priv.eddsa_priv, &melt, &confirm_sig.eddsa_signature); - melt_obj = json_pack ("{s:o, s:o, s:o, s:o, s:o, s:o}", - "coin_pub", - GNUNET_JSON_from_data_auto (&melt.coin_pub), - "denom_pub_hash", - GNUNET_JSON_from_data_auto (&melt.h_denom_pub), - "denom_sig", - GNUNET_JSON_from_rsa_signature ( - md->melted_coin.sig.rsa_signature), - "confirm_sig", - GNUNET_JSON_from_data_auto (&confirm_sig), - "value_with_fee", - TALER_JSON_from_amount ( - &md->melted_coin.melt_amount_with_fee), - "rc", - GNUNET_JSON_from_data_auto (&melt.rc)); - if (NULL == melt_obj) - { - GNUNET_break (0); - TALER_EXCHANGE_free_melt_data_ (md); - return NULL; - } + melt_obj = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_data_auto ("coin_pub", + &melt.coin_pub), + GNUNET_JSON_pack_data_auto ("denom_pub_hash", + &melt.h_denom_pub), + TALER_JSON_pack_denomination_signature ("denom_sig", + &md->melted_coin.sig), + GNUNET_JSON_pack_data_auto ("confirm_sig", + &confirm_sig), + TALER_JSON_pack_amount ("value_with_fee", + &md->melted_coin.melt_amount_with_fee), + GNUNET_JSON_pack_data_auto ("rc", + &melt.rc)); { char pub_str[sizeof (struct TALER_CoinSpendPublicKeyP) * 2]; char *end; @@ -596,12 +568,6 @@ TALER_EXCHANGE_melt (struct TALER_EXCHANGE_Handle *exchange, } -/** - * Cancel a melt request. This function cannot be used - * on a request handle if either callback was already invoked. - * - * @param mh the refresh melt handle - */ void TALER_EXCHANGE_melt_cancel (struct TALER_EXCHANGE_MeltHandle *mh) { 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 @@ /* This file is part of TALER - Copyright (C) 2017-2020 Taler Systems SA + Copyright (C) 2017-2021 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -300,28 +300,12 @@ handle_recoup_finished (void *cls, } -/** - * Ask the exchange to pay back a coin due to the exchange triggering - * the emergency recoup protocol for a given denomination. The value - * of the coin will be refunded to the original customer (without fees). - * - * @param exchange the exchange handle; the exchange must be ready to operate - * @param pk kind of coin to pay back - * @param denom_sig signature over the coin by the exchange using @a pk - * @param ps secret internals of the original planchet - * @param was_refreshed #GNUNET_YES if the coin in @a ps was refreshed - * @param recoup_cb the callback to call when the final result for this request is available - * @param recoup_cb_cls closure for @a recoup_cb - * @return NULL - * if the inputs are invalid (i.e. denomination key not with this exchange). - * In this case, the callback is not called. - */ struct TALER_EXCHANGE_RecoupHandle * TALER_EXCHANGE_recoup (struct TALER_EXCHANGE_Handle *exchange, const struct TALER_EXCHANGE_DenomPublicKey *pk, const struct TALER_DenominationSignature *denom_sig, const struct TALER_PlanchetSecretsP *ps, - int was_refreshed, + bool was_refreshed, TALER_EXCHANGE_RecoupResultCallback recoup_cb, void *recoup_cb_cls) { @@ -347,24 +331,17 @@ TALER_EXCHANGE_recoup (struct TALER_EXCHANGE_Handle *exchange, GNUNET_CRYPTO_eddsa_sign (&ps->coin_priv.eddsa_priv, &pr, &coin_sig.eddsa_signature); - recoup_obj = json_pack ("{s:o, s:o," /* denom pub/sig */ - " s:o," /* sig */ - " s:o, s:o}", /* coin_bks */ - "denom_pub_hash", GNUNET_JSON_from_data_auto ( - &h_denom_pub), - "denom_sig", GNUNET_JSON_from_rsa_signature ( - denom_sig->rsa_signature), - "coin_sig", GNUNET_JSON_from_data_auto (&coin_sig), - "coin_blind_key_secret", GNUNET_JSON_from_data_auto ( - &ps->blinding_key), - "refreshed", json_boolean (was_refreshed) - ); - if (NULL == recoup_obj) - { - GNUNET_break (0); - return NULL; - } - + recoup_obj = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_data_auto ("denom_pub_hash", + &h_denom_pub), + TALER_JSON_pack_denomination_signature ("denom_sig", + denom_sig), + GNUNET_JSON_pack_data_auto ("coin_sig", + &coin_sig), + GNUNET_JSON_pack_data_auto ("coin_blind_key_secret", + &ps->blinding_key), + GNUNET_JSON_pack_bool ("refreshed", + was_refreshed)); { char pub_str[sizeof (struct TALER_CoinSpendPublicKeyP) * 2]; char *end; @@ -426,12 +403,6 @@ TALER_EXCHANGE_recoup (struct TALER_EXCHANGE_Handle *exchange, } -/** - * Cancel a recoup request. This function cannot be used on a - * request handle if the callback was already invoked. - * - * @param ph the recoup handle - */ void TALER_EXCHANGE_recoup_cancel (struct TALER_EXCHANGE_RecoupHandle *ph) { diff --git a/src/lib/exchange_api_refreshes_reveal.c b/src/lib/exchange_api_refreshes_reveal.c index d0ca605ac..f54487ae3 100644 --- a/src/lib/exchange_api_refreshes_reveal.c +++ b/src/lib/exchange_api_refreshes_reveal.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2015-2020 Taler Systems SA + Copyright (C) 2015-2021 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -287,28 +287,6 @@ handle_refresh_reveal_finished (void *cls, } -/** - * Submit a /refresh/reval request to the exchange and get the exchange's - * response. - * - * This API is typically used by a wallet. Note that to ensure that - * no money is lost in case of hardware failures, the provided - * arguments should have been committed to persistent storage - * prior to calling this function. - * - * @param exchange the exchange handle; the exchange must be ready to operate - * @param refresh_data_length size of the @a refresh_data (returned - * in the `res_size` argument from #TALER_EXCHANGE_refresh_prepare()) - * @param refresh_data the refresh data as returned from - #TALER_EXCHANGE_refresh_prepare()) - * @param noreveal_index response from the exchange to the - * #TALER_EXCHANGE_melt() invocation - * @param reveal_cb the callback to call with the final result of the - * refresh operation - * @param reveal_cb_cls closure for the above callback - * @return a handle for this request; NULL if the argument was invalid. - * In this case, neither callback will be called. - */ struct TALER_EXCHANGE_RefreshesRevealHandle * TALER_EXCHANGE_refreshes_reveal ( struct TALER_EXCHANGE_Handle *exchange, @@ -425,23 +403,17 @@ TALER_EXCHANGE_refreshes_reveal ( } /* build main JSON request */ - reveal_obj = json_pack ("{s:o, s:o, s:o, s:o, s:o}", - "transfer_pub", - GNUNET_JSON_from_data_auto (&transfer_pub), - "transfer_privs", - transfer_privs, - "link_sigs", - link_sigs, - "new_denoms_h", - new_denoms_h, - "coin_evs", - coin_evs); - if (NULL == reveal_obj) - { - GNUNET_break (0); - return NULL; - } - + reveal_obj = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_data_auto ("transfer_pub", + &transfer_pub), + GNUNET_JSON_pack_array_steal ("transfer_privs", + transfer_privs), + GNUNET_JSON_pack_array_steal ("link_sigs", + link_sigs), + GNUNET_JSON_pack_array_steal ("new_denoms_h", + new_denoms_h), + GNUNET_JSON_pack_array_steal ("coin_evs", + coin_evs)); { char pub_str[sizeof (struct TALER_RefreshCommitmentP) * 2]; char *end; @@ -498,12 +470,6 @@ TALER_EXCHANGE_refreshes_reveal ( } -/** - * Cancel a refresh reveal request. This function cannot be used - * on a request handle if the callback was already invoked. - * - * @param rrh the refresh reval handle - */ void TALER_EXCHANGE_refreshes_reveal_cancel ( struct TALER_EXCHANGE_RefreshesRevealHandle *rrh) diff --git a/src/lib/exchange_api_refund.c b/src/lib/exchange_api_refund.c index 2ac612db5..f83a2985a 100644 --- a/src/lib/exchange_api_refund.c +++ b/src/lib/exchange_api_refund.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2020 Taler Systems SA + Copyright (C) 2014-2021 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -635,35 +635,6 @@ handle_refund_finished (void *cls, } -/** - * Submit a refund request to the exchange and get the exchange's - * response. This API is used by a merchant. Note that - * while we return the response verbatim to the caller for further - * processing, we do already verify that the response is well-formed - * (i.e. that signatures included in the response are all valid). If - * the exchange's reply is not well-formed, we return an HTTP status code - * of zero to @a cb. - * - * The @a exchange must be ready to operate (i.e. have - * finished processing the /keys reply). If this check fails, we do - * NOT initiate the transaction with the exchange and instead return NULL. - * - * @param exchange the exchange handle; the exchange must be ready to operate - * @param amount the amount to be refunded; must be larger than the refund fee - * (as that fee is still being subtracted), and smaller than the amount - * (with deposit fee) of the original deposit contribution of this coin - * @param h_contract_terms hash of the contact of the merchant with the customer that is being refunded - * @param coin_pub coin’s public key of the coin from the original deposit operation - * @param rtransaction_id transaction id for the transaction between merchant and customer (of refunding operation); - * this is needed as we may first do a partial refund and later a full refund. If both - * refunds are also over the same amount, we need the @a rtransaction_id to make the disjoint - * refund requests different (as requests are idempotent and otherwise the 2nd refund might not work). - * @param merchant_priv the private key of the merchant, used to generate signature for refund request - * @param cb the callback to call when a reply for this request is available - * @param cb_cls closure for the above callback - * @return a handle for this request; NULL if the inputs are invalid (i.e. - * signatures fail to verify). In this case, the callback is not called. - */ struct TALER_EXCHANGE_RefundHandle * TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange, const struct TALER_Amount *amount, @@ -714,25 +685,17 @@ TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange, "/coins/%s/refund", pub_str); } - refund_obj = json_pack ("{s:o," /* amount */ - " s:o," /* h_contract_terms */ - " s:I," /* rtransaction id */ - " s:o, s:o}", /* merchant_pub, merchant_sig */ - "refund_amount", TALER_JSON_from_amount (amount), - "h_contract_terms", GNUNET_JSON_from_data_auto ( - h_contract_terms), - "rtransaction_id", (json_int_t) rtransaction_id, - "merchant_pub", GNUNET_JSON_from_data_auto ( - &rr.merchant), - "merchant_sig", GNUNET_JSON_from_data_auto ( - &merchant_sig) - ); - if (NULL == refund_obj) - { - GNUNET_break (0); - return NULL; - } - + refund_obj = GNUNET_JSON_PACK ( + TALER_JSON_pack_amount ("refund_amount", + amount), + GNUNET_JSON_pack_data_auto ("h_contract_terms", + h_contract_terms), + GNUNET_JSON_pack_uint64 ("rtransaction_id", + rtransaction_id), + GNUNET_JSON_pack_data_auto ("merchant_pub", + &rr.merchant), + GNUNET_JSON_pack_data_auto ("merchant_sig", + &merchant_sig)); rh = GNUNET_new (struct TALER_EXCHANGE_RefundHandle); rh->exchange = exchange; rh->cb = cb; @@ -783,12 +746,6 @@ TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange, } -/** - * Cancel a refund permission request. This function cannot be used - * on a request handle if a response is already served for it. - * - * @param refund the refund permission request handle - */ void TALER_EXCHANGE_refund_cancel (struct TALER_EXCHANGE_RefundHandle *refund) { diff --git a/src/lib/exchange_api_withdraw2.c b/src/lib/exchange_api_withdraw2.c index 6adf85520..c8a959688 100644 --- a/src/lib/exchange_api_withdraw2.c +++ b/src/lib/exchange_api_withdraw2.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2020 Taler Systems SA + Copyright (C) 2014-2021 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -344,25 +344,6 @@ handle_reserve_withdraw_finished (void *cls, } -/** - * Withdraw a coin from the exchange using a /reserve/withdraw - * request. This API is typically used by a wallet to withdraw a tip - * where the reserve's signature was created by the merchant already. - * - * Note that to ensure that no money is lost in case of hardware - * failures, the caller must have committed (most of) the arguments to - * disk before calling, and be ready to repeat the request with the - * same arguments in case of failures. - * - * @param exchange the exchange handle; the exchange must be ready to operate - * @param pd planchet details of the planchet to withdraw - * @param reserve_priv private key of the reserve to withdraw from - * @param res_cb the callback to call when the final result for this request is available - * @param res_cb_cls closure for @a res_cb - * @return NULL - * if the inputs are invalid (i.e. denomination key not with this exchange). - * In this case, the callback is not called. - */ struct TALER_EXCHANGE_Withdraw2Handle * TALER_EXCHANGE_withdraw2 ( struct TALER_EXCHANGE_Handle *exchange, @@ -445,20 +426,14 @@ TALER_EXCHANGE_withdraw2 ( { json_t *withdraw_obj; - withdraw_obj = json_pack ("{s:o, s:o, s:o}", - "denom_pub_hash", - GNUNET_JSON_from_data_auto (&pd->denom_pub_hash), - "coin_ev", - GNUNET_JSON_from_data (pd->coin_ev, - pd->coin_ev_size), - "reserve_sig", - GNUNET_JSON_from_data_auto (&reserve_sig)); - if (NULL == withdraw_obj) - { - GNUNET_break (0); - GNUNET_free (wh); - return NULL; - } + withdraw_obj = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_data_auto ("denom_pub_hash", + &pd->denom_pub_hash), + GNUNET_JSON_pack_data_varsize ("coin_ev", + pd->coin_ev, + pd->coin_ev_size), + GNUNET_JSON_pack_data_auto ("reserve_sig", + &reserve_sig)); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Attempting to withdraw from reserve %s\n", TALER_B2S (&wh->reserve_pub)); @@ -502,12 +477,6 @@ TALER_EXCHANGE_withdraw2 ( } -/** - * Cancel a withdraw status request. This function cannot be used - * on a request handle if a response is already served for it. - * - * @param wh the withdraw sign request handle - */ void TALER_EXCHANGE_withdraw2_cancel (struct TALER_EXCHANGE_Withdraw2Handle *wh) { -- cgit v1.2.3