diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-07-31 20:27:16 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-07-31 20:27:16 +0200 |
commit | 1d54400a025ff62ad15b77ab117ea5188884b1a1 (patch) | |
tree | 195b21644b44a24b84bee159ca0011a1d372a109 | |
parent | 723a3b742e9b284400c5164d146dc953383b4384 (diff) | |
download | exchange-1d54400a025ff62ad15b77ab117ea5188884b1a1.tar.gz exchange-1d54400a025ff62ad15b77ab117ea5188884b1a1.zip |
-more eliminations of json_pack
-rw-r--r-- | src/include/taler_exchange_service.h | 8 | ||||
-rw-r--r-- | src/include/taler_json_lib.h | 12 | ||||
-rw-r--r-- | src/lib/auditor_api_deposit_confirmation.c | 62 | ||||
-rw-r--r-- | src/lib/exchange_api_auditor_add_denomination.c | 14 | ||||
-rw-r--r-- | src/lib/exchange_api_deposit.c | 57 | ||||
-rw-r--r-- | src/lib/exchange_api_handle.c | 232 | ||||
-rw-r--r-- | src/lib/exchange_api_management_auditor_disable.c | 20 | ||||
-rw-r--r-- | src/lib/exchange_api_management_auditor_enable.c | 32 | ||||
-rw-r--r-- | src/lib/exchange_api_management_post_keys.c | 90 | ||||
-rw-r--r-- | src/lib/exchange_api_management_revoke_denomination_key.c | 6 | ||||
-rw-r--r-- | src/lib/exchange_api_management_revoke_signing_key.c | 16 | ||||
-rw-r--r-- | src/lib/exchange_api_management_set_wire_fee.c | 36 | ||||
-rw-r--r-- | src/lib/exchange_api_management_wire_disable.c | 24 | ||||
-rw-r--r-- | src/lib/exchange_api_management_wire_enable.c | 28 | ||||
-rw-r--r-- | src/lib/exchange_api_melt.c | 62 | ||||
-rw-r--r-- | src/lib/exchange_api_recoup.c | 55 | ||||
-rw-r--r-- | src/lib/exchange_api_refreshes_reveal.c | 58 | ||||
-rw-r--r-- | src/lib/exchange_api_refund.c | 67 | ||||
-rw-r--r-- | 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 | |||
155 | struct TALER_Amount fee_refund; | 155 | struct TALER_Amount fee_refund; |
156 | 156 | ||
157 | /** | 157 | /** |
158 | * Set to #GNUNET_YES if this denomination key has been | 158 | * Set to true if this denomination key has been |
159 | * revoked by the exchange. | 159 | * revoked by the exchange. |
160 | */ | 160 | */ |
161 | int revoked; | 161 | bool revoked; |
162 | }; | 162 | }; |
163 | 163 | ||
164 | 164 | ||
@@ -1869,7 +1869,7 @@ typedef void | |||
1869 | * @param pk kind of coin to pay back | 1869 | * @param pk kind of coin to pay back |
1870 | * @param denom_sig signature over the coin by the exchange using @a pk | 1870 | * @param denom_sig signature over the coin by the exchange using @a pk |
1871 | * @param ps secret internals of the original planchet | 1871 | * @param ps secret internals of the original planchet |
1872 | * @param was_refreshed #GNUNET_YES if the coin in @a ps was refreshed | 1872 | * @param was_refreshed true if the coin in @a ps was refreshed |
1873 | * @param recoup_cb the callback to call when the final result for this request is available | 1873 | * @param recoup_cb the callback to call when the final result for this request is available |
1874 | * @param recoup_cb_cls closure for @a recoup_cb | 1874 | * @param recoup_cb_cls closure for @a recoup_cb |
1875 | * @return NULL | 1875 | * @return NULL |
@@ -1881,7 +1881,7 @@ TALER_EXCHANGE_recoup (struct TALER_EXCHANGE_Handle *exchange, | |||
1881 | const struct TALER_EXCHANGE_DenomPublicKey *pk, | 1881 | const struct TALER_EXCHANGE_DenomPublicKey *pk, |
1882 | const struct TALER_DenominationSignature *denom_sig, | 1882 | const struct TALER_DenominationSignature *denom_sig, |
1883 | const struct TALER_PlanchetSecretsP *ps, | 1883 | const struct TALER_PlanchetSecretsP *ps, |
1884 | int was_refreshed, | 1884 | bool was_refreshed, |
1885 | TALER_EXCHANGE_RecoupResultCallback recoup_cb, | 1885 | TALER_EXCHANGE_RecoupResultCallback recoup_cb, |
1886 | void *recoup_cb_cls); | 1886 | void *recoup_cb_cls); |
1887 | 1887 | ||
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, | |||
103 | * @return json pack specification | 103 | * @return json pack specification |
104 | */ | 104 | */ |
105 | struct GNUNET_JSON_PackSpec | 105 | struct GNUNET_JSON_PackSpec |
106 | TALER_JSON_pack_denomination_public_key (const char *name, | 106 | TALER_JSON_pack_denomination_public_key ( |
107 | const struct | 107 | const char *name, |
108 | TALER_DenominationPublicKey *pk); | 108 | const struct TALER_DenominationPublicKey *pk); |
109 | 109 | ||
110 | 110 | ||
111 | /** | 111 | /** |
@@ -117,9 +117,9 @@ TALER_JSON_pack_denomination_public_key (const char *name, | |||
117 | * @return json pack specification | 117 | * @return json pack specification |
118 | */ | 118 | */ |
119 | struct GNUNET_JSON_PackSpec | 119 | struct GNUNET_JSON_PackSpec |
120 | TALER_JSON_pack_denomination_signature (const char *name, | 120 | TALER_JSON_pack_denomination_signature ( |
121 | const struct | 121 | const char *name, |
122 | TALER_DenominationSignature *sig); | 122 | const struct TALER_DenominationSignature *sig); |
123 | 123 | ||
124 | 124 | ||
125 | /** | 125 | /** |
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 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of TALER | 2 | This file is part of TALER |
3 | Copyright (C) 2014-2020 Taler Systems SA | 3 | Copyright (C) 2014-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 |
@@ -323,37 +323,35 @@ TALER_AUDITOR_deposit_confirmation ( | |||
323 | } | 323 | } |
324 | 324 | ||
325 | deposit_confirmation_obj | 325 | deposit_confirmation_obj |
326 | = json_pack ("{s:o, s:o," /* h_wire, h_contract_terms */ | 326 | = GNUNET_JSON_PACK ( |
327 | " s:o, s:o," /* timestamp, refund_deadline */ | 327 | GNUNET_JSON_pack_data_auto ("h_wire", |
328 | " s:o, s:o," /* amount_without_fees, coin_pub */ | 328 | h_wire), |
329 | " s:o, s:o," /* merchant_pub, exchange_sig */ | 329 | GNUNET_JSON_pack_data_auto ("h_contract_terms", |
330 | " s:o, s:o," /* master_pub, ep_start */ | 330 | h_contract_terms), |
331 | " s:o, s:o," /* ep_expire, ep_end */ | 331 | GNUNET_JSON_pack_time_abs ("exchange_timestamp", |
332 | " s:o, s:o}", /* master_sig, exchange_pub */ | 332 | exchange_timestamp), |
333 | "h_wire", GNUNET_JSON_from_data_auto (h_wire), | 333 | GNUNET_JSON_pack_time_abs ("refund_deadline", |
334 | "h_contract_terms", GNUNET_JSON_from_data_auto ( | 334 | refund_deadline), |
335 | h_contract_terms), | 335 | TALER_JSON_pack_amount ("amount_without_fee", |
336 | "exchange_timestamp", GNUNET_JSON_from_time_abs ( | 336 | amount_without_fee), |
337 | exchange_timestamp), | 337 | GNUNET_JSON_pack_data_auto ("coin_pub", |
338 | "refund_deadline", GNUNET_JSON_from_time_abs (refund_deadline), | 338 | coin_pub), |
339 | "amount_without_fee", TALER_JSON_from_amount ( | 339 | GNUNET_JSON_pack_data_auto ("merchant_pub", |
340 | amount_without_fee), | 340 | merchant_pub), |
341 | "coin_pub", GNUNET_JSON_from_data_auto (coin_pub), | 341 | GNUNET_JSON_pack_data_auto ("exchange_sig", |
342 | "merchant_pub", GNUNET_JSON_from_data_auto (merchant_pub), | 342 | exchange_sig), |
343 | "exchange_sig", GNUNET_JSON_from_data_auto (exchange_sig), | 343 | GNUNET_JSON_pack_data_auto ("master_pub", |
344 | "master_pub", GNUNET_JSON_from_data_auto (master_pub), | 344 | master_pub), |
345 | "ep_start", GNUNET_JSON_from_time_abs (ep_start), | 345 | GNUNET_JSON_pack_time_abs ("ep_start", |
346 | "ep_expire", GNUNET_JSON_from_time_abs (ep_expire), | 346 | ep_start), |
347 | "ep_end", GNUNET_JSON_from_time_abs (ep_end), | 347 | GNUNET_JSON_pack_time_abs ("ep_expire", |
348 | "master_sig", GNUNET_JSON_from_data_auto (master_sig), | 348 | ep_expire), |
349 | "exchange_pub", GNUNET_JSON_from_data_auto (exchange_pub)); | 349 | GNUNET_JSON_pack_time_abs ("ep_end", |
350 | 350 | ep_end), | |
351 | if (NULL == deposit_confirmation_obj) | 351 | GNUNET_JSON_pack_data_auto ("master_sig", |
352 | { | 352 | master_sig), |
353 | GNUNET_break (0); | 353 | GNUNET_JSON_pack_data_auto ("exchange_pub", |
354 | return NULL; | 354 | exchange_pub)); |
355 | } | ||
356 | |||
357 | dh = GNUNET_new (struct TALER_AUDITOR_DepositConfirmationHandle); | 355 | dh = GNUNET_new (struct TALER_AUDITOR_DepositConfirmationHandle); |
358 | dh->auditor = auditor; | 356 | dh->auditor = auditor; |
359 | dh->cb = cb; | 357 | 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 ( | |||
187 | GNUNET_free (ah); | 187 | GNUNET_free (ah); |
188 | return NULL; | 188 | return NULL; |
189 | } | 189 | } |
190 | body = json_pack ("{s:o}", | 190 | body = GNUNET_JSON_PACK ( |
191 | "auditor_sig", | 191 | GNUNET_JSON_pack_data_auto ("auditor_sig", |
192 | GNUNET_JSON_from_data_auto (auditor_sig)); | 192 | auditor_sig)); |
193 | if (NULL == body) | ||
194 | { | ||
195 | GNUNET_break (0); | ||
196 | GNUNET_free (ah->url); | ||
197 | GNUNET_free (ah); | ||
198 | return NULL; | ||
199 | } | ||
200 | eh = curl_easy_init (); | 193 | eh = curl_easy_init (); |
194 | GNUNET_assert (NULL != eh); | ||
201 | if (GNUNET_OK != | 195 | if (GNUNET_OK != |
202 | TALER_curl_easy_post (&ah->post_ctx, | 196 | TALER_curl_easy_post (&ah->post_ctx, |
203 | eh, | 197 | 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 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of TALER | 2 | This file is part of TALER |
3 | Copyright (C) 2014-2020 Taler Systems SA | 3 | Copyright (C) 2014-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 |
@@ -663,38 +663,29 @@ TALER_EXCHANGE_deposit (struct TALER_EXCHANGE_Handle *exchange, | |||
663 | return NULL; | 663 | return NULL; |
664 | } | 664 | } |
665 | 665 | ||
666 | deposit_obj = json_pack ("{s:o, s:O," /* f/wire */ | 666 | deposit_obj = GNUNET_JSON_PACK ( |
667 | " s:o, s:o," /* h_wire, h_contract_terms */ | 667 | TALER_JSON_pack_amount ("contribution", |
668 | " s:o," /* denom_pub */ | 668 | amount), |
669 | " s:o, s:o," /* ub_sig, timestamp */ | 669 | GNUNET_JSON_pack_object_incref ("wire", |
670 | " s:o," /* merchant_pub */ | 670 | wire_details), |
671 | " s:o, s:o," /* refund_deadline, wire_deadline */ | 671 | GNUNET_JSON_pack_data_auto ("h_wire", |
672 | " s:o}", /* coin_sig */ | 672 | &h_wire), |
673 | "contribution", TALER_JSON_from_amount (amount), | 673 | GNUNET_JSON_pack_data_auto ("h_contract_terms", |
674 | "wire", wire_details, | 674 | h_contract_terms), |
675 | "h_wire", GNUNET_JSON_from_data_auto (&h_wire), | 675 | GNUNET_JSON_pack_data_auto ("denom_pub_hash", |
676 | "h_contract_terms", GNUNET_JSON_from_data_auto ( | 676 | &denom_pub_hash), |
677 | h_contract_terms), | 677 | TALER_JSON_pack_denomination_signature ("ub_sig", |
678 | "denom_pub_hash", GNUNET_JSON_from_data_auto ( | 678 | denom_sig), |
679 | &denom_pub_hash), | 679 | GNUNET_JSON_pack_time_abs ("timestamp", |
680 | "ub_sig", GNUNET_JSON_from_rsa_signature ( | 680 | timestamp), |
681 | denom_sig->rsa_signature), | 681 | GNUNET_JSON_pack_data_auto ("merchant_pub", |
682 | "timestamp", GNUNET_JSON_from_time_abs (timestamp), | 682 | merchant_pub), |
683 | "merchant_pub", GNUNET_JSON_from_data_auto ( | 683 | GNUNET_JSON_pack_time_abs ("refund_deadline", |
684 | merchant_pub), | 684 | refund_deadline), |
685 | "refund_deadline", GNUNET_JSON_from_time_abs ( | 685 | GNUNET_JSON_pack_time_abs ("wire_transfer_deadline", |
686 | refund_deadline), | 686 | wire_deadline), |
687 | "wire_transfer_deadline", GNUNET_JSON_from_time_abs ( | 687 | GNUNET_JSON_pack_data_auto ("coin_sig", |
688 | wire_deadline), | 688 | coin_sig)); |
689 | "coin_sig", GNUNET_JSON_from_data_auto (coin_sig) | ||
690 | ); | ||
691 | if (NULL == deposit_obj) | ||
692 | { | ||
693 | *ec = TALER_EC_GENERIC_JSON_ALLOCATION_FAILURE; | ||
694 | GNUNET_break (0); | ||
695 | return NULL; | ||
696 | } | ||
697 | |||
698 | dh = GNUNET_new (struct TALER_EXCHANGE_DepositHandle); | 689 | dh = GNUNET_new (struct TALER_EXCHANGE_DepositHandle); |
699 | dh->auditor_chance = AUDITOR_CHANCE; | 690 | dh->auditor_chance = AUDITOR_CHANCE; |
700 | dh->exchange = exchange; | 691 | 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 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of TALER | 2 | This file is part of TALER |
3 | Copyright (C) 2014-2018 Taler Systems SA | 3 | Copyright (C) 2014-2021 Taler Systems SA |
4 | 4 | ||
5 | TALER is free software; you can redistribute it and/or modify it | 5 | TALER is free software; you can redistribute it and/or modify it |
6 | under the terms of the GNU General Public License as published | 6 | under the terms of the GNU General Public License as published |
@@ -1612,22 +1612,17 @@ TALER_EXCHANGE_serialize_data (struct TALER_EXCHANGE_Handle *exchange) | |||
1612 | 1612 | ||
1613 | if (now.abs_value_us > sk->valid_until.abs_value_us) | 1613 | if (now.abs_value_us > sk->valid_until.abs_value_us) |
1614 | continue; /* skip keys that have expired */ | 1614 | continue; /* skip keys that have expired */ |
1615 | signkey = json_pack ("{s:o, s:o, s:o, s:o, s:o}", | 1615 | signkey = GNUNET_JSON_PACK ( |
1616 | "key", | 1616 | GNUNET_JSON_pack_data_auto ("key", |
1617 | GNUNET_JSON_from_data_auto | 1617 | &sk->key), |
1618 | (&sk->key), | 1618 | GNUNET_JSON_pack_data_auto ("master_sig", |
1619 | "master_sig", | 1619 | &sk->master_sig), |
1620 | GNUNET_JSON_from_data_auto | 1620 | GNUNET_JSON_pack_time_abs ("stamp_start", |
1621 | (&sk->master_sig), | 1621 | sk->valid_from), |
1622 | "stamp_start", | 1622 | GNUNET_JSON_pack_time_abs ("stamp_expire", |
1623 | GNUNET_JSON_from_time_abs | 1623 | sk->valid_until), |
1624 | (sk->valid_from), | 1624 | GNUNET_JSON_pack_time_abs ("stamp_end", |
1625 | "stamp_expire", | 1625 | sk->valid_legal)); |
1626 | GNUNET_JSON_from_time_abs | ||
1627 | (sk->valid_until), | ||
1628 | "stamp_end", | ||
1629 | GNUNET_JSON_from_time_abs | ||
1630 | (sk->valid_legal)); | ||
1631 | if (NULL == signkey) | 1626 | if (NULL == signkey) |
1632 | { | 1627 | { |
1633 | GNUNET_break (0); | 1628 | GNUNET_break (0); |
@@ -1656,57 +1651,35 @@ TALER_EXCHANGE_serialize_data (struct TALER_EXCHANGE_Handle *exchange) | |||
1656 | 1651 | ||
1657 | if (now.abs_value_us > dk->expire_deposit.abs_value_us) | 1652 | if (now.abs_value_us > dk->expire_deposit.abs_value_us) |
1658 | continue; /* skip keys that have expired */ | 1653 | continue; /* skip keys that have expired */ |
1659 | denom = json_pack ("{s:o, s:o, s:o, s:o, s:o " | 1654 | denom = GNUNET_JSON_PACK ( |
1660 | ",s:o, s:o, s:o, s:o, s:o " | 1655 | GNUNET_JSON_pack_time_abs ("stamp_expire_deposit", |
1661 | ",s:o}", | 1656 | dk->expire_deposit), |
1662 | "stamp_expire_deposit", | 1657 | GNUNET_JSON_pack_time_abs ("stamp_expire_withdraw", |
1663 | GNUNET_JSON_from_time_abs (dk->expire_deposit), | 1658 | dk->withdraw_valid_until), |
1664 | "stamp_expire_withdraw", | 1659 | GNUNET_JSON_pack_time_abs ("stamp_start", |
1665 | GNUNET_JSON_from_time_abs (dk->withdraw_valid_until), | 1660 | dk->valid_from), |
1666 | "stamp_start", | 1661 | GNUNET_JSON_pack_time_abs ("stamp_expire_legal", |
1667 | GNUNET_JSON_from_time_abs (dk->valid_from), | 1662 | dk->expire_legal), |
1668 | "stamp_expire_legal", | 1663 | TALER_JSON_pack_amount ("value", |
1669 | GNUNET_JSON_from_time_abs (dk->expire_legal), | 1664 | &dk->value), |
1670 | "value", | 1665 | TALER_JSON_pack_amount ("fee_withdraw", |
1671 | TALER_JSON_from_amount (&dk->value), | 1666 | &dk->fee_withdraw), |
1672 | "fee_withdraw", | 1667 | TALER_JSON_pack_amount ("fee_deposit", |
1673 | /* #6 */ | 1668 | &dk->fee_deposit), |
1674 | TALER_JSON_from_amount (&dk->fee_withdraw), | 1669 | TALER_JSON_pack_amount ("fee_refresh", |
1675 | "fee_deposit", | 1670 | &dk->fee_refresh), |
1676 | TALER_JSON_from_amount (&dk->fee_deposit), | 1671 | TALER_JSON_pack_amount ("fee_refund", |
1677 | "fee_refresh", | 1672 | &dk->fee_refund), |
1678 | TALER_JSON_from_amount (&dk->fee_refresh), | 1673 | GNUNET_JSON_pack_data_auto ("master_sig", |
1679 | "fee_refund", | 1674 | &dk->master_sig), |
1680 | TALER_JSON_from_amount (&dk->fee_refund), | 1675 | TALER_JSON_pack_denomination_public_key ("denom_pub", |
1681 | "master_sig", | 1676 | &dk->key)); |
1682 | GNUNET_JSON_from_data_auto (&dk->master_sig), | 1677 | GNUNET_assert (0 == |
1683 | /* #10 */ | 1678 | json_array_append_new (denoms, |
1684 | "denom_pub", | 1679 | denom)); |
1685 | GNUNET_JSON_from_rsa_public_key ( | ||
1686 | dk->key.rsa_public_key)); | ||
1687 | if (NULL == denom) | ||
1688 | { | ||
1689 | GNUNET_break (0); | ||
1690 | continue; | ||
1691 | } | ||
1692 | if (0 != json_array_append_new (denoms, | ||
1693 | denom)) | ||
1694 | { | ||
1695 | GNUNET_break (0); | ||
1696 | json_decref (denom); | ||
1697 | json_decref (denoms); | ||
1698 | json_decref (signkeys); | ||
1699 | return NULL; | ||
1700 | } | ||
1701 | } | 1680 | } |
1702 | auditors = json_array (); | 1681 | auditors = json_array (); |
1703 | if (NULL == auditors) | 1682 | GNUNET_assert (NULL != auditors); |
1704 | { | ||
1705 | GNUNET_break (0); | ||
1706 | json_decref (denoms); | ||
1707 | json_decref (signkeys); | ||
1708 | return NULL; | ||
1709 | } | ||
1710 | for (unsigned int i = 0; i<kd->num_auditors; i++) | 1683 | for (unsigned int i = 0; i<kd->num_auditors; i++) |
1711 | { | 1684 | { |
1712 | const struct TALER_EXCHANGE_AuditorInformation *ai = &kd->auditors[i]; | 1685 | const struct TALER_EXCHANGE_AuditorInformation *ai = &kd->auditors[i]; |
@@ -1733,92 +1706,53 @@ TALER_EXCHANGE_serialize_data (struct TALER_EXCHANGE_Handle *exchange) | |||
1733 | if (now.abs_value_us > dk->expire_deposit.abs_value_us) | 1706 | if (now.abs_value_us > dk->expire_deposit.abs_value_us) |
1734 | continue; /* skip auditor signatures for denomination keys that have expired */ | 1707 | continue; /* skip auditor signatures for denomination keys that have expired */ |
1735 | GNUNET_assert (adi->denom_key_offset < kd->num_denom_keys); | 1708 | GNUNET_assert (adi->denom_key_offset < kd->num_denom_keys); |
1736 | k = json_pack ("{s:o, s:o}", | 1709 | k = GNUNET_JSON_PACK ( |
1737 | "denom_pub_h", | 1710 | GNUNET_JSON_pack_data_auto ("denom_pub_h", |
1738 | GNUNET_JSON_from_data_auto (&dk->h_key), | 1711 | &dk->h_key), |
1739 | "auditor_sig", | 1712 | GNUNET_JSON_pack_data_auto ("auditor_sig", |
1740 | GNUNET_JSON_from_data_auto (&adi->auditor_sig)); | 1713 | &adi->auditor_sig)); |
1741 | if (NULL == k) | 1714 | GNUNET_assert (0 == |
1742 | { | 1715 | json_array_append_new (adenoms, |
1743 | GNUNET_break (0); | 1716 | k)); |
1744 | json_decref (adenoms); | ||
1745 | json_decref (denoms); | ||
1746 | json_decref (signkeys); | ||
1747 | json_decref (auditors); | ||
1748 | return NULL; | ||
1749 | } | ||
1750 | if (0 != json_array_append_new (adenoms, | ||
1751 | k)) | ||
1752 | { | ||
1753 | GNUNET_break (0); | ||
1754 | json_decref (k); | ||
1755 | json_decref (adenoms); | ||
1756 | json_decref (denoms); | ||
1757 | json_decref (signkeys); | ||
1758 | json_decref (auditors); | ||
1759 | return NULL; | ||
1760 | } | ||
1761 | } | 1717 | } |
1762 | 1718 | ||
1763 | a = json_pack ("{s:o, s:s, s:o}", | 1719 | a = GNUNET_JSON_PACK ( |
1764 | "auditor_pub", | 1720 | GNUNET_JSON_pack_data_auto ("auditor_pub", |
1765 | GNUNET_JSON_from_data_auto (&ai->auditor_pub), | 1721 | &ai->auditor_pub), |
1766 | "auditor_url", | 1722 | GNUNET_JSON_pack_string ("auditor_url", |
1767 | ai->auditor_url, | 1723 | ai->auditor_url), |
1768 | "denomination_keys", | 1724 | GNUNET_JSON_pack_array_steal ("denomination_keys", |
1769 | adenoms); | 1725 | adenoms)); |
1770 | if (NULL == a) | 1726 | GNUNET_assert (0 == |
1771 | { | 1727 | json_array_append_new (auditors, |
1772 | json_decref (adenoms); | 1728 | a)); |
1773 | json_decref (denoms); | ||
1774 | json_decref (signkeys); | ||
1775 | json_decref (auditors); | ||
1776 | return NULL; | ||
1777 | } | ||
1778 | if (0 != json_array_append_new (auditors, | ||
1779 | a)) | ||
1780 | { | ||
1781 | json_decref (a); | ||
1782 | json_decref (denoms); | ||
1783 | json_decref (signkeys); | ||
1784 | json_decref (auditors); | ||
1785 | return NULL; | ||
1786 | } | ||
1787 | } | ||
1788 | keys = json_pack ("{s:s, s:s, s:o, s:o, s:o, s:o" | ||
1789 | ",s:o, s:o}", | ||
1790 | /* 1 */ | ||
1791 | "version", | ||
1792 | kd->version, | ||
1793 | "currency", | ||
1794 | kd->currency, | ||
1795 | "master_public_key", | ||
1796 | GNUNET_JSON_from_data_auto (&kd->master_pub), | ||
1797 | "reserve_closing_delay", | ||
1798 | GNUNET_JSON_from_time_rel (kd->reserve_closing_delay), | ||
1799 | "list_issue_date", | ||
1800 | GNUNET_JSON_from_time_abs (kd->list_issue_date), | ||
1801 | "signkeys", | ||
1802 | signkeys, | ||
1803 | /* #7 */ | ||
1804 | "denoms", | ||
1805 | denoms, | ||
1806 | "auditors", | ||
1807 | auditors); | ||
1808 | if (NULL == keys) | ||
1809 | { | ||
1810 | GNUNET_break (0); | ||
1811 | return NULL; | ||
1812 | } | 1729 | } |
1813 | return json_pack ("{s:I, s:o, s:s, s:o}", | 1730 | keys = GNUNET_JSON_PACK ( |
1814 | "version", | 1731 | GNUNET_JSON_pack_string ("version", |
1815 | (json_int_t) EXCHANGE_SERIALIZATION_FORMAT_VERSION, | 1732 | kd->version), |
1816 | "expire", | 1733 | GNUNET_JSON_pack_string ("currency", |
1817 | GNUNET_JSON_from_time_abs (exchange->key_data_expiration), | 1734 | kd->currency), |
1818 | "exchange_url", | 1735 | GNUNET_JSON_pack_data_auto ("master_public_key", |
1819 | exchange->url, | 1736 | &kd->master_pub), |
1820 | "keys", | 1737 | GNUNET_JSON_pack_time_rel ("reserve_closing_delay", |
1821 | keys); | 1738 | kd->reserve_closing_delay), |
1739 | GNUNET_JSON_pack_time_abs ("list_issue_date", | ||
1740 | kd->list_issue_date), | ||
1741 | GNUNET_JSON_pack_array_steal ("signkeys", | ||
1742 | signkeys), | ||
1743 | GNUNET_JSON_pack_array_steal ("denoms", | ||
1744 | denoms), | ||
1745 | GNUNET_JSON_pack_array_steal ("auditors", | ||
1746 | auditors)); | ||
1747 | return GNUNET_JSON_PACK ( | ||
1748 | GNUNET_JSON_pack_uint64 ("version", | ||
1749 | EXCHANGE_SERIALIZATION_FORMAT_VERSION), | ||
1750 | GNUNET_JSON_pack_time_abs ("expire", | ||
1751 | exchange->key_data_expiration), | ||
1752 | GNUNET_JSON_pack_string ("exchange_url", | ||
1753 | exchange->url), | ||
1754 | GNUNET_JSON_pack_object_steal ("keys", | ||
1755 | keys)); | ||
1822 | } | 1756 | } |
1823 | 1757 | ||
1824 | 1758 | ||
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 @@ | |||
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 |
@@ -166,19 +166,13 @@ TALER_EXCHANGE_management_disable_auditor ( | |||
166 | GNUNET_free (ah); | 166 | GNUNET_free (ah); |
167 | return NULL; | 167 | return NULL; |
168 | } | 168 | } |
169 | body = json_pack ("{s:o, s:o}", | 169 | body = GNUNET_JSON_PACK ( |
170 | "master_sig", | 170 | GNUNET_JSON_pack_data_auto ("master_sig", |
171 | GNUNET_JSON_from_data_auto (master_sig), | 171 | master_sig), |
172 | "validity_end", | 172 | GNUNET_JSON_pack_time_abs ("validity_end", |
173 | GNUNET_JSON_from_time_abs (validity_end)); | 173 | validity_end)); |
174 | if (NULL == body) | ||
175 | { | ||
176 | GNUNET_break (0); | ||
177 | GNUNET_free (ah->url); | ||
178 | GNUNET_free (ah); | ||
179 | return NULL; | ||
180 | } | ||
181 | eh = curl_easy_init (); | 174 | eh = curl_easy_init (); |
175 | GNUNET_assert (NULL != eh); | ||
182 | if (GNUNET_OK != | 176 | if (GNUNET_OK != |
183 | TALER_curl_easy_post (&ah->post_ctx, | 177 | TALER_curl_easy_post (&ah->post_ctx, |
184 | eh, | 178 | 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 @@ | |||
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 |
@@ -150,25 +150,19 @@ TALER_EXCHANGE_management_enable_auditor ( | |||
150 | GNUNET_free (ah); | 150 | GNUNET_free (ah); |
151 | return NULL; | 151 | return NULL; |
152 | } | 152 | } |
153 | body = json_pack ("{s:s, s:s, s:o, s:o, s:o}", | 153 | body = GNUNET_JSON_PACK ( |
154 | "auditor_url", | 154 | GNUNET_JSON_pack_string ("auditor_url", |
155 | auditor_url, | 155 | auditor_url), |
156 | "auditor_name", | 156 | GNUNET_JSON_pack_string ("auditor_name", |
157 | auditor_name, | 157 | auditor_name), |
158 | "auditor_pub", | 158 | GNUNET_JSON_pack_data_auto ("auditor_pub", |
159 | GNUNET_JSON_from_data_auto (auditor_pub), | 159 | auditor_pub), |
160 | "master_sig", | 160 | GNUNET_JSON_pack_data_auto ("master_sig", |
161 | GNUNET_JSON_from_data_auto (master_sig), | 161 | master_sig), |
162 | "validity_start", | 162 | GNUNET_JSON_pack_time_abs ("validity_start", |
163 | GNUNET_JSON_from_time_abs (validity_start)); | 163 | validity_start)); |
164 | if (NULL == body) | ||
165 | { | ||
166 | GNUNET_break (0); | ||
167 | GNUNET_free (ah->url); | ||
168 | GNUNET_free (ah); | ||
169 | return NULL; | ||
170 | } | ||
171 | eh = curl_easy_init (); | 164 | eh = curl_easy_init (); |
165 | GNUNET_assert (NULL != eh); | ||
172 | if (GNUNET_OK != | 166 | if (GNUNET_OK != |
173 | TALER_curl_easy_post (&ah->post_ctx, | 167 | TALER_curl_easy_post (&ah->post_ctx, |
174 | eh, | 168 | 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 @@ | |||
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, |
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 ( | |||
163 | GNUNET_free (rh); | 163 | GNUNET_free (rh); |
164 | return NULL; | 164 | return NULL; |
165 | } | 165 | } |
166 | body = json_pack ("{s:o}", | 166 | body = GNUNET_JSON_PACK ( |
167 | "master_sig", | 167 | GNUNET_JSON_pack_data_auto ("master_sig", |
168 | GNUNET_JSON_from_data_auto (master_sig)); | 168 | master_sig)); |
169 | if (NULL == body) | 169 | if (NULL == body) |
170 | { | 170 | { |
171 | GNUNET_break (0); | 171 | 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 @@ | |||
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 |
@@ -160,17 +160,11 @@ TALER_EXCHANGE_management_revoke_signing_key ( | |||
160 | GNUNET_free (rh); | 160 | GNUNET_free (rh); |
161 | return NULL; | 161 | return NULL; |
162 | } | 162 | } |
163 | body = json_pack ("{s:o}", | 163 | body = GNUNET_JSON_PACK ( |
164 | "master_sig", | 164 | GNUNET_JSON_pack_data_auto ("master_sig", |
165 | GNUNET_JSON_from_data_auto (master_sig)); | 165 | master_sig)); |
166 | if (NULL == body) | ||
167 | { | ||
168 | GNUNET_break (0); | ||
169 | GNUNET_free (rh->url); | ||
170 | GNUNET_free (rh); | ||
171 | return NULL; | ||
172 | } | ||
173 | eh = curl_easy_init (); | 166 | eh = curl_easy_init (); |
167 | GNUNET_assert (NULL != eh); | ||
174 | if (GNUNET_OK != | 168 | if (GNUNET_OK != |
175 | TALER_curl_easy_post (&rh->post_ctx, | 169 | TALER_curl_easy_post (&rh->post_ctx, |
176 | eh, | 170 | 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 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of TALER | 2 | This file is part of TALER |
3 | Copyright (C) 2020 Taler Systems SA | 3 | Copyright (C) 2020-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 |
@@ -152,27 +152,21 @@ TALER_EXCHANGE_management_set_wire_fees ( | |||
152 | GNUNET_free (swfh); | 152 | GNUNET_free (swfh); |
153 | return NULL; | 153 | return NULL; |
154 | } | 154 | } |
155 | body = json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o}", | 155 | body = GNUNET_JSON_PACK ( |
156 | "wire_method", | 156 | GNUNET_JSON_pack_string ("wire_method", |
157 | wire_method, | 157 | wire_method), |
158 | "master_sig", | 158 | GNUNET_JSON_pack_data_auto ("master_sig", |
159 | GNUNET_JSON_from_data_auto (master_sig), | 159 | master_sig), |
160 | "fee_start", | 160 | GNUNET_JSON_pack_time_abs ("fee_start", |
161 | GNUNET_JSON_from_time_abs (validity_start), | 161 | validity_start), |
162 | "fee_end", | 162 | GNUNET_JSON_pack_time_abs ("fee_end", |
163 | GNUNET_JSON_from_time_abs (validity_end), | 163 | validity_end), |
164 | "closing_fee", | 164 | TALER_JSON_pack_amount ("closing_fee", |
165 | TALER_JSON_from_amount (closing_fee), | 165 | closing_fee), |
166 | "wire_fee", | 166 | TALER_JSON_pack_amount ("wire_fee", |
167 | TALER_JSON_from_amount (wire_fee)); | 167 | wire_fee)); |
168 | if (NULL == body) | ||
169 | { | ||
170 | GNUNET_break (0); | ||
171 | GNUNET_free (swfh->url); | ||
172 | GNUNET_free (swfh); | ||
173 | return NULL; | ||
174 | } | ||
175 | eh = curl_easy_init (); | 168 | eh = curl_easy_init (); |
169 | GNUNET_assert (NULL != eh); | ||
176 | if (GNUNET_OK != | 170 | if (GNUNET_OK != |
177 | TALER_curl_easy_post (&swfh->post_ctx, | 171 | TALER_curl_easy_post (&swfh->post_ctx, |
178 | eh, | 172 | 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 @@ | |||
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 |
@@ -154,21 +154,15 @@ TALER_EXCHANGE_management_disable_wire ( | |||
154 | GNUNET_free (wh); | 154 | GNUNET_free (wh); |
155 | return NULL; | 155 | return NULL; |
156 | } | 156 | } |
157 | body = json_pack ("{s:s, s:o, s:o}", | 157 | body = GNUNET_JSON_PACK ( |
158 | "payto_uri", | 158 | GNUNET_JSON_pack_string ("payto_uri", |
159 | payto_uri, | 159 | payto_uri), |
160 | "master_sig_del", | 160 | GNUNET_JSON_pack_data_auto ("master_sig_del", |
161 | GNUNET_JSON_from_data_auto (master_sig), | 161 | master_sig), |
162 | "validity_end", | 162 | GNUNET_JSON_pack_time_abs ("validity_end", |
163 | GNUNET_JSON_from_time_abs (validity_end)); | 163 | validity_end)); |
164 | if (NULL == body) | ||
165 | { | ||
166 | GNUNET_break (0); | ||
167 | GNUNET_free (wh->url); | ||
168 | GNUNET_free (wh); | ||
169 | return NULL; | ||
170 | } | ||
171 | eh = curl_easy_init (); | 164 | eh = curl_easy_init (); |
165 | GNUNET_assert (NULL != eh); | ||
172 | if (GNUNET_OK != | 166 | if (GNUNET_OK != |
173 | TALER_curl_easy_post (&wh->post_ctx, | 167 | TALER_curl_easy_post (&wh->post_ctx, |
174 | eh, | 168 | 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 @@ | |||
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 |
@@ -151,23 +151,17 @@ TALER_EXCHANGE_management_enable_wire ( | |||
151 | GNUNET_free (wh); | 151 | GNUNET_free (wh); |
152 | return NULL; | 152 | return NULL; |
153 | } | 153 | } |
154 | body = json_pack ("{s:s, s:o, s:o, s:o}", | 154 | body = GNUNET_JSON_PACK ( |
155 | "payto_uri", | 155 | GNUNET_JSON_pack_string ("payto_uri", |
156 | payto_uri, | 156 | payto_uri), |
157 | "master_sig_add", | 157 | GNUNET_JSON_pack_data_auto ("master_sig_add", |
158 | GNUNET_JSON_from_data_auto (master_sig1), | 158 | master_sig1), |
159 | "master_sig_wire", | 159 | GNUNET_JSON_pack_data_auto ("master_sig_wire", |
160 | GNUNET_JSON_from_data_auto (master_sig2), | 160 | master_sig2), |
161 | "validity_start", | 161 | GNUNET_JSON_pack_time_abs ("validity_start", |
162 | GNUNET_JSON_from_time_abs (validity_start)); | 162 | validity_start)); |
163 | if (NULL == body) | ||
164 | { | ||
165 | GNUNET_break (0); | ||
166 | GNUNET_free (wh->url); | ||
167 | GNUNET_free (wh); | ||
168 | return NULL; | ||
169 | } | ||
170 | eh = curl_easy_init (); | 163 | eh = curl_easy_init (); |
164 | GNUNET_assert (NULL != eh); | ||
171 | if (GNUNET_OK != | 165 | if (GNUNET_OK != |
172 | TALER_curl_easy_post (&wh->post_ctx, | 166 | TALER_curl_easy_post (&wh->post_ctx, |
173 | eh, | 167 | 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 @@ | |||
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 |
@@ -449,26 +449,6 @@ handle_melt_finished (void *cls, | |||
449 | } | 449 | } |
450 | 450 | ||
451 | 451 | ||
452 | /** | ||
453 | * Submit a melt request to the exchange and get the exchange's | ||
454 | * response. | ||
455 | * | ||
456 | * This API is typically used by a wallet. Note that to ensure that | ||
457 | * no money is lost in case of hardware failures, the provided | ||
458 | * argument should have been constructed using | ||
459 | * #TALER_EXCHANGE_refresh_prepare and committed to persistent storage | ||
460 | * prior to calling this function. | ||
461 | * | ||
462 | * @param exchange the exchange handle; the exchange must be ready to operate | ||
463 | * @param refresh_data_length size of the @a refresh_data (returned | ||
464 | * in the `res_size` argument from #TALER_EXCHANGE_refresh_prepare()) | ||
465 | * @param refresh_data the refresh data as returned from | ||
466 | #TALER_EXCHANGE_refresh_prepare()) | ||
467 | * @param melt_cb the callback to call with the result | ||
468 | * @param melt_cb_cls closure for @a melt_cb | ||
469 | * @return a handle for this request; NULL if the argument was invalid. | ||
470 | * In this case, neither callback will be called. | ||
471 | */ | ||
472 | struct TALER_EXCHANGE_MeltHandle * | 452 | struct TALER_EXCHANGE_MeltHandle * |
473 | TALER_EXCHANGE_melt (struct TALER_EXCHANGE_Handle *exchange, | 453 | TALER_EXCHANGE_melt (struct TALER_EXCHANGE_Handle *exchange, |
474 | size_t refresh_data_length, | 454 | size_t refresh_data_length, |
@@ -511,27 +491,19 @@ TALER_EXCHANGE_melt (struct TALER_EXCHANGE_Handle *exchange, | |||
511 | GNUNET_CRYPTO_eddsa_sign (&md->melted_coin.coin_priv.eddsa_priv, | 491 | GNUNET_CRYPTO_eddsa_sign (&md->melted_coin.coin_priv.eddsa_priv, |
512 | &melt, | 492 | &melt, |
513 | &confirm_sig.eddsa_signature); | 493 | &confirm_sig.eddsa_signature); |
514 | melt_obj = json_pack ("{s:o, s:o, s:o, s:o, s:o, s:o}", | 494 | melt_obj = GNUNET_JSON_PACK ( |
515 | "coin_pub", | 495 | GNUNET_JSON_pack_data_auto ("coin_pub", |
516 | GNUNET_JSON_from_data_auto (&melt.coin_pub), | 496 | &melt.coin_pub), |
517 | "denom_pub_hash", | 497 | GNUNET_JSON_pack_data_auto ("denom_pub_hash", |
518 | GNUNET_JSON_from_data_auto (&melt.h_denom_pub), | 498 | &melt.h_denom_pub), |
519 | "denom_sig", | 499 | TALER_JSON_pack_denomination_signature ("denom_sig", |
520 | GNUNET_JSON_from_rsa_signature ( | 500 | &md->melted_coin.sig), |
521 | md->melted_coin.sig.rsa_signature), | 501 | GNUNET_JSON_pack_data_auto ("confirm_sig", |
522 | "confirm_sig", | 502 | &confirm_sig), |
523 | GNUNET_JSON_from_data_auto (&confirm_sig), | 503 | TALER_JSON_pack_amount ("value_with_fee", |
524 | "value_with_fee", | 504 | &md->melted_coin.melt_amount_with_fee), |
525 | TALER_JSON_from_amount ( | 505 | GNUNET_JSON_pack_data_auto ("rc", |
526 | &md->melted_coin.melt_amount_with_fee), | 506 | &melt.rc)); |
527 | "rc", | ||
528 | GNUNET_JSON_from_data_auto (&melt.rc)); | ||
529 | if (NULL == melt_obj) | ||
530 | { | ||
531 | GNUNET_break (0); | ||
532 | TALER_EXCHANGE_free_melt_data_ (md); | ||
533 | return NULL; | ||
534 | } | ||
535 | { | 507 | { |
536 | char pub_str[sizeof (struct TALER_CoinSpendPublicKeyP) * 2]; | 508 | char pub_str[sizeof (struct TALER_CoinSpendPublicKeyP) * 2]; |
537 | char *end; | 509 | char *end; |
@@ -596,12 +568,6 @@ TALER_EXCHANGE_melt (struct TALER_EXCHANGE_Handle *exchange, | |||
596 | } | 568 | } |
597 | 569 | ||
598 | 570 | ||
599 | /** | ||
600 | * Cancel a melt request. This function cannot be used | ||
601 | * on a request handle if either callback was already invoked. | ||
602 | * | ||
603 | * @param mh the refresh melt handle | ||
604 | */ | ||
605 | void | 571 | void |
606 | TALER_EXCHANGE_melt_cancel (struct TALER_EXCHANGE_MeltHandle *mh) | 572 | TALER_EXCHANGE_melt_cancel (struct TALER_EXCHANGE_MeltHandle *mh) |
607 | { | 573 | { |
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 | { |
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 @@ | |||
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 |
@@ -287,28 +287,6 @@ handle_refresh_reveal_finished (void *cls, | |||
287 | } | 287 | } |
288 | 288 | ||
289 | 289 | ||
290 | /** | ||
291 | * Submit a /refresh/reval request to the exchange and get the exchange's | ||
292 | * response. | ||
293 | * | ||
294 | * This API is typically used by a wallet. Note that to ensure that | ||
295 | * no money is lost in case of hardware failures, the provided | ||
296 | * arguments should have been committed to persistent storage | ||
297 | * prior to calling this function. | ||
298 | * | ||
299 | * @param exchange the exchange handle; the exchange must be ready to operate | ||
300 | * @param refresh_data_length size of the @a refresh_data (returned | ||
301 | * in the `res_size` argument from #TALER_EXCHANGE_refresh_prepare()) | ||
302 | * @param refresh_data the refresh data as returned from | ||
303 | #TALER_EXCHANGE_refresh_prepare()) | ||
304 | * @param noreveal_index response from the exchange to the | ||
305 | * #TALER_EXCHANGE_melt() invocation | ||
306 | * @param reveal_cb the callback to call with the final result of the | ||
307 | * refresh operation | ||
308 | * @param reveal_cb_cls closure for the above callback | ||
309 | * @return a handle for this request; NULL if the argument was invalid. | ||
310 | * In this case, neither callback will be called. | ||
311 | */ | ||
312 | struct TALER_EXCHANGE_RefreshesRevealHandle * | 290 | struct TALER_EXCHANGE_RefreshesRevealHandle * |
313 | TALER_EXCHANGE_refreshes_reveal ( | 291 | TALER_EXCHANGE_refreshes_reveal ( |
314 | struct TALER_EXCHANGE_Handle *exchange, | 292 | struct TALER_EXCHANGE_Handle *exchange, |
@@ -425,23 +403,17 @@ TALER_EXCHANGE_refreshes_reveal ( | |||
425 | } | 403 | } |
426 | 404 | ||
427 | /* build main JSON request */ | 405 | /* build main JSON request */ |
428 | reveal_obj = json_pack ("{s:o, s:o, s:o, s:o, s:o}", | 406 | reveal_obj = GNUNET_JSON_PACK ( |
429 | "transfer_pub", | 407 | GNUNET_JSON_pack_data_auto ("transfer_pub", |
430 | GNUNET_JSON_from_data_auto (&transfer_pub), | 408 | &transfer_pub), |
431 | "transfer_privs", | 409 | GNUNET_JSON_pack_array_steal ("transfer_privs", |
432 | transfer_privs, | 410 | transfer_privs), |
433 | "link_sigs", | 411 | GNUNET_JSON_pack_array_steal ("link_sigs", |
434 | link_sigs, | 412 | link_sigs), |
435 | "new_denoms_h", | 413 | GNUNET_JSON_pack_array_steal ("new_denoms_h", |
436 | new_denoms_h, | 414 | new_denoms_h), |
437 | "coin_evs", | 415 | GNUNET_JSON_pack_array_steal ("coin_evs", |
438 | coin_evs); | 416 | coin_evs)); |
439 | if (NULL == reveal_obj) | ||
440 | { | ||
441 | GNUNET_break (0); | ||
442 | return NULL; | ||
443 | } | ||
444 | |||
445 | { | 417 | { |
446 | char pub_str[sizeof (struct TALER_RefreshCommitmentP) * 2]; | 418 | char pub_str[sizeof (struct TALER_RefreshCommitmentP) * 2]; |
447 | char *end; | 419 | char *end; |
@@ -498,12 +470,6 @@ TALER_EXCHANGE_refreshes_reveal ( | |||
498 | } | 470 | } |
499 | 471 | ||
500 | 472 | ||
501 | /** | ||
502 | * Cancel a refresh reveal request. This function cannot be used | ||
503 | * on a request handle if the callback was already invoked. | ||
504 | * | ||
505 | * @param rrh the refresh reval handle | ||
506 | */ | ||
507 | void | 473 | void |
508 | TALER_EXCHANGE_refreshes_reveal_cancel ( | 474 | TALER_EXCHANGE_refreshes_reveal_cancel ( |
509 | struct TALER_EXCHANGE_RefreshesRevealHandle *rrh) | 475 | 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 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of TALER | 2 | This file is part of TALER |
3 | Copyright (C) 2014-2020 Taler Systems SA | 3 | Copyright (C) 2014-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 |
@@ -635,35 +635,6 @@ handle_refund_finished (void *cls, | |||
635 | } | 635 | } |
636 | 636 | ||
637 | 637 | ||
638 | /** | ||
639 | * Submit a refund request to the exchange and get the exchange's | ||
640 | * response. This API is used by a merchant. Note that | ||
641 | * while we return the response verbatim to the caller for further | ||
642 | * processing, we do already verify that the response is well-formed | ||
643 | * (i.e. that signatures included in the response are all valid). If | ||
644 | * the exchange's reply is not well-formed, we return an HTTP status code | ||
645 | * of zero to @a cb. | ||
646 | * | ||
647 | * The @a exchange must be ready to operate (i.e. have | ||
648 | * finished processing the /keys reply). If this check fails, we do | ||
649 | * NOT initiate the transaction with the exchange and instead return NULL. | ||
650 | * | ||
651 | * @param exchange the exchange handle; the exchange must be ready to operate | ||
652 | * @param amount the amount to be refunded; must be larger than the refund fee | ||
653 | * (as that fee is still being subtracted), and smaller than the amount | ||
654 | * (with deposit fee) of the original deposit contribution of this coin | ||
655 | * @param h_contract_terms hash of the contact of the merchant with the customer that is being refunded | ||
656 | * @param coin_pub coin’s public key of the coin from the original deposit operation | ||
657 | * @param rtransaction_id transaction id for the transaction between merchant and customer (of refunding operation); | ||
658 | * this is needed as we may first do a partial refund and later a full refund. If both | ||
659 | * refunds are also over the same amount, we need the @a rtransaction_id to make the disjoint | ||
660 | * refund requests different (as requests are idempotent and otherwise the 2nd refund might not work). | ||
661 | * @param merchant_priv the private key of the merchant, used to generate signature for refund request | ||
662 | * @param cb the callback to call when a reply for this request is available | ||
663 | * @param cb_cls closure for the above callback | ||
664 | * @return a handle for this request; NULL if the inputs are invalid (i.e. | ||
665 | * signatures fail to verify). In this case, the callback is not called. | ||
666 | */ | ||
667 | struct TALER_EXCHANGE_RefundHandle * | 638 | struct TALER_EXCHANGE_RefundHandle * |
668 | TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange, | 639 | TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange, |
669 | const struct TALER_Amount *amount, | 640 | const struct TALER_Amount *amount, |
@@ -714,25 +685,17 @@ TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange, | |||
714 | "/coins/%s/refund", | 685 | "/coins/%s/refund", |
715 | pub_str); | 686 | pub_str); |
716 | } | 687 | } |
717 | refund_obj = json_pack ("{s:o," /* amount */ | 688 | refund_obj = GNUNET_JSON_PACK ( |
718 | " s:o," /* h_contract_terms */ | 689 | TALER_JSON_pack_amount ("refund_amount", |
719 | " s:I," /* rtransaction id */ | 690 | amount), |
720 | " s:o, s:o}", /* merchant_pub, merchant_sig */ | 691 | GNUNET_JSON_pack_data_auto ("h_contract_terms", |
721 | "refund_amount", TALER_JSON_from_amount (amount), | 692 | h_contract_terms), |
722 | "h_contract_terms", GNUNET_JSON_from_data_auto ( | 693 | GNUNET_JSON_pack_uint64 ("rtransaction_id", |
723 | h_contract_terms), | 694 | rtransaction_id), |
724 | "rtransaction_id", (json_int_t) rtransaction_id, | 695 | GNUNET_JSON_pack_data_auto ("merchant_pub", |
725 | "merchant_pub", GNUNET_JSON_from_data_auto ( | 696 | &rr.merchant), |
726 | &rr.merchant), | 697 | GNUNET_JSON_pack_data_auto ("merchant_sig", |
727 | "merchant_sig", GNUNET_JSON_from_data_auto ( | 698 | &merchant_sig)); |
728 | &merchant_sig) | ||
729 | ); | ||
730 | if (NULL == refund_obj) | ||
731 | { | ||
732 | GNUNET_break (0); | ||
733 | return NULL; | ||
734 | } | ||
735 | |||
736 | rh = GNUNET_new (struct TALER_EXCHANGE_RefundHandle); | 699 | rh = GNUNET_new (struct TALER_EXCHANGE_RefundHandle); |
737 | rh->exchange = exchange; | 700 | rh->exchange = exchange; |
738 | rh->cb = cb; | 701 | rh->cb = cb; |
@@ -783,12 +746,6 @@ TALER_EXCHANGE_refund (struct TALER_EXCHANGE_Handle *exchange, | |||
783 | } | 746 | } |
784 | 747 | ||
785 | 748 | ||
786 | /** | ||
787 | * Cancel a refund permission request. This function cannot be used | ||
788 | * on a request handle if a response is already served for it. | ||
789 | * | ||
790 | * @param refund the refund permission request handle | ||
791 | */ | ||
792 | void | 749 | void |
793 | TALER_EXCHANGE_refund_cancel (struct TALER_EXCHANGE_RefundHandle *refund) | 750 | TALER_EXCHANGE_refund_cancel (struct TALER_EXCHANGE_RefundHandle *refund) |
794 | { | 751 | { |
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 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of TALER | 2 | This file is part of TALER |
3 | Copyright (C) 2014-2020 Taler Systems SA | 3 | Copyright (C) 2014-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 |
@@ -344,25 +344,6 @@ handle_reserve_withdraw_finished (void *cls, | |||
344 | } | 344 | } |
345 | 345 | ||
346 | 346 | ||
347 | /** | ||
348 | * Withdraw a coin from the exchange using a /reserve/withdraw | ||
349 | * request. This API is typically used by a wallet to withdraw a tip | ||
350 | * where the reserve's signature was created by the merchant already. | ||
351 | * | ||
352 | * Note that to ensure that no money is lost in case of hardware | ||
353 | * failures, the caller must have committed (most of) the arguments to | ||
354 | * disk before calling, and be ready to repeat the request with the | ||
355 | * same arguments in case of failures. | ||
356 | * | ||
357 | * @param exchange the exchange handle; the exchange must be ready to operate | ||
358 | * @param pd planchet details of the planchet to withdraw | ||
359 | * @param reserve_priv private key of the reserve to withdraw from | ||
360 | * @param res_cb the callback to call when the final result for this request is available | ||
361 | * @param res_cb_cls closure for @a res_cb | ||
362 | * @return NULL | ||
363 | * if the inputs are invalid (i.e. denomination key not with this exchange). | ||
364 | * In this case, the callback is not called. | ||
365 | */ | ||
366 | struct TALER_EXCHANGE_Withdraw2Handle * | 347 | struct TALER_EXCHANGE_Withdraw2Handle * |
367 | TALER_EXCHANGE_withdraw2 ( | 348 | TALER_EXCHANGE_withdraw2 ( |
368 | struct TALER_EXCHANGE_Handle *exchange, | 349 | struct TALER_EXCHANGE_Handle *exchange, |
@@ -445,20 +426,14 @@ TALER_EXCHANGE_withdraw2 ( | |||
445 | { | 426 | { |
446 | json_t *withdraw_obj; | 427 | json_t *withdraw_obj; |
447 | 428 | ||
448 | withdraw_obj = json_pack ("{s:o, s:o, s:o}", | 429 | withdraw_obj = GNUNET_JSON_PACK ( |
449 | "denom_pub_hash", | 430 | GNUNET_JSON_pack_data_auto ("denom_pub_hash", |
450 | GNUNET_JSON_from_data_auto (&pd->denom_pub_hash), | 431 | &pd->denom_pub_hash), |
451 | "coin_ev", | 432 | GNUNET_JSON_pack_data_varsize ("coin_ev", |
452 | GNUNET_JSON_from_data (pd->coin_ev, | 433 | pd->coin_ev, |
453 | pd->coin_ev_size), | 434 | pd->coin_ev_size), |
454 | "reserve_sig", | 435 | GNUNET_JSON_pack_data_auto ("reserve_sig", |
455 | GNUNET_JSON_from_data_auto (&reserve_sig)); | 436 | &reserve_sig)); |
456 | if (NULL == withdraw_obj) | ||
457 | { | ||
458 | GNUNET_break (0); | ||
459 | GNUNET_free (wh); | ||
460 | return NULL; | ||
461 | } | ||
462 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 437 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
463 | "Attempting to withdraw from reserve %s\n", | 438 | "Attempting to withdraw from reserve %s\n", |
464 | TALER_B2S (&wh->reserve_pub)); | 439 | TALER_B2S (&wh->reserve_pub)); |
@@ -502,12 +477,6 @@ TALER_EXCHANGE_withdraw2 ( | |||
502 | } | 477 | } |
503 | 478 | ||
504 | 479 | ||
505 | /** | ||
506 | * Cancel a withdraw status request. This function cannot be used | ||
507 | * on a request handle if a response is already served for it. | ||
508 | * | ||
509 | * @param wh the withdraw sign request handle | ||
510 | */ | ||
511 | void | 480 | void |
512 | TALER_EXCHANGE_withdraw2_cancel (struct TALER_EXCHANGE_Withdraw2Handle *wh) | 481 | TALER_EXCHANGE_withdraw2_cancel (struct TALER_EXCHANGE_Withdraw2Handle *wh) |
513 | { | 482 | { |