improve status codes returned in case of denomination key troubles
This commit is contained in:
parent
40d9674856
commit
375a47d502
@ -250,6 +250,8 @@ verify_and_execute_deposit (struct MHD_Connection *connection,
|
|||||||
struct DepositContext dc;
|
struct DepositContext dc;
|
||||||
struct TEH_KS_StateHandle *mks;
|
struct TEH_KS_StateHandle *mks;
|
||||||
const struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki;
|
const struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki;
|
||||||
|
enum TALER_ErrorCode ec;
|
||||||
|
unsigned int hc;
|
||||||
|
|
||||||
/* check signature */
|
/* check signature */
|
||||||
dr.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_DEPOSIT);
|
dr.purpose.purpose = htonl (TALER_SIGNATURE_WALLET_COIN_DEPOSIT);
|
||||||
@ -287,12 +289,15 @@ verify_and_execute_deposit (struct MHD_Connection *connection,
|
|||||||
}
|
}
|
||||||
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,
|
||||||
TEH_KS_DKU_DEPOSIT);
|
TEH_KS_DKU_DEPOSIT,
|
||||||
|
&ec,
|
||||||
|
&hc);
|
||||||
if (NULL == dki)
|
if (NULL == dki)
|
||||||
{
|
{
|
||||||
TEH_KS_release (mks);
|
TEH_KS_release (mks);
|
||||||
return TEH_RESPONSE_reply_internal_db_error (connection,
|
return TEH_RESPONSE_reply_with_error (connection,
|
||||||
TALER_EC_DEPOSIT_DB_DENOMINATION_KEY_UNKNOWN);
|
ec,
|
||||||
|
hc);
|
||||||
}
|
}
|
||||||
TALER_amount_ntoh (&dc.value,
|
TALER_amount_ntoh (&dc.value,
|
||||||
&dki->issue.properties.value);
|
&dki->issue.properties.value);
|
||||||
@ -388,6 +393,7 @@ TEH_DEPOSIT_handler_deposit (struct TEH_RequestHandler *rh,
|
|||||||
json_t *wire;
|
json_t *wire;
|
||||||
char *emsg;
|
char *emsg;
|
||||||
enum TALER_ErrorCode ec;
|
enum TALER_ErrorCode ec;
|
||||||
|
unsigned int hc;
|
||||||
struct TALER_EXCHANGEDB_Deposit deposit;
|
struct TALER_EXCHANGEDB_Deposit deposit;
|
||||||
struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki;
|
struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki;
|
||||||
struct TEH_KS_StateHandle *key_state;
|
struct TEH_KS_StateHandle *key_state;
|
||||||
@ -497,16 +503,17 @@ TEH_DEPOSIT_handler_deposit (struct TEH_RequestHandler *rh,
|
|||||||
}
|
}
|
||||||
dki = TEH_KS_denomination_key_lookup_by_hash (key_state,
|
dki = TEH_KS_denomination_key_lookup_by_hash (key_state,
|
||||||
&deposit.coin.denom_pub_hash,
|
&deposit.coin.denom_pub_hash,
|
||||||
TEH_KS_DKU_DEPOSIT);
|
TEH_KS_DKU_DEPOSIT,
|
||||||
|
&ec,
|
||||||
|
&hc);
|
||||||
if (NULL == dki)
|
if (NULL == dki)
|
||||||
{
|
{
|
||||||
/* FIXME: #3887: if DK was revoked, we might want to give a 403 and not a 404! */
|
|
||||||
TEH_KS_release (key_state);
|
TEH_KS_release (key_state);
|
||||||
TALER_LOG_WARNING ("Unknown denomination key in /deposit request\n");
|
TALER_LOG_WARNING ("Unknown denomination key in /deposit request\n");
|
||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
return TEH_RESPONSE_reply_arg_unknown (connection,
|
return TEH_RESPONSE_reply_with_error (connection,
|
||||||
TALER_EC_DEPOSIT_DENOMINATION_KEY_UNKNOWN,
|
ec,
|
||||||
"denom_pub");
|
hc);
|
||||||
}
|
}
|
||||||
TALER_amount_ntoh (&deposit.deposit_fee,
|
TALER_amount_ntoh (&deposit.deposit_fee,
|
||||||
&dki->issue.properties.fee_deposit);
|
&dki->issue.properties.fee_deposit);
|
||||||
|
@ -1954,6 +1954,8 @@ TEH_KS_acquire_ (struct GNUNET_TIME_Absolute now,
|
|||||||
* @param key_state state to look in
|
* @param key_state state to look in
|
||||||
* @param denom_pub_hash hash of denomination public key
|
* @param denom_pub_hash hash of denomination public key
|
||||||
* @param use purpose for which the key is being located
|
* @param use purpose for which the key is being located
|
||||||
|
* @param ec[out] set to the error code, in case the operation failed
|
||||||
|
* @param hc[out] set to the HTTP status code to use
|
||||||
* @return the denomination key issue,
|
* @return the denomination key issue,
|
||||||
* or NULL if denom_pub could not be found (or is not valid at this time for the given @a use)
|
* or NULL if denom_pub could not be found (or is not valid at this time for the given @a use)
|
||||||
*/
|
*/
|
||||||
@ -1962,7 +1964,9 @@ TEH_KS_denomination_key_lookup_by_hash (const struct
|
|||||||
TEH_KS_StateHandle *key_state,
|
TEH_KS_StateHandle *key_state,
|
||||||
const struct
|
const struct
|
||||||
GNUNET_HashCode *denom_pub_hash,
|
GNUNET_HashCode *denom_pub_hash,
|
||||||
enum TEH_KS_DenominationKeyUse use)
|
enum TEH_KS_DenominationKeyUse use,
|
||||||
|
enum TALER_ErrorCode *ec,
|
||||||
|
unsigned int *hc)
|
||||||
{
|
{
|
||||||
struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki;
|
struct TALER_EXCHANGEDB_DenominationKeyIssueInformation *dki;
|
||||||
struct GNUNET_TIME_Absolute now;
|
struct GNUNET_TIME_Absolute now;
|
||||||
@ -1976,7 +1980,25 @@ TEH_KS_denomination_key_lookup_by_hash (const struct
|
|||||||
dki = GNUNET_CONTAINER_multihashmap_get (key_state->revoked_map,
|
dki = GNUNET_CONTAINER_multihashmap_get (key_state->revoked_map,
|
||||||
denom_pub_hash);
|
denom_pub_hash);
|
||||||
if (NULL == dki)
|
if (NULL == dki)
|
||||||
|
{
|
||||||
|
*hc = MHD_HTTP_NOT_FOUND;
|
||||||
|
switch (use)
|
||||||
|
{
|
||||||
|
case TEH_KS_DKU_PAYBACK:
|
||||||
|
*ec = TALER_EC_PAYBACK_DENOMINATION_KEY_UNKNOWN;
|
||||||
|
break;
|
||||||
|
case TEH_KS_DKU_ZOMBIE:
|
||||||
|
*ec = TALER_EC_REFRESH_PAYBACK_DENOMINATION_KEY_NOT_FOUND;
|
||||||
|
break;
|
||||||
|
case TEH_KS_DKU_WITHDRAW:
|
||||||
|
*ec = TALER_EC_WITHDRAW_DENOMINATION_KEY_NOT_FOUND;
|
||||||
|
break;
|
||||||
|
case TEH_KS_DKU_DEPOSIT:
|
||||||
|
*ec = TALER_EC_DEPOSIT_DENOMINATION_KEY_UNKNOWN;
|
||||||
|
break;
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
now = GNUNET_TIME_absolute_get ();
|
now = GNUNET_TIME_absolute_get ();
|
||||||
if (now.abs_value_us <
|
if (now.abs_value_us <
|
||||||
GNUNET_TIME_absolute_ntoh (dki->issue.properties.start).abs_value_us)
|
GNUNET_TIME_absolute_ntoh (dki->issue.properties.start).abs_value_us)
|
||||||
@ -1984,6 +2006,22 @@ TEH_KS_denomination_key_lookup_by_hash (const struct
|
|||||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||||
"Not returning DKI for %s, as start time is in the future\n",
|
"Not returning DKI for %s, as start time is in the future\n",
|
||||||
GNUNET_h2s (denom_pub_hash));
|
GNUNET_h2s (denom_pub_hash));
|
||||||
|
*hc = MHD_HTTP_PRECONDITION_FAILED;
|
||||||
|
switch (use)
|
||||||
|
{
|
||||||
|
case TEH_KS_DKU_PAYBACK:
|
||||||
|
*ec = TALER_EC_PAYBACK_DENOMINATION_VALIDITY_IN_FUTURE;
|
||||||
|
break;
|
||||||
|
case TEH_KS_DKU_ZOMBIE:
|
||||||
|
*ec = TALER_EC_REFRESH_PAYBACK_DENOMINATION_VALIDITY_IN_FUTURE;
|
||||||
|
break;
|
||||||
|
case TEH_KS_DKU_WITHDRAW:
|
||||||
|
*ec = TALER_EC_WITHDRAW_VALIDITY_IN_FUTURE;
|
||||||
|
break;
|
||||||
|
case TEH_KS_DKU_DEPOSIT:
|
||||||
|
*ec = TALER_EC_DEPOSIT_DENOMINATION_VALIDITY_IN_FUTURE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
now = GNUNET_TIME_absolute_get ();
|
now = GNUNET_TIME_absolute_get ();
|
||||||
@ -1997,6 +2035,8 @@ TEH_KS_denomination_key_lookup_by_hash (const struct
|
|||||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||||
"Not returning DKI for %s, as time to create coins has passed\n",
|
"Not returning DKI for %s, as time to create coins has passed\n",
|
||||||
GNUNET_h2s (denom_pub_hash));
|
GNUNET_h2s (denom_pub_hash));
|
||||||
|
*ec = TALER_EC_WITHDRAW_VALIDITY_IN_PAST;
|
||||||
|
*hc = MHD_HTTP_GONE;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (NULL == dki->denom_priv.rsa_private_key)
|
if (NULL == dki->denom_priv.rsa_private_key)
|
||||||
@ -2004,6 +2044,8 @@ TEH_KS_denomination_key_lookup_by_hash (const struct
|
|||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"Not returning DKI of %s for WITHDRAW operation as we lack the private key, even though the withdraw period did not yet expire!\n",
|
"Not returning DKI of %s for WITHDRAW operation as we lack the private key, even though the withdraw period did not yet expire!\n",
|
||||||
GNUNET_h2s (denom_pub_hash));
|
GNUNET_h2s (denom_pub_hash));
|
||||||
|
*ec = TALER_EC_DENOMINATION_KEY_LOST;
|
||||||
|
*hc = MHD_HTTP_SERVICE_UNAVAILABLE;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -2015,6 +2057,8 @@ TEH_KS_denomination_key_lookup_by_hash (const struct
|
|||||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||||
"Not returning DKI for %s, as time to spend coin has passed\n",
|
"Not returning DKI for %s, as time to spend coin has passed\n",
|
||||||
GNUNET_h2s (denom_pub_hash));
|
GNUNET_h2s (denom_pub_hash));
|
||||||
|
*ec = TALER_EC_DEPOSIT_DENOMINATION_EXPIRED;
|
||||||
|
*hc = MHD_HTTP_GONE;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -2026,6 +2070,8 @@ TEH_KS_denomination_key_lookup_by_hash (const struct
|
|||||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||||
"Not returning DKI for %s, as time to payback coin has passed\n",
|
"Not returning DKI for %s, as time to payback coin has passed\n",
|
||||||
GNUNET_h2s (denom_pub_hash));
|
GNUNET_h2s (denom_pub_hash));
|
||||||
|
*ec = TALER_EC_REFRESH_PAYBACK_DENOMINATION_EXPIRED;
|
||||||
|
*hc = MHD_HTTP_GONE;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -2037,6 +2083,8 @@ TEH_KS_denomination_key_lookup_by_hash (const struct
|
|||||||
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
||||||
"Not returning DKI for %s, as legal expiration of coin has passed\n",
|
"Not returning DKI for %s, as legal expiration of coin has passed\n",
|
||||||
GNUNET_h2s (denom_pub_hash));
|
GNUNET_h2s (denom_pub_hash));
|
||||||
|
*ec = TALER_EC_REFRESH_ZOMBIE_DENOMINATION_EXPIRED;
|
||||||
|
*hc = MHD_HTTP_GONE;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -129,6 +129,8 @@ enum TEH_KS_DenominationKeyUse
|
|||||||
* @param key_state state to look in
|
* @param key_state state to look in
|
||||||
* @param denom_pub_hash hash of denomination public key
|
* @param denom_pub_hash hash of denomination public key
|
||||||
* @param use purpose for which the key is being located
|
* @param use purpose for which the key is being located
|
||||||
|
* @param ec[out] set to the error code, in case the operation failed
|
||||||
|
* @param hc[out] set to the HTTP status code to use
|
||||||
* @return the denomination key issue,
|
* @return the denomination key issue,
|
||||||
* or NULL if denom_pub could not be found (or is not valid at this time for the given @a use)
|
* or NULL if denom_pub could not be found (or is not valid at this time for the given @a use)
|
||||||
*/
|
*/
|
||||||
@ -137,7 +139,9 @@ TEH_KS_denomination_key_lookup_by_hash (const struct
|
|||||||
TEH_KS_StateHandle *key_state,
|
TEH_KS_StateHandle *key_state,
|
||||||
const struct
|
const struct
|
||||||
GNUNET_HashCode *denom_pub_hash,
|
GNUNET_HashCode *denom_pub_hash,
|
||||||
enum TEH_KS_DenominationKeyUse use);
|
enum TEH_KS_DenominationKeyUse use,
|
||||||
|
enum TALER_ErrorCode *ec,
|
||||||
|
unsigned int *hc);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -429,6 +429,8 @@ verify_and_execute_payback (struct MHD_Connection *connection,
|
|||||||
struct GNUNET_HashCode c_hash;
|
struct GNUNET_HashCode c_hash;
|
||||||
char *coin_ev;
|
char *coin_ev;
|
||||||
size_t coin_ev_size;
|
size_t coin_ev_size;
|
||||||
|
enum TALER_ErrorCode ec;
|
||||||
|
unsigned int hc;
|
||||||
|
|
||||||
/* check denomination exists and is in payback mode */
|
/* check denomination exists and is in payback mode */
|
||||||
key_state = TEH_KS_acquire (GNUNET_TIME_absolute_get ());
|
key_state = TEH_KS_acquire (GNUNET_TIME_absolute_get ());
|
||||||
@ -441,15 +443,17 @@ verify_and_execute_payback (struct MHD_Connection *connection,
|
|||||||
}
|
}
|
||||||
dki = TEH_KS_denomination_key_lookup_by_hash (key_state,
|
dki = TEH_KS_denomination_key_lookup_by_hash (key_state,
|
||||||
&coin->denom_pub_hash,
|
&coin->denom_pub_hash,
|
||||||
TEH_KS_DKU_PAYBACK);
|
TEH_KS_DKU_PAYBACK,
|
||||||
|
&ec,
|
||||||
|
&hc);
|
||||||
if (NULL == dki)
|
if (NULL == dki)
|
||||||
{
|
{
|
||||||
TEH_KS_release (key_state);
|
TEH_KS_release (key_state);
|
||||||
TALER_LOG_WARNING (
|
TALER_LOG_WARNING (
|
||||||
"Denomination key in /payback request not in payback mode\n");
|
"Denomination key in /payback request not in payback mode\n");
|
||||||
return TEH_RESPONSE_reply_arg_unknown (connection,
|
return TEH_RESPONSE_reply_with_error (connection,
|
||||||
TALER_EC_PAYBACK_DENOMINATION_KEY_UNKNOWN,
|
ec,
|
||||||
"denom_pub");
|
hc);
|
||||||
}
|
}
|
||||||
TALER_amount_ntoh (&pc.value,
|
TALER_amount_ntoh (&pc.value,
|
||||||
&dki->issue.properties.value);
|
&dki->issue.properties.value);
|
||||||
|
@ -447,6 +447,8 @@ TEH_REFRESH_handler_refresh_melt (struct TEH_RequestHandler *rh,
|
|||||||
json_t *root;
|
json_t *root;
|
||||||
struct RefreshMeltContext rmc;
|
struct RefreshMeltContext rmc;
|
||||||
int res;
|
int res;
|
||||||
|
unsigned int hc;
|
||||||
|
enum TALER_ErrorCode ec;
|
||||||
struct TEH_KS_StateHandle *key_state;
|
struct TEH_KS_StateHandle *key_state;
|
||||||
struct GNUNET_JSON_Specification spec[] = {
|
struct GNUNET_JSON_Specification spec[] = {
|
||||||
GNUNET_JSON_spec_fixed_auto ("coin_pub",
|
GNUNET_JSON_spec_fixed_auto ("coin_pub",
|
||||||
@ -501,7 +503,9 @@ TEH_REFRESH_handler_refresh_melt (struct TEH_RequestHandler *rh,
|
|||||||
rmc.dki = TEH_KS_denomination_key_lookup_by_hash (key_state,
|
rmc.dki = TEH_KS_denomination_key_lookup_by_hash (key_state,
|
||||||
&rmc.refresh_session.coin.
|
&rmc.refresh_session.coin.
|
||||||
denom_pub_hash,
|
denom_pub_hash,
|
||||||
TEH_KS_DKU_DEPOSIT);
|
TEH_KS_DKU_DEPOSIT,
|
||||||
|
&ec,
|
||||||
|
&hc);
|
||||||
/* Consider case that denomination was revoked but
|
/* Consider case that denomination was revoked but
|
||||||
this coin was already seen and thus refresh is OK. */
|
this coin was already seen and thus refresh is OK. */
|
||||||
if (NULL == rmc.dki)
|
if (NULL == rmc.dki)
|
||||||
@ -511,7 +515,9 @@ TEH_REFRESH_handler_refresh_melt (struct TEH_RequestHandler *rh,
|
|||||||
dki = TEH_KS_denomination_key_lookup_by_hash (key_state,
|
dki = TEH_KS_denomination_key_lookup_by_hash (key_state,
|
||||||
&rmc.refresh_session.coin.
|
&rmc.refresh_session.coin.
|
||||||
denom_pub_hash,
|
denom_pub_hash,
|
||||||
TEH_KS_DKU_PAYBACK);
|
TEH_KS_DKU_PAYBACK,
|
||||||
|
&ec,
|
||||||
|
&hc);
|
||||||
if (NULL != dki)
|
if (NULL != dki)
|
||||||
{
|
{
|
||||||
struct TALER_CoinPublicInfo coin_info;
|
struct TALER_CoinPublicInfo coin_info;
|
||||||
@ -547,7 +553,9 @@ TEH_REFRESH_handler_refresh_melt (struct TEH_RequestHandler *rh,
|
|||||||
dki = TEH_KS_denomination_key_lookup_by_hash (key_state,
|
dki = TEH_KS_denomination_key_lookup_by_hash (key_state,
|
||||||
&rmc.refresh_session.coin.
|
&rmc.refresh_session.coin.
|
||||||
denom_pub_hash,
|
denom_pub_hash,
|
||||||
TEH_KS_DKU_ZOMBIE);
|
TEH_KS_DKU_ZOMBIE,
|
||||||
|
&ec,
|
||||||
|
&hc);
|
||||||
if (NULL != dki)
|
if (NULL != dki)
|
||||||
{
|
{
|
||||||
rmc.dki = dki;
|
rmc.dki = dki;
|
||||||
@ -558,9 +566,9 @@ TEH_REFRESH_handler_refresh_melt (struct TEH_RequestHandler *rh,
|
|||||||
if (NULL == rmc.dki)
|
if (NULL == rmc.dki)
|
||||||
{
|
{
|
||||||
TALER_LOG_WARNING ("Unknown denomination key in /refresh/melt request\n");
|
TALER_LOG_WARNING ("Unknown denomination key in /refresh/melt request\n");
|
||||||
res = TEH_RESPONSE_reply_arg_unknown (connection,
|
res = TEH_RESPONSE_reply_with_error (connection,
|
||||||
TALER_EC_REFRESH_MELT_DENOMINATION_KEY_NOT_FOUND,
|
ec,
|
||||||
"denom_pub");
|
hc);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -610,6 +610,8 @@ handle_refresh_reveal_json (struct MHD_Connection *connection,
|
|||||||
&dki_h[i]),
|
&dki_h[i]),
|
||||||
GNUNET_JSON_spec_end ()
|
GNUNET_JSON_spec_end ()
|
||||||
};
|
};
|
||||||
|
unsigned int hc;
|
||||||
|
enum TALER_ErrorCode ec;
|
||||||
|
|
||||||
res = TEH_PARSE_json_array (connection,
|
res = TEH_PARSE_json_array (connection,
|
||||||
new_denoms_h_json,
|
new_denoms_h_json,
|
||||||
@ -623,13 +625,15 @@ handle_refresh_reveal_json (struct MHD_Connection *connection,
|
|||||||
}
|
}
|
||||||
dkis[i] = TEH_KS_denomination_key_lookup_by_hash (key_state,
|
dkis[i] = TEH_KS_denomination_key_lookup_by_hash (key_state,
|
||||||
&dki_h[i],
|
&dki_h[i],
|
||||||
TEH_KS_DKU_WITHDRAW);
|
TEH_KS_DKU_WITHDRAW,
|
||||||
|
&ec,
|
||||||
|
&hc);
|
||||||
if (NULL == dkis[i])
|
if (NULL == dkis[i])
|
||||||
{
|
{
|
||||||
TEH_KS_release (key_state);
|
TEH_KS_release (key_state);
|
||||||
return TEH_RESPONSE_reply_arg_invalid (connection,
|
return TEH_RESPONSE_reply_with_error (connection,
|
||||||
TALER_EC_REFRESH_REVEAL_FRESH_DENOMINATION_KEY_NOT_FOUND,
|
ec,
|
||||||
"new_denoms_h");
|
hc);
|
||||||
}
|
}
|
||||||
GNUNET_assert (NULL != dkis[i]->denom_priv.rsa_private_key);
|
GNUNET_assert (NULL != dkis[i]->denom_priv.rsa_private_key);
|
||||||
}
|
}
|
||||||
|
@ -161,6 +161,8 @@ refund_transaction (void *cls,
|
|||||||
int deposit_found;
|
int deposit_found;
|
||||||
int refund_found;
|
int refund_found;
|
||||||
int fee_cmp;
|
int fee_cmp;
|
||||||
|
unsigned int hc;
|
||||||
|
enum TALER_ErrorCode ec;
|
||||||
|
|
||||||
dep = NULL;
|
dep = NULL;
|
||||||
ref = NULL;
|
ref = NULL;
|
||||||
@ -354,7 +356,9 @@ refund_transaction (void *cls,
|
|||||||
}
|
}
|
||||||
dki = TEH_KS_denomination_key_lookup_by_hash (mks,
|
dki = TEH_KS_denomination_key_lookup_by_hash (mks,
|
||||||
&dep->coin.denom_pub_hash,
|
&dep->coin.denom_pub_hash,
|
||||||
TEH_KS_DKU_DEPOSIT);
|
TEH_KS_DKU_DEPOSIT,
|
||||||
|
&ec,
|
||||||
|
&hc);
|
||||||
if (NULL == dki)
|
if (NULL == dki)
|
||||||
{
|
{
|
||||||
/* DKI not found, but we do have a coin with this DK in our database;
|
/* DKI not found, but we do have a coin with this DK in our database;
|
||||||
@ -363,9 +367,9 @@ refund_transaction (void *cls,
|
|||||||
TEH_KS_release (mks);
|
TEH_KS_release (mks);
|
||||||
TEH_plugin->free_coin_transaction_list (TEH_plugin->cls,
|
TEH_plugin->free_coin_transaction_list (TEH_plugin->cls,
|
||||||
tl);
|
tl);
|
||||||
*mhd_ret = TEH_RESPONSE_reply_internal_error (connection,
|
*mhd_ret = TEH_RESPONSE_reply_with_error (connection,
|
||||||
TALER_EC_REFUND_DENOMINATION_KEY_NOT_FOUND,
|
ec,
|
||||||
"denomination key not found");
|
hc);
|
||||||
return GNUNET_DB_STATUS_HARD_ERROR;
|
return GNUNET_DB_STATUS_HARD_ERROR;
|
||||||
}
|
}
|
||||||
TALER_amount_ntoh (&expect_fee,
|
TALER_amount_ntoh (&expect_fee,
|
||||||
|
@ -365,6 +365,8 @@ TEH_RESERVE_handler_reserve_withdraw (struct TEH_RequestHandler *rh,
|
|||||||
json_t *root;
|
json_t *root;
|
||||||
int res;
|
int res;
|
||||||
int mhd_ret;
|
int mhd_ret;
|
||||||
|
unsigned int hc;
|
||||||
|
enum TALER_ErrorCode ec;
|
||||||
struct TALER_Amount amount;
|
struct TALER_Amount amount;
|
||||||
struct TALER_Amount fee_withdraw;
|
struct TALER_Amount fee_withdraw;
|
||||||
struct GNUNET_JSON_Specification spec[] = {
|
struct GNUNET_JSON_Specification spec[] = {
|
||||||
@ -407,14 +409,16 @@ TEH_RESERVE_handler_reserve_withdraw (struct TEH_RequestHandler *rh,
|
|||||||
}
|
}
|
||||||
wc.dki = TEH_KS_denomination_key_lookup_by_hash (wc.key_state,
|
wc.dki = TEH_KS_denomination_key_lookup_by_hash (wc.key_state,
|
||||||
&wc.denom_pub_hash,
|
&wc.denom_pub_hash,
|
||||||
TEH_KS_DKU_WITHDRAW);
|
TEH_KS_DKU_WITHDRAW,
|
||||||
|
&ec,
|
||||||
|
&hc);
|
||||||
if (NULL == wc.dki)
|
if (NULL == wc.dki)
|
||||||
{
|
{
|
||||||
GNUNET_JSON_parse_free (spec);
|
GNUNET_JSON_parse_free (spec);
|
||||||
TEH_KS_release (wc.key_state);
|
TEH_KS_release (wc.key_state);
|
||||||
return TEH_RESPONSE_reply_arg_unknown (connection,
|
return TEH_RESPONSE_reply_with_error (connection,
|
||||||
TALER_EC_WITHDRAW_DENOMINATION_KEY_NOT_FOUND,
|
ec,
|
||||||
"denom_pub");
|
hc);
|
||||||
}
|
}
|
||||||
GNUNET_assert (NULL != wc.dki->denom_priv.rsa_private_key);
|
GNUNET_assert (NULL != wc.dki->denom_priv.rsa_private_key);
|
||||||
TALER_amount_ntoh (&amount,
|
TALER_amount_ntoh (&amount,
|
||||||
|
@ -361,6 +361,26 @@ TEH_RESPONSE_reply_internal_error (struct MHD_Connection *connection,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a response indicating an error.
|
||||||
|
*
|
||||||
|
* @param connection the MHD connection to use
|
||||||
|
* @param ec error code uniquely identifying the error
|
||||||
|
* @param http_status HTTP status code to use
|
||||||
|
* @return a MHD result code
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
TEH_RESPONSE_reply_with_error (struct MHD_Connection *connection,
|
||||||
|
enum TALER_ErrorCode ec,
|
||||||
|
unsigned int http_status)
|
||||||
|
{
|
||||||
|
return TEH_RESPONSE_reply_json_pack (connection,
|
||||||
|
http_status,
|
||||||
|
"{s:I}",
|
||||||
|
"code", (json_int_t) ec);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a response indicating an external error.
|
* Send a response indicating an external error.
|
||||||
*
|
*
|
||||||
|
@ -170,6 +170,20 @@ TEH_RESPONSE_reply_internal_error (struct MHD_Connection *connection,
|
|||||||
const char *hint);
|
const char *hint);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a response indicating an error.
|
||||||
|
*
|
||||||
|
* @param connection the MHD connection to use
|
||||||
|
* @param ec error code uniquely identifying the error
|
||||||
|
* @param http_status HTTP status code to use
|
||||||
|
* @return a MHD result code
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
TEH_RESPONSE_reply_with_error (struct MHD_Connection *connection,
|
||||||
|
enum TALER_ErrorCode ec,
|
||||||
|
unsigned int http_status);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a response indicating an external error.
|
* Send a response indicating an external error.
|
||||||
*
|
*
|
||||||
|
@ -297,6 +297,29 @@ enum TALER_ErrorCode
|
|||||||
*/
|
*/
|
||||||
TALER_EC_WITHDRAW_RESERVE_HISTORY_IMPOSSIBLE = 1113,
|
TALER_EC_WITHDRAW_RESERVE_HISTORY_IMPOSSIBLE = 1113,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validity period of the coin to be withdrawn
|
||||||
|
* is in the future. Returned with an HTTP
|
||||||
|
* status of #MHD_HTTP_PRECONDITION_FAILED.
|
||||||
|
*/
|
||||||
|
TALER_EC_WITHDRAW_VALIDITY_IN_FUTURE = 1114,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Withdraw period of the coin to be withdrawn
|
||||||
|
* is in the past. Returned with an HTTP
|
||||||
|
* status of #MHD_HTTP_GONE.
|
||||||
|
*/
|
||||||
|
TALER_EC_WITHDRAW_VALIDITY_IN_PAST = 1115,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The private key associated with the denomination
|
||||||
|
* key is unknown to the server, possibly because
|
||||||
|
* the key was revoked. Returned with an HTTP
|
||||||
|
* status of #MHD_HTTP_SERVICE_UNAVAILABLE.
|
||||||
|
*/
|
||||||
|
TALER_EC_DENOMINATION_KEY_LOST = 1116,
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The exchange failed to obtain the transaction history of the
|
* The exchange failed to obtain the transaction history of the
|
||||||
* given reserve from the database.
|
* given reserve from the database.
|
||||||
@ -453,6 +476,20 @@ enum TALER_ErrorCode
|
|||||||
*/
|
*/
|
||||||
TALER_EC_DEPOSIT_INVALID_TIMESTAMP = 1218,
|
TALER_EC_DEPOSIT_INVALID_TIMESTAMP = 1218,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validity period of the denomination key
|
||||||
|
* is in the future. Returned with an HTTP
|
||||||
|
* status of #MHD_HTTP_PRECONDITION_FAILED.
|
||||||
|
*/
|
||||||
|
TALER_EC_DEPOSIT_DENOMINATION_VALIDITY_IN_FUTURE = 1219,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Denomination key of the coin is past the
|
||||||
|
* deposit deadline. Returned with an HTTP
|
||||||
|
* status of #MHD_HTTP_GONE.
|
||||||
|
*/
|
||||||
|
TALER_EC_DEPOSIT_DENOMINATION_EXPIRED = 1220,
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The respective coin did not have sufficient residual value
|
* The respective coin did not have sufficient residual value
|
||||||
@ -531,6 +568,35 @@ enum TALER_ErrorCode
|
|||||||
*/
|
*/
|
||||||
TALER_EC_REFRESH_MELT_COIN_EXPIRED_NO_ZOMBIE = 1309,
|
TALER_EC_REFRESH_MELT_COIN_EXPIRED_NO_ZOMBIE = 1309,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The exchange is unaware of the denomination key that was
|
||||||
|
* used to sign the melted zombie coin. This response is provided
|
||||||
|
* with HTTP status code MHD_HTTP_NOT_FOUND.
|
||||||
|
*/
|
||||||
|
TALER_EC_REFRESH_PAYBACK_DENOMINATION_KEY_NOT_FOUND = 1301,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validity period of the denomination key
|
||||||
|
* is in the future. Returned with an HTTP
|
||||||
|
* status of #MHD_HTTP_PRECONDITION_FAILED.
|
||||||
|
*/
|
||||||
|
TALER_EC_REFRESH_PAYBACK_DENOMINATION_VALIDITY_IN_FUTURE = 1301,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Denomination key of the coin is past the
|
||||||
|
* deposit deadline. Returned with an HTTP
|
||||||
|
* status of #MHD_HTTP_GONE.
|
||||||
|
*/
|
||||||
|
TALER_EC_REFRESH_PAYBACK_DENOMINATION_EXPIRED = 1302,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Denomination key of the coin is past the
|
||||||
|
* deposit deadline. Returned with an HTTP
|
||||||
|
* status of #MHD_HTTP_GONE.
|
||||||
|
*/
|
||||||
|
TALER_EC_REFRESH_ZOMBIE_DENOMINATION_EXPIRED = 1303,
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The provided transfer keys do not match up with the
|
* The provided transfer keys do not match up with the
|
||||||
* original commitment. Information about the original
|
* original commitment. Information about the original
|
||||||
@ -921,7 +987,15 @@ enum TALER_ErrorCode
|
|||||||
* This response is provided with an HTTP status code of
|
* This response is provided with an HTTP status code of
|
||||||
* MHD_HTTP_INTERNAL_SERVER_ERROR
|
* MHD_HTTP_INTERNAL_SERVER_ERROR
|
||||||
*/
|
*/
|
||||||
TALER_EC_PAYBACK_COIN_BALANCE_NEGATIVE = 1857,
|
TALER_EC_PAYBACK_COIN_BALANCE_NEGATIVE = 1859,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validity period of the denomination key
|
||||||
|
* is in the future. Returned with an HTTP
|
||||||
|
* status of #MHD_HTTP_PRECONDITION_FAILED.
|
||||||
|
*/
|
||||||
|
TALER_EC_PAYBACK_DENOMINATION_VALIDITY_IN_FUTURE = 1860,
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The "have" parameter was not a natural number.
|
* The "have" parameter was not a natural number.
|
||||||
|
Loading…
Reference in New Issue
Block a user