-eliminate more json_pack format strings

This commit is contained in:
Christian Grothoff 2021-07-30 17:24:16 +02:00
parent 7e409c37ab
commit cbb905a9aa
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
14 changed files with 424 additions and 469 deletions

View File

@ -1161,7 +1161,7 @@ exchange_serve_process_config (void)
{ {
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"exchange", "exchange",
"master_public_key"); "MASTER_PUBLIC_KEY");
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
if (GNUNET_OK != if (GNUNET_OK !=

View File

@ -89,16 +89,15 @@ reply_deposit_success (struct MHD_Connection *connection,
ec, ec,
NULL); NULL);
} }
return TALER_MHD_reply_json_pack ( return TALER_MHD_REPLY_JSON_PACK (
connection, connection,
MHD_HTTP_OK, MHD_HTTP_OK,
"{s:o, s:o, s:o}", GNUNET_JSON_pack_time_abs ("exchange_timestamp",
"exchange_timestamp", exchange_timestamp),
GNUNET_JSON_from_time_abs (exchange_timestamp), GNUNET_JSON_pack_data_auto ("exchange_sig",
"exchange_sig", &sig),
GNUNET_JSON_from_data_auto (&sig), GNUNET_JSON_pack_data_auto ("exchange_pub",
"exchange_pub", &pub));
GNUNET_JSON_from_data_auto (&pub));
} }

View File

@ -78,20 +78,19 @@ reply_deposit_details (struct MHD_Connection *connection,
ec, ec,
NULL); NULL);
} }
return TALER_MHD_reply_json_pack (connection, return TALER_MHD_REPLY_JSON_PACK (
MHD_HTTP_OK, connection,
"{s:o, s:o, s:o, s:o, s:o}", MHD_HTTP_OK,
"wtid", GNUNET_JSON_from_data_auto ( GNUNET_JSON_pack_data_auto ("wtid",
wtid), wtid),
"execution_time", GNUNET_JSON_pack_time_abs ("execution_time",
GNUNET_JSON_from_time_abs (exec_time), exec_time),
"coin_contribution", TALER_JSON_pack_amount ("coin_contribution",
TALER_JSON_from_amount ( coin_contribution),
coin_contribution), GNUNET_JSON_pack_data_auto ("exchange_sig",
"exchange_sig", &sig),
GNUNET_JSON_from_data_auto (&sig), GNUNET_JSON_pack_data_auto ("exchange_pub",
"exchange_pub", &pub));
GNUNET_JSON_from_data_auto (&pub));
} }
@ -279,12 +278,11 @@ handle_track_transaction_request (
&ctx)) &ctx))
return mhd_ret; return mhd_ret;
if (GNUNET_YES == ctx.pending) if (GNUNET_YES == ctx.pending)
return TALER_MHD_reply_json_pack (connection, return TALER_MHD_REPLY_JSON_PACK (
MHD_HTTP_ACCEPTED, connection,
"{s:o}", MHD_HTTP_ACCEPTED,
"execution_time", GNUNET_JSON_pack_time_abs ("execution_time",
GNUNET_JSON_from_time_abs ( ctx.execution_time));
ctx.execution_time));
if (GNUNET_SYSERR == ctx.pending) if (GNUNET_SYSERR == ctx.pending)
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,

View File

