-remove more json_pack calls
This commit is contained in:
parent
8742b8b8d6
commit
723a3b742e
@ -184,13 +184,13 @@ TALER_BANK_admin_add_incoming (
|
|||||||
json_t *admin_obj;
|
json_t *admin_obj;
|
||||||
CURL *eh;
|
CURL *eh;
|
||||||
|
|
||||||
admin_obj = json_pack ("{s:o, s:o, s:s}",
|
admin_obj = GNUNET_JSON_PACK (
|
||||||
"reserve_pub",
|
GNUNET_JSON_pack_data_auto ("reserve_pub",
|
||||||
GNUNET_JSON_from_data_auto (reserve_pub),
|
reserve_pub),
|
||||||
"amount",
|
TALER_JSON_pack_amount ("amount",
|
||||||
TALER_JSON_from_amount (amount),
|
amount),
|
||||||
"debit_account",
|
GNUNET_JSON_pack_string ("debit_account",
|
||||||
debit_account);
|
debit_account));
|
||||||
if (NULL == admin_obj)
|
if (NULL == admin_obj)
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
|
@ -319,13 +319,17 @@ TALER_BANK_transfer (
|
|||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
transfer_obj = json_pack ("{s:o, s:o, s:s, s:o, s:s}",
|
transfer_obj = GNUNET_JSON_PACK (
|
||||||
"request_uid", GNUNET_JSON_from_data_auto (
|
GNUNET_JSON_pack_data_auto ("request_uid",
|
||||||
&wp->request_uid),
|
&wp->request_uid),
|
||||||
"amount", TALER_JSON_from_amount (&amount),
|
TALER_JSON_pack_amount ("amount",
|
||||||
"exchange_base_url", exchange_base_url,
|
&amount),
|
||||||
"wtid", GNUNET_JSON_from_data_auto (&wp->wtid),
|
GNUNET_JSON_pack_string ("exchange_base_url",
|
||||||
"credit_account", destination_account_uri);
|
exchange_base_url),
|
||||||
|
GNUNET_JSON_pack_data_auto ("wtid",
|
||||||
|
&wp->wtid),
|
||||||
|
GNUNET_JSON_pack_string ("credit_account",
|
||||||
|
destination_account_uri));
|
||||||
if (NULL == transfer_obj)
|
if (NULL == transfer_obj)
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
|
@ -1083,13 +1083,12 @@ handle_admin_add_incoming (struct TALER_FAKEBANK_Handle *h,
|
|||||||
json_decref (json);
|
json_decref (json);
|
||||||
|
|
||||||
/* Finally build response object */
|
/* Finally build response object */
|
||||||
return TALER_MHD_reply_json_pack (connection,
|
return TALER_MHD_REPLY_JSON_PACK (connection,
|
||||||
MHD_HTTP_OK,
|
MHD_HTTP_OK,
|
||||||
"{s:I, s:o}",
|
GNUNET_JSON_pack_uint64 ("row_id",
|
||||||
"row_id",
|
row_id),
|
||||||
(json_int_t) row_id,
|
GNUNET_JSON_pack_time_abs ("timestamp",
|
||||||
"timestamp",
|
timestamp));
|
||||||
GNUNET_JSON_from_time_abs (timestamp));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1211,14 +1210,14 @@ handle_transfer (struct TALER_FAKEBANK_Handle *h,
|
|||||||
json_decref (json);
|
json_decref (json);
|
||||||
|
|
||||||
/* Finally build response object */
|
/* Finally build response object */
|
||||||
return TALER_MHD_reply_json_pack (connection,
|
return TALER_MHD_REPLY_JSON_PACK (
|
||||||
MHD_HTTP_OK,
|
connection,
|
||||||
"{s:I, s:o}",
|
MHD_HTTP_OK,
|
||||||
"row_id",
|
GNUNET_JSON_pack_uint64 ("row_id",
|
||||||
(json_int_t) row_id,
|
row_id),
|
||||||
/* dummy timestamp */
|
/* dummy timestamp */
|
||||||
"timestamp", GNUNET_JSON_from_time_abs (
|
GNUNET_JSON_pack_time_abs ("timestamp",
|
||||||
GNUNET_TIME_UNIT_ZERO_ABS));
|
GNUNET_TIME_UNIT_ZERO_ABS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1438,11 +1437,12 @@ handle_debit_history (struct TALER_FAKEBANK_Handle *h,
|
|||||||
pthread_mutex_unlock (&h->big_lock));
|
pthread_mutex_unlock (&h->big_lock));
|
||||||
GNUNET_free (debit_payto);
|
GNUNET_free (debit_payto);
|
||||||
/* FIXME: suspend for long-polling instead */
|
/* FIXME: suspend for long-polling instead */
|
||||||
return TALER_MHD_reply_json_pack (connection,
|
return TALER_MHD_REPLY_JSON_PACK (
|
||||||
MHD_HTTP_OK,
|
connection,
|
||||||
"{s:o}",
|
MHD_HTTP_OK,
|
||||||
"outgoing_transactions",
|
GNUNET_JSON_pack_array_steal (
|
||||||
history);
|
"outgoing_transactions",
|
||||||
|
history));
|
||||||
}
|
}
|
||||||
if (t->debit_account != acc)
|
if (t->debit_account != acc)
|
||||||
{
|
{
|
||||||
@ -1487,17 +1487,21 @@ handle_debit_history (struct TALER_FAKEBANK_Handle *h,
|
|||||||
GNUNET_asprintf (&credit_payto,
|
GNUNET_asprintf (&credit_payto,
|
||||||
"payto://x-taler-bank/localhost/%s",
|
"payto://x-taler-bank/localhost/%s",
|
||||||
pos->credit_account->account_name);
|
pos->credit_account->account_name);
|
||||||
trans = json_pack (
|
trans = GNUNET_JSON_PACK (
|
||||||
"{s:I, s:o, s:o, s:s, s:s, s:s, s:o}",
|
GNUNET_JSON_pack_uint64 ("row_id",
|
||||||
"row_id", (json_int_t) pos->row_id,
|
pos->row_id),
|
||||||
"date", GNUNET_JSON_from_time_abs (pos->date),
|
GNUNET_JSON_pack_time_abs ("date",
|
||||||
"amount", TALER_JSON_from_amount (&pos->amount),
|
pos->date),
|
||||||
"credit_account", credit_payto,
|
TALER_JSON_pack_amount ("amount",
|
||||||
"debit_account", debit_payto, // FIXME: inefficient to return this here always!
|
&pos->amount),
|
||||||
"exchange_base_url",
|
GNUNET_JSON_pack_string ("credit_account",
|
||||||
pos->subject.debit.exchange_base_url,
|
credit_payto),
|
||||||
"wtid", GNUNET_JSON_from_data_auto (
|
GNUNET_JSON_pack_string ("debit_account",
|
||||||
&pos->subject.debit.wtid));
|
debit_payto), // FIXME: inefficient to return this here always!
|
||||||
|
GNUNET_JSON_pack_string ("exchange_base_url",
|
||||||
|
pos->subject.debit.exchange_base_url),
|
||||||
|
GNUNET_JSON_pack_data_auto ("wtid",
|
||||||
|
&pos->subject.debit.wtid));
|
||||||
GNUNET_assert (NULL != trans);
|
GNUNET_assert (NULL != trans);
|
||||||
GNUNET_free (credit_payto);
|
GNUNET_free (credit_payto);
|
||||||
GNUNET_assert (0 ==
|
GNUNET_assert (0 ==
|
||||||
@ -1515,11 +1519,11 @@ handle_debit_history (struct TALER_FAKEBANK_Handle *h,
|
|||||||
GNUNET_assert (0 ==
|
GNUNET_assert (0 ==
|
||||||
pthread_mutex_unlock (&h->big_lock));
|
pthread_mutex_unlock (&h->big_lock));
|
||||||
GNUNET_free (debit_payto);
|
GNUNET_free (debit_payto);
|
||||||
return TALER_MHD_reply_json_pack (connection,
|
return TALER_MHD_REPLY_JSON_PACK (connection,
|
||||||
MHD_HTTP_OK,
|
MHD_HTTP_OK,
|
||||||
"{s:o}",
|
GNUNET_JSON_pack_array_steal (
|
||||||
"outgoing_transactions",
|
"outgoing_transactions",
|
||||||
history);
|
history));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1593,11 +1597,11 @@ handle_credit_history (struct TALER_FAKEBANK_Handle *h,
|
|||||||
pthread_mutex_unlock (&h->big_lock));
|
pthread_mutex_unlock (&h->big_lock));
|
||||||
GNUNET_free (credit_payto);
|
GNUNET_free (credit_payto);
|
||||||
/* FIXME: suspend for long-polling instead */
|
/* FIXME: suspend for long-polling instead */
|
||||||
return TALER_MHD_reply_json_pack (connection,
|
return TALER_MHD_REPLY_JSON_PACK (connection,
|
||||||
MHD_HTTP_OK,
|
MHD_HTTP_OK,
|
||||||
"{s:o}",
|
GNUNET_JSON_pack_array_steal (
|
||||||
"incoming_transactions",
|
"incoming_transactions",
|
||||||
history);
|
history));
|
||||||
}
|
}
|
||||||
if (skip)
|
if (skip)
|
||||||
{
|
{
|
||||||
@ -1631,15 +1635,19 @@ handle_credit_history (struct TALER_FAKEBANK_Handle *h,
|
|||||||
GNUNET_asprintf (&debit_payto,
|
GNUNET_asprintf (&debit_payto,
|
||||||
"payto://x-taler-bank/localhost/%s",
|
"payto://x-taler-bank/localhost/%s",
|
||||||
pos->debit_account->account_name);
|
pos->debit_account->account_name);
|
||||||
trans = json_pack (
|
trans = GNUNET_JSON_PACK (
|
||||||
"{s:I, s:o, s:o, s:s, s:s, s:o}",
|
GNUNET_JSON_pack_uint64 ("row_id",
|
||||||
"row_id", (json_int_t) pos->row_id,
|
pos->row_id),
|
||||||
"date", GNUNET_JSON_from_time_abs (pos->date),
|
GNUNET_JSON_pack_time_abs ("date",
|
||||||
"amount", TALER_JSON_from_amount (&pos->amount),
|
pos->date),
|
||||||
"credit_account", credit_payto, // FIXME: inefficient to repeat this always here!
|
TALER_JSON_pack_amount ("amount",
|
||||||
"debit_account", debit_payto,
|
&pos->amount),
|
||||||
"reserve_pub", GNUNET_JSON_from_data_auto (
|
GNUNET_JSON_pack_string ("credit_account",
|
||||||
&pos->subject.credit.reserve_pub));
|
credit_payto), // FIXME: inefficient to repeat this always here!
|
||||||
|
GNUNET_JSON_pack_string ("debit_account",
|
||||||
|
debit_payto),
|
||||||
|
GNUNET_JSON_pack_data_auto ("reserve_pub",
|
||||||
|
&pos->subject.credit.reserve_pub));
|
||||||
GNUNET_assert (NULL != trans);
|
GNUNET_assert (NULL != trans);
|
||||||
GNUNET_free (debit_payto);
|
GNUNET_free (debit_payto);
|
||||||
GNUNET_assert (0 ==
|
GNUNET_assert (0 ==
|
||||||
@ -1657,11 +1665,11 @@ handle_credit_history (struct TALER_FAKEBANK_Handle *h,
|
|||||||
GNUNET_assert (0 ==
|
GNUNET_assert (0 ==
|
||||||
pthread_mutex_unlock (&h->big_lock));
|
pthread_mutex_unlock (&h->big_lock));
|
||||||
GNUNET_free (credit_payto);
|
GNUNET_free (credit_payto);
|
||||||
return TALER_MHD_reply_json_pack (connection,
|
return TALER_MHD_REPLY_JSON_PACK (connection,
|
||||||
MHD_HTTP_OK,
|
MHD_HTTP_OK,
|
||||||
"{s:o}",
|
GNUNET_JSON_pack_array_steal (
|
||||||
"incoming_transactions",
|
"incoming_transactions",
|
||||||
history);
|
history));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
This file is part of TALER
|
This file is part of TALER
|
||||||
Copyright (C) 2020 Taler Systems SA
|
Copyright (C) 2020-2021 Taler Systems SA
|
||||||
|
|
||||||
TALER is free software; you can redistribute it and/or modify it under the
|
TALER is free software; you can redistribute it and/or modify it under the
|
||||||
terms of the GNU General Public License as published by the Free Software
|
terms of the GNU General Public License as published by the Free Software
|
||||||
@ -295,11 +295,11 @@ output_operation (const char *op_name,
|
|||||||
json_t *action;
|
json_t *action;
|
||||||
|
|
||||||
GNUNET_assert (NULL != out);
|
GNUNET_assert (NULL != out);
|
||||||
action = json_pack ("{ s:s, s:o }",
|
action = GNUNET_JSON_PACK (
|
||||||
"operation",
|
GNUNET_JSON_pack_string ("operation",
|
||||||
op_name,
|
op_name),
|
||||||
"arguments",
|
GNUNET_JSON_pack_object_steal ("arguments",
|
||||||
op_value);
|
op_value));
|
||||||
GNUNET_break (0 ==
|
GNUNET_break (0 ==
|
||||||
json_array_append_new (out,
|
json_array_append_new (out,
|
||||||
action));
|
action));
|
||||||
@ -660,6 +660,15 @@ keys_cb (
|
|||||||
switch (hr->http_status)
|
switch (hr->http_status)
|
||||||
{
|
{
|
||||||
case MHD_HTTP_OK:
|
case MHD_HTTP_OK:
|
||||||
|
if (! json_is_object (hr->reply))
|
||||||
|
{
|
||||||
|
GNUNET_break (0);
|
||||||
|
TALER_EXCHANGE_disconnect (exchange);
|
||||||
|
exchange = NULL;
|
||||||
|
test_shutdown ();
|
||||||
|
global_ret = EXIT_FAILURE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
@ -673,11 +682,11 @@ keys_cb (
|
|||||||
global_ret = EXIT_FAILURE;
|
global_ret = EXIT_FAILURE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
in = json_pack ("{s:s,s:O}",
|
in = GNUNET_JSON_PACK (
|
||||||
"operation",
|
GNUNET_JSON_pack_string ("operation",
|
||||||
OP_INPUT_KEYS,
|
OP_INPUT_KEYS),
|
||||||
"arguments",
|
GNUNET_JSON_pack_object_incref ("arguments",
|
||||||
hr->reply);
|
(json_t *) hr->reply));
|
||||||
if (NULL == args[0])
|
if (NULL == args[0])
|
||||||
{
|
{
|
||||||
json_dumpf (in,
|
json_dumpf (in,
|
||||||
@ -1141,11 +1150,11 @@ sign_denomkeys (const json_t *denomkeys)
|
|||||||
&auditor_priv,
|
&auditor_priv,
|
||||||
&auditor_sig);
|
&auditor_sig);
|
||||||
output_operation (OP_SIGN_DENOMINATION,
|
output_operation (OP_SIGN_DENOMINATION,
|
||||||
json_pack ("{s:o, 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),
|
||||||
"auditor_sig",
|
GNUNET_JSON_pack_data_auto ("auditor_sig",
|
||||||
GNUNET_JSON_from_data_auto (&auditor_sig)));
|
&auditor_sig)));
|
||||||
}
|
}
|
||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
}
|
}
|
||||||
@ -1214,7 +1223,10 @@ do_sign (char *const *args)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (NULL == out)
|
if (NULL == out)
|
||||||
|
{
|
||||||
out = json_array ();
|
out = json_array ();
|
||||||
|
GNUNET_assert (NULL != out);
|
||||||
|
}
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
sign_denomkeys (denomkeys))
|
sign_denomkeys (denomkeys))
|
||||||
{
|
{
|
||||||
@ -1247,11 +1259,14 @@ do_setup (char *const *args)
|
|||||||
if (NULL != *args)
|
if (NULL != *args)
|
||||||
{
|
{
|
||||||
if (NULL == out)
|
if (NULL == out)
|
||||||
|
{
|
||||||
out = json_array ();
|
out = json_array ();
|
||||||
|
GNUNET_assert (NULL != out);
|
||||||
|
}
|
||||||
output_operation (OP_SETUP,
|
output_operation (OP_SETUP,
|
||||||
json_pack ("{s:o}",
|
GNUNET_JSON_PACK (
|
||||||
"auditor_pub",
|
GNUNET_JSON_pack_data_auto ("auditor_pub",
|
||||||
GNUNET_JSON_from_data_auto (&auditor_pub)));
|
&auditor_pub)));
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user