diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-04-11 19:27:18 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-04-11 19:27:18 +0200 |
commit | a2bb69910a4a10453d66f37f02eaefb6bb511c35 (patch) | |
tree | 852c519dd942079cfd28cdf0c43d8595a3f97156 /src/exchange/taler-exchange-httpd_responses.c | |
parent | 58373f2a92536be08db1fc7e9c4dc872e382c2c4 (diff) | |
download | exchange-a2bb69910a4a10453d66f37f02eaefb6bb511c35.tar.gz exchange-a2bb69910a4a10453d66f37f02eaefb6bb511c35.tar.bz2 exchange-a2bb69910a4a10453d66f37f02eaefb6bb511c35.zip |
refactor /wire/deposit response generation to do all JSON logic in httpd_responses.c
Diffstat (limited to 'src/exchange/taler-exchange-httpd_responses.c')
-rw-r--r-- | src/exchange/taler-exchange-httpd_responses.c | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/src/exchange/taler-exchange-httpd_responses.c b/src/exchange/taler-exchange-httpd_responses.c index a47b29cae..6c839b382 100644 --- a/src/exchange/taler-exchange-httpd_responses.c +++ b/src/exchange/taler-exchange-httpd_responses.c @@ -1133,13 +1133,13 @@ TMH_RESPONSE_reply_deposit_wtid (struct MHD_Connection *connection, MHD_HTTP_OK, "{s:o, s:o, s:o, s:o, s:o, s:o}", "wtid", GNUNET_JSON_from_data (wtid, - sizeof (*wtid)), + sizeof (*wtid)), "execution_time", GNUNET_JSON_from_time_abs (exec_time), "coin_contribution", TALER_JSON_from_amount (coin_contribution), "exchange_sig", GNUNET_JSON_from_data (&sig, - sizeof (sig)), + sizeof (sig)), "exchange_pub", GNUNET_JSON_from_data (&pub, - sizeof (pub))); + sizeof (pub))); } @@ -1151,7 +1151,7 @@ TMH_RESPONSE_reply_deposit_wtid (struct MHD_Connection *connection, * @param total total amount that was transferred * @param merchant_pub public key of the merchant * @param h_wire destination account - * @param deposits details about the combined deposits + * @param wdd_head linked list with details about the combined deposits * @return MHD result code */ int @@ -1159,8 +1159,27 @@ TMH_RESPONSE_reply_wire_deposit_details (struct MHD_Connection *connection, const struct TALER_Amount *total, const struct TALER_MerchantPublicKeyP *merchant_pub, const struct GNUNET_HashCode *h_wire, - json_t *deposits) + const struct TMH_WireDepositDetail *wdd_head) { + const struct TMH_WireDepositDetail *wdd_pos; + json_t *deposits; + + deposits = json_array (); + + /* NOTE: We usually keep JSON stuff out of the _DB file, and this + is also ugly if we ever add signatures over this data. (#4135) */ + for (wdd_pos = wdd_head; NULL != wdd_pos; wdd_pos = wdd_pos->next) + { + json_array_append (deposits, + json_pack ("{s:o, s:o, s:o, s:I, s:o}", + "deposit_value", TALER_JSON_from_amount (&wdd_pos->deposit_value), + "deposit_fee", TALER_JSON_from_amount (&wdd_pos->deposit_fee), + "H_contract", GNUNET_JSON_from_data (&wdd_pos->h_contract, + sizeof (struct GNUNET_HashCode)), + "transaction_id", (json_int_t) wdd_pos->transaction_id, + "coin_pub", GNUNET_JSON_from_data (&wdd_pos->coin_pub, + sizeof (struct TALER_CoinSpendPublicKeyP)))); + } /* FIXME: #4135: signing not implemented here */ return TMH_RESPONSE_reply_json_pack (connection, MHD_HTTP_OK, |