diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-07-30 17:24:16 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-07-30 17:24:18 +0200 |
commit | cbb905a9aae891c6c3af5ead5709951c4f038a2a (patch) | |
tree | a4d2ef3818c58924329e9db8eb588ac07aec129c | |
parent | 7e409c37ab6f339811441c8803109afb218d0854 (diff) |
-eliminate more json_pack format strings
-rw-r--r-- | src/exchange/taler-exchange-httpd.c | 2 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_deposit.c | 15 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_deposits_get.c | 38 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_keys.c | 249 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_link.c | 26 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_melt.c | 44 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_recoup.c | 20 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_refreshes_reveal.c | 67 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_refund.c | 55 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_reserves_get.c | 14 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_responses.c | 217 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_transfers_get.c | 72 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_wire.c | 47 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_withdraw.c | 27 |
14 files changed, 424 insertions, 469 deletions
diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c index 6113152af..ea8830be4 100644 --- a/src/exchange/taler-exchange-httpd.c +++ b/src/exchange/taler-exchange-httpd.c @@ -1161,7 +1161,7 @@ exchange_serve_process_config (void) { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "exchange", - "master_public_key"); + "MASTER_PUBLIC_KEY"); return GNUNET_SYSERR; } if (GNUNET_OK != diff --git a/src/exchange/taler-exchange-httpd_deposit.c b/src/exchange/taler-exchange-httpd_deposit.c index 5e802fb0e..ba94f25d6 100644 --- a/src/exchange/taler-exchange-httpd_deposit.c +++ b/src/exchange/taler-exchange-httpd_deposit.c @@ -89,16 +89,15 @@ reply_deposit_success (struct MHD_Connection *connection, ec, NULL); } - return TALER_MHD_reply_json_pack ( + return TALER_MHD_REPLY_JSON_PACK ( connection, MHD_HTTP_OK, - "{s:o, s:o, s:o}", - "exchange_timestamp", - GNUNET_JSON_from_time_abs (exchange_timestamp), - "exchange_sig", - GNUNET_JSON_from_data_auto (&sig), - "exchange_pub", - GNUNET_JSON_from_data_auto (&pub)); + GNUNET_JSON_pack_time_abs ("exchange_timestamp", + exchange_timestamp), + GNUNET_JSON_pack_data_auto ("exchange_sig", + &sig), + GNUNET_JSON_pack_data_auto ("exchange_pub", + &pub)); } diff --git a/src/exchange/taler-exchange-httpd_deposits_get.c b/src/exchange/taler-exchange-httpd_deposits_get.c index 90f28b4e3..c51e0f426 100644 --- a/src/exchange/taler-exchange-httpd_deposits_get.c +++ b/src/exchange/taler-exchange-httpd_deposits_get.c @@ -78,20 +78,19 @@ reply_deposit_details (struct MHD_Connection *connection, ec, NULL); } - return TALER_MHD_reply_json_pack (connection, - MHD_HTTP_OK, - "{s:o, s:o, s:o, s:o, s:o}", - "wtid", GNUNET_JSON_from_data_auto ( - wtid), - "execution_time", - GNUNET_JSON_from_time_abs (exec_time), - "coin_contribution", - TALER_JSON_from_amount ( - coin_contribution), - "exchange_sig", - GNUNET_JSON_from_data_auto (&sig), - "exchange_pub", - GNUNET_JSON_from_data_auto (&pub)); + return TALER_MHD_REPLY_JSON_PACK ( + connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_data_auto ("wtid", + wtid), + GNUNET_JSON_pack_time_abs ("execution_time", + exec_time), + TALER_JSON_pack_amount ("coin_contribution", + coin_contribution), + GNUNET_JSON_pack_data_auto ("exchange_sig", + &sig), + GNUNET_JSON_pack_data_auto ("exchange_pub", + &pub)); } @@ -279,12 +278,11 @@ handle_track_transaction_request ( &ctx)) return mhd_ret; if (GNUNET_YES == ctx.pending) - return TALER_MHD_reply_json_pack (connection, - MHD_HTTP_ACCEPTED, - "{s:o}", - "execution_time", - GNUNET_JSON_from_time_abs ( - ctx.execution_time)); + return TALER_MHD_REPLY_JSON_PACK ( + connection, + MHD_HTTP_ACCEPTED, + GNUNET_JSON_pack_time_abs ("execution_time", + ctx.execution_time)); if (GNUNET_SYSERR == ctx.pending) return TALER_MHD_reply_with_error (connection, MHD_HTTP_INTERNAL_SERVER_ERROR, diff --git a/src/exchange/taler-exchange-httpd_keys.c b/src/exchange/taler-exchange-httpd_keys.c index b12a1e420..0cd618042 100644 --- a/src/exchange/taler-exchange-httpd_keys.c +++ b/src/exchange/taler-exchange-httpd_keys.c @@ -1074,12 +1074,11 @@ get_auditor_sigs (void *cls, GNUNET_break (0 == json_array_append_new ( ctx->denom_keys, - json_pack ( - "{s:o, s:o}", - "denom_pub_h", - GNUNET_JSON_from_data_auto (h_denom_pub), - "auditor_sig", - GNUNET_JSON_from_data_auto (&as->asig)))); + GNUNET_JSON_PACK ( + GNUNET_JSON_pack_data_auto ("denom_pub_h", + h_denom_pub), + GNUNET_JSON_pack_data_auto ("auditor_sig", + &as->asig)))); } return GNUNET_OK; } @@ -1104,6 +1103,7 @@ auditor_info_cb ( struct GetAuditorSigsContext ctx; ctx.denom_keys = json_array (); + GNUNET_assert (NULL != ctx.denom_keys); ctx.auditor_pub = auditor_pub; GNUNET_CONTAINER_multihashmap_iterate (ksh->denomkey_map, &get_auditor_sigs, @@ -1111,15 +1111,15 @@ auditor_info_cb ( GNUNET_break (0 == json_array_append_new ( ksh->auditors, - json_pack ("{s:s, s:o, s:s, s:o}", - "auditor_name", - auditor_name, - "auditor_pub", - GNUNET_JSON_from_data_auto (auditor_pub), - "auditor_url", - auditor_url, - "denomination_keys", - ctx.denom_keys))); + GNUNET_JSON_PACK ( + GNUNET_JSON_pack_string ("auditor_name", + auditor_name), + GNUNET_JSON_pack_data_auto ("auditor_pub", + auditor_pub), + GNUNET_JSON_pack_string ("auditor_url", + auditor_url), + GNUNET_JSON_pack_array_steal ("denomination_keys", + ctx.denom_keys)))); } @@ -1204,17 +1204,17 @@ add_sign_key_cb (void *cls, 0 == json_array_append_new ( ctx->signkeys, - json_pack ("{s:o, s:o, s:o, s:o, s:o}", - "stamp_start", - GNUNET_JSON_from_time_abs (sk->meta.start), - "stamp_expire", - GNUNET_JSON_from_time_abs (sk->meta.expire_sign), - "stamp_end", - GNUNET_JSON_from_time_abs (sk->meta.expire_legal), - "master_sig", - GNUNET_JSON_from_data_auto (&sk->master_sig), - "key", - GNUNET_JSON_from_data_auto (&sk->exchange_pub)))); + GNUNET_JSON_PACK ( + GNUNET_JSON_pack_time_abs ("stamp_start", + sk->meta.start), + GNUNET_JSON_pack_time_abs ("stamp_expire", + sk->meta.expire_sign), + GNUNET_JSON_pack_time_abs ("stamp_end", + sk->meta.expire_legal), + GNUNET_JSON_pack_data_auto ("master_sig", + &sk->master_sig), + GNUNET_JSON_pack_data_auto ("key", + &sk->exchange_pub)))); return GNUNET_OK; } @@ -1266,9 +1266,9 @@ add_denom_key_cb (void *cls, 0 == json_array_append_new ( dkc->recoup, - json_pack ("{s:o}", - "h_denom_pub", - GNUNET_JSON_from_data_auto (h_denom_pub)))); + GNUNET_JSON_PACK ( + GNUNET_JSON_pack_data_auto ("h_denom_pub", + h_denom_pub)))); } else { @@ -1440,23 +1440,29 @@ create_krd (struct TEH_KeyStateHandle *ksh, ksh->signature_expires); } - keys = json_pack ( - "{s:s, s:s, s:o, s:o, s:O, s:O," - " s:O, s:O, s:o, s:o, s:o}", - /* 1-6 */ - "version", EXCHANGE_PROTOCOL_VERSION, - "currency", TEH_currency, - "master_public_key", GNUNET_JSON_from_data_auto (&TEH_master_public_key), - "reserve_closing_delay", GNUNET_JSON_from_time_rel ( - TEH_reserve_closing_delay), - "signkeys", signkeys, - "recoup", recoup, - /* 7-11 */ - "denoms", denoms, - "auditors", ksh->auditors, - "list_issue_date", GNUNET_JSON_from_time_abs (last_cpd), - "eddsa_pub", GNUNET_JSON_from_data_auto (&exchange_pub), - "eddsa_sig", GNUNET_JSON_from_data_auto (&exchange_sig)); + keys = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_string ("version", + EXCHANGE_PROTOCOL_VERSION), + GNUNET_JSON_pack_string ("currency", + TEH_currency), + GNUNET_JSON_pack_data_auto ("master_public_key", + &TEH_master_public_key), + GNUNET_JSON_pack_time_rel ("reserve_closing_delay", + TEH_reserve_closing_delay), + GNUNET_JSON_pack_array_incref ("signkeys", + signkeys), + GNUNET_JSON_pack_array_incref ("recoup", + recoup), + GNUNET_JSON_pack_array_incref ("denoms", + denoms), + GNUNET_JSON_pack_array_incref ("auditors", + ksh->auditors), + GNUNET_JSON_pack_time_abs ("list_issue_date", + last_cpd), + GNUNET_JSON_pack_data_auto ("eddsa_pub", + &exchange_pub), + GNUNET_JSON_pack_data_auto ("eddsa_sig", + &exchange_sig)); GNUNET_assert (NULL != keys); { @@ -1601,34 +1607,29 @@ finish_keys_response (struct TEH_KeyStateHandle *ksh) 0 == json_array_append_new ( denoms, - json_pack ("{s:o, s:o, s:o, s:o, s:o," - " s:o, s:o, s:o, s:o, s:o," - " s:o}", - "master_sig", - GNUNET_JSON_from_data_auto (&dk->master_sig), - "stamp_start", - GNUNET_JSON_from_time_abs (dk->meta.start), - "stamp_expire_withdraw", - GNUNET_JSON_from_time_abs (dk->meta.expire_withdraw), - "stamp_expire_deposit", - GNUNET_JSON_from_time_abs (dk->meta.expire_deposit), - "stamp_expire_legal", - GNUNET_JSON_from_time_abs (dk->meta.expire_legal), - /* 5 entries until here */ - "denom_pub", - GNUNET_JSON_from_rsa_public_key ( - dk->denom_pub.rsa_public_key), - "value", - TALER_JSON_from_amount (&dk->meta.value), - "fee_withdraw", - TALER_JSON_from_amount (&dk->meta.fee_withdraw), - "fee_deposit", - TALER_JSON_from_amount (&dk->meta.fee_deposit), - "fee_refresh", - TALER_JSON_from_amount (&dk->meta.fee_refresh), - /* 10 entries until here */ - "fee_refund", - TALER_JSON_from_amount (&dk->meta.fee_refund)))); + GNUNET_JSON_PACK ( + GNUNET_JSON_pack_data_auto ("master_sig", + &dk->master_sig), + GNUNET_JSON_pack_time_abs ("stamp_start", + dk->meta.start), + GNUNET_JSON_pack_time_abs ("stamp_expire_withdraw", + dk->meta.expire_withdraw), + GNUNET_JSON_pack_time_abs ("stamp_expire_deposit", + dk->meta.expire_deposit), + GNUNET_JSON_pack_time_abs ("stamp_expire_legal", + dk->meta.expire_legal), + GNUNET_JSON_pack_rsa_public_key ("denom_pub", + dk->denom_pub.rsa_public_key), + TALER_JSON_pack_amount ("value", + &dk->meta.value), + TALER_JSON_pack_amount ("fee_withdraw", + &dk->meta.fee_withdraw), + TALER_JSON_pack_amount ("fee_deposit", + &dk->meta.fee_deposit), + TALER_JSON_pack_amount ("fee_refresh", + &dk->meta.fee_refresh), + TALER_JSON_pack_amount ("fee_refund", + &dk->meta.fee_refund)))); } } GNUNET_CONTAINER_heap_destroy (heap); @@ -2400,36 +2401,31 @@ add_future_denomkey_cb (void *cls, 0 == json_array_append_new ( fbc->denoms, - json_pack ("{s:o, s:o, s:o, s:o, s:o," - " s:o, s:o, s:o, s:o, s:o," - " s:o, s:s}", - /* 1-5 */ - "value", - TALER_JSON_from_amount (&meta.value), - "stamp_start", - GNUNET_JSON_from_time_abs (meta.start), - "stamp_expire_withdraw", - GNUNET_JSON_from_time_abs (meta.expire_withdraw), - "stamp_expire_deposit", - GNUNET_JSON_from_time_abs (meta.expire_deposit), - "stamp_expire_legal", - GNUNET_JSON_from_time_abs (meta.expire_legal), - /* 6-10 */ - "denom_pub", - GNUNET_JSON_from_rsa_public_key (hd->denom_pub.rsa_public_key), - "fee_withdraw", - TALER_JSON_from_amount (&meta.fee_withdraw), - "fee_deposit", - TALER_JSON_from_amount (&meta.fee_deposit), - "fee_refresh", - TALER_JSON_from_amount (&meta.fee_refresh), - "fee_refund", - TALER_JSON_from_amount (&meta.fee_refund), - /* 11- */ - "denom_secmod_sig", - GNUNET_JSON_from_data_auto (&hd->sm_sig), - "section_name", - hd->section_name))); + GNUNET_JSON_PACK ( + TALER_JSON_pack_amount ("value", + &meta.value), + GNUNET_JSON_pack_time_abs ("stamp_start", + meta.start), + GNUNET_JSON_pack_time_abs ("stamp_expire_withdraw", + meta.expire_withdraw), + GNUNET_JSON_pack_time_abs ("stamp_expire_deposit", + meta.expire_deposit), + GNUNET_JSON_pack_time_abs ("stamp_expire_legal", + meta.expire_legal), + GNUNET_JSON_pack_rsa_public_key ("denom_pub", + hd->denom_pub.rsa_public_key), + TALER_JSON_pack_amount ("fee_withdraw", + &meta.fee_withdraw), + TALER_JSON_pack_amount ("fee_deposit", + &meta.fee_deposit), + TALER_JSON_pack_amount ("fee_refresh", + &meta.fee_refresh), + TALER_JSON_pack_amount ("fee_refund", + &meta.fee_refund), + GNUNET_JSON_pack_data_auto ("denom_secmod_sig", + &hd->sm_sig), + GNUNET_JSON_pack_string ("section_name", + hd->section_name)))); return GNUNET_OK; } @@ -2469,17 +2465,17 @@ add_future_signkey_cb (void *cls, GNUNET_assert (0 == json_array_append_new ( fbc->signkeys, - json_pack ("{s:o, s:o, s:o, s:o, s:o}", - "key", - GNUNET_JSON_from_data_auto (&hsk->exchange_pub), - "stamp_start", - GNUNET_JSON_from_time_abs (hsk->start_time), - "stamp_expire", - GNUNET_JSON_from_time_abs (stamp_expire), - "stamp_end", - GNUNET_JSON_from_time_abs (legal_end), - "signkey_secmod_sig", - GNUNET_JSON_from_data_auto (&hsk->sm_sig)))); + GNUNET_JSON_PACK ( + GNUNET_JSON_pack_data_auto ("key", + &hsk->exchange_pub), + GNUNET_JSON_pack_time_abs ("stamp_start", + hsk->start_time), + GNUNET_JSON_pack_time_abs ("stamp_expire", + stamp_expire), + GNUNET_JSON_pack_time_abs ("stamp_end", + legal_end), + GNUNET_JSON_pack_data_auto ("signkey_secmod_sig", + &hsk->sm_sig)))); return GNUNET_OK; } @@ -2516,18 +2512,17 @@ TEH_keys_management_get_handler (const struct TEH_RequestHandler *rh, GNUNET_CONTAINER_multipeermap_iterate (ksh->helpers->esign_keys, &add_future_signkey_cb, &fbc); - reply = json_pack ( - "{s:o, s:o, s:o, s:o, s:o}", - "future_denoms", - fbc.denoms, - "future_signkeys", - fbc.signkeys, - "master_pub", - GNUNET_JSON_from_data_auto (&TEH_master_public_key), - "denom_secmod_public_key", - GNUNET_JSON_from_data_auto (&denom_sm_pub), - "signkey_secmod_public_key", - GNUNET_JSON_from_data_auto (&esign_sm_pub)); + reply = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_array_steal ("future_denoms", + fbc.denoms), + GNUNET_JSON_pack_array_steal ("future_signkeys", + fbc.signkeys), + GNUNET_JSON_pack_data_auto ("master_pub", + &TEH_master_public_key), + GNUNET_JSON_pack_data_auto ("denom_secmod_public_key", + &denom_sm_pub), + GNUNET_JSON_pack_data_auto ("signkey_secmod_public_key", + &esign_sm_pub)); GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Returning GET /management/keys response:\n"); if (NULL == reply) diff --git a/src/exchange/taler-exchange-httpd_link.c b/src/exchange/taler-exchange-httpd_link.c index b93d2e718..a39e58641 100644 --- a/src/exchange/taler-exchange-httpd_link.c +++ b/src/exchange/taler-exchange-httpd_link.c @@ -81,15 +81,13 @@ handle_link_data (void *cls, { json_t *obj; - obj = json_pack ("{s:o, s:o, s:o}", - "denom_pub", - GNUNET_JSON_from_rsa_public_key ( - pos->denom_pub.rsa_public_key), - "ev_sig", - GNUNET_JSON_from_rsa_signature - (pos->ev_sig.rsa_signature), - "link_sig", - GNUNET_JSON_from_data_auto (&pos->orig_coin_link_sig)); + obj = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_rsa_public_key ("denom_pub", + pos->denom_pub.rsa_public_key), + GNUNET_JSON_pack_rsa_signature ("ev_sig", + pos->ev_sig.rsa_signature), + GNUNET_JSON_pack_data_auto ("link_sig", + &pos->orig_coin_link_sig)); if ( (NULL == obj) || (0 != json_array_append_new (list, @@ -102,11 +100,11 @@ handle_link_data (void *cls, { json_t *root; - root = json_pack ("{s:o, s:o}", - "new_coins", - list, - "transfer_pub", - GNUNET_JSON_from_data_auto (transfer_pub)); + root = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_array_steal ("new_coins", + list), + GNUNET_JSON_pack_data_auto ("transfer_pub", + transfer_pub)); if ( (NULL == root) || (0 != json_array_append_new (ctx->mlist, diff --git a/src/exchange/taler-exchange-httpd_melt.c b/src/exchange/taler-exchange-httpd_melt.c index 8e51a4174..427808260 100644 --- a/src/exchange/taler-exchange-httpd_melt.c +++ b/src/exchange/taler-exchange-httpd_melt.c @@ -66,24 +66,24 @@ reply_melt_insufficient_funds ( MHD_HTTP_INTERNAL_SERVER_ERROR, TALER_EC_EXCHANGE_MELT_HISTORY_DB_ERROR_INSUFFICIENT_FUNDS, NULL); - return TALER_MHD_reply_json_pack ( + return TALER_MHD_REPLY_JSON_PACK ( connection, MHD_HTTP_CONFLICT, - "{s:s, s:I, s:o, s:o, s:o, s:o, s:o}", - "hint", - TALER_ErrorCode_get_hint (TALER_EC_EXCHANGE_MELT_INSUFFICIENT_FUNDS), - "code", - (json_int_t) TALER_EC_EXCHANGE_MELT_INSUFFICIENT_FUNDS, - "coin_pub", - GNUNET_JSON_from_data_auto (coin_pub), - "original_value", - TALER_JSON_from_amount (coin_value), - "residual_value", - TALER_JSON_from_amount (residual), - "requested_value", - TALER_JSON_from_amount (requested), - "history", - history); + GNUNET_JSON_pack_string ("hint", + TALER_ErrorCode_get_hint ( + TALER_EC_EXCHANGE_MELT_INSUFFICIENT_FUNDS)), + GNUNET_JSON_pack_uint64 ("code", + TALER_EC_EXCHANGE_MELT_INSUFFICIENT_FUNDS), + GNUNET_JSON_pack_data_auto ("coin_pub", + coin_pub), + TALER_JSON_pack_amount ("original_value", + coin_value), + TALER_JSON_pack_amount ("residual_value", + residual), + TALER_JSON_pack_amount ("requested_value", + requested), + GNUNET_JSON_pack_array_steal ("history", + history)); } @@ -119,13 +119,15 @@ reply_melt_success (struct MHD_Connection *connection, ec, NULL); } - return TALER_MHD_reply_json_pack ( + return TALER_MHD_REPLY_JSON_PACK ( connection, MHD_HTTP_OK, - "{s:i, s:o, s:o}", - "noreveal_index", (int) noreveal_index, - "exchange_sig", GNUNET_JSON_from_data_auto (&sig), - "exchange_pub", GNUNET_JSON_from_data_auto (&pub)); + GNUNET_JSON_pack_uint64 ("noreveal_index", + noreveal_index), + GNUNET_JSON_pack_data_auto ("exchange_sig", + &sig), + GNUNET_JSON_pack_data_auto ("exchange_pub", + &pub)); } diff --git a/src/exchange/taler-exchange-httpd_recoup.c b/src/exchange/taler-exchange-httpd_recoup.c index 991b16e27..521b75627 100644 --- a/src/exchange/taler-exchange-httpd_recoup.c +++ b/src/exchange/taler-exchange-httpd_recoup.c @@ -490,20 +490,20 @@ verify_and_execute_recoup (struct MHD_Connection *connection, } /* Recoup succeeded, return result */ return (refreshed) - ? TALER_MHD_reply_json_pack (connection, + ? TALER_MHD_REPLY_JSON_PACK (connection, MHD_HTTP_OK, - "{s:o, s:b}", - "old_coin_pub", - GNUNET_JSON_from_data_auto ( + GNUNET_JSON_pack_data_auto ( + "old_coin_pub", &pc.target.old_coin_pub), - "refreshed", 1) - : TALER_MHD_reply_json_pack (connection, + GNUNET_JSON_pack_bool ("refreshed", + true)) + : TALER_MHD_REPLY_JSON_PACK (connection, MHD_HTTP_OK, - "{s:o, s:b}", - "reserve_pub", - GNUNET_JSON_from_data_auto ( + GNUNET_JSON_pack_data_auto ( + "reserve_pub", &pc.target.reserve_pub), - "refreshed", 0); + GNUNET_JSON_pack_bool ("refreshed", + false)); } diff --git a/src/exchange/taler-exchange-httpd_refreshes_reveal.c b/src/exchange/taler-exchange-httpd_refreshes_reveal.c index 4fbc949ee..5cbb6e6c3 100644 --- a/src/exchange/taler-exchange-httpd_refreshes_reveal.c +++ b/src/exchange/taler-exchange-httpd_refreshes_reveal.c @@ -60,51 +60,26 @@ reply_refreshes_reveal_success (struct MHD_Connection *connection, json_t *list; list = json_array (); - if (NULL == list) - { - GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_JSON_ALLOCATION_FAILURE, - "json_array() call failed"); - } + GNUNET_assert (NULL != list); for (unsigned int freshcoin_index = 0; freshcoin_index < num_freshcoins; freshcoin_index++) { json_t *obj; - obj = json_pack ("{s:o}", - "ev_sig", - GNUNET_JSON_from_rsa_signature ( - sigs[freshcoin_index].rsa_signature)); - if (NULL == obj) - { - json_decref (list); - GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_JSON_ALLOCATION_FAILURE, - "json_pack() failed"); - } - if (0 != - json_array_append_new (list, - obj)) - { - json_decref (list); - GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_JSON_ALLOCATION_FAILURE, - "json_array_append_new() failed"); - } + obj = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_rsa_signature ("ev_sig", + sigs[freshcoin_index].rsa_signature)); + GNUNET_assert (0 == + json_array_append_new (list, + obj)); } - return TALER_MHD_reply_json_pack (connection, - MHD_HTTP_OK, - "{s:o}", - "ev_sigs", - list); + return TALER_MHD_REPLY_JSON_PACK ( + connection, + MHD_HTTP_OK, + GNUNET_JSON_pack_array_steal ("ev_sigs", + list)); } @@ -409,18 +384,16 @@ refreshes_reveal_transaction (void *cls, &rc_expected)) { GNUNET_break_op (0); - *mhd_ret = TALER_MHD_reply_json_pack ( + *mhd_ret = TALER_MHD_REPLY_JSON_PACK ( connection, MHD_HTTP_CONFLICT, - "{s:s, s:I, s:o}", - "hint", - TALER_ErrorCode_get_hint ( - TALER_EC_EXCHANGE_REFRESHES_REVEAL_COMMITMENT_VIOLATION), - "code", - (json_int_t) TALER_EC_EXCHANGE_REFRESHES_REVEAL_COMMITMENT_VIOLATION, - "rc_expected", - GNUNET_JSON_from_data_auto ( - &rc_expected)); + GNUNET_JSON_pack_string ("hint", + TALER_ErrorCode_get_hint ( + TALER_EC_EXCHANGE_REFRESHES_REVEAL_COMMITMENT_VIOLATION)), + GNUNET_JSON_pack_uint64 ("code", + TALER_EC_EXCHANGE_REFRESHES_REVEAL_COMMITMENT_VIOLATION), + GNUNET_JSON_pack_data_auto ("rc_expected", + &rc_expected)); return GNUNET_DB_STATUS_HARD_ERROR; } } /* end of checking "rc_expected" */ diff --git a/src/exchange/taler-exchange-httpd_refund.c b/src/exchange/taler-exchange-httpd_refund.c index 35b179be4..c2b2d800e 100644 --- a/src/exchange/taler-exchange-httpd_refund.c +++ b/src/exchange/taler-exchange-httpd_refund.c @@ -71,12 +71,13 @@ reply_refund_success (struct MHD_Connection *connection, ec, NULL); } - return TALER_MHD_reply_json_pack ( + return TALER_MHD_REPLY_JSON_PACK ( connection, MHD_HTTP_OK, - "{s:o, s:o}", - "exchange_sig", GNUNET_JSON_from_data_auto (&sig), - "exchange_pub", GNUNET_JSON_from_data_auto (&pub)); + GNUNET_JSON_pack_data_auto ("exchange_sig", + &sig), + GNUNET_JSON_pack_data_auto ("exchange_pub", + &pub)); } @@ -227,18 +228,20 @@ refund_transaction (void *cls, TEH_plugin->free_coin_transaction_list (TEH_plugin->cls, tln); tli->next = NULL; - *mhd_ret = TALER_MHD_reply_json_pack ( + *mhd_ret = TALER_MHD_REPLY_JSON_PACK ( connection, MHD_HTTP_PRECONDITION_FAILED, - "{s:o, s:s, s:I, s:o}", - "detail", - TALER_JSON_from_amount (&ref->refund_amount), - "hint", TALER_ErrorCode_get_hint ( - TALER_EC_EXCHANGE_REFUND_INCONSISTENT_AMOUNT), - "code", (json_int_t) TALER_EC_EXCHANGE_REFUND_INCONSISTENT_AMOUNT, - "history", TEH_RESPONSE_compile_transaction_history ( - &refund->coin.coin_pub, - tli)); + TALER_JSON_pack_amount ("detail", + &ref->refund_amount), + GNUNET_JSON_pack_string ("hint", + TALER_ErrorCode_get_hint ( + TALER_EC_EXCHANGE_REFUND_INCONSISTENT_AMOUNT)), + GNUNET_JSON_pack_uint64 ("code", + TALER_EC_EXCHANGE_REFUND_INCONSISTENT_AMOUNT), + GNUNET_JSON_pack_array_steal ("history", + TEH_RESPONSE_compile_transaction_history ( + &refund->coin.coin_pub, + tli))); TEH_plugin->free_coin_transaction_list (TEH_plugin->cls, tli); return GNUNET_DB_STATUS_HARD_ERROR; @@ -324,20 +327,20 @@ refund_transaction (void *cls, if (1 == TALER_amount_cmp (&refund_total, &deposit_total) ) { - *mhd_ret = TALER_MHD_reply_json_pack ( + *mhd_ret = TALER_MHD_REPLY_JSON_PACK ( connection, MHD_HTTP_CONFLICT, - "{s:s, s:s, s:I, s:o}", - "detail", - "total amount refunded exceeds total amount deposited for this coin", - "hint", - TALER_ErrorCode_get_hint ( - TALER_EC_EXCHANGE_REFUND_CONFLICT_DEPOSIT_INSUFFICIENT), - "code", - (json_int_t) TALER_EC_EXCHANGE_REFUND_CONFLICT_DEPOSIT_INSUFFICIENT, - "history", - TEH_RESPONSE_compile_transaction_history (&refund->coin.coin_pub, - tlx)); + GNUNET_JSON_pack_string ("detail", + "total amount refunded exceeds total amount deposited for this coin"), + GNUNET_JSON_pack_string ("hint", + TALER_ErrorCode_get_hint ( + TALER_EC_EXCHANGE_REFUND_CONFLICT_DEPOSIT_INSUFFICIENT)), + GNUNET_JSON_pack_uint64 ("code", + TALER_EC_EXCHANGE_REFUND_CONFLICT_DEPOSIT_INSUFFICIENT), + GNUNET_JSON_pack_array_steal ("history", + TEH_RESPONSE_compile_transaction_history ( + &refund->coin.coin_pub, + tlx))); TEH_plugin->free_coin_transaction_list (TEH_plugin->cls, tlx); return GNUNET_DB_STATUS_HARD_ERROR; diff --git a/src/exchange/taler-exchange-httpd_reserves_get.c b/src/exchange/taler-exchange-httpd_reserves_get.c index b901afbbc..6ad393a28 100644 --- a/src/exchange/taler-exchange-httpd_reserves_get.c +++ b/src/exchange/taler-exchange-httpd_reserves_get.c @@ -40,7 +40,6 @@ static MHD_RESULT reply_reserve_history_success (struct MHD_Connection *connection, const struct TALER_EXCHANGEDB_ReserveHistory *rh) { - json_t *json_balance; json_t *json_history; struct TALER_Amount balance; @@ -51,12 +50,13 @@ reply_reserve_history_success (struct MHD_Connection *connection, MHD_HTTP_INTERNAL_SERVER_ERROR, TALER_EC_GENERIC_JSON_ALLOCATION_FAILURE, NULL); - json_balance = TALER_JSON_from_amount (&balance); - return TALER_MHD_reply_json_pack (connection, - MHD_HTTP_OK, - "{s:o, s:o}", - "balance", json_balance, - "history", json_history); + return TALER_MHD_REPLY_JSON_PACK ( + connection, + MHD_HTTP_OK, + TALER_JSON_pack_amount ("balance", + &balance), + GNUNET_JSON_pack_array_steal ("history", + json_history)); } diff --git a/src/exchange/taler-exchange-httpd_responses.c b/src/exchange/taler-exchange-httpd_responses.c index 40c7fd7e0..e05b537ec 100644 --- a/src/exchange/taler-exchange-httpd_responses.c +++ b/src/exchange/taler-exchange-httpd_responses.c @@ -381,25 +381,25 @@ TEH_RESPONSE_compile_transaction_history ( if (0 != json_array_append_new ( history, - json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o}", - "type", - "RECOUP-REFRESH", - "amount", - TALER_JSON_from_amount (&pr->value), - "exchange_sig", - GNUNET_JSON_from_data_auto (&esig), - "exchange_pub", - GNUNET_JSON_from_data_auto (&epub), - "old_coin_pub", - GNUNET_JSON_from_data_auto (&pr->old_coin_pub), - "h_denom_pub", - GNUNET_JSON_from_data_auto (&pr->coin.denom_pub_hash), - "coin_sig", - GNUNET_JSON_from_data_auto (&pr->coin_sig), - "coin_blind", - GNUNET_JSON_from_data_auto (&pr->coin_blind), - "timestamp", - GNUNET_JSON_from_time_abs (pr->timestamp)))) + GNUNET_JSON_PACK ( + GNUNET_JSON_pack_string ("type", + "RECOUP-REFRESH"), + TALER_JSON_pack_amount ("amount", + &pr->value), + GNUNET_JSON_pack_data_auto ("exchange_sig", + &esig), + GNUNET_JSON_pack_data_auto ("exchange_pub", + &epub), + GNUNET_JSON_pack_data_auto ("old_coin_pub", + &pr->old_coin_pub), + GNUNET_JSON_pack_data_auto ("h_denom_pub", + &pr->coin.denom_pub_hash), + GNUNET_JSON_pack_data_auto ("coin_sig", + &pr->coin_sig), + GNUNET_JSON_pack_data_auto ("coin_blind", + &pr->coin_blind), + GNUNET_JSON_pack_time_abs ("timestamp", + pr->timestamp)))) { GNUNET_break (0); json_decref (history); @@ -447,20 +447,19 @@ TEH_RESPONSE_reply_unknown_denom_pub_hash ( ec, NULL); } - return TALER_MHD_reply_json_pack ( + return TALER_MHD_REPLY_JSON_PACK ( connection, MHD_HTTP_NOT_FOUND, - "{s:I,s:o,s:o,s:o,s:o}", - "code", - TALER_EC_EXCHANGE_GENERIC_DENOMINATION_KEY_UNKNOWN, - "timestamp", - GNUNET_JSON_from_time_abs (now), - "exchange_pub", - GNUNET_JSON_from_data_auto (&epub), - "exchange_sig", - GNUNET_JSON_from_data_auto (&esig), - "h_denom_pub", - GNUNET_JSON_from_data_auto (dph)); + GNUNET_JSON_pack_uint64 ("code", + TALER_EC_EXCHANGE_GENERIC_DENOMINATION_KEY_UNKNOWN), + GNUNET_JSON_pack_time_abs ("timestamp", + now), + GNUNET_JSON_pack_data_auto ("exchange_pub", + &epub), + GNUNET_JSON_pack_data_auto ("exchange_sig", + &esig), + GNUNET_JSON_pack_data_auto ("h_denom_pub", + dph)); } @@ -499,22 +498,21 @@ TEH_RESPONSE_reply_expired_denom_pub_hash ( ec, NULL); } - return TALER_MHD_reply_json_pack ( + return TALER_MHD_REPLY_JSON_PACK ( connection, MHD_HTTP_GONE, - "{s:I,s:s,s:o,s:o,s:o,s:o}", - "code", - ec, - "oper", - oper, - "timestamp", - GNUNET_JSON_from_time_abs (now), - "exchange_pub", - GNUNET_JSON_from_data_auto (&epub), - "exchange_sig", - GNUNET_JSON_from_data_auto (&esig), - "h_denom_pub", - GNUNET_JSON_from_data_auto (dph)); + GNUNET_JSON_pack_uint64 ("code", + ec), + GNUNET_JSON_pack_string ("oper", + oper), + GNUNET_JSON_pack_time_abs ("timestamp", + now), + GNUNET_JSON_pack_data_auto ("exchange_pub", + &epub), + GNUNET_JSON_pack_data_auto ("exchange_sig", + &esig), + GNUNET_JSON_pack_data_auto ("h_denom_pub", + dph)); } @@ -549,12 +547,15 @@ TEH_RESPONSE_reply_coin_insufficient_funds ( TALER_EC_GENERIC_JSON_ALLOCATION_FAILURE, "Failed to generated proof of insufficient funds"); } - return TALER_MHD_reply_json_pack (connection, - MHD_HTTP_CONFLICT, - "{s:s, s:I, s:o}", - "hint", TALER_ErrorCode_get_hint (ec), - "code", (json_int_t) ec, - "history", history); + return TALER_MHD_REPLY_JSON_PACK ( + connection, + MHD_HTTP_CONFLICT, + GNUNET_JSON_pack_string ("hint", + TALER_ErrorCode_get_hint (ec)), + GNUNET_JSON_pack_uint64 ("code", + ec), + GNUNET_JSON_pack_array_steal ("history", + history)); } @@ -612,17 +613,17 @@ TEH_RESPONSE_compile_reserve_history ( if (0 != json_array_append_new ( json_history, - json_pack ("{s:s, s:o, s:s, s:I, s:o}", - "type", - "CREDIT", - "timestamp", - GNUNET_JSON_from_time_abs (bank->execution_date), - "sender_account_url", - bank->sender_account_details, - "wire_reference", - (json_int_t) bank->wire_reference, - "amount", - TALER_JSON_from_amount (&bank->amount)))) + GNUNET_JSON_PACK ( + GNUNET_JSON_pack_string ("type", + "CREDIT"), + GNUNET_JSON_pack_time_abs ("timestamp", + bank->execution_date), + GNUNET_JSON_pack_string ("sender_account_url", + bank->sender_account_details), + GNUNET_JSON_pack_uint64 ("wire_reference", + bank->wire_reference), + TALER_JSON_pack_amount ("amount", + &bank->amount)))) { GNUNET_break (0); json_decref (json_history); @@ -657,20 +658,19 @@ TEH_RESPONSE_compile_reserve_history ( if (0 != json_array_append_new ( json_history, - json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o}", - "type", - "WITHDRAW", - "reserve_sig", - GNUNET_JSON_from_data_auto (&withdraw->reserve_sig), - "h_coin_envelope", - GNUNET_JSON_from_data_auto ( - &withdraw->h_coin_envelope), - "h_denom_pub", - GNUNET_JSON_from_data_auto (&withdraw->denom_pub_hash), - "withdraw_fee", - TALER_JSON_from_amount (&withdraw->withdraw_fee), - "amount", - TALER_JSON_from_amount (&value)))) + GNUNET_JSON_PACK ( + GNUNET_JSON_pack_string ("type", + "WITHDRAW"), + GNUNET_JSON_pack_data_auto ("reserve_sig", + &withdraw->reserve_sig), + GNUNET_JSON_pack_data_auto ("h_coin_envelope", + &withdraw->h_coin_envelope), + GNUNET_JSON_pack_data_auto ("h_denom_pub", + &withdraw->denom_pub_hash), + TALER_JSON_pack_amount ("withdraw_fee", + &withdraw->withdraw_fee), + TALER_JSON_pack_amount ("amount", + &value)))) { GNUNET_break (0); json_decref (json_history); @@ -722,21 +722,21 @@ TEH_RESPONSE_compile_reserve_history ( } if (0 != - json_array_append_new (json_history, - json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o}", - "type", "RECOUP", - "exchange_pub", - GNUNET_JSON_from_data_auto (&pub), - "exchange_sig", - GNUNET_JSON_from_data_auto (&sig), - "timestamp", - GNUNET_JSON_from_time_abs ( - recoup->timestamp), - "amount", TALER_JSON_from_amount ( - &recoup->value), - "coin_pub", - GNUNET_JSON_from_data_auto ( - &recoup->coin.coin_pub)))) + json_array_append_new ( + json_history, + GNUNET_JSON_PACK ( + GNUNET_JSON_pack_string ("type", + "RECOUP"), + GNUNET_JSON_pack_data_auto ("exchange_pub", + &pub), + GNUNET_JSON_pack_data_auto ("exchange_sig", + &sig), + GNUNET_JSON_pack_time_abs ("timestamp", + recoup->timestamp), + TALER_JSON_pack_amount ("amount", + &recoup->value), + GNUNET_JSON_pack_data_auto ("coin_pub", + &recoup->coin.coin_pub)))) { GNUNET_break (0); json_decref (json_history); @@ -799,24 +799,23 @@ TEH_RESPONSE_compile_reserve_history ( if (0 != json_array_append_new ( json_history, - json_pack ( - "{s:s, s:s, s:o, s:o, s:o, s:o, s:o, s:o}", - "type", - "CLOSING", - "receiver_account_details", - closing->receiver_account_details, - "wtid", - GNUNET_JSON_from_data_auto (&closing->wtid), - "exchange_pub", - GNUNET_JSON_from_data_auto (&pub), - "exchange_sig", - GNUNET_JSON_from_data_auto (&sig), - "timestamp", - GNUNET_JSON_from_time_abs (closing->execution_date), - "amount", - TALER_JSON_from_amount (&value), - "closing_fee", - TALER_JSON_from_amount (&closing->closing_fee)))) + GNUNET_JSON_PACK ( + GNUNET_JSON_pack_string ("type", + "CLOSING"), + GNUNET_JSON_pack_string ("receiver_account_details", + closing->receiver_account_details), + GNUNET_JSON_pack_data_auto ("wtid", + &closing->wtid), + GNUNET_JSON_pack_data_auto ("exchange_pub", + &pub), + GNUNET_JSON_pack_data_auto ("exchange_sig", + &sig), + GNUNET_JSON_pack_time_abs ("timestamp", + closing->execution_date), + TALER_JSON_pack_amount ("amount", + &value), + TALER_JSON_pack_amount ("closing_fee", + &closing->closing_fee)))) { GNUNET_break (0); json_decref (json_history); diff --git a/src/exchange/taler-exchange-httpd_transfers_get.c b/src/exchange/taler-exchange-httpd_transfers_get.c index 578b94284..c4e276cc3 100644 --- a/src/exchange/taler-exchange-httpd_transfers_get.c +++ b/src/exchange/taler-exchange-httpd_transfers_get.c @@ -99,17 +99,9 @@ reply_transfer_details (struct MHD_Connection *connection, struct TALER_ExchangePublicKeyP pub; struct TALER_ExchangeSignatureP sig; - GNUNET_TIME_round_abs (&exec_time); deposits = json_array (); - if (NULL == deposits) - { - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_JSON_ALLOCATION_FAILURE, - "json_array() failed"); - - } + GNUNET_assert (NULL != deposits); hash_context = GNUNET_CRYPTO_hash_context_start (); for (const struct AggregatedDepositDetail *wdd_pos = wdd_head; NULL != wdd_pos; @@ -126,20 +118,17 @@ reply_transfer_details (struct MHD_Connection *connection, &dd, sizeof (struct TALER_WireDepositDetailP)); if (0 != - json_array_append_new (deposits, - json_pack ("{s:o, s:o, s:o, s:o}", - "h_contract_terms", - GNUNET_JSON_from_data_auto ( - &wdd_pos->h_contract_terms), - "coin_pub", - GNUNET_JSON_from_data_auto ( - &wdd_pos->coin_pub), - "deposit_value", - TALER_JSON_from_amount ( - &wdd_pos->deposit_value), - "deposit_fee", - TALER_JSON_from_amount ( - &wdd_pos->deposit_fee)))) + json_array_append_new ( + deposits, + GNUNET_JSON_PACK ( + GNUNET_JSON_pack_data_auto ("h_contract_terms", + &wdd_pos->h_contract_terms), + GNUNET_JSON_pack_data_auto ("coin_pub", + &wdd_pos->coin_pub), + TALER_JSON_pack_amount ("deposit_value", + &wdd_pos->deposit_value), + TALER_JSON_pack_amount ("deposit_fee", + &wdd_pos->deposit_fee)))) { json_decref (deposits); GNUNET_CRYPTO_hash_context_abort (hash_context); @@ -174,24 +163,25 @@ reply_transfer_details (struct MHD_Connection *connection, } } - return TALER_MHD_reply_json_pack (connection, - MHD_HTTP_OK, - "{s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o}", - "total", TALER_JSON_from_amount (total), - "wire_fee", TALER_JSON_from_amount ( - wire_fee), - "merchant_pub", - GNUNET_JSON_from_data_auto ( - merchant_pub), - "h_wire", GNUNET_JSON_from_data_auto ( - h_wire), - "execution_time", - GNUNET_JSON_from_time_abs (exec_time), - "deposits", deposits, - "exchange_sig", - GNUNET_JSON_from_data_auto (&sig), - "exchange_pub", - GNUNET_JSON_from_data_auto (&pub)); + return TALER_MHD_REPLY_JSON_PACK ( + connection, + MHD_HTTP_OK, + TALER_JSON_pack_amount ("total", + total), + TALER_JSON_pack_amount ("wire_fee", + wire_fee), + GNUNET_JSON_pack_data_auto ("merchant_pub", + merchant_pub), + GNUNET_JSON_pack_data_auto ("h_wire", + h_wire), + GNUNET_JSON_pack_time_abs ("execution_time", + exec_time), + GNUNET_JSON_pack_array_steal ("deposits", + deposits), + GNUNET_JSON_pack_data_auto ("exchange_sig", + &sig), + GNUNET_JSON_pack_data_auto ("exchange_pub", + &pub)); } diff --git a/src/exchange/taler-exchange-httpd_wire.c b/src/exchange/taler-exchange-httpd_wire.c index 20fecd499..f919303ab 100644 --- a/src/exchange/taler-exchange-httpd_wire.c +++ b/src/exchange/taler-exchange-httpd_wire.c @@ -134,11 +134,11 @@ add_wire_account (void *cls, if (0 != json_array_append_new ( a, - json_pack ("{s:s, s:o}", - "payto_uri", - payto_uri, - "master_sig", - GNUNET_JSON_from_data_auto (master_sig)))) + GNUNET_JSON_PACK ( + GNUNET_JSON_pack_string ("payto_uri", + payto_uri), + GNUNET_JSON_pack_data_auto ("master_sig", + master_sig)))) { GNUNET_break (0); /* out of memory!? */ return; @@ -170,17 +170,17 @@ add_wire_fee (void *cls, if (0 != json_array_append_new ( a, - json_pack ("{s:o, s:o, s:o, s:o, s:o}", - "wire_fee", - TALER_JSON_from_amount (wire_fee), - "closing_fee", - TALER_JSON_from_amount (closing_fee), - "start_date", - GNUNET_JSON_from_time_abs (start_date), - "end_date", - GNUNET_JSON_from_time_abs (end_date), - "sig", - GNUNET_JSON_from_data_auto (master_sig)))) + GNUNET_JSON_PACK ( + TALER_JSON_pack_amount ("wire_fee", + wire_fee), + TALER_JSON_pack_amount ("closing_fee", + closing_fee), + GNUNET_JSON_pack_time_abs ("start_date", + start_date), + GNUNET_JSON_pack_time_abs ("end_date", + end_date), + GNUNET_JSON_pack_data_auto ("sig", + master_sig)))) { GNUNET_break (0); /* out of memory!? */ return; @@ -283,14 +283,13 @@ build_wire_state (void) json_t *wire_reply; struct WireStateHandle *wsh; - wire_reply = json_pack ( - "{s:o, s:o, s:o}", - "accounts", - wire_accounts_array, - "fees", - wire_fee_object, - "master_public_key", - GNUNET_JSON_from_data_auto (&TEH_master_public_key)); + wire_reply = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_array_steal ("accounts", + wire_accounts_array), + GNUNET_JSON_pack_object_steal ("fees", + wire_fee_object), + GNUNET_JSON_pack_data_auto ("master_public_key", + &TEH_master_public_key)); if (NULL == wire_reply) { GNUNET_break (0); diff --git a/src/exchange/taler-exchange-httpd_withdraw.c b/src/exchange/taler-exchange-httpd_withdraw.c index 5c484653b..a5e6db0ad 100644 --- a/src/exchange/taler-exchange-httpd_withdraw.c +++ b/src/exchange/taler-exchange-httpd_withdraw.c @@ -78,18 +78,18 @@ reply_withdraw_insufficient_funds ( TALER_EC_GENERIC_DB_INVARIANT_FAILURE, "reserve balance corrupt"); } - return TALER_MHD_reply_json_pack ( + return TALER_MHD_REPLY_JSON_PACK ( connection, MHD_HTTP_CONFLICT, - "{s:s, s:I, s:o, s:o}", - "hint", - TALER_ErrorCode_get_hint (TALER_EC_EXCHANGE_WITHDRAW_INSUFFICIENT_FUNDS), - "code", - (json_int_t) TALER_EC_EXCHANGE_WITHDRAW_INSUFFICIENT_FUNDS, - "balance", - TALER_JSON_from_amount (&balance), - "history", - json_history); + GNUNET_JSON_pack_string ("hint", + TALER_ErrorCode_get_hint ( + TALER_EC_EXCHANGE_WITHDRAW_INSUFFICIENT_FUNDS)), + GNUNET_JSON_pack_uint64 ("code", + TALER_EC_EXCHANGE_WITHDRAW_INSUFFICIENT_FUNDS), + TALER_JSON_pack_amount ("balance", + &balance), + GNUNET_JSON_pack_array_steal ("history", + json_history)); } @@ -523,12 +523,11 @@ TEH_handler_withdraw (const struct TEH_RequestHandler *rh, { MHD_RESULT ret; - ret = TALER_MHD_reply_json_pack ( + ret = TALER_MHD_REPLY_JSON_PACK ( connection, MHD_HTTP_OK, - "{s:o}", - "ev_sig", GNUNET_JSON_from_rsa_signature ( - wc.collectable.sig.rsa_signature)); + GNUNET_JSON_pack_rsa_signature ("ev_sig", + wc.collectable.sig.rsa_signature)); GNUNET_CRYPTO_rsa_signature_free (wc.collectable.sig.rsa_signature); return ret; } |