more refactoring for libtalermhd
This commit is contained in:
parent
7c11a822ba
commit
cf6ba0c771
@ -291,9 +291,10 @@ verify_and_execute_deposit (struct MHD_Connection *connection,
|
|||||||
if (NULL == mks)
|
if (NULL == mks)
|
||||||
{
|
{
|
||||||
TALER_LOG_ERROR ("Lacking keys to operate\n");
|
TALER_LOG_ERROR ("Lacking keys to operate\n");
|
||||||
return TEH_RESPONSE_reply_internal_error (connection,
|
return TALER_MHD_reply_with_error (connection,
|
||||||
TALER_EC_EXCHANGE_BAD_CONFIGURATION,
|
MHD_HTTP_INTERNAL_SERVER_ERROR,
|
||||||
"no keys");
|
TALER_EC_EXCHANGE_BAD_CONFIGURATION,
|
||||||
|
"no keys");
|
||||||
}
|
}
|
||||||
dki = TEH_KS_denomination_key_lookup_by_hash (mks,
|
dki = TEH_KS_denomination_key_lookup_by_hash (mks,
|
||||||
&deposit->coin.denom_pub_hash,
|
&deposit->coin.denom_pub_hash,
|
||||||
@ -465,9 +466,10 @@ TEH_DEPOSIT_handler_deposit (struct TEH_RequestHandler *rh,
|
|||||||
&emsg)))
|
&emsg)))
|
||||||
{
|
{
|
||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
res = TEH_RESPONSE_reply_external_error (connection,
|
res = TALER_MHD_reply_with_error (connection,
|
||||||
ec,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
emsg);
|
ec,
|
||||||
|
emsg);
|
||||||
GNUNET_free (emsg);
|
GNUNET_free (emsg);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <gnunet/gnunet_util_lib.h>
|
#include <gnunet/gnunet_util_lib.h>
|
||||||
#include <microhttpd.h>
|
#include <microhttpd.h>
|
||||||
#include "taler-exchange-httpd.h"
|
#include "taler-exchange-httpd.h"
|
||||||
|
#include "taler_error_codes.h"
|
||||||
#include "taler_exchangedb_lib.h"
|
#include "taler_exchangedb_lib.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ TEH_MHD_handler_static_response (struct TEH_RequestHandler *rh,
|
|||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return MHD_NO;
|
return MHD_NO;
|
||||||
}
|
}
|
||||||
TEH_RESPONSE_add_global_headers (response);
|
TALER_MHD_add_global_headers (response);
|
||||||
if (NULL != rh->mime_type)
|
if (NULL != rh->mime_type)
|
||||||
(void) MHD_add_response_header (response,
|
(void) MHD_add_response_header (response,
|
||||||
MHD_HTTP_HEADER_CONTENT_TYPE,
|
MHD_HTTP_HEADER_CONTENT_TYPE,
|
||||||
@ -128,11 +128,11 @@ TEH_MHD_handler_send_json_pack_error (struct TEH_RequestHandler *rh,
|
|||||||
(void) connection_cls;
|
(void) connection_cls;
|
||||||
(void) upload_data;
|
(void) upload_data;
|
||||||
(void) upload_data_size;
|
(void) upload_data_size;
|
||||||
return TEH_RESPONSE_reply_json_pack (connection,
|
return TALER_MHD_reply_json_pack (connection,
|
||||||
rh->response_code,
|
rh->response_code,
|
||||||
"{s:s}",
|
"{s:s}",
|
||||||
"error",
|
"error",
|
||||||
rh->data);
|
rh->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <gnunet/gnunet_json_lib.h>
|
#include <gnunet/gnunet_json_lib.h>
|
||||||
#include <jansson.h>
|
#include <jansson.h>
|
||||||
#include <microhttpd.h>
|
#include <microhttpd.h>
|
||||||
|
#include "taler_mhd_lib.h"
|
||||||
#include "taler_signatures.h"
|
#include "taler_signatures.h"
|
||||||
#include "taler-exchange-httpd_test.h"
|
#include "taler-exchange-httpd_test.h"
|
||||||
#include "taler-exchange-httpd_parsing.h"
|
#include "taler-exchange-httpd_parsing.h"
|
||||||
@ -88,11 +89,11 @@ TEH_TEST_handler_test_base32 (struct TEH_RequestHandler *rh,
|
|||||||
&hc);
|
&hc);
|
||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
json_decref (json);
|
json_decref (json);
|
||||||
return TEH_RESPONSE_reply_json_pack (connection,
|
return TALER_MHD_reply_json_pack (connection,
|
||||||
MHD_HTTP_OK,
|
MHD_HTTP_OK,
|
||||||
"{s:o}",
|
"{s:o}",
|
||||||
"output",
|
"output",
|
||||||
GNUNET_JSON_from_data_auto (&hc));
|
GNUNET_JSON_from_data_auto (&hc));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -172,11 +173,11 @@ TEH_TEST_handler_test_encrypt (struct TEH_RequestHandler *rh,
|
|||||||
in_ptr_size);
|
in_ptr_size);
|
||||||
GNUNET_free (out);
|
GNUNET_free (out);
|
||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
return TEH_RESPONSE_reply_json_pack (connection,
|
return TALER_MHD_reply_json_pack (connection,
|
||||||
MHD_HTTP_OK,
|
MHD_HTTP_OK,
|
||||||
"{s:o}",
|
"{s:o}",
|
||||||
"output",
|
"output",
|
||||||
json);
|
json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -237,11 +238,11 @@ TEH_TEST_handler_test_hkdf (struct TEH_RequestHandler *rh,
|
|||||||
NULL, 0));
|
NULL, 0));
|
||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
json = GNUNET_JSON_from_data_auto (&hc);
|
json = GNUNET_JSON_from_data_auto (&hc);
|
||||||
return TEH_RESPONSE_reply_json_pack (connection,
|
return TALER_MHD_reply_json_pack (connection,
|
||||||
MHD_HTTP_OK,
|
MHD_HTTP_OK,
|
||||||
"{s:o}",
|
"{s:o}",
|
||||||
"output",
|
"output",
|
||||||
json);
|
json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -298,16 +299,17 @@ TEH_TEST_handler_test_ecdhe (struct TEH_RequestHandler *rh,
|
|||||||
&hc))
|
&hc))
|
||||||
{
|
{
|
||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
return TEH_RESPONSE_reply_internal_error (connection,
|
return TALER_MHD_reply_with_error (connection,
|
||||||
TALER_EC_TEST_ECDH_ERROR,
|
MHD_HTTP_INTERNAL_SERVER_ERROR,
|
||||||
"Failed to perform ECDH");
|
TALER_EC_TEST_ECDH_ERROR,
|
||||||
|
"Failed to perform ECDH");
|
||||||
}
|
}
|
||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
return TEH_RESPONSE_reply_json_pack (connection,
|
return TALER_MHD_reply_json_pack (connection,
|
||||||
MHD_HTTP_OK,
|
MHD_HTTP_OK,
|
||||||
"{s:o}",
|
"{s:o}",
|
||||||
"ecdh_hash",
|
"ecdh_hash",
|
||||||
GNUNET_JSON_from_data_auto (&hc));
|
GNUNET_JSON_from_data_auto (&hc));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -369,9 +371,10 @@ TEH_TEST_handler_test_eddsa (struct TEH_RequestHandler *rh,
|
|||||||
&pub))
|
&pub))
|
||||||
{
|
{
|
||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
return TEH_RESPONSE_reply_signature_invalid (connection,
|
return TALER_MHD_reply_with_error (connection,
|
||||||
TALER_EC_TEST_EDDSA_INVALID,
|
MHD_HTTP_FORBIDDEN,
|
||||||
"eddsa_sig");
|
TALER_EC_TEST_EDDSA_INVALID,
|
||||||
|
"eddsa_sig");
|
||||||
}
|
}
|
||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
pk = GNUNET_CRYPTO_eddsa_key_create ();
|
pk = GNUNET_CRYPTO_eddsa_key_create ();
|
||||||
@ -382,20 +385,21 @@ TEH_TEST_handler_test_eddsa (struct TEH_RequestHandler *rh,
|
|||||||
&sig))
|
&sig))
|
||||||
{
|
{
|
||||||
GNUNET_free (pk);
|
GNUNET_free (pk);
|
||||||
return TEH_RESPONSE_reply_internal_error (connection,
|
return TALER_MHD_reply_with_error (connection,
|
||||||
TALER_EC_TEST_EDDSA_ERROR,
|
MHD_HTTP_INTERNAL_SERVER_ERROR,
|
||||||
"Failed to EdDSA-sign");
|
TALER_EC_TEST_EDDSA_ERROR,
|
||||||
|
"Failed to EdDSA-sign");
|
||||||
}
|
}
|
||||||
GNUNET_CRYPTO_eddsa_key_get_public (pk,
|
GNUNET_CRYPTO_eddsa_key_get_public (pk,
|
||||||
&pub);
|
&pub);
|
||||||
GNUNET_free (pk);
|
GNUNET_free (pk);
|
||||||
return TEH_RESPONSE_reply_json_pack (connection,
|
return TALER_MHD_reply_json_pack (connection,
|
||||||
MHD_HTTP_OK,
|
MHD_HTTP_OK,
|
||||||
"{s:o, s:o}",
|
"{s:o, s:o}",
|
||||||
"eddsa_pub",
|
"eddsa_pub",
|
||||||
GNUNET_JSON_from_data_auto (&pub),
|
GNUNET_JSON_from_data_auto (&pub),
|
||||||
"eddsa_sig",
|
"eddsa_sig",
|
||||||
GNUNET_JSON_from_data_auto (&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)
|
if (NULL == rsa_pk)
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return TEH_RESPONSE_reply_internal_error (connection,
|
return TALER_MHD_reply_with_error (connection,
|
||||||
TALER_EC_TEST_RSA_GEN_ERROR,
|
MHD_HTTP_INTERNAL_SERVER_ERROR,
|
||||||
"Failed to create RSA key");
|
TALER_EC_TEST_RSA_GEN_ERROR,
|
||||||
|
"Failed to create RSA key");
|
||||||
}
|
}
|
||||||
pub = GNUNET_CRYPTO_rsa_private_key_get_public (rsa_pk);
|
pub = GNUNET_CRYPTO_rsa_private_key_get_public (rsa_pk);
|
||||||
if (NULL == pub)
|
if (NULL == pub)
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return TEH_RESPONSE_reply_internal_error (connection,
|
return TALER_MHD_reply_with_error (connection,
|
||||||
TALER_EC_TEST_RSA_PUB_ERROR,
|
MHD_HTTP_INTERNAL_SERVER_ERROR,
|
||||||
"Failed to get public RSA key");
|
TALER_EC_TEST_RSA_PUB_ERROR,
|
||||||
|
"Failed to get public RSA key");
|
||||||
}
|
}
|
||||||
res = TEH_RESPONSE_reply_json_pack (connection,
|
res = TALER_MHD_reply_json_pack (connection,
|
||||||
MHD_HTTP_OK,
|
MHD_HTTP_OK,
|
||||||
"{s:o}",
|
"{s:o}",
|
||||||
"rsa_pub",
|
"rsa_pub",
|
||||||
GNUNET_JSON_from_rsa_public_key (pub));
|
GNUNET_JSON_from_rsa_public_key (pub));
|
||||||
GNUNET_CRYPTO_rsa_public_key_free (pub);
|
GNUNET_CRYPTO_rsa_public_key_free (pub);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -497,9 +503,10 @@ TEH_TEST_handler_test_rsa_sign (struct TEH_RequestHandler *rh,
|
|||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
return TEH_RESPONSE_reply_internal_error (connection,
|
return TALER_MHD_reply_with_error (connection,
|
||||||
TALER_EC_TEST_RSA_GEN_ERROR,
|
MHD_HTTP_INTERNAL_SERVER_ERROR,
|
||||||
"Failed to create RSA key");
|
TALER_EC_TEST_RSA_GEN_ERROR,
|
||||||
|
"Failed to create RSA key");
|
||||||
}
|
}
|
||||||
sig = GNUNET_CRYPTO_rsa_sign_blinded (rsa_pk,
|
sig = GNUNET_CRYPTO_rsa_sign_blinded (rsa_pk,
|
||||||
in_ptr,
|
in_ptr,
|
||||||
@ -508,16 +515,17 @@ TEH_TEST_handler_test_rsa_sign (struct TEH_RequestHandler *rh,
|
|||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
return TEH_RESPONSE_reply_internal_error (connection,
|
return TALER_MHD_reply_with_error (connection,
|
||||||
TALER_EC_TEST_RSA_SIGN_ERROR,
|
MHD_HTTP_INTERNAL_SERVER_ERROR,
|
||||||
"Failed to RSA-sign");
|
TALER_EC_TEST_RSA_SIGN_ERROR,
|
||||||
|
"Failed to RSA-sign");
|
||||||
}
|
}
|
||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
res = TEH_RESPONSE_reply_json_pack (connection,
|
res = TALER_MHD_reply_json_pack (connection,
|
||||||
MHD_HTTP_OK,
|
MHD_HTTP_OK,
|
||||||
"{s:o}",
|
"{s:o}",
|
||||||
"rsa_blind_sig",
|
"rsa_blind_sig",
|
||||||
GNUNET_JSON_from_rsa_signature (sig));
|
GNUNET_JSON_from_rsa_signature (sig));
|
||||||
GNUNET_CRYPTO_rsa_signature_free (sig);
|
GNUNET_CRYPTO_rsa_signature_free (sig);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -573,11 +581,11 @@ TEH_TEST_handler_test_transfer (struct TEH_RequestHandler *rh,
|
|||||||
TALER_link_reveal_transfer_secret (&trans_priv,
|
TALER_link_reveal_transfer_secret (&trans_priv,
|
||||||
&coin_pub,
|
&coin_pub,
|
||||||
&secret);
|
&secret);
|
||||||
return TEH_RESPONSE_reply_json_pack (connection,
|
return TALER_MHD_reply_json_pack (connection,
|
||||||
MHD_HTTP_OK,
|
MHD_HTTP_OK,
|
||||||
"{s:o}",
|
"{s:o}",
|
||||||
"secret",
|
"secret",
|
||||||
GNUNET_JSON_from_data_auto (&secret));
|
GNUNET_JSON_from_data_auto (&secret));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include <jansson.h>
|
#include <jansson.h>
|
||||||
#include <microhttpd.h>
|
#include <microhttpd.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
#include "taler_mhd_lib.h"
|
||||||
#include "taler_signatures.h"
|
#include "taler_signatures.h"
|
||||||
#include "taler-exchange-httpd_parsing.h"
|
#include "taler-exchange-httpd_parsing.h"
|
||||||
#include "taler-exchange-httpd_keystate.h"
|
#include "taler-exchange-httpd_keystate.h"
|
||||||
@ -42,12 +43,12 @@ static int
|
|||||||
reply_transfer_pending (struct MHD_Connection *connection,
|
reply_transfer_pending (struct MHD_Connection *connection,
|
||||||
struct GNUNET_TIME_Absolute planned_exec_time)
|
struct GNUNET_TIME_Absolute planned_exec_time)
|
||||||
{
|
{
|
||||||
return TEH_RESPONSE_reply_json_pack (connection,
|
return TALER_MHD_reply_json_pack (connection,
|
||||||
MHD_HTTP_ACCEPTED,
|
MHD_HTTP_ACCEPTED,
|
||||||
"{s:o}",
|
"{s:o}",
|
||||||
"execution_time",
|
"execution_time",
|
||||||
GNUNET_JSON_from_time_abs (
|
GNUNET_JSON_from_time_abs (
|
||||||
planned_exec_time));
|
planned_exec_time));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -92,24 +93,25 @@ reply_track_transaction (struct MHD_Connection *connection,
|
|||||||
&pub,
|
&pub,
|
||||||
&sig))
|
&sig))
|
||||||
{
|
{
|
||||||
return TEH_RESPONSE_reply_internal_error (connection,
|
return TALER_MHD_reply_with_error (connection,
|
||||||
TALER_EC_EXCHANGE_BAD_CONFIGURATION,
|
MHD_HTTP_INTERNAL_SERVER_ERROR,
|
||||||
"no keys");
|
TALER_EC_EXCHANGE_BAD_CONFIGURATION,
|
||||||
|
"no keys");
|
||||||
}
|
}
|
||||||
return TEH_RESPONSE_reply_json_pack (connection,
|
return TALER_MHD_reply_json_pack (connection,
|
||||||
MHD_HTTP_OK,
|
MHD_HTTP_OK,
|
||||||
"{s:o, s:o, s:o, s:o, s:o}",
|
"{s:o, s:o, s:o, s:o, s:o}",
|
||||||
"wtid", GNUNET_JSON_from_data_auto (
|
"wtid", GNUNET_JSON_from_data_auto (
|
||||||
wtid),
|
wtid),
|
||||||
"execution_time",
|
"execution_time",
|
||||||
GNUNET_JSON_from_time_abs (exec_time),
|
GNUNET_JSON_from_time_abs (exec_time),
|
||||||
"coin_contribution",
|
"coin_contribution",
|
||||||
TALER_JSON_from_amount (
|
TALER_JSON_from_amount (
|
||||||
coin_contribution),
|
coin_contribution),
|
||||||
"exchange_sig",
|
"exchange_sig",
|
||||||
GNUNET_JSON_from_data_auto (&sig),
|
GNUNET_JSON_from_data_auto (&sig),
|
||||||
"exchange_pub",
|
"exchange_pub",
|
||||||
GNUNET_JSON_from_data_auto (&pub));
|
GNUNET_JSON_from_data_auto (&pub));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -249,15 +251,19 @@ track_transaction_transaction (void *cls,
|
|||||||
if (GNUNET_DB_STATUS_HARD_ERROR == qs)
|
if (GNUNET_DB_STATUS_HARD_ERROR == qs)
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
*mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection,
|
*mhd_ret = TALER_MHD_reply_with_error (connection,
|
||||||
TALER_EC_TRACK_TRANSACTION_DB_FETCH_FAILED);
|
MHD_HTTP_INTERNAL_SERVER_ERROR,
|
||||||
|
TALER_EC_TRACK_TRANSACTION_DB_FETCH_FAILED,
|
||||||
|
"failed to fetch transaction data");
|
||||||
}
|
}
|
||||||
return qs;
|
return qs;
|
||||||
}
|
}
|
||||||
if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
|
if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
|
||||||
{
|
{
|
||||||
*mhd_ret = TEH_RESPONSE_reply_transaction_unknown (connection,
|
*mhd_ret = TALER_MHD_reply_with_error (connection,
|
||||||
TALER_EC_TRACK_TRANSACTION_NOT_FOUND);
|
MHD_HTTP_NOT_FOUND,
|
||||||
|
TALER_EC_TRACK_TRANSACTION_NOT_FOUND,
|
||||||
|
"transaction unknown");
|
||||||
return GNUNET_DB_STATUS_HARD_ERROR;
|
return GNUNET_DB_STATUS_HARD_ERROR;
|
||||||
}
|
}
|
||||||
return qs;
|
return qs;
|
||||||
@ -295,9 +301,10 @@ check_and_handle_track_transaction_request (struct MHD_Connection *connection,
|
|||||||
&merchant_pub->eddsa_pub))
|
&merchant_pub->eddsa_pub))
|
||||||
{
|
{
|
||||||
GNUNET_break_op (0);
|
GNUNET_break_op (0);
|
||||||
return TEH_RESPONSE_reply_signature_invalid (connection,
|
return TALER_MHD_reply_with_error (connection,
|
||||||
TALER_EC_TRACK_TRANSACTION_MERCHANT_SIGNATURE_INVALID,
|
MHD_HTTP_FORBIDDEN,
|
||||||
"merchant_sig");
|
TALER_EC_TRACK_TRANSACTION_MERCHANT_SIGNATURE_INVALID,
|
||||||
|
"merchant_sig");
|
||||||
}
|
}
|
||||||
ctx.pending = GNUNET_NO;
|
ctx.pending = GNUNET_NO;
|
||||||
ctx.tps = tps;
|
ctx.tps = tps;
|
||||||
@ -314,8 +321,10 @@ check_and_handle_track_transaction_request (struct MHD_Connection *connection,
|
|||||||
return reply_transfer_pending (connection,
|
return reply_transfer_pending (connection,
|
||||||
ctx.execution_time);
|
ctx.execution_time);
|
||||||
if (GNUNET_SYSERR == ctx.pending)
|
if (GNUNET_SYSERR == ctx.pending)
|
||||||
return TEH_RESPONSE_reply_internal_db_error (connection,
|
return TALER_MHD_reply_with_error (connection,
|
||||||
TALER_EC_TRACK_TRANSACTION_DB_FEE_INCONSISTENT);
|
MHD_HTTP_INTERNAL_SERVER_ERROR,
|
||||||
|
TALER_EC_TRACK_TRANSACTION_DB_FEE_INCONSISTENT,
|
||||||
|
"fees are inconsistent");
|
||||||
return reply_track_transaction (connection,
|
return reply_track_transaction (connection,
|
||||||
&tps->h_contract_terms,
|
&tps->h_contract_terms,
|
||||||
&tps->h_wire,
|
&tps->h_wire,
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "taler-exchange-httpd_keystate.h"
|
#include "taler-exchange-httpd_keystate.h"
|
||||||
#include "taler-exchange-httpd_track_transfer.h"
|
#include "taler-exchange-httpd_track_transfer.h"
|
||||||
#include "taler-exchange-httpd_responses.h"
|
#include "taler-exchange-httpd_responses.h"
|
||||||
|
#include "taler_mhd_lib.h"
|
||||||
#include "taler_wire_lib.h"
|
#include "taler_wire_lib.h"
|
||||||
|
|
||||||
|
|
||||||
@ -148,29 +149,30 @@ reply_track_transfer_details (struct MHD_Connection *connection,
|
|||||||
&sig))
|
&sig))
|
||||||
{
|
{
|
||||||
json_decref (deposits);
|
json_decref (deposits);
|
||||||
return TEH_RESPONSE_reply_internal_error (connection,
|
return TALER_MHD_reply_with_error (connection,
|
||||||
TALER_EC_EXCHANGE_BAD_CONFIGURATION,
|
MHD_HTTP_INTERNAL_SERVER_ERROR,
|
||||||
"no keys");
|
TALER_EC_EXCHANGE_BAD_CONFIGURATION,
|
||||||
|
"no keys");
|
||||||
}
|
}
|
||||||
|
|
||||||
return TEH_RESPONSE_reply_json_pack (connection,
|
return TALER_MHD_reply_json_pack (connection,
|
||||||
MHD_HTTP_OK,
|
MHD_HTTP_OK,
|
||||||
"{s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o}",
|
"{s:o, s:o, s:o, s:o, s:o, s:o, s:o, s:o}",
|
||||||
"total", TALER_JSON_from_amount (total),
|
"total", TALER_JSON_from_amount (total),
|
||||||
"wire_fee", TALER_JSON_from_amount (
|
"wire_fee", TALER_JSON_from_amount (
|
||||||
wire_fee),
|
wire_fee),
|
||||||
"merchant_pub",
|
"merchant_pub",
|
||||||
GNUNET_JSON_from_data_auto (
|
GNUNET_JSON_from_data_auto (
|
||||||
merchant_pub),
|
merchant_pub),
|
||||||
"H_wire", GNUNET_JSON_from_data_auto (
|
"H_wire", GNUNET_JSON_from_data_auto (
|
||||||
h_wire),
|
h_wire),
|
||||||
"execution_time",
|
"execution_time",
|
||||||
GNUNET_JSON_from_time_abs (exec_time),
|
GNUNET_JSON_from_time_abs (exec_time),
|
||||||
"deposits", deposits,
|
"deposits", deposits,
|
||||||
"exchange_sig",
|
"exchange_sig",
|
||||||
GNUNET_JSON_from_data_auto (&sig),
|
GNUNET_JSON_from_data_auto (&sig),
|
||||||
"exchange_pub",
|
"exchange_pub",
|
||||||
GNUNET_JSON_from_data_auto (&pub));
|
GNUNET_JSON_from_data_auto (&pub));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -396,23 +398,28 @@ track_transfer_transaction (void *cls,
|
|||||||
if (GNUNET_DB_STATUS_HARD_ERROR == qs)
|
if (GNUNET_DB_STATUS_HARD_ERROR == qs)
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
*mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection,
|
*mhd_ret = TALER_MHD_reply_with_error (connection,
|
||||||
TALER_EC_TRACK_TRANSFER_DB_FETCH_FAILED);
|
MHD_HTTP_INTERNAL_SERVER_ERROR,
|
||||||
|
TALER_EC_TRACK_TRANSFER_DB_FETCH_FAILED,
|
||||||
|
"failed to fetch transaction data");
|
||||||
}
|
}
|
||||||
return qs;
|
return qs;
|
||||||
}
|
}
|
||||||
if (GNUNET_SYSERR == ctx->is_valid)
|
if (GNUNET_SYSERR == ctx->is_valid)
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
*mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection,
|
*mhd_ret = TALER_MHD_reply_with_error (connection,
|
||||||
TALER_EC_TRACK_TRANSFER_DB_INCONSISTENT);
|
MHD_HTTP_INTERNAL_SERVER_ERROR,
|
||||||
|
TALER_EC_TRACK_TRANSFER_DB_INCONSISTENT,
|
||||||
|
"exchange database internally inconsistent");
|
||||||
return GNUNET_DB_STATUS_HARD_ERROR;
|
return GNUNET_DB_STATUS_HARD_ERROR;
|
||||||
}
|
}
|
||||||
if (GNUNET_NO == ctx->is_valid)
|
if (GNUNET_NO == ctx->is_valid)
|
||||||
{
|
{
|
||||||
*mhd_ret = TEH_RESPONSE_reply_arg_unknown (connection,
|
*mhd_ret = TALER_MHD_reply_with_error (connection,
|
||||||
TALER_EC_TRACK_TRANSFER_WTID_NOT_FOUND,
|
MHD_HTTP_NOT_FOUND,
|
||||||
"wtid");
|
TALER_EC_TRACK_TRANSFER_WTID_NOT_FOUND,
|
||||||
|
"wtid");
|
||||||
return GNUNET_DB_STATUS_HARD_ERROR;
|
return GNUNET_DB_STATUS_HARD_ERROR;
|
||||||
}
|
}
|
||||||
qs = TEH_plugin->get_wire_fee (TEH_plugin->cls,
|
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_DB_STATUS_SUCCESS_NO_RESULTS) )
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
*mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection,
|
*mhd_ret = TALER_MHD_reply_with_error (connection,
|
||||||
TALER_EC_TRACK_TRANSFER_WIRE_FEE_NOT_FOUND);
|
MHD_HTTP_INTERNAL_SERVER_ERROR,
|
||||||
|
TALER_EC_TRACK_TRANSFER_WIRE_FEE_NOT_FOUND,
|
||||||
|
"did not find wire fee");
|
||||||
}
|
}
|
||||||
return qs;
|
return qs;
|
||||||
}
|
}
|
||||||
@ -441,8 +450,10 @@ track_transfer_transaction (void *cls,
|
|||||||
&ctx->wire_fee))
|
&ctx->wire_fee))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
*mhd_ret = TEH_RESPONSE_reply_internal_db_error (connection,
|
*mhd_ret = TALER_MHD_reply_with_error (connection,
|
||||||
TALER_EC_TRACK_TRANSFER_WIRE_FEE_INCONSISTENT);
|
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_HARD_ERROR;
|
||||||
}
|
}
|
||||||
return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
|
return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "taler-exchange-httpd_validation.h"
|
#include "taler-exchange-httpd_validation.h"
|
||||||
#include "taler-exchange-httpd_wire.h"
|
#include "taler-exchange-httpd_wire.h"
|
||||||
#include "taler_json_lib.h"
|
#include "taler_json_lib.h"
|
||||||
|
#include "taler_mhd_lib.h"
|
||||||
#include <jansson.h>
|
#include <jansson.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -140,9 +141,9 @@ TEH_WIRE_handler_wire (struct TEH_RequestHandler *rh,
|
|||||||
(void) upload_data;
|
(void) upload_data;
|
||||||
(void) upload_data_size;
|
(void) upload_data_size;
|
||||||
GNUNET_assert (NULL != wire_methods);
|
GNUNET_assert (NULL != wire_methods);
|
||||||
return TEH_RESPONSE_reply_json (connection,
|
return TALER_MHD_reply_json (connection,
|
||||||
wire_methods,
|
wire_methods,
|
||||||
MHD_HTTP_OK);
|
MHD_HTTP_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user