@ -1074,12 +1074,11 @@ get_auditor_sigs (void *cls,
GNUNET_break (0 == GNUNET_break (0 ==
json_array_append_new ( json_array_append_new (
ctx->denom_keys, ctx->denom_keys,
json_pack ( GNUNET_JSON_PACK (
"{s:o, s:o}", GNUNET_JSON_pack_data_auto ("denom_pub_h",
"denom_pub_h", h_denom_pub),
GNUNET_JSON_from_data_auto (h_denom_pub), GNUNET_JSON_pack_data_auto ("auditor_sig",
"auditor_sig", &as->asig))));
GNUNET_JSON_from_data_auto (&as->asig))));
} }
return GNUNET_OK; return GNUNET_OK;
} }
@ -1104,6 +1103,7 @@ auditor_info_cb (
struct GetAuditorSigsContext ctx; struct GetAuditorSigsContext ctx;
ctx.denom_keys = json_array (); ctx.denom_keys = json_array ();
GNUNET_assert (NULL != ctx.denom_keys);
ctx.auditor_pub = auditor_pub; ctx.auditor_pub = auditor_pub;
GNUNET_CONTAINER_multihashmap_iterate (ksh->denomkey_map, GNUNET_CONTAINER_multihashmap_iterate (ksh->denomkey_map,
&get_auditor_sigs, &get_auditor_sigs,
@ -1111,15 +1111,15 @@ auditor_info_cb (
GNUNET_break (0 == GNUNET_break (0 ==
json_array_append_new ( json_array_append_new (
ksh->auditors, ksh->auditors,
json_pack ("{s:s, s:o, s:s, s:o}", GNUNET_JSON_PACK (
"auditor_name", GNUNET_JSON_pack_string ("auditor_name",
auditor_name, auditor_name),
"auditor_pub", GNUNET_JSON_pack_data_auto ("auditor_pub",
GNUNET_JSON_from_data_auto (auditor_pub), auditor_pub),
"auditor_url", GNUNET_JSON_pack_string ("auditor_url",
auditor_url, auditor_url),
"denomination_keys", GNUNET_JSON_pack_array_steal ("denomination_keys",
ctx.denom_keys))); ctx.denom_keys))));
} }
@ -1204,17 +1204,17 @@ add_sign_key_cb (void *cls,
0 == 0 ==
json_array_append_new ( json_array_append_new (
ctx->signkeys, ctx->signkeys,
json_pack ("{s:o, s:o, s:o, s:o, s:o}", GNUNET_JSON_PACK (
"stamp_start", GNUNET_JSON_pack_time_abs ("stamp_start",
GNUNET_JSON_from_time_abs (sk->meta.start), sk->meta.start),
"stamp_expire", GNUNET_JSON_pack_time_abs ("stamp_expire",
GNUNET_JSON_from_time_abs (sk->meta.expire_sign), sk->meta.expire_sign),
"stamp_end", GNUNET_JSON_pack_time_abs ("stamp_end",
GNUNET_JSON_from_time_abs (sk->meta.expire_legal), sk->meta.expire_legal),
"master_sig", GNUNET_JSON_pack_data_auto ("master_sig",
GNUNET_JSON_from_data_auto (&sk->master_sig), &sk->master_sig),
"key", GNUNET_JSON_pack_data_auto ("key",
GNUNET_JSON_from_data_auto (&sk->exchange_pub)))); &sk->exchange_pub))));
return GNUNET_OK; return GNUNET_OK;
} }
@ -1266,9 +1266,9 @@ add_denom_key_cb (void *cls,
0 == 0 ==
json_array_append_new ( json_array_append_new (
dkc->recoup, dkc->recoup,
json_pack ("{s:o}", GNUNET_JSON_PACK (
"h_denom_pub", GNUNET_JSON_pack_data_auto ("h_denom_pub",
GNUNET_JSON_from_data_auto (h_denom_pub)))); h_denom_pub))));
} }
else else
{ {
@ -1440,23 +1440,29 @@ create_krd (struct TEH_KeyStateHandle *ksh,
ksh->signature_expires); ksh->signature_expires);
} }
keys = json_pack ( keys = GNUNET_JSON_PACK (
"{s:s, s:s, s:o, s:o, s:O, s:O," GNUNET_JSON_pack_string ("version",
" s:O, s:O, s:o, s:o, s:o}", EXCHANGE_PROTOCOL_VERSION),
/* 1-6 */ GNUNET_JSON_pack_string ("currency",
"version", EXCHANGE_PROTOCOL_VERSION, TEH_currency),
"currency", TEH_currency, GNUNET_JSON_pack_data_auto ("master_public_key",
"master_public_key", GNUNET_JSON_from_data_auto (&TEH_master_public_key), &TEH_master_public_key),
"reserve_closing_delay", GNUNET_JSON_from_time_rel ( GNUNET_JSON_pack_time_rel ("reserve_closing_delay",
TEH_reserve_closing_delay), TEH_reserve_closing_delay),
"signkeys", signkeys, GNUNET_JSON_pack_array_incref ("signkeys",
"recoup", recoup, signkeys),
/* 7-11 */ GNUNET_JSON_pack_array_incref ("recoup",
"denoms", denoms, recoup),
"auditors", ksh->auditors, GNUNET_JSON_pack_array_incref ("denoms",
"list_issue_date", GNUNET_JSON_from_time_abs (last_cpd), denoms),
"eddsa_pub", GNUNET_JSON_from_data_auto (&exchange_pub), GNUNET_JSON_pack_array_incref ("auditors",
"eddsa_sig", GNUNET_JSON_from_data_auto (&exchange_sig)); 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); GNUNET_assert (NULL != keys);
{ {
@ -1601,34 +1607,29 @@ finish_keys_response (struct TEH_KeyStateHandle *ksh)
0 == 0 ==
json_array_append_new ( json_array_append_new (
denoms, denoms,
json_pack ("{s:o, s:o, s:o, s:o, s:o," GNUNET_JSON_PACK (
" s:o, s:o, s:o, s:o, s:o," GNUNET_JSON_pack_data_auto ("master_sig",
" s:o}", &dk->master_sig),
"master_sig", GNUNET_JSON_pack_time_abs ("stamp_start",
GNUNET_JSON_from_data_auto (&dk->master_sig), dk->meta.start),
"stamp_start", GNUNET_JSON_pack_time_abs ("stamp_expire_withdraw",
GNUNET_JSON_from_time_abs (dk->meta.start), dk->meta.expire_withdraw),
"stamp_expire_withdraw", GNUNET_JSON_pack_time_abs ("stamp_expire_deposit",
GNUNET_JSON_from_time_abs (dk->meta.expire_withdraw), dk->meta.expire_deposit),
"stamp_expire_deposit", GNUNET_JSON_pack_time_abs ("stamp_expire_legal",
GNUNET_JSON_from_time_abs (dk->meta.expire_deposit), dk->meta.expire_legal),
"stamp_expire_legal", GNUNET_JSON_pack_rsa_public_key ("denom_pub",
GNUNET_JSON_from_time_abs (dk->meta.expire_legal), dk->denom_pub.rsa_public_key),
/* 5 entries until here */ TALER_JSON_pack_amount ("value",
"denom_pub", &dk->meta.value),
GNUNET_JSON_from_rsa_public_key ( TALER_JSON_pack_amount ("fee_withdraw",
dk->denom_pub.rsa_public_key), &dk->meta.fee_withdraw),
"value", TALER_JSON_pack_amount ("fee_deposit",
TALER_JSON_from_amount (&dk->meta.value), &dk->meta.fee_deposit),
"fee_withdraw", TALER_JSON_pack_amount ("fee_refresh",
TALER_JSON_from_amount (&dk->meta.fee_withdraw), &dk->meta.fee_refresh),
"fee_deposit", TALER_JSON_pack_amount ("fee_refund",
TALER_JSON_from_amount (&dk->meta.fee_deposit), &dk->meta.fee_refund))));
"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_CONTAINER_heap_destroy (heap); GNUNET_CONTAINER_heap_destroy (heap);
@ -2400,36 +2401,31 @@ add_future_denomkey_cb (void *cls,
0 == 0 ==
json_array_append_new ( json_array_append_new (
fbc->denoms, fbc->denoms,
json_pack ("{s:o, s:o, s:o, s:o, s:o," GNUNET_JSON_PACK (
" s:o, s:o, s:o, s:o, s:o," TALER_JSON_pack_amount ("value",
" s:o, s:s}", &meta.value),
/* 1-5 */ GNUNET_JSON_pack_time_abs ("stamp_start",
"value", meta.start),
TALER_JSON_from_amount (&meta.value), GNUNET_JSON_pack_time_abs ("stamp_expire_withdraw",
"stamp_start", meta.expire_withdraw),
GNUNET_JSON_from_time_abs (meta.start), GNUNET_JSON_pack_time_abs ("stamp_expire_deposit",
"stamp_expire_withdraw", meta.expire_deposit),
GNUNET_JSON_from_time_abs (meta.expire_withdraw), GNUNET_JSON_pack_time_abs ("stamp_expire_legal",
"stamp_expire_deposit", meta.expire_legal),
GNUNET_JSON_from_time_abs (meta.expire_deposit), GNUNET_JSON_pack_rsa_public_key ("denom_pub",
"stamp_expire_legal", hd->denom_pub.rsa_public_key),
GNUNET_JSON_from_time_abs (meta.expire_legal), TALER_JSON_pack_amount ("fee_withdraw",
/* 6-10 */ &meta.fee_withdraw),
"denom_pub", TALER_JSON_pack_amount ("fee_deposit",
GNUNET_JSON_from_rsa_public_key (hd->denom_pub.rsa_public_key), &meta.fee_deposit),
"fee_withdraw", TALER_JSON_pack_amount ("fee_refresh",
TALER_JSON_from_amount (&meta.fee_withdraw), &meta.fee_refresh),
"fee_deposit", TALER_JSON_pack_amount ("fee_refund",
TALER_JSON_from_amount (&meta.fee_deposit), &meta.fee_refund),
"fee_refresh", GNUNET_JSON_pack_data_auto ("denom_secmod_sig",
TALER_JSON_from_amount (&meta.fee_refresh), &hd->sm_sig),
"fee_refund", GNUNET_JSON_pack_string ("section_name",
TALER_JSON_from_amount (&meta.fee_refund), hd->section_name))));
/* 11- */
"denom_secmod_sig",
GNUNET_JSON_from_data_auto (&hd->sm_sig),
"section_name",
hd->section_name)));
return GNUNET_OK; return GNUNET_OK;
} }
@ -2469,17 +2465,17 @@ add_future_signkey_cb (void *cls,
GNUNET_assert (0 == GNUNET_assert (0 ==
json_array_append_new ( json_array_append_new (
fbc->signkeys, fbc->signkeys,
json_pack ("{s:o, s:o, s:o, s:o, s:o}", GNUNET_JSON_PACK (
"key", GNUNET_JSON_pack_data_auto ("key",
GNUNET_JSON_from_data_auto (&hsk->exchange_pub), &hsk->exchange_pub),
"stamp_start", GNUNET_JSON_pack_time_abs ("stamp_start",
GNUNET_JSON_from_time_abs (hsk->start_time), hsk->start_time),
"stamp_expire", GNUNET_JSON_pack_time_abs ("stamp_expire",
GNUNET_JSON_from_time_abs (stamp_expire), stamp_expire),
"stamp_end", GNUNET_JSON_pack_time_abs ("stamp_end",
GNUNET_JSON_from_time_abs (legal_end), legal_end),
"signkey_secmod_sig", GNUNET_JSON_pack_data_auto ("signkey_secmod_sig",
GNUNET_JSON_from_data_auto (&hsk->sm_sig)))); &hsk->sm_sig))));
return GNUNET_OK; 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, GNUNET_CONTAINER_multipeermap_iterate (ksh->helpers->esign_keys,
&add_future_signkey_cb, &add_future_signkey_cb,
&fbc); &fbc);
reply = json_pack ( reply = GNUNET_JSON_PACK (
"{s:o, s:o, s:o, s:o, s:o}", GNUNET_JSON_pack_array_steal ("future_denoms",
"future_denoms", fbc.denoms),
fbc.denoms, GNUNET_JSON_pack_array_steal ("future_signkeys",
"future_signkeys", fbc.signkeys),
fbc.signkeys, GNUNET_JSON_pack_data_auto ("master_pub",
"master_pub", &TEH_master_public_key),
GNUNET_JSON_from_data_auto (&TEH_master_public_key), GNUNET_JSON_pack_data_auto ("denom_secmod_public_key",
"denom_secmod_public_key", &denom_sm_pub),
GNUNET_JSON_from_data_auto (&denom_sm_pub), GNUNET_JSON_pack_data_auto ("signkey_secmod_public_key",
"signkey_secmod_public_key", &esign_sm_pub));
GNUNET_JSON_from_data_auto (&esign_sm_pub));
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Returning GET /management/keys response:\n"); "Returning GET /management/keys response:\n");
if (NULL == reply) if (NULL == reply)

View File

@ -81,15 +81,13 @@ handle_link_data (void *cls,
{ {
json_t *obj; json_t *obj;
obj = json_pack ("{s:o, s:o, s:o}", obj = GNUNET_JSON_PACK (
"denom_pub", GNUNET_JSON_pack_rsa_public_key ("denom_pub",
GNUNET_JSON_from_rsa_public_key ( pos->denom_pub.rsa_public_key),
pos->denom_pub.rsa_public_key), GNUNET_JSON_pack_rsa_signature ("ev_sig",
"ev_sig", pos->ev_sig.rsa_signature),
GNUNET_JSON_from_rsa_signature GNUNET_JSON_pack_data_auto ("link_sig",
(pos->ev_sig.rsa_signature), &pos->orig_coin_link_sig));
"link_sig",
GNUNET_JSON_from_data_auto (&pos->orig_coin_link_sig));
if ( (NULL == obj) || if ( (NULL == obj) ||
(0 != (0 !=
json_array_append_new (list, json_array_append_new (list,
@ -102,11 +100,11 @@ handle_link_data (void *cls,
{ {
json_t *root; json_t *root;
root = json_pack ("{s:o, s:o}", root = GNUNET_JSON_PACK (
"new_coins", GNUNET_JSON_pack_array_steal ("new_coins",
list, list),
"transfer_pub", GNUNET_JSON_pack_data_auto ("transfer_pub",
GNUNET_JSON_from_data_auto (transfer_pub)); transfer_pub));
if ( (NULL == root) || if ( (NULL == root) ||
(0 != (0 !=
json_array_append_new (ctx->mlist, json_array_append_new (ctx->mlist,

View File

@ -66,24 +66,24 @@ reply_melt_insufficient_funds (
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_EXCHANGE_MELT_HISTORY_DB_ERROR_INSUFFICIENT_FUNDS, TALER_EC_EXCHANGE_MELT_HISTORY_DB_ERROR_INSUFFICIENT_FUNDS,
NULL); NULL);
return TALER_MHD_reply_json_pack ( return TALER_MHD_REPLY_JSON_PACK (
connection, connection,
MHD_HTTP_CONFLICT, MHD_HTTP_CONFLICT,
"{s:s, s:I, s:o, s:o, s:o, s:o, s:o}", GNUNET_JSON_pack_string ("hint",
"hint", TALER_ErrorCode_get_hint (
TALER_ErrorCode_get_hint (TALER_EC_EXCHANGE_MELT_INSUFFICIENT_FUNDS), TALER_EC_EXCHANGE_MELT_INSUFFICIENT_FUNDS)),
"code", GNUNET_JSON_pack_uint64 ("code",
(json_int_t) TALER_EC_EXCHANGE_MELT_INSUFFICIENT_FUNDS, TALER_EC_EXCHANGE_MELT_INSUFFICIENT_FUNDS),
"coin_pub", GNUNET_JSON_pack_data_auto ("coin_pub",
GNUNET_JSON_from_data_auto (coin_pub), coin_pub),
"original_value", TALER_JSON_pack_amount ("original_value",
TALER_JSON_from_amount (coin_value), coin_value),
"residual_value", TALER_JSON_pack_amount ("residual_value",
TALER_JSON_from_amount (residual), residual),
"requested_value", TALER_JSON_pack_amount ("requested_value",
TALER_JSON_from_amount (requested), requested),
"history", GNUNET_JSON_pack_array_steal ("history",
history); history));
} }
@ -119,13 +119,15 @@ reply_melt_success (struct MHD_Connection *connection,
ec, ec,
NULL); NULL);
} }
return TALER_MHD_reply_json_pack ( return TALER_MHD_REPLY_JSON_PACK (
connection, connection,
MHD_HTTP_OK, MHD_HTTP_OK,
"{s:i, s:o, s:o}", GNUNET_JSON_pack_uint64 ("noreveal_index",
"noreveal_index", (int) noreveal_index, noreveal_index),
"exchange_sig", GNUNET_JSON_from_data_auto (&sig), GNUNET_JSON_pack_data_auto ("exchange_sig",
"exchange_pub", GNUNET_JSON_from_data_auto (&pub)); &sig),
GNUNET_JSON_pack_data_auto ("exchange_pub",
&pub));
} }

View File

@ -490,20 +490,20 @@ verify_and_execute_recoup (struct MHD_Connection *connection,
} }
/* Recoup succeeded, return result */ /* Recoup succeeded, return result */
return (refreshed) return (refreshed)
? TALER_MHD_reply_json_pack (connection, ? TALER_MHD_REPLY_JSON_PACK (connection,
MHD_HTTP_OK, MHD_HTTP_OK,
"{s:o, s:b}", GNUNET_JSON_pack_data_auto (
"old_coin_pub", "old_coin_pub",
GNUNET_JSON_from_data_auto (
&pc.target.old_coin_pub), &pc.target.old_coin_pub),
"refreshed", 1) GNUNET_JSON_pack_bool ("refreshed",
: TALER_MHD_reply_json_pack (connection, true))
: TALER_MHD_REPLY_JSON_PACK (connection,
MHD_HTTP_OK, MHD_HTTP_OK,
"{s:o, s:b}", GNUNET_JSON_pack_data_auto (
"reserve_pub", "reserve_pub",
GNUNET_JSON_from_data_auto (
&pc.target.reserve_pub), &pc.target.reserve_pub),
"refreshed", 0); GNUNET_JSON_pack_bool ("refreshed",
false));
} }

View File

@ -60,51 +60,26 @@ reply_refreshes_reveal_success (struct MHD_Connection *connection,
json_t *list; json_t *list;
list = json_array (); list = json_array ();
if (NULL == list) GNUNET_assert (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");
}
for (unsigned int freshcoin_index = 0; for (unsigned int freshcoin_index = 0;
freshcoin_index < num_freshcoins; freshcoin_index < num_freshcoins;
freshcoin_index++) freshcoin_index++)
{ {
json_t *obj; json_t *obj;
obj = json_pack ("{s:o}", obj = GNUNET_JSON_PACK (
"ev_sig", GNUNET_JSON_pack_rsa_signature ("ev_sig",
GNUNET_JSON_from_rsa_signature ( sigs[freshcoin_index].rsa_signature));
sigs[freshcoin_index].rsa_signature)); GNUNET_assert (0 ==
if (NULL == obj) 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_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");
}
} }
return TALER_MHD_reply_json_pack (connection, return TALER_MHD_REPLY_JSON_PACK (
MHD_HTTP_OK, connection,
"{s:o}", MHD_HTTP_OK,
"ev_sigs", GNUNET_JSON_pack_array_steal ("ev_sigs",
list); list));
} }
@ -409,18 +384,16 @@ refreshes_reveal_transaction (void *cls,
&rc_expected)) &rc_expected))
{ {
GNUNET_break_op (0); GNUNET_break_op (0);
*mhd_ret = TALER_MHD_reply_json_pack ( *mhd_ret = TALER_MHD_REPLY_JSON_PACK (
connection, connection,
MHD_HTTP_CONFLICT, MHD_HTTP_CONFLICT,
"{s:s, s:I, s:o}", GNUNET_JSON_pack_string ("hint",
"hint", TALER_ErrorCode_get_hint (
TALER_ErrorCode_get_hint ( TALER_EC_EXCHANGE_REFRESHES_REVEAL_COMMITMENT_VIOLATION)),
TALER_EC_EXCHANGE_REFRESHES_REVEAL_COMMITMENT_VIOLATION), GNUNET_JSON_pack_uint64 ("code",
"code", TALER_EC_EXCHANGE_REFRESHES_REVEAL_COMMITMENT_VIOLATION),
(json_int_t) TALER_EC_EXCHANGE_REFRESHES_REVEAL_COMMITMENT_VIOLATION, GNUNET_JSON_pack_data_auto ("rc_expected",
"rc_expected", &rc_expected));
GNUNET_JSON_from_data_auto (
&rc_expected));
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
} }
} /* end of checking "rc_expected" */ } /* end of checking "rc_expected" */

View File

@ -71,12 +71,13 @@ reply_refund_success (struct MHD_Connection *connection,
ec, ec,
NULL); NULL);
} }
return TALER_MHD_reply_json_pack ( return TALER_MHD_REPLY_JSON_PACK (
connection, connection,
MHD_HTTP_OK, MHD_HTTP_OK,
"{s:o, s:o}", GNUNET_JSON_pack_data_auto ("exchange_sig",
"exchange_sig", GNUNET_JSON_from_data_auto (&sig), &sig),
"exchange_pub", GNUNET_JSON_from_data_auto (&pub)); 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, TEH_plugin->free_coin_transaction_list (TEH_plugin->cls,
tln); tln);
tli->next = NULL; tli->next = NULL;
*mhd_ret = TALER_MHD_reply_json_pack ( *mhd_ret = TALER_MHD_REPLY_JSON_PACK (
connection, connection,
MHD_HTTP_PRECONDITION_FAILED, MHD_HTTP_PRECONDITION_FAILED,
"{s:o, s:s, s:I, s:o}", TALER_JSON_pack_amount ("detail",
"detail", &ref->refund_amount),
TALER_JSON_from_amount (&ref->refund_amount), GNUNET_JSON_pack_string ("hint",
"hint", TALER_ErrorCode_get_hint ( TALER_ErrorCode_get_hint (
TALER_EC_EXCHANGE_REFUND_INCONSISTENT_AMOUNT), TALER_EC_EXCHANGE_REFUND_INCONSISTENT_AMOUNT)),
"code", (json_int_t) TALER_EC_EXCHANGE_REFUND_INCONSISTENT_AMOUNT, GNUNET_JSON_pack_uint64 ("code",
"history", TEH_RESPONSE_compile_transaction_history ( TALER_EC_EXCHANGE_REFUND_INCONSISTENT_AMOUNT),
&refund->coin.coin_pub, GNUNET_JSON_pack_array_steal ("history",
tli)); TEH_RESPONSE_compile_transaction_history (
&refund->coin.coin_pub,
tli)));
TEH_plugin->free_coin_transaction_list (TEH_plugin->cls, TEH_plugin->free_coin_transaction_list (TEH_plugin->cls,
tli); tli);
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
@ -324,20 +327,20 @@ refund_transaction (void *cls,
if (1 == TALER_amount_cmp (&refund_total, if (1 == TALER_amount_cmp (&refund_total,
&deposit_total) ) &deposit_total) )
{ {
*mhd_ret = TALER_MHD_reply_json_pack ( *mhd_ret = TALER_MHD_REPLY_JSON_PACK (
connection, connection,
MHD_HTTP_CONFLICT, MHD_HTTP_CONFLICT,
"{s:s, s:s, s:I, s:o}", GNUNET_JSON_pack_string ("detail",
"detail", "total amount refunded exceeds total amount deposited for this coin"),
"total amount refunded exceeds total amount deposited for this coin", GNUNET_JSON_pack_string ("hint",
"hint", TALER_ErrorCode_get_hint (
TALER_ErrorCode_get_hint ( TALER_EC_EXCHANGE_REFUND_CONFLICT_DEPOSIT_INSUFFICIENT)),
TALER_EC_EXCHANGE_REFUND_CONFLICT_DEPOSIT_INSUFFICIENT), GNUNET_JSON_pack_uint64 ("code",
"code", TALER_EC_EXCHANGE_REFUND_CONFLICT_DEPOSIT_INSUFFICIENT),
(json_int_t) TALER_EC_EXCHANGE_REFUND_CONFLICT_DEPOSIT_INSUFFICIENT, GNUNET_JSON_pack_array_steal ("history",
"history", TEH_RESPONSE_compile_transaction_history (
TEH_RESPONSE_compile_transaction_history (&refund->coin.coin_pub, &refund->coin.coin_pub,
tlx)); tlx)));
TEH_plugin->free_coin_transaction_list (TEH_plugin->cls, TEH_plugin->free_coin_transaction_list (TEH_plugin->cls,
tlx); tlx);
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;

View File

@ -40,7 +40,6 @@ static MHD_RESULT
reply_reserve_history_success (struct MHD_Connection *connection, reply_reserve_history_success (struct MHD_Connection *connection,
const struct TALER_EXCHANGEDB_ReserveHistory *rh) const struct TALER_EXCHANGEDB_ReserveHistory *rh)
{ {
json_t *json_balance;
json_t *json_history; json_t *json_history;
struct TALER_Amount balance; struct TALER_Amount balance;
@ -51,12 +50,13 @@ reply_reserve_history_success (struct MHD_Connection *connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_GENERIC_JSON_ALLOCATION_FAILURE, TALER_EC_GENERIC_JSON_ALLOCATION_FAILURE,
NULL); NULL);
json_balance = TALER_JSON_from_amount (&balance); return TALER_MHD_REPLY_JSON_PACK (
return TALER_MHD_reply_json_pack (connection, connection,
MHD_HTTP_OK, MHD_HTTP_OK,
"{s:o, s:o}", TALER_JSON_pack_amount ("balance",
"balance", json_balance, &balance),
"history", json_history); GNUNET_JSON_pack_array_steal ("history",
json_history));
} }

View File

@ -381,25 +381,25 @@ TEH_RESPONSE_compile_transaction_history (
if (0 != if (0 !=
json_array_append_new ( json_array_append_new (
history, history,
json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o}", GNUNET_JSON_PACK (
"type", GNUNET_JSON_pack_string ("type",
"RECOUP-REFRESH", "RECOUP-REFRESH"),
"amount", TALER_JSON_pack_amount ("amount",
TALER_JSON_from_amount (&pr->value), &pr->value),
"exchange_sig", GNUNET_JSON_pack_data_auto ("exchange_sig",
GNUNET_JSON_from_data_auto (&esig), &esig),
"exchange_pub", GNUNET_JSON_pack_data_auto ("exchange_pub",
GNUNET_JSON_from_data_auto (&epub), &epub),
"old_coin_pub", GNUNET_JSON_pack_data_auto ("old_coin_pub",
GNUNET_JSON_from_data_auto (&pr->old_coin_pub), &pr->old_coin_pub),
"h_denom_pub", GNUNET_JSON_pack_data_auto ("h_denom_pub",
GNUNET_JSON_from_data_auto (&pr->coin.denom_pub_hash), &pr->coin.denom_pub_hash),
"coin_sig", GNUNET_JSON_pack_data_auto ("coin_sig",
GNUNET_JSON_from_data_auto (&pr->coin_sig), &pr->coin_sig),
"coin_blind", GNUNET_JSON_pack_data_auto ("coin_blind",
GNUNET_JSON_from_data_auto (&pr->coin_blind), &pr->coin_blind),
"timestamp", GNUNET_JSON_pack_time_abs ("timestamp",
GNUNET_JSON_from_time_abs (pr->timestamp)))) pr->timestamp))))
{ {
GNUNET_break (0); GNUNET_break (0);
json_decref (history); json_decref (history);
@ -447,20 +447,19 @@ TEH_RESPONSE_reply_unknown_denom_pub_hash (
ec, ec,
NULL); NULL);
} }
return TALER_MHD_reply_json_pack ( return TALER_MHD_REPLY_JSON_PACK (
connection, connection,
MHD_HTTP_NOT_FOUND, MHD_HTTP_NOT_FOUND,
"{s:I,s:o,s:o,s:o,s:o}", GNUNET_JSON_pack_uint64 ("code",
"code", TALER_EC_EXCHANGE_GENERIC_DENOMINATION_KEY_UNKNOWN),
TALER_EC_EXCHANGE_GENERIC_DENOMINATION_KEY_UNKNOWN, GNUNET_JSON_pack_time_abs ("timestamp",
"timestamp", now),
GNUNET_JSON_from_time_abs (now), GNUNET_JSON_pack_data_auto ("exchange_pub",
"exchange_pub", &epub),
GNUNET_JSON_from_data_auto (&epub), GNUNET_JSON_pack_data_auto ("exchange_sig",
"exchange_sig", &esig),
GNUNET_JSON_from_data_auto (&esig), GNUNET_JSON_pack_data_auto ("h_denom_pub",
"h_denom_pub", dph));
GNUNET_JSON_from_data_auto (dph));
} }
@ -499,22 +498,21 @@ TEH_RESPONSE_reply_expired_denom_pub_hash (
ec, ec,
NULL); NULL);
} }
return TALER_MHD_reply_json_pack ( return TALER_MHD_REPLY_JSON_PACK (
connection, connection,
MHD_HTTP_GONE, MHD_HTTP_GONE,
"{s:I,s:s,s:o,s:o,s:o,s:o}", GNUNET_JSON_pack_uint64 ("code",
"code", ec),
ec, GNUNET_JSON_pack_string ("oper",
"oper", oper),
oper, GNUNET_JSON_pack_time_abs ("timestamp",
"timestamp", now),
GNUNET_JSON_from_time_abs (now), GNUNET_JSON_pack_data_auto ("exchange_pub",
"exchange_pub", &epub),
GNUNET_JSON_from_data_auto (&epub), GNUNET_JSON_pack_data_auto ("exchange_sig",
"exchange_sig", &esig),
GNUNET_JSON_from_data_auto (&esig), GNUNET_JSON_pack_data_auto ("h_denom_pub",
"h_denom_pub", dph));
GNUNET_JSON_from_data_auto (dph));
} }
@ -549,12 +547,15 @@ TEH_RESPONSE_reply_coin_insufficient_funds (
TALER_EC_GENERIC_JSON_ALLOCATION_FAILURE, TALER_EC_GENERIC_JSON_ALLOCATION_FAILURE,
"Failed to generated proof of insufficient funds"); "Failed to generated proof of insufficient funds");
} }
return TALER_MHD_reply_json_pack (connection, return TALER_MHD_REPLY_JSON_PACK (
MHD_HTTP_CONFLICT, connection,
"{s:s, s:I, s:o}", MHD_HTTP_CONFLICT,
"hint", TALER_ErrorCode_get_hint (ec), GNUNET_JSON_pack_string ("hint",
"code", (json_int_t) ec, TALER_ErrorCode_get_hint (ec)),
"history", history); GNUNET_JSON_pack_uint64 ("code",
ec),
GNUNET_JSON_pack_array_steal ("history",
history));
} }
@ -612,17 +613,17 @@ TEH_RESPONSE_compile_reserve_history (
if (0 != if (0 !=
json_array_append_new ( json_array_append_new (
json_history, json_history,
json_pack ("{s:s, s:o, s:s, s:I, s:o}", GNUNET_JSON_PACK (
"type", GNUNET_JSON_pack_string ("type",
"CREDIT", "CREDIT"),
"timestamp", GNUNET_JSON_pack_time_abs ("timestamp",
GNUNET_JSON_from_time_abs (bank->execution_date), bank->execution_date),
"sender_account_url", GNUNET_JSON_pack_string ("sender_account_url",
bank->sender_account_details, bank->sender_account_details),
"wire_reference", GNUNET_JSON_pack_uint64 ("wire_reference",
(json_int_t) bank->wire_reference, bank->wire_reference),
"amount", TALER_JSON_pack_amount ("amount",
TALER_JSON_from_amount (&bank->amount)))) &bank->amount))))
{ {
GNUNET_break (0); GNUNET_break (0);
json_decref (json_history); json_decref (json_history);
@ -657,20 +658,19 @@ TEH_RESPONSE_compile_reserve_history (
if (0 != if (0 !=
json_array_append_new ( json_array_append_new (
json_history, json_history,
json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o}", GNUNET_JSON_PACK (
"type", GNUNET_JSON_pack_string ("type",
"WITHDRAW", "WITHDRAW"),
"reserve_sig", GNUNET_JSON_pack_data_auto ("reserve_sig",
GNUNET_JSON_from_data_auto (&withdraw->reserve_sig), &withdraw->reserve_sig),
"h_coin_envelope", GNUNET_JSON_pack_data_auto ("h_coin_envelope",
GNUNET_JSON_from_data_auto ( &withdraw->h_coin_envelope),
&withdraw->h_coin_envelope), GNUNET_JSON_pack_data_auto ("h_denom_pub",
"h_denom_pub", &withdraw->denom_pub_hash),
GNUNET_JSON_from_data_auto (&withdraw->denom_pub_hash), TALER_JSON_pack_amount ("withdraw_fee",
"withdraw_fee", &withdraw->withdraw_fee),
TALER_JSON_from_amount (&withdraw->withdraw_fee), TALER_JSON_pack_amount ("amount",
"amount", &value))))
TALER_JSON_from_amount (&value))))
{ {
GNUNET_break (0); GNUNET_break (0);
json_decref (json_history); json_decref (json_history);
@ -722,21 +722,21 @@ TEH_RESPONSE_compile_reserve_history (
} }
if (0 != if (0 !=
json_array_append_new (json_history, json_array_append_new (
json_pack ("{s:s, s:o, s:o, s:o, s:o, s:o}", json_history,
"type", "RECOUP", GNUNET_JSON_PACK (
"exchange_pub", GNUNET_JSON_pack_string ("type",
GNUNET_JSON_from_data_auto (&pub), "RECOUP"),
"exchange_sig", GNUNET_JSON_pack_data_auto ("exchange_pub",
GNUNET_JSON_from_data_auto (&sig), &pub),
"timestamp", GNUNET_JSON_pack_data_auto ("exchange_sig",
GNUNET_JSON_from_time_abs ( &sig),
recoup->timestamp), GNUNET_JSON_pack_time_abs ("timestamp",
"amount", TALER_JSON_from_amount ( recoup->timestamp),
&recoup->value), TALER_JSON_pack_amount ("amount",
"coin_pub", &recoup->value),
GNUNET_JSON_from_data_auto ( GNUNET_JSON_pack_data_auto ("coin_pub",
&recoup->coin.coin_pub)))) &recoup->coin.coin_pub))))
{ {
GNUNET_break (0); GNUNET_break (0);
json_decref (json_history); json_decref (json_history);
@ -799,24 +799,23 @@ TEH_RESPONSE_compile_reserve_history (
if (0 != if (0 !=
json_array_append_new ( json_array_append_new (
json_history, json_history,
json_pack ( GNUNET_JSON_PACK (
"{s:s, s:s, s:o, s:o, s:o, s:o, s:o, s:o}", GNUNET_JSON_pack_string ("type",
"type", "CLOSING"),
"CLOSING", GNUNET_JSON_pack_string ("receiver_account_details",
"receiver_account_details", closing->receiver_account_details),
closing->receiver_account_details, GNUNET_JSON_pack_data_auto ("wtid",
"wtid", &closing->wtid),
GNUNET_JSON_from_data_auto (&closing->wtid), GNUNET_JSON_pack_data_auto ("exchange_pub",
"exchange_pub", &pub),
GNUNET_JSON_from_data_auto (&pub), GNUNET_JSON_pack_data_auto ("exchange_sig",
"exchange_sig", &sig),
GNUNET_JSON_from_data_auto (&sig), GNUNET_JSON_pack_time_abs ("timestamp",
"timestamp", closing->execution_date),
GNUNET_JSON_from_time_abs (closing->execution_date), TALER_JSON_pack_amount ("amount",
"amount", &value),
TALER_JSON_from_amount (&value), TALER_JSON_pack_amount ("closing_fee",
"closing_fee", &closing->closing_fee))))
TALER_JSON_from_amount (&closing->closing_fee))))
{ {
GNUNET_break (0); GNUNET_break (0);
json_decref (json_history); json_decref (json_history);

View File

@ -99,17 +99,9 @@ reply_transfer_details (struct MHD_Connection *connection,
struct TALER_ExchangePublicKeyP pub; struct TALER_ExchangePublicKeyP pub;
struct TALER_ExchangeSignatureP sig; struct TALER_ExchangeSignatureP sig;
GNUNET_TIME_round_abs (&exec_time); GNUNET_TIME_round_abs (&exec_time);
deposits = json_array (); deposits = json_array ();
if (NULL == deposits) GNUNET_assert (NULL != deposits);
{
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_GENERIC_JSON_ALLOCATION_FAILURE,
"json_array() failed");
}
hash_context = GNUNET_CRYPTO_hash_context_start (); hash_context = GNUNET_CRYPTO_hash_context_start ();
for (const struct AggregatedDepositDetail *wdd_pos = wdd_head; for (const struct AggregatedDepositDetail *wdd_pos = wdd_head;
NULL != wdd_pos; NULL != wdd_pos;
@ -126,20 +118,17 @@ reply_transfer_details (struct MHD_Connection *connection,
&dd, &dd,
sizeof (struct TALER_WireDepositDetailP)); sizeof (struct TALER_WireDepositDetailP));
if (0 != if (0 !=
json_array_append_new (deposits, json_array_append_new (
json_pack ("{s:o, s:o, s:o, s:o}", deposits,
"h_contract_terms", GNUNET_JSON_PACK (
GNUNET_JSON_from_data_auto ( GNUNET_JSON_pack_data_auto ("h_contract_terms",
&wdd_pos->h_contract_terms), &wdd_pos->h_contract_terms),
"coin_pub", GNUNET_JSON_pack_data_auto ("coin_pub",
GNUNET_JSON_from_data_auto ( &wdd_pos->coin_pub),
&wdd_pos->coin_pub), TALER_JSON_pack_amount ("deposit_value",
"deposit_value", &wdd_pos->deposit_value),
TALER_JSON_from_amount ( TALER_JSON_pack_amount ("deposit_fee",
&wdd_pos->deposit_value), &wdd_pos->deposit_fee))))
"deposit_fee",
TALER_JSON_from_amount (
&wdd_pos->deposit_fee))))
{ {
json_decref (deposits); json_decref (deposits);
GNUNET_CRYPTO_hash_context_abort (hash_context); 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, return TALER_MHD_REPLY_JSON_PACK (
MHD_HTTP_OK, connection,
"{s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o}", MHD_HTTP_OK,
"total", TALER_JSON_from_amount (total), TALER_JSON_pack_amount ("total",
"wire_fee", TALER_JSON_from_amount ( total),
wire_fee), TALER_JSON_pack_amount ("wire_fee",
"merchant_pub", wire_fee),
GNUNET_JSON_from_data_auto ( GNUNET_JSON_pack_data_auto ("merchant_pub",
merchant_pub), merchant_pub),
"h_wire", GNUNET_JSON_from_data_auto ( GNUNET_JSON_pack_data_auto ("h_wire",
h_wire), h_wire),
"execution_time", GNUNET_JSON_pack_time_abs ("execution_time",
GNUNET_JSON_from_time_abs (exec_time), exec_time),
"deposits", deposits, GNUNET_JSON_pack_array_steal ("deposits",
"exchange_sig", deposits),
GNUNET_JSON_from_data_auto (&sig), GNUNET_JSON_pack_data_auto ("exchange_sig",
"exchange_pub", &sig),
GNUNET_JSON_from_data_auto (&pub)); GNUNET_JSON_pack_data_auto ("exchange_pub",
&pub));
} }

View File

@ -134,11 +134,11 @@ add_wire_account (void *cls,
if (0 != if (0 !=
json_array_append_new ( json_array_append_new (
a, a,
json_pack ("{s:s, s:o}", GNUNET_JSON_PACK (
"payto_uri", GNUNET_JSON_pack_string ("payto_uri",
payto_uri, payto_uri),
"master_sig", GNUNET_JSON_pack_data_auto ("master_sig",
GNUNET_JSON_from_data_auto (master_sig)))) master_sig))))
{ {
GNUNET_break (0); /* out of memory!? */ GNUNET_break (0); /* out of memory!? */
return; return;
@ -170,17 +170,17 @@ add_wire_fee (void *cls,
if (0 != if (0 !=
json_array_append_new ( json_array_append_new (
a, a,
json_pack ("{s:o, s:o, s:o, s:o, s:o}", GNUNET_JSON_PACK (
"wire_fee", TALER_JSON_pack_amount ("wire_fee",
TALER_JSON_from_amount (wire_fee), wire_fee),
"closing_fee", TALER_JSON_pack_amount ("closing_fee",
TALER_JSON_from_amount (closing_fee), closing_fee),
"start_date", GNUNET_JSON_pack_time_abs ("start_date",
GNUNET_JSON_from_time_abs (start_date), start_date),
"end_date", GNUNET_JSON_pack_time_abs ("end_date",
GNUNET_JSON_from_time_abs (end_date), end_date),
"sig", GNUNET_JSON_pack_data_auto ("sig",
GNUNET_JSON_from_data_auto (master_sig)))) master_sig))))
{ {
GNUNET_break (0); /* out of memory!? */ GNUNET_break (0); /* out of memory!? */
return; return;
@ -283,14 +283,13 @@ build_wire_state (void)
json_t *wire_reply; json_t *wire_reply;
struct WireStateHandle *wsh; struct WireStateHandle *wsh;
wire_reply = json_pack ( wire_reply = GNUNET_JSON_PACK (
"{s:o, s:o, s:o}", GNUNET_JSON_pack_array_steal ("accounts",
"accounts", wire_accounts_array),
wire_accounts_array, GNUNET_JSON_pack_object_steal ("fees",
"fees", wire_fee_object),
wire_fee_object, GNUNET_JSON_pack_data_auto ("master_public_key",
"master_public_key", &TEH_master_public_key));
GNUNET_JSON_from_data_auto (&TEH_master_public_key));
if (NULL == wire_reply) if (NULL == wire_reply)
{ {
GNUNET_break (0); GNUNET_break (0);

View File

@ -78,18 +78,18 @@ reply_withdraw_insufficient_funds (
TALER_EC_GENERIC_DB_INVARIANT_FAILURE, TALER_EC_GENERIC_DB_INVARIANT_FAILURE,
"reserve balance corrupt"); "reserve balance corrupt");
} }
return TALER_MHD_reply_json_pack ( return TALER_MHD_REPLY_JSON_PACK (
connection, connection,
MHD_HTTP_CONFLICT, MHD_HTTP_CONFLICT,
"{s:s, s:I, s:o, s:o}", GNUNET_JSON_pack_string ("hint",
"hint", TALER_ErrorCode_get_hint (
TALER_ErrorCode_get_hint (TALER_EC_EXCHANGE_WITHDRAW_INSUFFICIENT_FUNDS), TALER_EC_EXCHANGE_WITHDRAW_INSUFFICIENT_FUNDS)),
"code", GNUNET_JSON_pack_uint64 ("code",
(json_int_t) TALER_EC_EXCHANGE_WITHDRAW_INSUFFICIENT_FUNDS, TALER_EC_EXCHANGE_WITHDRAW_INSUFFICIENT_FUNDS),
"balance", TALER_JSON_pack_amount ("balance",
TALER_JSON_from_amount (&balance), &balance),
"history", GNUNET_JSON_pack_array_steal ("history",
json_history); json_history));
} }
@ -523,12 +523,11 @@ TEH_handler_withdraw (const struct TEH_RequestHandler *rh,
{ {
MHD_RESULT ret; MHD_RESULT ret;
ret = TALER_MHD_reply_json_pack ( ret = TALER_MHD_REPLY_JSON_PACK (
connection, connection,
MHD_HTTP_OK, MHD_HTTP_OK,
"{s:o}", GNUNET_JSON_pack_rsa_signature ("ev_sig",
"ev_sig", GNUNET_JSON_from_rsa_signature ( wc.collectable.sig.rsa_signature));
wc.collectable.sig.rsa_signature));
GNUNET_CRYPTO_rsa_signature_free (wc.collectable.sig.rsa_signature); GNUNET_CRYPTO_rsa_signature_free (wc.collectable.sig.rsa_signature);
return ret; return ret;
} }