diff options
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/taler-merchant-httpd_history.c | 43 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_pay.c | 7 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_proposal.c | 15 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_track-transaction.c | 7 |
4 files changed, 29 insertions, 43 deletions
diff --git a/src/backend/taler-merchant-httpd_history.c b/src/backend/taler-merchant-httpd_history.c index 8efd89aa..1190a03c 100644 --- a/src/backend/taler-merchant-httpd_history.c +++ b/src/backend/taler-merchant-httpd_history.c @@ -39,27 +39,19 @@ */ static void -history_cb (void *cls, - const struct TALER_MerchantPublicKeyP *merchant_pub, - const char *exchange_uri, - const struct GNUNET_HashCode *h_proposal_data, - const struct GNUNET_HashCode *h_wire, - struct GNUNET_TIME_Absolute timestamp, - struct GNUNET_TIME_Absolute refund, - const struct TALER_Amount *total_amount) +pd_cb (void *cls, + const char *order_id, + const json_t *proposal_data) { json_t *response = cls; json_t *entry; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "history_cb\n"); + /*FIXME: more details to be returned*/ GNUNET_break (NULL != - (entry = json_pack ("{s:o, s:s, s:o, s:o}", - "h_proposal_data", GNUNET_JSON_from_data_auto (h_proposal_data), - "exchange", exchange_uri, - "timestamp", GNUNET_JSON_from_time_abs (timestamp), - "total_amount", - TALER_JSON_from_amount (total_amount)))); + (entry = json_pack ("{s:s, s:o}", + "order_id", order_id, + "proposal_data", proposal_data))); + GNUNET_break (0 == json_array_append (response, entry)); } @@ -87,6 +79,7 @@ MH_handler_history (struct TMH_RequestHandler *rh, json_t *response; unsigned int ret; unsigned long long seconds; + struct MerchantInstance *mi; response = json_array (); /*FIXME who decrefs this?*/ str = MHD_lookup_connection_value (connection, @@ -108,14 +101,24 @@ MH_handler_history (struct TMH_RequestHandler *rh, TALER_EC_HISTORY_TIMESTAMP_OVERFLOW, "Timestamp overflowed"); + str = MHD_lookup_connection_value (connection, + MHD_GET_ARGUMENT_KIND, + "instance"); + if (NULL == str) + return TMH_RESPONSE_reply_arg_missing (connection, + TALER_EC_PARAMETER_MISSING, + "instance"); + mi = TMH_lookup_instance (str); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Querying history back to %llu\n", date.abs_value_us); - ret = db->find_transactions_by_date (db->cls, - date, - history_cb, - response); + ret = db->find_proposal_data_by_date (db->cls, + date, + &mi->pubkey, + pd_cb, + response); if (GNUNET_SYSERR == ret) return TMH_RESPONSE_reply_internal_error (connection, TALER_EC_HISTORY_DB_FETCH_ERROR, diff --git a/src/backend/taler-merchant-httpd_pay.c b/src/backend/taler-merchant-httpd_pay.c index f3be11ad..2d86a12b 100644 --- a/src/backend/taler-merchant-httpd_pay.c +++ b/src/backend/taler-merchant-httpd_pay.c @@ -922,7 +922,6 @@ parse_pay (struct MHD_Connection *connection, json_t *root, struct PayContext *p unsigned int coins_index; const char *chosen_exchange; const char *order_id; - struct GNUNET_HashCode h_oid; struct TALER_MerchantPublicKeyP merchant_pub; int res; struct GNUNET_JSON_Specification spec[] = { @@ -942,13 +941,9 @@ parse_pay (struct MHD_Connection *connection, json_t *root, struct PayContext *p return res; } - GNUNET_CRYPTO_hash (order_id, - strlen (order_id), - &h_oid); - res = db->find_proposal_data (db->cls, &pc->proposal_data, - &h_oid, + order_id, &merchant_pub); diff --git a/src/backend/taler-merchant-httpd_proposal.c b/src/backend/taler-merchant-httpd_proposal.c index c0dca1bf..ac71653a 100644 --- a/src/backend/taler-merchant-httpd_proposal.c +++ b/src/backend/taler-merchant-httpd_proposal.c @@ -137,7 +137,6 @@ proposal_put (struct MHD_Connection *connection, json_t *order) struct TALER_Amount total; struct TALER_Amount max_fee; const char *order_id; - struct GNUNET_HashCode h_oid; json_t *products; json_t *merchant; struct GNUNET_TIME_Absolute timestamp; @@ -259,15 +258,13 @@ proposal_put (struct MHD_Connection *connection, json_t *order) &pdps.purpose, &merchant_sig); - GNUNET_CRYPTO_hash (order_id, - strlen (order_id), - &h_oid); - + /* fetch timestamp from order */ if (GNUNET_OK != db->insert_proposal_data (db->cls, - &h_oid, + order_id, &mi->pubkey, + timestamp, order)) { GNUNET_JSON_parse_free (spec); @@ -371,7 +368,6 @@ MH_handler_proposal_lookup (struct TMH_RequestHandler *rh, { const char *order_id; const char *instance; - struct GNUNET_HashCode h_oid; int res; json_t *proposal_data; struct MerchantInstance *mi; @@ -394,13 +390,10 @@ MH_handler_proposal_lookup (struct TMH_RequestHandler *rh, return TMH_RESPONSE_reply_arg_missing (connection, TALER_EC_PARAMETER_MISSING, "order_id"); - GNUNET_CRYPTO_hash (order_id, - strlen (order_id), - &h_oid); res = db->find_proposal_data (db->cls, &proposal_data, - &h_oid, + order_id, &mi->pubkey); if (GNUNET_NO == res) return TMH_RESPONSE_reply_not_found (connection, diff --git a/src/backend/taler-merchant-httpd_track-transaction.c b/src/backend/taler-merchant-httpd_track-transaction.c index 608c3eb9..17b45425 100644 --- a/src/backend/taler-merchant-httpd_track-transaction.c +++ b/src/backend/taler-merchant-httpd_track-transaction.c @@ -848,7 +848,6 @@ MH_handler_track_transaction (struct TMH_RequestHandler *rh, const char *instance; int ret; struct GNUNET_HashCode h_instance; - struct GNUNET_HashCode h_order_id; struct GNUNET_HashCode h_proposal_data; struct json_t *proposal_data; @@ -912,10 +911,6 @@ MH_handler_track_transaction (struct TMH_RequestHandler *rh, strlen (instance), &h_instance); - GNUNET_CRYPTO_hash (order_id, - strlen (order_id), - &h_order_id); - tctx->mi = GNUNET_CONTAINER_multihashmap_get (by_id_map, &h_instance); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -929,7 +924,7 @@ MH_handler_track_transaction (struct TMH_RequestHandler *rh, if (GNUNET_YES != db->find_proposal_data (db->cls, &proposal_data, - &h_order_id, + order_id, &tctx->mi->pubkey)) return TMH_RESPONSE_reply_not_found (connection, |