From e8a88392da98c3325ba39b20901a5c220158d1f5 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 23 Nov 2019 18:47:07 +0100 Subject: more refactoring towards using libtalermhd --- src/exchange/taler-exchange-httpd_deposit.c | 109 ++++++++++++++++------------ 1 file changed, 63 insertions(+), 46 deletions(-) (limited to 'src/exchange/taler-exchange-httpd_deposit.c') diff --git a/src/exchange/taler-exchange-httpd_deposit.c b/src/exchange/taler-exchange-httpd_deposit.c index fd36bb4a0..7e71dcaa6 100644 --- a/src/exchange/taler-exchange-httpd_deposit.c +++ b/src/exchange/taler-exchange-httpd_deposit.c @@ -29,6 +29,7 @@ #include #include #include "taler_json_lib.h" +#include "taler_mhd_lib.h" #include "taler-exchange-httpd_parsing.h" #include "taler-exchange-httpd_deposit.h" #include "taler-exchange-httpd_responses.h" @@ -83,17 +84,17 @@ reply_deposit_success (struct MHD_Connection *connection, &pub, &sig)) { - return TEH_RESPONSE_reply_internal_error (connection, - TALER_EC_EXCHANGE_BAD_CONFIGURATION, - "no keys"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_EXCHANGE_BAD_CONFIGURATION, + "no keys"); } - return TEH_RESPONSE_reply_json_pack (connection, - MHD_HTTP_OK, - "{s:s, s:o, s:o}", - "status", "DEPOSIT_OK", - "sig", GNUNET_JSON_from_data_auto (&sig), - "pub", GNUNET_JSON_from_data_auto ( - &pub)); + return TALER_MHD_reply_json_pack (connection, + MHD_HTTP_OK, + "{s:s, s:o, s:o}", + "status", "DEPOSIT_OK", + "sig", GNUNET_JSON_from_data_auto (&sig), + "pub", GNUNET_JSON_from_data_auto (&pub)); } @@ -149,8 +150,10 @@ deposit_transaction (void *cls, { if (GNUNET_DB_STATUS_HARD_ERROR == qs) { - *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_DEPOSIT_HISTORY_DB_ERROR); + *mhd_ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_DEPOSIT_HISTORY_DB_ERROR, + "Could not check for existing identical deposit"); return GNUNET_DB_STATUS_HARD_ERROR; } return qs; @@ -197,8 +200,10 @@ deposit_transaction (void *cls, { TEH_plugin->free_coin_transaction_list (TEH_plugin->cls, tl); - *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_DEPOSIT_HISTORY_DB_ERROR); + *mhd_ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_DEPOSIT_HISTORY_DB_ERROR, + "could not access coin history"); return GNUNET_DB_STATUS_HARD_ERROR; } /* Check that cost of all transactions is smaller than @@ -223,8 +228,10 @@ deposit_transaction (void *cls, if (GNUNET_DB_STATUS_HARD_ERROR == qs) { TALER_LOG_WARNING ("Failed to store /deposit information in database\n"); - *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_DEPOSIT_STORE_DB_ERROR); + *mhd_ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_DEPOSIT_STORE_DB_ERROR, + "Could not persist /deposit data"); } return qs; } @@ -273,9 +280,10 @@ verify_and_execute_deposit (struct MHD_Connection *connection, &deposit->coin.coin_pub.eddsa_pub)) { TALER_LOG_WARNING ("Invalid signature on /deposit request\n"); - return TEH_RESPONSE_reply_signature_invalid (connection, - TALER_EC_DEPOSIT_COIN_SIGNATURE_INVALID, - "coin_sig"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_UNAUTHORIZED, + TALER_EC_DEPOSIT_COIN_SIGNATURE_INVALID, + "coin_sig"); } /* check denomination */ @@ -295,9 +303,10 @@ verify_and_execute_deposit (struct MHD_Connection *connection, if (NULL == dki) { TEH_KS_release (mks); - return TEH_RESPONSE_reply_with_error (connection, - ec, - hc); + return TALER_MHD_reply_with_error (connection, + ec, + hc, + "Could not find denomination key used in deposit"); } TALER_amount_ntoh (&dc.value, &dki->issue.properties.value); @@ -445,9 +454,10 @@ TEH_DEPOSIT_handler_deposit (struct TEH_RequestHandler *rh, { GNUNET_break_op (0); GNUNET_JSON_parse_free (spec); - return TEH_RESPONSE_reply_arg_invalid (connection, - TALER_EC_DEPOSIT_REFUND_DEADLINE_AFTER_WIRE_DEADLINE, - "refund_deadline"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_BAD_REQUEST, + TALER_EC_DEPOSIT_REFUND_DEADLINE_AFTER_WIRE_DEADLINE, + "refund_deadline"); } if (TALER_EC_NONE != @@ -466,9 +476,10 @@ TEH_DEPOSIT_handler_deposit (struct TEH_RequestHandler *rh, { GNUNET_break_op (0); GNUNET_JSON_parse_free (spec); - return TEH_RESPONSE_reply_arg_invalid (connection, - TALER_EC_DEPOSIT_INVALID_TIMESTAMP, - "timestamp"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_BAD_REQUEST, + TALER_EC_DEPOSIT_INVALID_TIMESTAMP, + "timestamp"); } if (GNUNET_OK != TALER_JSON_merchant_wire_signature_hash (wire, @@ -477,18 +488,20 @@ TEH_DEPOSIT_handler_deposit (struct TEH_RequestHandler *rh, TALER_LOG_WARNING ( "Failed to parse JSON wire format specification for /deposit request\n"); GNUNET_JSON_parse_free (spec); - return TEH_RESPONSE_reply_arg_invalid (connection, - TALER_EC_DEPOSIT_INVALID_WIRE_FORMAT_JSON, - "wire"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_BAD_REQUEST, + TALER_EC_DEPOSIT_INVALID_WIRE_FORMAT_JSON, + "wire"); } if (0 != GNUNET_memcmp (&deposit.h_wire, &my_h_wire)) { /* Client hashed contract differently than we did, reject */ GNUNET_JSON_parse_free (spec); - return TEH_RESPONSE_reply_arg_invalid (connection, - TALER_EC_DEPOSIT_INVALID_WIRE_FORMAT_CONTRACT_HASH_CONFLICT, - "H_wire"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_BAD_REQUEST, + TALER_EC_DEPOSIT_INVALID_WIRE_FORMAT_CONTRACT_HASH_CONFLICT, + "H_wire"); } /* check denomination exists and is valid */ @@ -497,9 +510,10 @@ TEH_DEPOSIT_handler_deposit (struct TEH_RequestHandler *rh, { TALER_LOG_ERROR ("Lacking keys to operate\n"); GNUNET_JSON_parse_free (spec); - return TEH_RESPONSE_reply_internal_error (connection, - TALER_EC_EXCHANGE_BAD_CONFIGURATION, - "no keys"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_EXCHANGE_BAD_CONFIGURATION, + "no keys"); } dki = TEH_KS_denomination_key_lookup_by_hash (key_state, &deposit.coin.denom_pub_hash, @@ -511,9 +525,10 @@ TEH_DEPOSIT_handler_deposit (struct TEH_RequestHandler *rh, TEH_KS_release (key_state); TALER_LOG_WARNING ("Unknown denomination key in /deposit request\n"); GNUNET_JSON_parse_free (spec); - return TEH_RESPONSE_reply_with_error (connection, - ec, - hc); + return TALER_MHD_reply_with_error (connection, + ec, + hc, + "Could not find denomination key used in deposit"); } TALER_amount_ntoh (&deposit.deposit_fee, &dki->issue.properties.fee_deposit); @@ -525,9 +540,10 @@ TEH_DEPOSIT_handler_deposit (struct TEH_RequestHandler *rh, TALER_LOG_WARNING ("Invalid coin passed for /deposit\n"); TEH_KS_release (key_state); GNUNET_JSON_parse_free (spec); - return TEH_RESPONSE_reply_signature_invalid (connection, - TALER_EC_DEPOSIT_DENOMINATION_SIGNATURE_INVALID, - "ub_sig"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_UNAUTHORIZED, + TALER_EC_DEPOSIT_DENOMINATION_SIGNATURE_INVALID, + "ub_sig"); } TALER_amount_ntoh (&deposit.deposit_fee, &dki->issue.properties.fee_deposit); @@ -538,9 +554,10 @@ TEH_DEPOSIT_handler_deposit (struct TEH_RequestHandler *rh, { GNUNET_break_op (0); GNUNET_JSON_parse_free (spec); - return TEH_RESPONSE_reply_external_error (connection, - TALER_EC_DEPOSIT_NEGATIVE_VALUE_AFTER_FEE, - "deposited amount smaller than depositing fee"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_BAD_REQUEST, + TALER_EC_DEPOSIT_NEGATIVE_VALUE_AFTER_FEE, + "deposited amount smaller than depositing fee"); } /* make sure coin is 'known' in database */ -- cgit v1.2.3 From cf6ba0c77196b77f5c54f0533ac1be3d1d5ee6d6 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 23 Nov 2019 21:03:05 +0100 Subject: more refactoring for libtalermhd --- src/exchange/taler-exchange-httpd_deposit.c | 14 ++- src/exchange/taler-exchange-httpd_keystate.h | 1 + src/exchange/taler-exchange-httpd_mhd.c | 12 +- src/exchange/taler-exchange-httpd_test.c | 134 +++++++++++---------- .../taler-exchange-httpd_track_transaction.c | 73 ++++++----- src/exchange/taler-exchange-httpd_track_transfer.c | 75 +++++++----- src/exchange/taler-exchange-httpd_wire.c | 7 +- 7 files changed, 174 insertions(+), 142 deletions(-) (limited to 'src/exchange/taler-exchange-httpd_deposit.c') diff --git a/src/exchange/taler-exchange-httpd_deposit.c b/src/exchange/taler-exchange-httpd_deposit.c index 7e71dcaa6..1db8d7621 100644 --- a/src/exchange/taler-exchange-httpd_deposit.c +++ b/src/exchange/taler-exchange-httpd_deposit.c @@ -291,9 +291,10 @@ verify_and_execute_deposit (struct MHD_Connection *connection, if (NULL == mks) { TALER_LOG_ERROR ("Lacking keys to operate\n"); - return TEH_RESPONSE_reply_internal_error (connection, - TALER_EC_EXCHANGE_BAD_CONFIGURATION, - "no keys"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_EXCHANGE_BAD_CONFIGURATION, + "no keys"); } dki = TEH_KS_denomination_key_lookup_by_hash (mks, &deposit->coin.denom_pub_hash, @@ -465,9 +466,10 @@ TEH_DEPOSIT_handler_deposit (struct TEH_RequestHandler *rh, &emsg))) { GNUNET_JSON_parse_free (spec); - res = TEH_RESPONSE_reply_external_error (connection, - ec, - emsg); + res = TALER_MHD_reply_with_error (connection, + MHD_HTTP_BAD_REQUEST, + ec, + emsg); GNUNET_free (emsg); return res; } diff --git a/src/exchange/taler-exchange-httpd_keystate.h b/src/exchange/taler-exchange-httpd_keystate.h index 708b043b5..5d92af2b2 100644 --- a/src/exchange/taler-exchange-httpd_keystate.h +++ b/src/exchange/taler-exchange-httpd_keystate.h @@ -26,6 +26,7 @@ #include #include #include "taler-exchange-httpd.h" +#include "taler_error_codes.h" #include "taler_exchangedb_lib.h" diff --git a/src/exchange/taler-exchange-httpd_mhd.c b/src/exchange/taler-exchange-httpd_mhd.c index 36d10bae3..825a1b310 100644 --- a/src/exchange/taler-exchange-httpd_mhd.c +++ b/src/exchange/taler-exchange-httpd_mhd.c @@ -67,7 +67,7 @@ TEH_MHD_handler_static_response (struct TEH_RequestHandler *rh, GNUNET_break (0); return MHD_NO; } - TEH_RESPONSE_add_global_headers (response); + TALER_MHD_add_global_headers (response); if (NULL != rh->mime_type) (void) MHD_add_response_header (response, MHD_HTTP_HEADER_CONTENT_TYPE, @@ -128,11 +128,11 @@ TEH_MHD_handler_send_json_pack_error (struct TEH_RequestHandler *rh, (void) connection_cls; (void) upload_data; (void) upload_data_size; - return TEH_RESPONSE_reply_json_pack (connection, - rh->response_code, - "{s:s}", - "error", - rh->data); + return TALER_MHD_reply_json_pack (connection, + rh->response_code, + "{s:s}", + "error", + rh->data); } diff --git a/src/exchange/taler-exchange-httpd_test.c b/src/exchange/taler-exchange-httpd_test.c index 0a64f267f..4d0e7d691 100644 --- a/src/exchange/taler-exchange-httpd_test.c +++ b/src/exchange/taler-exchange-httpd_test.c @@ -24,6 +24,7 @@ #include #include #include +#include "taler_mhd_lib.h" #include "taler_signatures.h" #include "taler-exchange-httpd_test.h" #include "taler-exchange-httpd_parsing.h" @@ -88,11 +89,11 @@ TEH_TEST_handler_test_base32 (struct TEH_RequestHandler *rh, &hc); GNUNET_JSON_parse_free (spec); json_decref (json); - return TEH_RESPONSE_reply_json_pack (connection, - MHD_HTTP_OK, - "{s:o}", - "output", - GNUNET_JSON_from_data_auto (&hc)); + return TALER_MHD_reply_json_pack (connection, + MHD_HTTP_OK, + "{s:o}", + "output", + GNUNET_JSON_from_data_auto (&hc)); } @@ -172,11 +173,11 @@ TEH_TEST_handler_test_encrypt (struct TEH_RequestHandler *rh, in_ptr_size); GNUNET_free (out); GNUNET_JSON_parse_free (spec); - return TEH_RESPONSE_reply_json_pack (connection, - MHD_HTTP_OK, - "{s:o}", - "output", - json); + return TALER_MHD_reply_json_pack (connection, + MHD_HTTP_OK, + "{s:o}", + "output", + json); } @@ -237,11 +238,11 @@ TEH_TEST_handler_test_hkdf (struct TEH_RequestHandler *rh, NULL, 0)); GNUNET_JSON_parse_free (spec); json = GNUNET_JSON_from_data_auto (&hc); - return TEH_RESPONSE_reply_json_pack (connection, - MHD_HTTP_OK, - "{s:o}", - "output", - json); + return TALER_MHD_reply_json_pack (connection, + MHD_HTTP_OK, + "{s:o}", + "output", + json); } @@ -298,16 +299,17 @@ TEH_TEST_handler_test_ecdhe (struct TEH_RequestHandler *rh, &hc)) { GNUNET_JSON_parse_free (spec); - return TEH_RESPONSE_reply_internal_error (connection, - TALER_EC_TEST_ECDH_ERROR, - "Failed to perform ECDH"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_TEST_ECDH_ERROR, + "Failed to perform ECDH"); } GNUNET_JSON_parse_free (spec); - return TEH_RESPONSE_reply_json_pack (connection, - MHD_HTTP_OK, - "{s:o}", - "ecdh_hash", - GNUNET_JSON_from_data_auto (&hc)); + return TALER_MHD_reply_json_pack (connection, + MHD_HTTP_OK, + "{s:o}", + "ecdh_hash", + GNUNET_JSON_from_data_auto (&hc)); } @@ -369,9 +371,10 @@ TEH_TEST_handler_test_eddsa (struct TEH_RequestHandler *rh, &pub)) { GNUNET_JSON_parse_free (spec); - return TEH_RESPONSE_reply_signature_invalid (connection, - TALER_EC_TEST_EDDSA_INVALID, - "eddsa_sig"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_FORBIDDEN, + TALER_EC_TEST_EDDSA_INVALID, + "eddsa_sig"); } GNUNET_JSON_parse_free (spec); pk = GNUNET_CRYPTO_eddsa_key_create (); @@ -382,20 +385,21 @@ TEH_TEST_handler_test_eddsa (struct TEH_RequestHandler *rh, &sig)) { GNUNET_free (pk); - return TEH_RESPONSE_reply_internal_error (connection, - TALER_EC_TEST_EDDSA_ERROR, - "Failed to EdDSA-sign"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_TEST_EDDSA_ERROR, + "Failed to EdDSA-sign"); } GNUNET_CRYPTO_eddsa_key_get_public (pk, &pub); GNUNET_free (pk); - return TEH_RESPONSE_reply_json_pack (connection, - MHD_HTTP_OK, - "{s:o, s:o}", - "eddsa_pub", - GNUNET_JSON_from_data_auto (&pub), - "eddsa_sig", - GNUNET_JSON_from_data_auto (&sig)); + return TALER_MHD_reply_json_pack (connection, + MHD_HTTP_OK, + "{s:o, s:o}", + "eddsa_pub", + GNUNET_JSON_from_data_auto (&pub), + "eddsa_sig", + GNUNET_JSON_from_data_auto (&sig)); } @@ -425,23 +429,25 @@ TEH_TEST_handler_test_rsa_get (struct TEH_RequestHandler *rh, if (NULL == rsa_pk) { GNUNET_break (0); - return TEH_RESPONSE_reply_internal_error (connection, - TALER_EC_TEST_RSA_GEN_ERROR, - "Failed to create RSA key"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_TEST_RSA_GEN_ERROR, + "Failed to create RSA key"); } pub = GNUNET_CRYPTO_rsa_private_key_get_public (rsa_pk); if (NULL == pub) { GNUNET_break (0); - return TEH_RESPONSE_reply_internal_error (connection, - TALER_EC_TEST_RSA_PUB_ERROR, - "Failed to get public RSA key"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_TEST_RSA_PUB_ERROR, + "Failed to get public RSA key"); } - res = TEH_RESPONSE_reply_json_pack (connection, - MHD_HTTP_OK, - "{s:o}", - "rsa_pub", - GNUNET_JSON_from_rsa_public_key (pub)); + res = TALER_MHD_reply_json_pack (connection, + MHD_HTTP_OK, + "{s:o}", + "rsa_pub", + GNUNET_JSON_from_rsa_public_key (pub)); GNUNET_CRYPTO_rsa_public_key_free (pub); return res; } @@ -497,9 +503,10 @@ TEH_TEST_handler_test_rsa_sign (struct TEH_RequestHandler *rh, { GNUNET_break (0); GNUNET_JSON_parse_free (spec); - return TEH_RESPONSE_reply_internal_error (connection, - TALER_EC_TEST_RSA_GEN_ERROR, - "Failed to create RSA key"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_TEST_RSA_GEN_ERROR, + "Failed to create RSA key"); } sig = GNUNET_CRYPTO_rsa_sign_blinded (rsa_pk, in_ptr, @@ -508,16 +515,17 @@ TEH_TEST_handler_test_rsa_sign (struct TEH_RequestHandler *rh, { GNUNET_break (0); GNUNET_JSON_parse_free (spec); - return TEH_RESPONSE_reply_internal_error (connection, - TALER_EC_TEST_RSA_SIGN_ERROR, - "Failed to RSA-sign"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_TEST_RSA_SIGN_ERROR, + "Failed to RSA-sign"); } GNUNET_JSON_parse_free (spec); - res = TEH_RESPONSE_reply_json_pack (connection, - MHD_HTTP_OK, - "{s:o}", - "rsa_blind_sig", - GNUNET_JSON_from_rsa_signature (sig)); + res = TALER_MHD_reply_json_pack (connection, + MHD_HTTP_OK, + "{s:o}", + "rsa_blind_sig", + GNUNET_JSON_from_rsa_signature (sig)); GNUNET_CRYPTO_rsa_signature_free (sig); return res; } @@ -573,11 +581,11 @@ TEH_TEST_handler_test_transfer (struct TEH_RequestHandler *rh, TALER_link_reveal_transfer_secret (&trans_priv, &coin_pub, &secret); - return TEH_RESPONSE_reply_json_pack (connection, - MHD_HTTP_OK, - "{s:o}", - "secret", - GNUNET_JSON_from_data_auto (&secret)); + return TALER_MHD_reply_json_pack (connection, + MHD_HTTP_OK, + "{s:o}", + "secret", + GNUNET_JSON_from_data_auto (&secret)); } diff --git a/src/exchange/taler-exchange-httpd_track_transaction.c b/src/exchange/taler-exchange-httpd_track_transaction.c index 3b8d14a01..5a057d665 100644 --- a/src/exchange/taler-exchange-httpd_track_transaction.c +++ b/src/exchange/taler-exchange-httpd_track_transaction.c @@ -23,6 +23,7 @@ #include #include #include +#include "taler_mhd_lib.h" #include "taler_signatures.h" #include "taler-exchange-httpd_parsing.h" #include "taler-exchange-httpd_keystate.h" @@ -42,12 +43,12 @@ static int reply_transfer_pending (struct MHD_Connection *connection, struct GNUNET_TIME_Absolute planned_exec_time) { - return TEH_RESPONSE_reply_json_pack (connection, - MHD_HTTP_ACCEPTED, - "{s:o}", - "execution_time", - GNUNET_JSON_from_time_abs ( - planned_exec_time)); + return TALER_MHD_reply_json_pack (connection, + MHD_HTTP_ACCEPTED, + "{s:o}", + "execution_time", + GNUNET_JSON_from_time_abs ( + planned_exec_time)); } @@ -92,24 +93,25 @@ reply_track_transaction (struct MHD_Connection *connection, &pub, &sig)) { - return TEH_RESPONSE_reply_internal_error (connection, - TALER_EC_EXCHANGE_BAD_CONFIGURATION, - "no keys"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_EXCHANGE_BAD_CONFIGURATION, + "no keys"); } - return TEH_RESPONSE_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, + "{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)); } @@ -249,15 +251,19 @@ track_transaction_transaction (void *cls, if (GNUNET_DB_STATUS_HARD_ERROR == qs) { GNUNET_break (0); - *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_TRACK_TRANSACTION_DB_FETCH_FAILED); + *mhd_ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_TRACK_TRANSACTION_DB_FETCH_FAILED, + "failed to fetch transaction data"); } return qs; } if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) { - *mhd_ret = TEH_RESPONSE_reply_transaction_unknown (connection, - TALER_EC_TRACK_TRANSACTION_NOT_FOUND); + *mhd_ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_TRACK_TRANSACTION_NOT_FOUND, + "transaction unknown"); return GNUNET_DB_STATUS_HARD_ERROR; } return qs; @@ -295,9 +301,10 @@ check_and_handle_track_transaction_request (struct MHD_Connection *connection, &merchant_pub->eddsa_pub)) { GNUNET_break_op (0); - return TEH_RESPONSE_reply_signature_invalid (connection, - TALER_EC_TRACK_TRANSACTION_MERCHANT_SIGNATURE_INVALID, - "merchant_sig"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_FORBIDDEN, + TALER_EC_TRACK_TRANSACTION_MERCHANT_SIGNATURE_INVALID, + "merchant_sig"); } ctx.pending = GNUNET_NO; ctx.tps = tps; @@ -314,8 +321,10 @@ check_and_handle_track_transaction_request (struct MHD_Connection *connection, return reply_transfer_pending (connection, ctx.execution_time); if (GNUNET_SYSERR == ctx.pending) - return TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_TRACK_TRANSACTION_DB_FEE_INCONSISTENT); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_TRACK_TRANSACTION_DB_FEE_INCONSISTENT, + "fees are inconsistent"); return reply_track_transaction (connection, &tps->h_contract_terms, &tps->h_wire, diff --git a/src/exchange/taler-exchange-httpd_track_transfer.c b/src/exchange/taler-exchange-httpd_track_transfer.c index cacbfaa85..83521f736 100644 --- a/src/exchange/taler-exchange-httpd_track_transfer.c +++ b/src/exchange/taler-exchange-httpd_track_transfer.c @@ -28,6 +28,7 @@ #include "taler-exchange-httpd_keystate.h" #include "taler-exchange-httpd_track_transfer.h" #include "taler-exchange-httpd_responses.h" +#include "taler_mhd_lib.h" #include "taler_wire_lib.h" @@ -148,29 +149,30 @@ reply_track_transfer_details (struct MHD_Connection *connection, &sig)) { json_decref (deposits); - return TEH_RESPONSE_reply_internal_error (connection, - TALER_EC_EXCHANGE_BAD_CONFIGURATION, - "no keys"); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_EXCHANGE_BAD_CONFIGURATION, + "no keys"); } - return TEH_RESPONSE_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, + "{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)); } @@ -396,23 +398,28 @@ track_transfer_transaction (void *cls, if (GNUNET_DB_STATUS_HARD_ERROR == qs) { GNUNET_break (0); - *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_TRACK_TRANSFER_DB_FETCH_FAILED); + *mhd_ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_TRACK_TRANSFER_DB_FETCH_FAILED, + "failed to fetch transaction data"); } return qs; } if (GNUNET_SYSERR == ctx->is_valid) { GNUNET_break (0); - *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_TRACK_TRANSFER_DB_INCONSISTENT); + *mhd_ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_TRACK_TRANSFER_DB_INCONSISTENT, + "exchange database internally inconsistent"); return GNUNET_DB_STATUS_HARD_ERROR; } if (GNUNET_NO == ctx->is_valid) { - *mhd_ret = TEH_RESPONSE_reply_arg_unknown (connection, - TALER_EC_TRACK_TRANSFER_WTID_NOT_FOUND, - "wtid"); + *mhd_ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_TRACK_TRANSFER_WTID_NOT_FOUND, + "wtid"); return GNUNET_DB_STATUS_HARD_ERROR; } qs = TEH_plugin->get_wire_fee (TEH_plugin->cls, @@ -430,8 +437,10 @@ track_transfer_transaction (void *cls, (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS) ) { GNUNET_break (0); - *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_TRACK_TRANSFER_WIRE_FEE_NOT_FOUND); + *mhd_ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_TRACK_TRANSFER_WIRE_FEE_NOT_FOUND, + "did not find wire fee"); } return qs; } @@ -441,8 +450,10 @@ track_transfer_transaction (void *cls, &ctx->wire_fee)) { GNUNET_break (0); - *mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection, - TALER_EC_TRACK_TRANSFER_WIRE_FEE_INCONSISTENT); + *mhd_ret = TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_TRACK_TRANSFER_WIRE_FEE_INCONSISTENT, + "could not subtract wire fee"); return GNUNET_DB_STATUS_HARD_ERROR; } return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; diff --git a/src/exchange/taler-exchange-httpd_wire.c b/src/exchange/taler-exchange-httpd_wire.c index 91c928f94..4e4c34db5 100644 --- a/src/exchange/taler-exchange-httpd_wire.c +++ b/src/exchange/taler-exchange-httpd_wire.c @@ -25,6 +25,7 @@ #include "taler-exchange-httpd_validation.h" #include "taler-exchange-httpd_wire.h" #include "taler_json_lib.h" +#include "taler_mhd_lib.h" #include /** @@ -140,9 +141,9 @@ TEH_WIRE_handler_wire (struct TEH_RequestHandler *rh, (void) upload_data; (void) upload_data_size; GNUNET_assert (NULL != wire_methods); - return TEH_RESPONSE_reply_json (connection, - wire_methods, - MHD_HTTP_OK); + return TALER_MHD_reply_json (connection, + wire_methods, + MHD_HTTP_OK); } -- cgit v1.2.3 From c22efccce8ce864ff8fd84fa968f5c0d44c36d3d Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 23 Nov 2019 21:12:27 +0100 Subject: migrate parsing logic to libtalermhd --- src/exchange/Makefile.am | 1 - src/exchange/taler-exchange-httpd.c | 3 +- src/exchange/taler-exchange-httpd_deposit.c | 17 +- src/exchange/taler-exchange-httpd_parsing.c | 286 --------------------- src/exchange/taler-exchange-httpd_parsing.h | 139 ---------- src/exchange/taler-exchange-httpd_payback.c | 17 +- src/exchange/taler-exchange-httpd_refresh_link.c | 11 +- src/exchange/taler-exchange-httpd_refresh_melt.c | 18 +- src/exchange/taler-exchange-httpd_refresh_reveal.c | 57 ++-- src/exchange/taler-exchange-httpd_refund.c | 17 +- src/exchange/taler-exchange-httpd_reserve_status.c | 12 +- .../taler-exchange-httpd_reserve_withdraw.c | 18 +- src/exchange/taler-exchange-httpd_test.c | 123 +++++---- .../taler-exchange-httpd_track_transaction.c | 18 +- src/exchange/taler-exchange-httpd_track_transfer.c | 12 +- 15 files changed, 158 insertions(+), 591 deletions(-) delete mode 100644 src/exchange/taler-exchange-httpd_parsing.c delete mode 100644 src/exchange/taler-exchange-httpd_parsing.h (limited to 'src/exchange/taler-exchange-httpd_deposit.c') diff --git a/src/exchange/Makefile.am b/src/exchange/Makefile.am index 899e98d2e..8e1621821 100644 --- a/src/exchange/Makefile.am +++ b/src/exchange/Makefile.am @@ -47,7 +47,6 @@ taler_exchange_httpd_SOURCES = \ taler-exchange-httpd_deposit.c taler-exchange-httpd_deposit.h \ taler-exchange-httpd_keystate.c taler-exchange-httpd_keystate.h \ taler-exchange-httpd_mhd.c taler-exchange-httpd_mhd.h \ - taler-exchange-httpd_parsing.c taler-exchange-httpd_parsing.h \ taler-exchange-httpd_payback.c taler-exchange-httpd_payback.h \ taler-exchange-httpd_refresh_link.c taler-exchange-httpd_refresh_link.h \ taler-exchange-httpd_refresh_melt.c taler-exchange-httpd_refresh_melt.h \ diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c index b3f73de60..30efb8bc2 100644 --- a/src/exchange/taler-exchange-httpd.c +++ b/src/exchange/taler-exchange-httpd.c @@ -28,7 +28,6 @@ #include #include #include "taler_mhd_lib.h" -#include "taler-exchange-httpd_parsing.h" #include "taler-exchange-httpd_mhd.h" #include "taler-exchange-httpd_deposit.h" #include "taler-exchange-httpd_refund.h" @@ -175,7 +174,7 @@ handle_mhd_completion_callback (void *cls, "Request completed\n"); if (NULL == ecls) return; - TEH_PARSE_post_cleanup_callback (ecls->opaque_post_parsing_context); + TALER_MHD_parse_post_cleanup_callback (ecls->opaque_post_parsing_context); GNUNET_free (ecls); *con_cls = NULL; /* check that we didn't leave any transactions hanging */ diff --git a/src/exchange/taler-exchange-httpd_deposit.c b/src/exchange/taler-exchange-httpd_deposit.c index 1db8d7621..28116e28b 100644 --- a/src/exchange/taler-exchange-httpd_deposit.c +++ b/src/exchange/taler-exchange-httpd_deposit.c @@ -30,7 +30,6 @@ #include #include "taler_json_lib.h" #include "taler_mhd_lib.h" -#include "taler-exchange-httpd_parsing.h" #include "taler-exchange-httpd_deposit.h" #include "taler-exchange-httpd_responses.h" #include "taler-exchange-httpd_keystate.h" @@ -428,11 +427,11 @@ TEH_DEPOSIT_handler_deposit (struct TEH_RequestHandler *rh, }; (void) rh; - res = TEH_PARSE_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); if (GNUNET_SYSERR == res) return MHD_NO; if ( (GNUNET_NO == res) || @@ -441,9 +440,9 @@ TEH_DEPOSIT_handler_deposit (struct TEH_RequestHandler *rh, memset (&deposit, 0, sizeof (deposit)); - res = TEH_PARSE_json_data (connection, - json, - spec); + res = TALER_MHD_parse_json_data (connection, + json, + spec); json_decref (json); if (GNUNET_SYSERR == res) return MHD_NO; /* hard failure */ diff --git a/src/exchange/taler-exchange-httpd_parsing.c b/src/exchange/taler-exchange-httpd_parsing.c deleted file mode 100644 index fb8932b9a..000000000 --- a/src/exchange/taler-exchange-httpd_parsing.c +++ /dev/null @@ -1,286 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2014, 2015, 2016 GNUnet e.V. - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU Affero General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License along with - TALER; see the file COPYING. If not, see -*/ - -/** - * @file taler-exchange-httpd_parsing.c - * @brief functions to parse incoming requests (MHD arguments and JSON snippets) - * @author Florian Dold - * @author Benedikt Mueller - * @author Christian Grothoff - */ - -#include "platform.h" -#include -#include -#include "taler_json_lib.h" -#include "taler-exchange-httpd_parsing.h" -#include "taler-exchange-httpd_responses.h" - - -/** - * Maximum POST request size. - */ -#define REQUEST_BUFFER_MAX (1024 * 1024) - - -/** - * Process a POST request containing a JSON object. This function - * realizes an MHD POST processor that will (incrementally) process - * JSON data uploaded to the HTTP server. It will store the required - * state in the @a con_cls, which must be cleaned up using - * #TEH_PARSE_post_cleanup_callback(). - * - * @param connection the MHD connection - * @param con_cls the closure (points to a `struct Buffer *`) - * @param upload_data the POST data - * @param upload_data_size number of bytes in @a upload_data - * @param json the JSON object for a completed request - * @return - * #GNUNET_YES if json object was parsed or at least - * may be parsed in the future (call again); - * `*json` will be NULL if we need to be called again, - * and non-NULL if we are done. - * #GNUNET_NO is request incomplete or invalid - * (error message was generated) - * #GNUNET_SYSERR on internal error - * (we could not even queue an error message, - * close HTTP session with MHD_NO) - */ -int -TEH_PARSE_post_json (struct MHD_Connection *connection, - void **con_cls, - const char *upload_data, - size_t *upload_data_size, - json_t **json) -{ - enum GNUNET_JSON_PostResult pr; - - pr = GNUNET_JSON_post_parser (REQUEST_BUFFER_MAX, - connection, - con_cls, - upload_data, - upload_data_size, - json); - switch (pr) - { - - case GNUNET_JSON_PR_OUT_OF_MEMORY: - return (MHD_NO == TEH_RESPONSE_reply_internal_error - (connection, - TALER_EC_PARSER_OUT_OF_MEMORY, - "out of memory")) ? GNUNET_SYSERR : GNUNET_NO; - - case GNUNET_JSON_PR_CONTINUE: - return GNUNET_YES; - - case GNUNET_JSON_PR_REQUEST_TOO_LARGE: - return (MHD_NO == TEH_RESPONSE_reply_request_too_large - (connection)) ? GNUNET_SYSERR : GNUNET_NO; - - case GNUNET_JSON_PR_JSON_INVALID: - return (MHD_YES == - TEH_RESPONSE_reply_invalid_json (connection)) - ? GNUNET_NO : GNUNET_SYSERR; - case GNUNET_JSON_PR_SUCCESS: - GNUNET_break (NULL != *json); - return GNUNET_YES; - } - /* this should never happen */ - GNUNET_break (0); - return GNUNET_SYSERR; -} - - -/** - * Function called whenever we are done with a request - * to clean up our state. - * - * @param con_cls value as it was left by - * #TEH_PARSE_post_json(), to be cleaned up - */ -void -TEH_PARSE_post_cleanup_callback (void *con_cls) -{ - GNUNET_JSON_post_parser_cleanup (con_cls); -} - - -/** - * Extract base32crockford encoded data from request. - * - * Queues an error response to the connection if the parameter is - * missing or invalid. - * - * @param connection the MHD connection - * @param param_name the name of the parameter with the key - * @param[out] out_data pointer to store the result - * @param out_size expected size of data - * @return - * #GNUNET_YES if the the argument is present - * #GNUNET_NO if the argument is absent or malformed - * #GNUNET_SYSERR on internal error (error response could not be sent) - */ -int -TEH_PARSE_mhd_request_arg_data (struct MHD_Connection *connection, - const char *param_name, - void *out_data, - size_t out_size) -{ - const char *str; - - str = MHD_lookup_connection_value (connection, - MHD_GET_ARGUMENT_KIND, - param_name); - if (NULL == str) - { - return (MHD_NO == - TEH_RESPONSE_reply_arg_missing (connection, - TALER_EC_PARAMETER_MISSING, - param_name)) - ? GNUNET_SYSERR : GNUNET_NO; - } - if (GNUNET_OK != - GNUNET_STRINGS_string_to_data (str, - strlen (str), - out_data, - out_size)) - return (MHD_NO == - TEH_RESPONSE_reply_arg_invalid (connection, - TALER_EC_PARAMETER_MALFORMED, - param_name)) - ? GNUNET_SYSERR : GNUNET_NO; - return GNUNET_OK; -} - - -/** - * Parse JSON object into components based on the given field - * specification. Generates error response on parse errors. - * - * @param connection the connection to send an error response to - * @param root the JSON node to start the navigation at. - * @param[in,out] spec field specification for the parser - * @return - * #GNUNET_YES if navigation was successful (caller is responsible - * for freeing allocated variable-size data using - * GNUNET_JSON_parse_free() when done) - * #GNUNET_NO if json is malformed, error response was generated - * #GNUNET_SYSERR on internal error - */ -int -TEH_PARSE_json_data (struct MHD_Connection *connection, - const json_t *root, - struct GNUNET_JSON_Specification *spec) -{ - int ret; - const char *error_json_name; - unsigned int error_line; - - ret = GNUNET_JSON_parse (root, - spec, - &error_json_name, - &error_line); - if (GNUNET_SYSERR == ret) - { - if (NULL == error_json_name) - error_json_name = ""; - ret = (MHD_YES == - TEH_RESPONSE_reply_json_pack (connection, - MHD_HTTP_BAD_REQUEST, - "{s:s, s:I, s:s, s:I}", - "error", "parse error", - "code", - (json_int_t) - TALER_EC_JSON_INVALID_WITH_DETAILS, - "field", error_json_name, - "line", (json_int_t) error_line)) - ? GNUNET_NO : GNUNET_SYSERR; - return ret; - } - return GNUNET_YES; -} - - -/** - * Parse JSON array into components based on the given field - * specification. Generates error response on parse errors. - * - * @param connection the connection to send an error response to - * @param root the JSON node to start the navigation at. - * @param[in,out] spec field specification for the parser - * @param ... -1-terminated list of array offsets of type 'int' - * @return - * #GNUNET_YES if navigation was successful (caller is responsible - * for freeing allocated variable-size data using - * GNUNET_JSON_parse_free() when done) - * #GNUNET_NO if json is malformed, error response was generated - * #GNUNET_SYSERR on internal error - */ -int -TEH_PARSE_json_array (struct MHD_Connection *connection, - const json_t *root, - struct GNUNET_JSON_Specification *spec, - ...) -{ - int ret; - const char *error_json_name; - unsigned int error_line; - va_list ap; - json_int_t dim; - - va_start (ap, spec); - dim = 0; - while ( (-1 != (ret = va_arg (ap, int))) && - (NULL != root) ) - { - dim++; - root = json_array_get (root, ret); - } - va_end (ap); - if (NULL == root) - { - ret = (MHD_YES == - TEH_RESPONSE_reply_json_pack (connection, - MHD_HTTP_BAD_REQUEST, - "{s:s, s:I}", - "error", "parse error", - "dimension", dim)) - ? GNUNET_NO : GNUNET_SYSERR; - return ret; - } - ret = GNUNET_JSON_parse (root, - spec, - &error_json_name, - &error_line); - if (GNUNET_SYSERR == ret) - { - if (NULL == error_json_name) - error_json_name = ""; - ret = (MHD_YES == - TEH_RESPONSE_reply_json_pack (connection, - MHD_HTTP_BAD_REQUEST, - "{s:s, s:s, s:I}", - "error", "parse error", - "field", error_json_name, - "line", (json_int_t) error_line)) - ? GNUNET_NO : GNUNET_SYSERR; - return ret; - } - return GNUNET_YES; -} - - -/* end of taler-exchange-httpd_parsing.c */ diff --git a/src/exchange/taler-exchange-httpd_parsing.h b/src/exchange/taler-exchange-httpd_parsing.h deleted file mode 100644 index 9c5381756..000000000 --- a/src/exchange/taler-exchange-httpd_parsing.h +++ /dev/null @@ -1,139 +0,0 @@ -/* - This file is part of TALER - Copyright (C) 2014, 2015, 2016 GNUnet e.V. - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU Affero General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License along with - TALER; see the file COPYING. If not, see -*/ -/** - * @file taler-exchange-httpd_parsing.h - * @brief functions to parse incoming requests - * @author Florian Dold - * @author Benedikt Mueller - * @author Christian Grothoff - */ -#ifndef TALER_EXCHANGE_HTTPD_PARSING_H -#define TALER_EXCHANGE_HTTPD_PARSING_H - -#include -#include -#include "taler_util.h" -#include "taler_json_lib.h" - - -/** - * Process a POST request containing a JSON object. This - * function realizes an MHD POST processor that will - * (incrementally) process JSON data uploaded to the HTTP - * server. It will store the required state in the - * "connection_cls", which must be cleaned up using - * #TEH_PARSE_post_cleanup_callback(). - * - * @param connection the MHD connection - * @param con_cls the closure (points to a `struct Buffer *`) - * @param upload_data the POST data - * @param upload_data_size number of bytes in @a upload_data - * @param json the JSON object for a completed request - * @return - * #GNUNET_YES if json object was parsed or at least - * may be parsed in the future (call again); - * `*json` will be NULL if we need to be called again, - * and non-NULL if we are done. - * #GNUNET_NO is request incomplete or invalid - * (error message was generated) - * #GNUNET_SYSERR on internal error - * (we could not even queue an error message, - * close HTTP session with MHD_NO) - */ -int -TEH_PARSE_post_json (struct MHD_Connection *connection, - void **con_cls, - const char *upload_data, - size_t *upload_data_size, - json_t **json); - - -/** - * Function called whenever we are done with a request - * to clean up our state. - * - * @param con_cls value as it was left by - * #TEH_PARSE_post_json(), to be cleaned up - */ -void -TEH_PARSE_post_cleanup_callback (void *con_cls); - - -/** - * Parse JSON object into components based on the given field - * specification. - * - * @param connection the connection to send an error response to - * @param root the JSON node to start the navigation at. - * @param spec field specification for the parser - * @return - * #GNUNET_YES if navigation was successful (caller is responsible - * for freeing allocated variable-size data using - * GNUNET_JSON_parse_free() when done) - * #GNUNET_NO if json is malformed, error response was generated - * #GNUNET_SYSERR on internal error - */ -int -TEH_PARSE_json_data (struct MHD_Connection *connection, - const json_t *root, - struct GNUNET_JSON_Specification *spec); - - -/** - * Parse JSON array into components based on the given field - * specification. Generates error response on parse errors. - * - * @param connection the connection to send an error response to - * @param root the JSON node to start the navigation at. - * @param[in,out] spec field specification for the parser - * @param ... -1-terminated list of array offsets of type 'int' - * @return - * #GNUNET_YES if navigation was successful (caller is responsible - * for freeing allocated variable-size data using - * GNUNET_JSON_parse_free() when done) - * #GNUNET_NO if json is malformed, error response was generated - * #GNUNET_SYSERR on internal error - */ -int -TEH_PARSE_json_array (struct MHD_Connection *connection, - const json_t *root, - struct GNUNET_JSON_Specification *spec, - ...); - - -/** - * Extraxt fixed-size base32crockford encoded data from request. - * - * Queues an error response to the connection if the parameter is missing or - * invalid. - * - * @param connection the MHD connection - * @param param_name the name of the parameter with the key - * @param[out] out_data pointer to store the result - * @param out_size expected size of @a out_data - * @return - * #GNUNET_YES if the the argument is present - * #GNUNET_NO if the argument is absent or malformed - * #GNUNET_SYSERR on internal error (error response could not be sent) - */ -int -TEH_PARSE_mhd_request_arg_data (struct MHD_Connection *connection, - const char *param_name, - void *out_data, - size_t out_size); - - -#endif /* TALER_EXCHANGE_HTTPD_PARSING_H */ diff --git a/src/exchange/taler-exchange-httpd_payback.c b/src/exchange/taler-exchange-httpd_payback.c index e8a179f1b..f5f315bed 100644 --- a/src/exchange/taler-exchange-httpd_payback.c +++ b/src/exchange/taler-exchange-httpd_payback.c @@ -28,7 +28,6 @@ #include #include "taler_json_lib.h" #include "taler_mhd_lib.h" -#include "taler-exchange-httpd_parsing.h" #include "taler-exchange-httpd_payback.h" #include "taler-exchange-httpd_responses.h" #include "taler-exchange-httpd_keystate.h" @@ -605,18 +604,18 @@ TEH_PAYBACK_handler_payback (struct TEH_RequestHandler *rh, }; (void) rh; - res = TEH_PARSE_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); if (GNUNET_SYSERR == res) return MHD_NO; if ( (GNUNET_NO == res) || (NULL == json) ) return MHD_YES; - res = TEH_PARSE_json_data (connection, - json, - spec); + res = TALER_MHD_parse_json_data (connection, + json, + spec); json_decref (json); if (GNUNET_SYSERR == res) return MHD_NO; /* hard failure */ diff --git a/src/exchange/taler-exchange-httpd_refresh_link.c b/src/exchange/taler-exchange-httpd_refresh_link.c index 10aed2df8..c3d36e29b 100644 --- a/src/exchange/taler-exchange-httpd_refresh_link.c +++ b/src/exchange/taler-exchange-httpd_refresh_link.c @@ -25,7 +25,6 @@ #include #include #include "taler_mhd_lib.h" -#include "taler-exchange-httpd_parsing.h" #include "taler-exchange-httpd_mhd.h" #include "taler-exchange-httpd_refresh_link.h" #include "taler-exchange-httpd_responses.h" @@ -204,11 +203,11 @@ TEH_REFRESH_handler_refresh_link (struct TEH_RequestHandler *rh, memset (&ctx, 0, sizeof (ctx)); - res = TEH_PARSE_mhd_request_arg_data (connection, - "coin_pub", - &ctx.coin_pub, - sizeof (struct - TALER_CoinSpendPublicKeyP)); + res = TALER_MHD_parse_request_arg_data (connection, + "coin_pub", + &ctx.coin_pub, + sizeof (struct + TALER_CoinSpendPublicKeyP)); if (GNUNET_SYSERR == res) return MHD_NO; if (GNUNET_OK != res) diff --git a/src/exchange/taler-exchange-httpd_refresh_melt.c b/src/exchange/taler-exchange-httpd_refresh_melt.c index 2de5027f1..20e788452 100644 --- a/src/exchange/taler-exchange-httpd_refresh_melt.c +++ b/src/exchange/taler-exchange-httpd_refresh_melt.c @@ -24,8 +24,8 @@ #include #include #include +#include "taler_json_lib.h" #include "taler_mhd_lib.h" -#include "taler-exchange-httpd_parsing.h" #include "taler-exchange-httpd_mhd.h" #include "taler-exchange-httpd_refresh_melt.h" #include "taler-exchange-httpd_responses.h" @@ -482,11 +482,11 @@ TEH_REFRESH_handler_refresh_melt (struct TEH_RequestHandler *rh, }; (void) rh; - res = TEH_PARSE_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &root); + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &root); if (GNUNET_SYSERR == res) return MHD_NO; if ( (GNUNET_NO == res) || @@ -496,9 +496,9 @@ TEH_REFRESH_handler_refresh_melt (struct TEH_RequestHandler *rh, memset (&rmc, 0, sizeof (rmc)); - res = TEH_PARSE_json_data (connection, - root, - spec); + res = TALER_MHD_parse_json_data (connection, + root, + spec); json_decref (root); if (GNUNET_OK != res) return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; diff --git a/src/exchange/taler-exchange-httpd_refresh_reveal.c b/src/exchange/taler-exchange-httpd_refresh_reveal.c index a1200f39e..5276a105a 100644 --- a/src/exchange/taler-exchange-httpd_refresh_reveal.c +++ b/src/exchange/taler-exchange-httpd_refresh_reveal.c @@ -25,7 +25,6 @@ #include #include #include "taler_mhd_lib.h" -#include "taler-exchange-httpd_parsing.h" #include "taler-exchange-httpd_mhd.h" #include "taler-exchange-httpd_refresh_reveal.h" #include "taler-exchange-httpd_responses.h" @@ -586,11 +585,11 @@ handle_refresh_reveal_json (struct MHD_Connection *connection, }; int res; - res = TEH_PARSE_json_array (connection, - tp_json, - trans_spec, - i, - -1); + res = TALER_MHD_parse_json_array (connection, + tp_json, + trans_spec, + i, + -1); if (GNUNET_OK != res) return (GNUNET_NO == res) ? MHD_YES : MHD_NO; } @@ -627,11 +626,11 @@ handle_refresh_reveal_json (struct MHD_Connection *connection, unsigned int hc; enum TALER_ErrorCode ec; - res = TEH_PARSE_json_array (connection, - new_denoms_h_json, - spec, - i, - -1); + res = TALER_MHD_parse_json_array (connection, + new_denoms_h_json, + spec, + i, + -1); if (GNUNET_OK != res) { TEH_KS_release (key_state); @@ -664,11 +663,11 @@ handle_refresh_reveal_json (struct MHD_Connection *connection, GNUNET_JSON_spec_end () }; - res = TEH_PARSE_json_array (connection, - coin_evs, - spec, - i, - -1); + res = TALER_MHD_parse_json_array (connection, + coin_evs, + spec, + i, + -1); if (GNUNET_OK != res) { for (unsigned int j = 0; j #include "taler_json_lib.h" #include "taler_mhd_lib.h" -#include "taler-exchange-httpd_parsing.h" #include "taler-exchange-httpd_refund.h" #include "taler-exchange-httpd_responses.h" #include "taler-exchange-httpd_keystate.h" @@ -526,18 +525,18 @@ TEH_REFUND_handler_refund (struct TEH_RequestHandler *rh, }; (void) rh; - res = TEH_PARSE_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); if (GNUNET_SYSERR == res) return MHD_NO; if ( (GNUNET_NO == res) || (NULL == json) ) return MHD_YES; - res = TEH_PARSE_json_data (connection, - json, - spec); + res = TALER_MHD_parse_json_data (connection, + json, + spec); json_decref (json); if (GNUNET_SYSERR == res) return MHD_NO; /* hard failure */ diff --git a/src/exchange/taler-exchange-httpd_reserve_status.c b/src/exchange/taler-exchange-httpd_reserve_status.c index 0e46c0b24..60cdd4f5a 100644 --- a/src/exchange/taler-exchange-httpd_reserve_status.c +++ b/src/exchange/taler-exchange-httpd_reserve_status.c @@ -24,8 +24,8 @@ #include #include #include "taler_mhd_lib.h" +#include "taler_json_lib.h" #include "taler-exchange-httpd_reserve_status.h" -#include "taler-exchange-httpd_parsing.h" #include "taler-exchange-httpd_responses.h" #include "taler-exchange-httpd_keystate.h" @@ -137,11 +137,11 @@ TEH_RESERVE_handler_reserve_status (struct TEH_RequestHandler *rh, int res; int mhd_ret; - res = TEH_PARSE_mhd_request_arg_data (connection, - "reserve_pub", - &rsc.reserve_pub, - sizeof (struct - TALER_ReservePublicKeyP)); + res = TALER_MHD_parse_request_arg_data (connection, + "reserve_pub", + &rsc.reserve_pub, + sizeof (struct + TALER_ReservePublicKeyP)); if (GNUNET_SYSERR == res) return MHD_NO; /* internal error */ if (GNUNET_NO == res) diff --git a/src/exchange/taler-exchange-httpd_reserve_withdraw.c b/src/exchange/taler-exchange-httpd_reserve_withdraw.c index 229da564a..120a1e86a 100644 --- a/src/exchange/taler-exchange-httpd_reserve_withdraw.c +++ b/src/exchange/taler-exchange-httpd_reserve_withdraw.c @@ -26,9 +26,9 @@ #include "platform.h" #include #include +#include "taler_json_lib.h" #include "taler_mhd_lib.h" #include "taler-exchange-httpd_reserve_withdraw.h" -#include "taler-exchange-httpd_parsing.h" #include "taler-exchange-httpd_responses.h" #include "taler-exchange-httpd_keystate.h" @@ -394,18 +394,18 @@ TEH_RESERVE_handler_reserve_withdraw (struct TEH_RequestHandler *rh, }; (void) rh; - res = TEH_PARSE_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &root); + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &root); if (GNUNET_SYSERR == res) return MHD_NO; if ( (GNUNET_NO == res) || (NULL == root) ) return MHD_YES; - res = TEH_PARSE_json_data (connection, - root, - spec); + res = TALER_MHD_parse_json_data (connection, + root, + spec); json_decref (root); if (GNUNET_OK != res) return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; diff --git a/src/exchange/taler-exchange-httpd_test.c b/src/exchange/taler-exchange-httpd_test.c index 4d0e7d691..4b3c50b2c 100644 --- a/src/exchange/taler-exchange-httpd_test.c +++ b/src/exchange/taler-exchange-httpd_test.c @@ -27,7 +27,6 @@ #include "taler_mhd_lib.h" #include "taler_signatures.h" #include "taler-exchange-httpd_test.h" -#include "taler-exchange-httpd_parsing.h" #include "taler-exchange-httpd_responses.h" @@ -70,18 +69,18 @@ TEH_TEST_handler_test_base32 (struct TEH_RequestHandler *rh, }; (void) rh; - res = TEH_PARSE_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); if (GNUNET_SYSERR == res) return MHD_NO; if ( (GNUNET_NO == res) || (NULL == json) ) return MHD_YES; - res = TEH_PARSE_json_data (connection, - json, - spec); + res = TALER_MHD_parse_json_data (connection, + json, + spec); if (GNUNET_YES != res) return (GNUNET_NO == res) ? MHD_YES : MHD_NO; GNUNET_CRYPTO_hash (in_ptr, @@ -135,18 +134,18 @@ TEH_TEST_handler_test_encrypt (struct TEH_RequestHandler *rh, }; char *out; - res = TEH_PARSE_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); if (GNUNET_SYSERR == res) return MHD_NO; if ( (GNUNET_NO == res) || (NULL == json) ) return MHD_YES; - res = TEH_PARSE_json_data (connection, - json, - spec); + res = TALER_MHD_parse_json_data (connection, + json, + spec); json_decref (json); if (GNUNET_YES != res) return (GNUNET_NO == res) ? MHD_YES : MHD_NO; @@ -215,18 +214,18 @@ TEH_TEST_handler_test_hkdf (struct TEH_RequestHandler *rh, GNUNET_JSON_spec_end () }; - res = TEH_PARSE_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); if (GNUNET_SYSERR == res) return MHD_NO; if ( (GNUNET_NO == res) || (NULL == json) ) return MHD_YES; - res = TEH_PARSE_json_data (connection, - json, - spec); + res = TALER_MHD_parse_json_data (connection, + json, + spec); json_decref (json); if (GNUNET_YES != res) return (GNUNET_NO == res) ? MHD_YES : MHD_NO; @@ -278,18 +277,18 @@ TEH_TEST_handler_test_ecdhe (struct TEH_RequestHandler *rh, GNUNET_JSON_spec_end () }; - res = TEH_PARSE_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); if (GNUNET_SYSERR == res) return MHD_NO; if ( (GNUNET_NO == res) || (NULL == json) ) return MHD_YES; - res = TEH_PARSE_json_data (connection, - json, - spec); + res = TALER_MHD_parse_json_data (connection, + json, + spec); json_decref (json); if (GNUNET_YES != res) return (GNUNET_NO == res) ? MHD_YES : MHD_NO; @@ -347,18 +346,18 @@ TEH_TEST_handler_test_eddsa (struct TEH_RequestHandler *rh, }; struct GNUNET_CRYPTO_EddsaPrivateKey *pk; - res = TEH_PARSE_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); if (GNUNET_SYSERR == res) return MHD_NO; if ( (GNUNET_NO == res) || (NULL == json) ) return MHD_YES; - res = TEH_PARSE_json_data (connection, - json, - spec); + res = TALER_MHD_parse_json_data (connection, + json, + spec); json_decref (json); if (GNUNET_YES != res) return (GNUNET_NO == res) ? MHD_YES : MHD_NO; @@ -482,18 +481,18 @@ TEH_TEST_handler_test_rsa_sign (struct TEH_RequestHandler *rh, GNUNET_JSON_spec_end () }; - res = TEH_PARSE_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); if (GNUNET_SYSERR == res) return MHD_NO; if ( (GNUNET_NO == res) || (NULL == json) ) return MHD_YES; - res = TEH_PARSE_json_data (connection, - json, - spec); + res = TALER_MHD_parse_json_data (connection, + json, + spec); json_decref (json); if (GNUNET_YES != res) return (GNUNET_NO == res) ? MHD_YES : MHD_NO; @@ -563,18 +562,18 @@ TEH_TEST_handler_test_transfer (struct TEH_RequestHandler *rh, }; struct TALER_TransferSecretP secret; - res = TEH_PARSE_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); if (GNUNET_SYSERR == res) return MHD_NO; if ( (GNUNET_NO == res) || (NULL == json) ) return MHD_YES; - res = TEH_PARSE_json_data (connection, - json, - spec); + res = TALER_MHD_parse_json_data (connection, + json, + spec); json_decref (json); if (GNUNET_YES != res) return (GNUNET_NO == res) ? MHD_YES : MHD_NO; @@ -609,11 +608,11 @@ TEH_TEST_handler_test (struct TEH_RequestHandler *rh, json_t *json; int res; - res = TEH_PARSE_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); if (GNUNET_SYSERR == res) return MHD_NO; if ( (GNUNET_NO == res) || (NULL == json) ) diff --git a/src/exchange/taler-exchange-httpd_track_transaction.c b/src/exchange/taler-exchange-httpd_track_transaction.c index 5a057d665..757f28bad 100644 --- a/src/exchange/taler-exchange-httpd_track_transaction.c +++ b/src/exchange/taler-exchange-httpd_track_transaction.c @@ -23,9 +23,9 @@ #include #include #include +#include "taler_json_lib.h" #include "taler_mhd_lib.h" #include "taler_signatures.h" -#include "taler-exchange-httpd_parsing.h" #include "taler-exchange-httpd_keystate.h" #include "taler-exchange-httpd_track_transaction.h" #include "taler-exchange-httpd_responses.h" @@ -366,18 +366,18 @@ TEH_TRACKING_handler_track_transaction (struct TEH_RequestHandler *rh, }; (void) rh; - res = TEH_PARSE_post_json (connection, - connection_cls, - upload_data, - upload_data_size, - &json); + res = TALER_MHD_parse_post_json (connection, + connection_cls, + upload_data, + upload_data_size, + &json); if (GNUNET_SYSERR == res) return MHD_NO; if ( (GNUNET_NO == res) || (NULL == json) ) return MHD_YES; - res = TEH_PARSE_json_data (connection, - json, - spec); + res = TALER_MHD_parse_json_data (connection, + json, + spec); if (GNUNET_OK != res) { json_decref (json); diff --git a/src/exchange/taler-exchange-httpd_track_transfer.c b/src/exchange/taler-exchange-httpd_track_transfer.c index 83521f736..f40d7c819 100644 --- a/src/exchange/taler-exchange-httpd_track_transfer.c +++ b/src/exchange/taler-exchange-httpd_track_transfer.c @@ -24,10 +24,10 @@ #include #include #include "taler_signatures.h" -#include "taler-exchange-httpd_parsing.h" #include "taler-exchange-httpd_keystate.h" #include "taler-exchange-httpd_track_transfer.h" #include "taler-exchange-httpd_responses.h" +#include "taler_json_lib.h" #include "taler_mhd_lib.h" #include "taler_wire_lib.h" @@ -503,11 +503,11 @@ TEH_TRACKING_handler_track_transfer (struct TEH_RequestHandler *rh, int mhd_ret; memset (&ctx, 0, sizeof (ctx)); - res = TEH_PARSE_mhd_request_arg_data (connection, - "wtid", - &ctx.wtid, - sizeof (struct - TALER_WireTransferIdentifierRawP)); + res = TALER_MHD_parse_request_arg_data (connection, + "wtid", + &ctx.wtid, + sizeof (struct + TALER_WireTransferIdentifierRawP)); if (GNUNET_SYSERR == res) return MHD_NO; /* internal error */ if (GNUNET_NO == res) -- cgit v1.2.3 From 4c42e7924e8705ab94c6dd2eab3ec8742fa9acc5 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 23 Nov 2019 21:38:09 +0100 Subject: fix --- src/exchange/taler-exchange-httpd_deposit.c | 4 ++-- src/exchange/taler-exchange-httpd_payback.c | 2 +- src/exchange/taler-exchange-httpd_refresh_melt.c | 2 +- src/exchange/taler-exchange-httpd_refresh_reveal.c | 2 +- src/exchange/taler-exchange-httpd_refund.c | 2 +- src/exchange/taler-exchange-httpd_reserve_withdraw.c | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/exchange/taler-exchange-httpd_deposit.c') diff --git a/src/exchange/taler-exchange-httpd_deposit.c b/src/exchange/taler-exchange-httpd_deposit.c index 28116e28b..23a97fb1b 100644 --- a/src/exchange/taler-exchange-httpd_deposit.c +++ b/src/exchange/taler-exchange-httpd_deposit.c @@ -304,8 +304,8 @@ verify_and_execute_deposit (struct MHD_Connection *connection, { TEH_KS_release (mks); return TALER_MHD_reply_with_error (connection, - ec, hc, + ec, "Could not find denomination key used in deposit"); } TALER_amount_ntoh (&dc.value, @@ -527,8 +527,8 @@ TEH_DEPOSIT_handler_deposit (struct TEH_RequestHandler *rh, TALER_LOG_WARNING ("Unknown denomination key in /deposit request\n"); GNUNET_JSON_parse_free (spec); return TALER_MHD_reply_with_error (connection, - ec, hc, + ec, "Could not find denomination key used in deposit"); } TALER_amount_ntoh (&deposit.deposit_fee, diff --git a/src/exchange/taler-exchange-httpd_payback.c b/src/exchange/taler-exchange-httpd_payback.c index f5f315bed..b7fe593d9 100644 --- a/src/exchange/taler-exchange-httpd_payback.c +++ b/src/exchange/taler-exchange-httpd_payback.c @@ -449,8 +449,8 @@ verify_and_execute_payback (struct MHD_Connection *connection, TALER_LOG_WARNING ( "Denomination key in /payback request not in payback mode\n"); return TALER_MHD_reply_with_error (connection, - ec, hc, + ec, "denomination not allowing payback"); } TALER_amount_ntoh (&pc.value, diff --git a/src/exchange/taler-exchange-httpd_refresh_melt.c b/src/exchange/taler-exchange-httpd_refresh_melt.c index 20e788452..71f1a6142 100644 --- a/src/exchange/taler-exchange-httpd_refresh_melt.c +++ b/src/exchange/taler-exchange-httpd_refresh_melt.c @@ -585,8 +585,8 @@ TEH_REFRESH_handler_refresh_melt (struct TEH_RequestHandler *rh, { TALER_LOG_WARNING ("Unknown denomination key in /refresh/melt request\n"); res = TALER_MHD_reply_with_error (connection, - ec, hc, + ec, "unknown denomination"); goto cleanup; } diff --git a/src/exchange/taler-exchange-httpd_refresh_reveal.c b/src/exchange/taler-exchange-httpd_refresh_reveal.c index 5276a105a..97e687ea9 100644 --- a/src/exchange/taler-exchange-httpd_refresh_reveal.c +++ b/src/exchange/taler-exchange-httpd_refresh_reveal.c @@ -645,8 +645,8 @@ handle_refresh_reveal_json (struct MHD_Connection *connection, { TEH_KS_release (key_state); return TALER_MHD_reply_with_error (connection, - ec, hc, + ec, "failed to find denomination key"); } GNUNET_assert (NULL != dkis[i]->denom_priv.rsa_private_key); diff --git a/src/exchange/taler-exchange-httpd_refund.c b/src/exchange/taler-exchange-httpd_refund.c index 5b0d4ca58..6a96ff982 100644 --- a/src/exchange/taler-exchange-httpd_refund.c +++ b/src/exchange/taler-exchange-httpd_refund.c @@ -372,8 +372,8 @@ refund_transaction (void *cls, TEH_plugin->free_coin_transaction_list (TEH_plugin->cls, tl); *mhd_ret = TALER_MHD_reply_with_error (connection, - ec, hc, + ec, "denomination not found, but coin known"); return GNUNET_DB_STATUS_HARD_ERROR; } diff --git a/src/exchange/taler-exchange-httpd_reserve_withdraw.c b/src/exchange/taler-exchange-httpd_reserve_withdraw.c index 120a1e86a..2b4d2b93d 100644 --- a/src/exchange/taler-exchange-httpd_reserve_withdraw.c +++ b/src/exchange/taler-exchange-httpd_reserve_withdraw.c @@ -429,8 +429,8 @@ TEH_RESERVE_handler_reserve_withdraw (struct TEH_RequestHandler *rh, GNUNET_JSON_parse_free (spec); TEH_KS_release (wc.key_state); return TALER_MHD_reply_with_error (connection, - ec, hc, + ec, "could not find denomination key"); } GNUNET_assert (NULL != wc.dki->denom_priv.rsa_private_key); -- cgit v1.2.3