indentation and minor updates to reflect latest API docs
This commit is contained in:
parent
42147c2501
commit
80b29ed2ae
@ -24,11 +24,13 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Number of characters (plus 1 for 0-termination) we use to
|
* @brief Number of characters (plus 1 for 0-termination) we use to
|
||||||
* represent currency names (i.e. EUR, USD, etc.). We use
|
* represent currency names (i.e. EUR, USD, etc.). We use 8+4 for
|
||||||
* 4 for alignment as 3 characters are typical and we need a
|
* alignment in the `struct TALER_Amount`. The amount is typically an
|
||||||
* 0-terminator. So do not change this.
|
* ISO 4217 currency code when an alpha-numeric 3-digit code is used.
|
||||||
|
* For regional currencies, the first character should be a "*" followed
|
||||||
|
* by a region-specific name (i.e. "*BRETAGNEFR").
|
||||||
*/
|
*/
|
||||||
#define TALER_CURRENCY_LEN 4
|
#define TALER_CURRENCY_LEN 12
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The "fraction" value in a `struct TALER_Amount` represents which
|
* @brief The "fraction" value in a `struct TALER_Amount` represents which
|
||||||
|
@ -186,7 +186,7 @@ TMH_DB_execute_deposit (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
TALER_LOG_WARNING ("Failed to store /deposit information in database\n");
|
TALER_LOG_WARNING ("Failed to store /deposit information in database\n");
|
||||||
TMH_plugin->rollback (TMH_plugin->cls,
|
TMH_plugin->rollback (TMH_plugin->cls,
|
||||||
session);
|
session);
|
||||||
return TMH_RESPONSE_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,30 +218,31 @@ TMH_DB_execute_deposit (struct MHD_Connection *connection,
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TMH_DB_execute_withdraw_status (struct MHD_Connection *connection,
|
TMH_DB_execute_withdraw_status (struct MHD_Connection *connection,
|
||||||
const struct TALER_ReservePublicKeyP *reserve_pub)
|
const struct TALER_ReservePublicKeyP *reserve_pub)
|
||||||
{
|
{
|
||||||
struct TALER_MINTDB_Session *session;
|
struct TALER_MINTDB_Session *session;
|
||||||
struct TALER_MINTDB_ReserveHistory *rh;
|
struct TALER_MINTDB_ReserveHistory *rh;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
if (NULL == (session = TMH_plugin->get_session (TMH_plugin->cls,
|
if (NULL == (session = TMH_plugin->get_session (TMH_plugin->cls,
|
||||||
GNUNET_NO)))
|
GNUNET_NO)))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return TMH_RESPONSE_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
rh = TMH_plugin->get_reserve_history (TMH_plugin->cls,
|
rh = TMH_plugin->get_reserve_history (TMH_plugin->cls,
|
||||||
session,
|
session,
|
||||||
reserve_pub);
|
reserve_pub);
|
||||||
if (NULL == rh)
|
if (NULL == rh)
|
||||||
return TMH_RESPONSE_reply_json_pack (connection,
|
return TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_NOT_FOUND,
|
MHD_HTTP_NOT_FOUND,
|
||||||
"{s:s}",
|
"{s:s, s:s}",
|
||||||
"error", "Reserve not found");
|
"error", "Reserve not found",
|
||||||
|
"parameter", "withdraw_pub");
|
||||||
res = TMH_RESPONSE_reply_withdraw_status_success (connection,
|
res = TMH_RESPONSE_reply_withdraw_status_success (connection,
|
||||||
rh);
|
rh);
|
||||||
TMH_plugin->free_reserve_history (TMH_plugin->cls,
|
TMH_plugin->free_reserve_history (TMH_plugin->cls,
|
||||||
rh);
|
rh);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,11 +263,11 @@ TMH_DB_execute_withdraw_status (struct MHD_Connection *connection,
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TMH_DB_execute_withdraw_sign (struct MHD_Connection *connection,
|
TMH_DB_execute_withdraw_sign (struct MHD_Connection *connection,
|
||||||
const struct TALER_ReservePublicKeyP *reserve,
|
const struct TALER_ReservePublicKeyP *reserve,
|
||||||
const struct TALER_DenominationPublicKey *denomination_pub,
|
const struct TALER_DenominationPublicKey *denomination_pub,
|
||||||
const char *blinded_msg,
|
const char *blinded_msg,
|
||||||
size_t blinded_msg_len,
|
size_t blinded_msg_len,
|
||||||
const struct TALER_ReserveSignatureP *signature)
|
const struct TALER_ReserveSignatureP *signature)
|
||||||
{
|
{
|
||||||
struct TALER_MINTDB_Session *session;
|
struct TALER_MINTDB_Session *session;
|
||||||
struct TALER_MINTDB_ReserveHistory *rh;
|
struct TALER_MINTDB_ReserveHistory *rh;
|
||||||
@ -290,15 +291,15 @@ TMH_DB_execute_withdraw_sign (struct MHD_Connection *connection,
|
|||||||
&h_blind);
|
&h_blind);
|
||||||
|
|
||||||
if (NULL == (session = TMH_plugin->get_session (TMH_plugin->cls,
|
if (NULL == (session = TMH_plugin->get_session (TMH_plugin->cls,
|
||||||
GNUNET_NO)))
|
GNUNET_NO)))
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return TMH_RESPONSE_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
res = TMH_plugin->get_collectable_blindcoin (TMH_plugin->cls,
|
res = TMH_plugin->get_collectable_blindcoin (TMH_plugin->cls,
|
||||||
session,
|
session,
|
||||||
&h_blind,
|
&h_blind,
|
||||||
&collectable);
|
&collectable);
|
||||||
if (GNUNET_SYSERR == res)
|
if (GNUNET_SYSERR == res)
|
||||||
{
|
{
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
@ -319,15 +320,15 @@ TMH_DB_execute_withdraw_sign (struct MHD_Connection *connection,
|
|||||||
/* Check if balance is sufficient */
|
/* Check if balance is sufficient */
|
||||||
key_state = TMH_KS_acquire ();
|
key_state = TMH_KS_acquire ();
|
||||||
dki = TMH_KS_denomination_key_lookup (key_state,
|
dki = TMH_KS_denomination_key_lookup (key_state,
|
||||||
denomination_pub);
|
denomination_pub);
|
||||||
if (NULL == dki)
|
if (NULL == dki)
|
||||||
{
|
{
|
||||||
TMH_KS_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
return TMH_RESPONSE_reply_json_pack (connection,
|
return TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_NOT_FOUND,
|
MHD_HTTP_NOT_FOUND,
|
||||||
"{s:s}",
|
"{s:s}",
|
||||||
"error",
|
"error",
|
||||||
"Denomination not found");
|
"Denomination not found");
|
||||||
}
|
}
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
TMH_plugin->start (TMH_plugin->cls,
|
TMH_plugin->start (TMH_plugin->cls,
|
||||||
@ -339,18 +340,15 @@ TMH_DB_execute_withdraw_sign (struct MHD_Connection *connection,
|
|||||||
}
|
}
|
||||||
|
|
||||||
rh = TMH_plugin->get_reserve_history (TMH_plugin->cls,
|
rh = TMH_plugin->get_reserve_history (TMH_plugin->cls,
|
||||||
session,
|
session,
|
||||||
reserve);
|
reserve);
|
||||||
if (NULL == rh)
|
if (NULL == rh)
|
||||||
{
|
{
|
||||||
TMH_plugin->rollback (TMH_plugin->cls,
|
TMH_plugin->rollback (TMH_plugin->cls,
|
||||||
session);
|
session);
|
||||||
TMH_KS_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
return TMH_RESPONSE_reply_json_pack (connection,
|
return TMH_RESPONSE_reply_arg_unknown (connection,
|
||||||
MHD_HTTP_NOT_FOUND,
|
"reserve_pub");
|
||||||
"{s:s}",
|
|
||||||
"error",
|
|
||||||
"Reserve not found");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* calculate amount required including fees */
|
/* calculate amount required including fees */
|
||||||
@ -386,7 +384,7 @@ TMH_DB_execute_withdraw_sign (struct MHD_Connection *connection,
|
|||||||
&pos->details.bank->amount))
|
&pos->details.bank->amount))
|
||||||
{
|
{
|
||||||
TMH_plugin->rollback (TMH_plugin->cls,
|
TMH_plugin->rollback (TMH_plugin->cls,
|
||||||
session);
|
session);
|
||||||
TMH_KS_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
return TMH_RESPONSE_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
@ -394,7 +392,7 @@ TMH_DB_execute_withdraw_sign (struct MHD_Connection *connection,
|
|||||||
break;
|
break;
|
||||||
case TALER_MINTDB_RO_WITHDRAW_COIN:
|
case TALER_MINTDB_RO_WITHDRAW_COIN:
|
||||||
tdki = TMH_KS_denomination_key_lookup (key_state,
|
tdki = TMH_KS_denomination_key_lookup (key_state,
|
||||||
&pos->details.withdraw->denom_pub);
|
&pos->details.withdraw->denom_pub);
|
||||||
TALER_amount_ntoh (&value,
|
TALER_amount_ntoh (&value,
|
||||||
&tdki->issue.value);
|
&tdki->issue.value);
|
||||||
if (0 == (res & 2))
|
if (0 == (res & 2))
|
||||||
@ -406,7 +404,7 @@ TMH_DB_execute_withdraw_sign (struct MHD_Connection *connection,
|
|||||||
&value))
|
&value))
|
||||||
{
|
{
|
||||||
TMH_plugin->rollback (TMH_plugin->cls,
|
TMH_plugin->rollback (TMH_plugin->cls,
|
||||||
session);
|
session);
|
||||||
TMH_KS_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
return TMH_RESPONSE_reply_internal_db_error (connection);
|
return TMH_RESPONSE_reply_internal_db_error (connection);
|
||||||
}
|
}
|
||||||
@ -426,13 +424,13 @@ TMH_DB_execute_withdraw_sign (struct MHD_Connection *connection,
|
|||||||
TMH_plugin->rollback (TMH_plugin->cls,
|
TMH_plugin->rollback (TMH_plugin->cls,
|
||||||
session);
|
session);
|
||||||
res = TMH_RESPONSE_reply_withdraw_sign_insufficient_funds (connection,
|
res = TMH_RESPONSE_reply_withdraw_sign_insufficient_funds (connection,
|
||||||
rh);
|
rh);
|
||||||
TMH_plugin->free_reserve_history (TMH_plugin->cls,
|
TMH_plugin->free_reserve_history (TMH_plugin->cls,
|
||||||
rh);
|
rh);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
TMH_plugin->free_reserve_history (TMH_plugin->cls,
|
TMH_plugin->free_reserve_history (TMH_plugin->cls,
|
||||||
rh);
|
rh);
|
||||||
|
|
||||||
/* Balance is good, sign the coin! */
|
/* Balance is good, sign the coin! */
|
||||||
sig = GNUNET_CRYPTO_rsa_sign (dki->denom_priv.rsa_private_key,
|
sig = GNUNET_CRYPTO_rsa_sign (dki->denom_priv.rsa_private_key,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
This file is part of TALER
|
This file is part of TALER
|
||||||
Copyright (C) 2014 GNUnet e.V.
|
Copyright (C) 2014, 2015 GNUnet e.V.
|
||||||
|
|
||||||
TALER is free software; you can redistribute it and/or modify it under the
|
TALER is free software; you can redistribute it and/or modify it under the
|
||||||
terms of the GNU Affero General Public License as published by the Free Software
|
terms of the GNU Affero General Public License as published by the Free Software
|
||||||
@ -23,8 +23,8 @@
|
|||||||
* @author Christian Grothoff
|
* @author Christian Grothoff
|
||||||
*
|
*
|
||||||
* TODO:
|
* TODO:
|
||||||
* - missing 'wire' format check (well-formed SEPA-details)
|
* - missing 'wire' format check (well-formed SEPA-details) (#3624)
|
||||||
* - ugliy if-construction for deposit type
|
* - ugly if-construction for deposit type
|
||||||
*/
|
*/
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include <gnunet/gnunet_util_lib.h>
|
#include <gnunet/gnunet_util_lib.h>
|
||||||
@ -80,19 +80,19 @@ verify_and_execute_deposit (struct MHD_Connection *connection,
|
|||||||
&deposit->coin.coin_pub.ecdsa_pub))
|
&deposit->coin.coin_pub.ecdsa_pub))
|
||||||
{
|
{
|
||||||
TALER_LOG_WARNING ("Invalid signature on /deposit request\n");
|
TALER_LOG_WARNING ("Invalid signature on /deposit request\n");
|
||||||
return TMH_RESPONSE_reply_arg_invalid (connection,
|
return TMH_RESPONSE_reply_signature_invalid (connection,
|
||||||
"csig");
|
"coin_sig");
|
||||||
}
|
}
|
||||||
/* check denomination exists and is valid */
|
/* check denomination exists and is valid */
|
||||||
key_state = TMH_KS_acquire ();
|
key_state = TMH_KS_acquire ();
|
||||||
dki = TMH_KS_denomination_key_lookup (key_state,
|
dki = TMH_KS_denomination_key_lookup (key_state,
|
||||||
&deposit->coin.denom_pub);
|
&deposit->coin.denom_pub);
|
||||||
if (NULL == dki)
|
if (NULL == dki)
|
||||||
{
|
{
|
||||||
TMH_KS_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
TALER_LOG_WARNING ("Unknown denomination key in /deposit request\n");
|
TALER_LOG_WARNING ("Unknown denomination key in /deposit request\n");
|
||||||
return TMH_RESPONSE_reply_arg_invalid (connection,
|
return TMH_RESPONSE_reply_arg_unknown (connection,
|
||||||
"denom_pub");
|
"denom_pub");
|
||||||
}
|
}
|
||||||
/* check coin signature */
|
/* check coin signature */
|
||||||
if (GNUNET_YES !=
|
if (GNUNET_YES !=
|
||||||
@ -100,7 +100,8 @@ verify_and_execute_deposit (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
TALER_LOG_WARNING ("Invalid coin passed for /deposit\n");
|
TALER_LOG_WARNING ("Invalid coin passed for /deposit\n");
|
||||||
TMH_KS_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
return TMH_RESPONSE_reply_coin_invalid (connection);
|
return TMH_RESPONSE_reply_signature_invalid (connection,
|
||||||
|
"ub_sig");
|
||||||
}
|
}
|
||||||
TALER_amount_ntoh (&fee_deposit,
|
TALER_amount_ntoh (&fee_deposit,
|
||||||
&dki->issue.fee_deposit);
|
&dki->issue.fee_deposit);
|
||||||
@ -110,7 +111,7 @@ verify_and_execute_deposit (struct MHD_Connection *connection,
|
|||||||
TMH_KS_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
return (MHD_YES ==
|
return (MHD_YES ==
|
||||||
TMH_RESPONSE_reply_external_error (connection,
|
TMH_RESPONSE_reply_external_error (connection,
|
||||||
"deposited amount smaller than depositing fee"))
|
"deposited amount smaller than depositing fee"))
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
TMH_KS_release (key_state);
|
TMH_KS_release (key_state);
|
||||||
@ -145,12 +146,12 @@ parse_and_handle_deposit_request (struct MHD_Connection *connection,
|
|||||||
struct TMH_KS_StateHandle *ks;
|
struct TMH_KS_StateHandle *ks;
|
||||||
struct TMH_PARSE_FieldSpecification spec[] = {
|
struct TMH_PARSE_FieldSpecification spec[] = {
|
||||||
TMH_PARSE_MEMBER_DENOMINATION_PUBLIC_KEY ("denom_pub", &deposit.coin.denom_pub),
|
TMH_PARSE_MEMBER_DENOMINATION_PUBLIC_KEY ("denom_pub", &deposit.coin.denom_pub),
|
||||||
TMH_PARSE_MEMBER_DENOMINATION_SIGNATURE ("ubsig", &deposit.coin.denom_sig),
|
TMH_PARSE_MEMBER_DENOMINATION_SIGNATURE ("ub_sig", &deposit.coin.denom_sig),
|
||||||
TMH_PARSE_MEMBER_FIXED ("coin_pub", &deposit.coin.coin_pub),
|
TMH_PARSE_MEMBER_FIXED ("coin_pub", &deposit.coin.coin_pub),
|
||||||
TMH_PARSE_MEMBER_FIXED ("merchant_pub", &deposit.merchant_pub),
|
TMH_PARSE_MEMBER_FIXED ("merchant_pub", &deposit.merchant_pub),
|
||||||
TMH_PARSE_MEMBER_FIXED ("H_a", &deposit.h_contract),
|
TMH_PARSE_MEMBER_FIXED ("H_contract", &deposit.h_contract),
|
||||||
TMH_PARSE_MEMBER_FIXED ("H_wire", &deposit.h_wire),
|
TMH_PARSE_MEMBER_FIXED ("H_wire", &deposit.h_wire),
|
||||||
TMH_PARSE_MEMBER_FIXED ("csig", &deposit.csig),
|
TMH_PARSE_MEMBER_FIXED ("coin_sig", &deposit.csig),
|
||||||
TMH_PARSE_MEMBER_FIXED ("transaction_id", &deposit.transaction_id),
|
TMH_PARSE_MEMBER_FIXED ("transaction_id", &deposit.transaction_id),
|
||||||
TMH_PARSE_MEMBER_TIME_ABS ("timestamp", &deposit.timestamp),
|
TMH_PARSE_MEMBER_TIME_ABS ("timestamp", &deposit.timestamp),
|
||||||
TMH_PARSE_MEMBER_TIME_ABS ("refund_deadline", &deposit.refund_deadline),
|
TMH_PARSE_MEMBER_TIME_ABS ("refund_deadline", &deposit.refund_deadline),
|
||||||
@ -170,7 +171,7 @@ parse_and_handle_deposit_request (struct MHD_Connection *connection,
|
|||||||
wire))
|
wire))
|
||||||
{
|
{
|
||||||
TMH_PARSE_release_data (spec);
|
TMH_PARSE_release_data (spec);
|
||||||
return TMH_RESPONSE_reply_arg_invalid (connection,
|
return TMH_RESPONSE_reply_arg_unknown (connection,
|
||||||
"wire");
|
"wire");
|
||||||
}
|
}
|
||||||
if (NULL == (wire_enc = json_dumps (wire, JSON_COMPACT | JSON_SORT_KEYS)))
|
if (NULL == (wire_enc = json_dumps (wire, JSON_COMPACT | JSON_SORT_KEYS)))
|
||||||
@ -192,7 +193,7 @@ parse_and_handle_deposit_request (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
TMH_KS_release (ks);
|
TMH_KS_release (ks);
|
||||||
TMH_PARSE_release_data (spec);
|
TMH_PARSE_release_data (spec);
|
||||||
return TMH_RESPONSE_reply_arg_invalid (connection,
|
return TMH_RESPONSE_reply_arg_unknown (connection,
|
||||||
"denom_pub");
|
"denom_pub");
|
||||||
}
|
}
|
||||||
TALER_amount_ntoh (&deposit.deposit_fee,
|
TALER_amount_ntoh (&deposit.deposit_fee,
|
||||||
|
@ -406,18 +406,18 @@ TMH_KS_acquire (void)
|
|||||||
GNUNET_NO);
|
GNUNET_NO);
|
||||||
key_state->reload_time = GNUNET_TIME_absolute_get ();
|
key_state->reload_time = GNUNET_TIME_absolute_get ();
|
||||||
TALER_MINTDB_denomination_keys_iterate (TMH_mint_directory,
|
TALER_MINTDB_denomination_keys_iterate (TMH_mint_directory,
|
||||||
&reload_keys_denom_iter,
|
&reload_keys_denom_iter,
|
||||||
key_state);
|
key_state);
|
||||||
TALER_MINTDB_signing_keys_iterate (TMH_mint_directory,
|
TALER_MINTDB_signing_keys_iterate (TMH_mint_directory,
|
||||||
&reload_keys_sign_iter,
|
&reload_keys_sign_iter,
|
||||||
key_state);
|
key_state);
|
||||||
key_state->next_reload = GNUNET_TIME_absolute_ntoh (key_state->current_sign_key_issue.issue.expire);
|
key_state->next_reload = GNUNET_TIME_absolute_ntoh (key_state->current_sign_key_issue.issue.expire);
|
||||||
if (0 == key_state->next_reload.abs_value_us)
|
if (0 == key_state->next_reload.abs_value_us)
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"No valid signing key found!\n");
|
"No valid signing key found!\n");
|
||||||
|
|
||||||
keys = json_pack ("{s:o, s:o, s:o, s:o}",
|
keys = json_pack ("{s:o, s:o, s:o, s:o}",
|
||||||
"TMH_master_public_key",
|
"master_public_key",
|
||||||
TALER_json_from_data (&TMH_master_public_key,
|
TALER_json_from_data (&TMH_master_public_key,
|
||||||
sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)),
|
sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)),
|
||||||
"signkeys", key_state->sign_keys_array,
|
"signkeys", key_state->sign_keys_array,
|
||||||
@ -436,8 +436,8 @@ TMH_KS_acquire (void)
|
|||||||
&sig);
|
&sig);
|
||||||
keys = json_pack ("{s:o, s:o}",
|
keys = json_pack ("{s:o, s:o}",
|
||||||
"keys", keys,
|
"keys", keys,
|
||||||
"eddsa-signature", TALER_json_from_eddsa_sig (&ks.purpose,
|
"eddsa_sig", TALER_json_from_eddsa_sig (&ks.purpose,
|
||||||
&sig.eddsa_signature));
|
&sig.eddsa_signature));
|
||||||
key_state->keys_json = json_dumps (keys,
|
key_state->keys_json = json_dumps (keys,
|
||||||
JSON_INDENT (2));
|
JSON_INDENT (2));
|
||||||
json_decref (keys);
|
json_decref (keys);
|
||||||
|
@ -276,9 +276,9 @@ TMH_PARSE_post_cleanup_callback (void *con_cls)
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TMH_PARSE_mhd_request_arg_data (struct MHD_Connection *connection,
|
TMH_PARSE_mhd_request_arg_data (struct MHD_Connection *connection,
|
||||||
const char *param_name,
|
const char *param_name,
|
||||||
void *out_data,
|
void *out_data,
|
||||||
size_t out_size)
|
size_t out_size)
|
||||||
{
|
{
|
||||||
const char *str;
|
const char *str;
|
||||||
|
|
||||||
@ -406,14 +406,11 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
ret = (MHD_YES ==
|
ret = (MHD_YES ==
|
||||||
TMH_RESPONSE_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:s, s:o}",
|
"{s:s, s:s, s:o}",
|
||||||
"error",
|
"error", "missing field in JSON",
|
||||||
"missing field in JSON",
|
"field", fname,
|
||||||
"field",
|
"path", path))
|
||||||
fname,
|
|
||||||
"path",
|
|
||||||
path))
|
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -432,11 +429,10 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
ret = (MHD_YES ==
|
ret = (MHD_YES ==
|
||||||
TMH_RESPONSE_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:o}",
|
"{s:s, s:o}",
|
||||||
"error",
|
"error", "missing index in JSON",
|
||||||
"missing index in JSON",
|
"path", path))
|
||||||
"path", path))
|
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -458,10 +454,8 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection,
|
|||||||
TMH_RESPONSE_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:o}",
|
"{s:s, s:o}",
|
||||||
"error",
|
"error", "string expected",
|
||||||
"string expected",
|
"path", path))
|
||||||
"path",
|
|
||||||
path))
|
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -471,12 +465,10 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
ret = (MHD_YES ==
|
ret = (MHD_YES ==
|
||||||
TMH_RESPONSE_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:o}",
|
"{s:s, s:o}",
|
||||||
"error",
|
"error", "malformed binary data in JSON",
|
||||||
"malformed binary data in JSON",
|
"path", path))
|
||||||
"path",
|
|
||||||
path))
|
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -517,11 +509,10 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection,
|
|||||||
*len = 0;
|
*len = 0;
|
||||||
ret = (MHD_YES ==
|
ret = (MHD_YES ==
|
||||||
TMH_RESPONSE_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:o}",
|
"{s:s, s:o}",
|
||||||
"error",
|
"error", "malformed binary data in JSON",
|
||||||
"malformed binary data in JSON",
|
"path", path))
|
||||||
"path", path))
|
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -539,12 +530,12 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection,
|
|||||||
{
|
{
|
||||||
ret = (MHD_YES ==
|
ret = (MHD_YES ==
|
||||||
TMH_RESPONSE_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:i, s:i, s:o}",
|
"{s:s, s:i, s:i, s:o}",
|
||||||
"error", "wrong JSON field type",
|
"error", "wrong JSON field type",
|
||||||
"type_expected", typ,
|
"type_expected", typ,
|
||||||
"type_actual", json_typeof (root),
|
"type_actual", json_typeof (root),
|
||||||
"path", path))
|
"path", path))
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -570,10 +561,8 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection,
|
|||||||
TMH_RESPONSE_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:o}",
|
"{s:s, s:o}",
|
||||||
"error",
|
"error", "string expected",
|
||||||
"string expected",
|
"path", path))
|
||||||
"path",
|
|
||||||
path))
|
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -590,10 +579,8 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection,
|
|||||||
TMH_RESPONSE_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:o}",
|
"{s:s, s:o}",
|
||||||
"error",
|
"error", "malformed binary data in JSON",
|
||||||
"malformed binary data in JSON",
|
"path", path))
|
||||||
"path",
|
|
||||||
path))
|
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -606,10 +593,8 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection,
|
|||||||
TMH_RESPONSE_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:o}",
|
"{s:s, s:o}",
|
||||||
"error",
|
"error", "malformed RSA public key in JSON",
|
||||||
"malformed RSA public key in JSON",
|
"path", path))
|
||||||
"path",
|
|
||||||
path))
|
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -634,10 +619,8 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection,
|
|||||||
TMH_RESPONSE_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:o}",
|
"{s:s, s:o}",
|
||||||
"error",
|
"error", "string expected",
|
||||||
"string expected",
|
"path", path))
|
||||||
"path",
|
|
||||||
path))
|
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -654,10 +637,8 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection,
|
|||||||
TMH_RESPONSE_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:o}",
|
"{s:s, s:o}",
|
||||||
"error",
|
"error", "malformed binary data in JSON",
|
||||||
"malformed binary data in JSON",
|
"path", path))
|
||||||
"path",
|
|
||||||
path))
|
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -670,10 +651,8 @@ TMH_PARSE_navigate_json (struct MHD_Connection *connection,
|
|||||||
TMH_RESPONSE_reply_json_pack (connection,
|
TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:o}",
|
"{s:s, s:o}",
|
||||||
"error",
|
"error", "malformed RSA signature in JSON",
|
||||||
"malformed RSA signature in JSON",
|
"path", path))
|
||||||
"path",
|
|
||||||
path))
|
|
||||||
? GNUNET_NO : GNUNET_SYSERR;
|
? GNUNET_NO : GNUNET_SYSERR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -139,9 +139,9 @@ handle_refresh_melt_binary (struct MHD_Connection *connection,
|
|||||||
/* We require total value of coins being melted and
|
/* We require total value of coins being melted and
|
||||||
total value of coins being generated to match! */
|
total value of coins being generated to match! */
|
||||||
return TMH_RESPONSE_reply_json_pack (connection,
|
return TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s}",
|
"{s:s}",
|
||||||
"error", "value mismatch");
|
"error", "value mismatch");
|
||||||
}
|
}
|
||||||
return TMH_DB_execute_refresh_melt (connection,
|
return TMH_DB_execute_refresh_melt (connection,
|
||||||
session_hash,
|
session_hash,
|
||||||
|
@ -39,8 +39,8 @@
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TMH_RESPONSE_reply_json (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_json (struct MHD_Connection *connection,
|
||||||
const json_t *json,
|
const json_t *json,
|
||||||
unsigned int response_code)
|
unsigned int response_code)
|
||||||
{
|
{
|
||||||
struct MHD_Response *resp;
|
struct MHD_Response *resp;
|
||||||
char *json_str;
|
char *json_str;
|
||||||
@ -72,9 +72,9 @@ TMH_RESPONSE_reply_json (struct MHD_Connection *connection,
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TMH_RESPONSE_reply_json_pack (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_json_pack (struct MHD_Connection *connection,
|
||||||
unsigned int response_code,
|
unsigned int response_code,
|
||||||
const char *fmt,
|
const char *fmt,
|
||||||
...)
|
...)
|
||||||
{
|
{
|
||||||
json_t *json;
|
json_t *json;
|
||||||
va_list argp;
|
va_list argp;
|
||||||
@ -86,8 +86,8 @@ TMH_RESPONSE_reply_json_pack (struct MHD_Connection *connection,
|
|||||||
if (NULL == json)
|
if (NULL == json)
|
||||||
return MHD_NO;
|
return MHD_NO;
|
||||||
ret = TMH_RESPONSE_reply_json (connection,
|
ret = TMH_RESPONSE_reply_json (connection,
|
||||||
json,
|
json,
|
||||||
response_code);
|
response_code);
|
||||||
json_decref (json);
|
json_decref (json);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -102,33 +102,53 @@ TMH_RESPONSE_reply_json_pack (struct MHD_Connection *connection,
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TMH_RESPONSE_reply_arg_invalid (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_arg_invalid (struct MHD_Connection *connection,
|
||||||
const char *param_name)
|
const char *param_name)
|
||||||
{
|
{
|
||||||
return TMH_RESPONSE_reply_json_pack (connection,
|
return TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:s}",
|
"{s:s, s:s}",
|
||||||
"error", "invalid parameter",
|
"error", "invalid parameter",
|
||||||
"parameter", param_name);
|
"parameter", param_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a response indicating an invalid coin. (I.e. the signature
|
* Send a response indicating an argument refering to a
|
||||||
* over the public key of the coin does not match a valid signing key
|
* resource unknown to the mint (i.e. unknown reserve or
|
||||||
* of this mint).
|
* denomination key).
|
||||||
*
|
*
|
||||||
* @param connection the MHD connection to use
|
* @param connection the MHD connection to use
|
||||||
* @return MHD result code
|
* @param param_name the parameter that is invalid
|
||||||
|
* @return a MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TMH_RESPONSE_reply_coin_invalid (struct MHD_Connection *connection)
|
TMH_RESPONSE_reply_arg_unknown (struct MHD_Connection *connection,
|
||||||
|
const char *param_name)
|
||||||
{
|
{
|
||||||
/* TODO: may want to be more precise in the future and
|
|
||||||
distinguish bogus signatures from bogus public keys. */
|
|
||||||
return TMH_RESPONSE_reply_json_pack (connection,
|
return TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_NOT_FOUND,
|
MHD_HTTP_NOT_FOUND,
|
||||||
"{s:s}",
|
"{s:s, s:s}",
|
||||||
"error", "Coin is not valid");
|
"error", "unknown entity referenced",
|
||||||
|
"parameter", param_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a response indicating an invalid signature.
|
||||||
|
*
|
||||||
|
* @param connection the MHD connection to use
|
||||||
|
* @param param_name the parameter that is invalid
|
||||||
|
* @return a MHD result code
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
TMH_RESPONSE_reply_signature_invalid (struct MHD_Connection *connection,
|
||||||
|
const char *param_name)
|
||||||
|
{
|
||||||
|
return TMH_RESPONSE_reply_json_pack (connection,
|
||||||
|
MHD_HTTP_UNAUTHORIZED,
|
||||||
|
"{s:s, s:s}",
|
||||||
|
"error", "invalid signature",
|
||||||
|
"parameter", param_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -141,13 +161,13 @@ TMH_RESPONSE_reply_coin_invalid (struct MHD_Connection *connection)
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TMH_RESPONSE_reply_arg_missing (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_arg_missing (struct MHD_Connection *connection,
|
||||||
const char *param_name)
|
const char *param_name)
|
||||||
{
|
{
|
||||||
return TMH_RESPONSE_reply_json_pack (connection,
|
return TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{ s:s, s:s}",
|
"{ s:s, s:s}",
|
||||||
"error", "missing parameter",
|
"error", "missing parameter",
|
||||||
"parameter", param_name);
|
"parameter", param_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -160,13 +180,13 @@ TMH_RESPONSE_reply_arg_missing (struct MHD_Connection *connection,
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TMH_RESPONSE_reply_internal_error (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_internal_error (struct MHD_Connection *connection,
|
||||||
const char *hint)
|
const char *hint)
|
||||||
{
|
{
|
||||||
return TMH_RESPONSE_reply_json_pack (connection,
|
return TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_INTERNAL_SERVER_ERROR,
|
||||||
"{s:s, s:s}",
|
"{s:s, s:s}",
|
||||||
"error", "internal error",
|
"error", "internal error",
|
||||||
"hint", hint);
|
"hint", hint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -256,10 +276,10 @@ int
|
|||||||
TMH_RESPONSE_reply_invalid_json (struct MHD_Connection *connection)
|
TMH_RESPONSE_reply_invalid_json (struct MHD_Connection *connection)
|
||||||
{
|
{
|
||||||
return TMH_RESPONSE_reply_json_pack (connection,
|
return TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s}",
|
"{s:s}",
|
||||||
"error",
|
"error",
|
||||||
"invalid json");
|
"invalid json");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -312,10 +332,10 @@ TMH_RESPONSE_reply_deposit_success (struct MHD_Connection *connection,
|
|||||||
sig_json = TALER_json_from_eddsa_sig (&dc.purpose,
|
sig_json = TALER_json_from_eddsa_sig (&dc.purpose,
|
||||||
&sig.eddsa_signature);
|
&sig.eddsa_signature);
|
||||||
ret = TMH_RESPONSE_reply_json_pack (connection,
|
ret = TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_OK,
|
MHD_HTTP_OK,
|
||||||
"{s:s, s:o}",
|
"{s:s, s:o}",
|
||||||
"status", "DEPOSIT_OK",
|
"status", "DEPOSIT_OK",
|
||||||
"signature", sig_json);
|
"signature", sig_json);
|
||||||
json_decref (sig_json);
|
json_decref (sig_json);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -369,7 +389,7 @@ compile_transaction_history (const struct TALER_MINTDB_TransactionList *tl)
|
|||||||
{
|
{
|
||||||
struct TALER_RefreshMeltCoinAffirmationPS ms;
|
struct TALER_RefreshMeltCoinAffirmationPS ms;
|
||||||
const struct TALER_MINTDB_RefreshMelt *melt = pos->details.melt;
|
const struct TALER_MINTDB_RefreshMelt *melt = pos->details.melt;
|
||||||
|
t
|
||||||
type = "melt";
|
type = "melt";
|
||||||
value = melt->amount_with_fee;
|
value = melt->amount_with_fee;
|
||||||
ms.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_MELT);
|
ms.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_MELT);
|
||||||
@ -493,7 +513,7 @@ compile_reserve_history (const struct TALER_MINTDB_ReserveHistory *rh,
|
|||||||
case TALER_MINTDB_RO_WITHDRAW_COIN:
|
case TALER_MINTDB_RO_WITHDRAW_COIN:
|
||||||
|
|
||||||
dki = TMH_KS_denomination_key_lookup (key_state,
|
dki = TMH_KS_denomination_key_lookup (key_state,
|
||||||
&pos->details.withdraw->denom_pub);
|
&pos->details.withdraw->denom_pub);
|
||||||
TALER_amount_ntoh (&value,
|
TALER_amount_ntoh (&value,
|
||||||
&dki->issue.value);
|
&dki->issue.value);
|
||||||
if (0 == ret)
|
if (0 == ret)
|
||||||
@ -556,7 +576,7 @@ compile_reserve_history (const struct TALER_MINTDB_ReserveHistory *rh,
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TMH_RESPONSE_reply_withdraw_status_success (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_withdraw_status_success (struct MHD_Connection *connection,
|
||||||
const struct TALER_MINTDB_ReserveHistory *rh)
|
const struct TALER_MINTDB_ReserveHistory *rh)
|
||||||
{
|
{
|
||||||
json_t *json_balance;
|
json_t *json_balance;
|
||||||
json_t *json_history;
|
json_t *json_history;
|
||||||
@ -567,13 +587,13 @@ TMH_RESPONSE_reply_withdraw_status_success (struct MHD_Connection *connection,
|
|||||||
&balance);
|
&balance);
|
||||||
if (NULL == json_history)
|
if (NULL == json_history)
|
||||||
return TMH_RESPONSE_reply_internal_error (connection,
|
return TMH_RESPONSE_reply_internal_error (connection,
|
||||||
"balance calculation failure");
|
"balance calculation failure");
|
||||||
json_balance = TALER_json_from_amount (&balance);
|
json_balance = TALER_json_from_amount (&balance);
|
||||||
ret = TMH_RESPONSE_reply_json_pack (connection,
|
ret = TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_OK,
|
MHD_HTTP_OK,
|
||||||
"{s:o, s:o}",
|
"{s:o, s:o}",
|
||||||
"balance", json_balance,
|
"balance", json_balance,
|
||||||
"history", json_history);
|
"history", json_history);
|
||||||
json_decref (json_history);
|
json_decref (json_history);
|
||||||
json_decref (json_balance);
|
json_decref (json_balance);
|
||||||
return ret;
|
return ret;
|
||||||
@ -591,7 +611,7 @@ TMH_RESPONSE_reply_withdraw_status_success (struct MHD_Connection *connection,
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TMH_RESPONSE_reply_withdraw_sign_insufficient_funds (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_withdraw_sign_insufficient_funds (struct MHD_Connection *connection,
|
||||||
const struct TALER_MINTDB_ReserveHistory *rh)
|
const struct TALER_MINTDB_ReserveHistory *rh)
|
||||||
{
|
{
|
||||||
json_t *json_balance;
|
json_t *json_balance;
|
||||||
json_t *json_history;
|
json_t *json_history;
|
||||||
@ -602,14 +622,14 @@ TMH_RESPONSE_reply_withdraw_sign_insufficient_funds (struct MHD_Connection *conn
|
|||||||
&balance);
|
&balance);
|
||||||
if (NULL == json_history)
|
if (NULL == json_history)
|
||||||
return TMH_RESPONSE_reply_internal_error (connection,
|
return TMH_RESPONSE_reply_internal_error (connection,
|
||||||
"balance calculation failure");
|
"balance calculation failure");
|
||||||
json_balance = TALER_json_from_amount (&balance);
|
json_balance = TALER_json_from_amount (&balance);
|
||||||
ret = TMH_RESPONSE_reply_json_pack (connection,
|
ret = TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_PAYMENT_REQUIRED,
|
MHD_HTTP_PAYMENT_REQUIRED,
|
||||||
"{s:s, s:o, s:o}",
|
"{s:s, s:o, s:o}",
|
||||||
"error", "Insufficient funds"
|
"error", "Insufficient funds"
|
||||||
"balance", json_balance,
|
"balance", json_balance,
|
||||||
"history", json_history);
|
"history", json_history);
|
||||||
json_decref (json_history);
|
json_decref (json_history);
|
||||||
json_decref (json_balance);
|
json_decref (json_balance);
|
||||||
return ret;
|
return ret;
|
||||||
@ -625,16 +645,16 @@ TMH_RESPONSE_reply_withdraw_sign_insufficient_funds (struct MHD_Connection *conn
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TMH_RESPONSE_reply_withdraw_sign_success (struct MHD_Connection *connection,
|
TMH_RESPONSE_reply_withdraw_sign_success (struct MHD_Connection *connection,
|
||||||
const struct TALER_MINTDB_CollectableBlindcoin *collectable)
|
const struct TALER_MINTDB_CollectableBlindcoin *collectable)
|
||||||
{
|
{
|
||||||
json_t *sig_json;
|
json_t *sig_json;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
sig_json = TALER_json_from_rsa_signature (collectable->sig.rsa_signature);
|
sig_json = TALER_json_from_rsa_signature (collectable->sig.rsa_signature);
|
||||||
ret = TMH_RESPONSE_reply_json_pack (connection,
|
ret = TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_OK,
|
MHD_HTTP_OK,
|
||||||
"{s:o}",
|
"{s:o}",
|
||||||
"ev_sig", sig_json);
|
"ev_sig", sig_json);
|
||||||
json_decref (sig_json);
|
json_decref (sig_json);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -774,12 +794,12 @@ TMH_RESPONSE_reply_refresh_reveal_missmatch (struct MHD_Connection *connection,
|
|||||||
const char *missmatch_object)
|
const char *missmatch_object)
|
||||||
{
|
{
|
||||||
return TMH_RESPONSE_reply_json_pack (connection,
|
return TMH_RESPONSE_reply_json_pack (connection,
|
||||||
MHD_HTTP_BAD_REQUEST,
|
MHD_HTTP_BAD_REQUEST,
|
||||||
"{s:s, s:i, s:i, s:s}",
|
"{s:s, s:i, s:i, s:s}",
|
||||||
"error", "commitment violation",
|
"error", "commitment violation",
|
||||||
"offset", (int) off,
|
"offset", (int) off,
|
||||||
"index", (int) j,
|
"index", (int) j,
|
||||||
"object", missmatch_object);
|
"object", missmatch_object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,6 +64,18 @@ TMH_RESPONSE_reply_json_pack (struct MHD_Connection *connection,
|
|||||||
...);
|
...);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a response indicating an invalid signature.
|
||||||
|
*
|
||||||
|
* @param connection the MHD connection to use
|
||||||
|
* @param param_name the parameter that is invalid
|
||||||
|
* @return a MHD result code
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
TMH_RESPONSE_reply_signature_invalid (struct MHD_Connection *connection,
|
||||||
|
const char *param_name);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a response indicating an invalid argument.
|
* Send a response indicating an invalid argument.
|
||||||
*
|
*
|
||||||
@ -77,15 +89,17 @@ TMH_RESPONSE_reply_arg_invalid (struct MHD_Connection *connection,
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a response indicating an invalid coin. (I.e. the signature
|
* Send a response indicating an argument refering to a
|
||||||
* over the public key of the coin does not match a valid signing key
|
* resource unknown to the mint (i.e. unknown reserve or
|
||||||
* of this mint).
|
* denomination key).
|
||||||
*
|
*
|
||||||
* @param connection the MHD connection to use
|
* @param connection the MHD connection to use
|
||||||
* @return MHD result code
|
* @param param_name the parameter that is invalid
|
||||||
|
* @return a MHD result code
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
TMH_RESPONSE_reply_coin_invalid (struct MHD_Connection *connection);
|
TMH_RESPONSE_reply_arg_unknown (struct MHD_Connection *connection,
|
||||||
|
const char *param_name);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,7 +61,7 @@ TMH_WITHDRAW_handler_withdraw_status (struct TMH_RequestHandler *rh,
|
|||||||
if (GNUNET_NO == res)
|
if (GNUNET_NO == res)
|
||||||
return MHD_YES; /* parse error */
|
return MHD_YES; /* parse error */
|
||||||
return TMH_DB_execute_withdraw_status (connection,
|
return TMH_DB_execute_withdraw_status (connection,
|
||||||
&reserve_pub);
|
&reserve_pub);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ TMH_WITHDRAW_handler_withdraw_sign (struct TMH_RequestHandler *rh,
|
|||||||
if (NULL == dki)
|
if (NULL == dki)
|
||||||
{
|
{
|
||||||
TMH_PARSE_release_data (spec);
|
TMH_PARSE_release_data (spec);
|
||||||
return TMH_RESPONSE_reply_arg_invalid (connection,
|
return TMH_RESPONSE_reply_arg_unknown (connection,
|
||||||
"denom_pub");
|
"denom_pub");
|
||||||
}
|
}
|
||||||
TALER_amount_ntoh (&amount,
|
TALER_amount_ntoh (&amount,
|
||||||
@ -165,8 +165,8 @@ TMH_WITHDRAW_handler_withdraw_sign (struct TMH_RequestHandler *rh,
|
|||||||
{
|
{
|
||||||
TALER_LOG_WARNING ("Client supplied invalid signature for /withdraw/sign request\n");
|
TALER_LOG_WARNING ("Client supplied invalid signature for /withdraw/sign request\n");
|
||||||
TMH_PARSE_release_data (spec);
|
TMH_PARSE_release_data (spec);
|
||||||
return TMH_RESPONSE_reply_arg_invalid (connection,
|
return TMH_RESPONSE_reply_signature_invalid (connection,
|
||||||
"reserve_sig");
|
"reserve_sig");
|
||||||
}
|
}
|
||||||
res = TMH_DB_execute_withdraw_sign (connection,
|
res = TMH_DB_execute_withdraw_sign (connection,
|
||||||
&wsrd.reserve_pub,
|
&wsrd.reserve_pub,
|
||||||
|
@ -84,7 +84,8 @@ TALER_json_from_abs (struct GNUNET_TIME_Absolute stamp)
|
|||||||
json_t *j;
|
json_t *j;
|
||||||
char *mystr;
|
char *mystr;
|
||||||
int ret;
|
int ret;
|
||||||
ret = GNUNET_asprintf (&mystr, "%llu",
|
ret = GNUNET_asprintf (&mystr,
|
||||||
|
"%llu",
|
||||||
(long long) (stamp.abs_value_us / (1000 * 1000)));
|
(long long) (stamp.abs_value_us / (1000 * 1000)));
|
||||||
GNUNET_assert (ret > 0);
|
GNUNET_assert (ret > 0);
|
||||||
j = json_string (mystr);
|
j = json_string (mystr);
|
||||||
@ -117,11 +118,11 @@ TALER_json_from_eddsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpo
|
|||||||
|
|
||||||
el = TALER_json_from_data (purpose,
|
el = TALER_json_from_data (purpose,
|
||||||
ntohl (purpose->size));
|
ntohl (purpose->size));
|
||||||
json_object_set_new (root, "eddsa-val", el);
|
json_object_set_new (root, "eddsa_val", el);
|
||||||
|
|
||||||
el = TALER_json_from_data (signature,
|
el = TALER_json_from_data (signature,
|
||||||
sizeof (struct GNUNET_CRYPTO_EddsaSignature));
|
sizeof (struct GNUNET_CRYPTO_EddsaSignature));
|
||||||
json_object_set_new (root, "eddsa-sig", el);
|
json_object_set_new (root, "eddsa_sig", el);
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
@ -151,11 +152,11 @@ TALER_json_from_ecdsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpo
|
|||||||
|
|
||||||
el = TALER_json_from_data (purpose,
|
el = TALER_json_from_data (purpose,
|
||||||
ntohl (purpose->size));
|
ntohl (purpose->size));
|
||||||
json_object_set_new (root, "ecdsa-val", el);
|
json_object_set_new (root, "ecdsa_val", el);
|
||||||
|
|
||||||
el = TALER_json_from_data (signature,
|
el = TALER_json_from_data (signature,
|
||||||
sizeof (struct GNUNET_CRYPTO_EddsaSignature));
|
sizeof (struct GNUNET_CRYPTO_EddsaSignature));
|
||||||
json_object_set_new (root, "ecdsa-sig", el);
|
json_object_set_new (root, "ecdsa_sig", el);
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user