clean up taler-exchange-httpd_wire logic
This commit is contained in:
parent
7fee395bb6
commit
2e5dc6bc72
@ -91,8 +91,6 @@ load_account (void *cls,
|
|||||||
{
|
{
|
||||||
json_t *wire_s;
|
json_t *wire_s;
|
||||||
json_error_t error;
|
json_error_t error;
|
||||||
char *url;
|
|
||||||
char *method;
|
|
||||||
|
|
||||||
if (NULL == (wire_s = json_load_file (ai->wire_response_filename,
|
if (NULL == (wire_s = json_load_file (ai->wire_response_filename,
|
||||||
JSON_REJECT_DUPLICATES,
|
JSON_REJECT_DUPLICATES,
|
||||||
@ -108,31 +106,37 @@ load_account (void *cls,
|
|||||||
*ret = GNUNET_SYSERR;
|
*ret = GNUNET_SYSERR;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (NULL == (url = TALER_JSON_wire_to_payto (wire_s)))
|
|
||||||
{
|
{
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
char *url;
|
||||||
"Wire response file `%s' lacks `payto_uri' entry\n",
|
|
||||||
ai->wire_response_filename);
|
if (NULL == (url = TALER_JSON_wire_to_payto (wire_s)))
|
||||||
json_decref (wire_s);
|
{
|
||||||
*ret = GNUNET_SYSERR;
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
return;
|
"Wire response file `%s' malformed\n",
|
||||||
}
|
ai->wire_response_filename);
|
||||||
if (0 != strcasecmp (url,
|
json_decref (wire_s);
|
||||||
ai->payto_uri))
|
*ret = GNUNET_SYSERR;
|
||||||
{
|
return;
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
}
|
||||||
"URL in Wire response file `%s' does not match URL in configuration (%s vs %s)!\n",
|
if (0 != strcasecmp (url,
|
||||||
ai->wire_response_filename,
|
ai->payto_uri))
|
||||||
url,
|
{
|
||||||
ai->payto_uri);
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
json_decref (wire_s);
|
"URL in wire response file `%s' does not match URL in configuration (%s vs %s)!\n",
|
||||||
|
ai->wire_response_filename,
|
||||||
|
url,
|
||||||
|
ai->payto_uri);
|
||||||
|
json_decref (wire_s);
|
||||||
|
GNUNET_free (url);
|
||||||
|
*ret = GNUNET_SYSERR;
|
||||||
|
return;
|
||||||
|
}
|
||||||
GNUNET_free (url);
|
GNUNET_free (url);
|
||||||
*ret = GNUNET_SYSERR;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
GNUNET_free (url);
|
|
||||||
/* Provide friendly error message if user forgot to sign wire response. */
|
/* Provide friendly error message if user forgot to sign wire response. */
|
||||||
if (NULL == json_object_get (wire_s, "master_sig"))
|
if (NULL == json_object_get (wire_s,
|
||||||
|
"master_sig"))
|
||||||
{
|
{
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"Wire response file `%s' has not been signed."
|
"Wire response file `%s' has not been signed."
|
||||||
@ -154,9 +158,8 @@ load_account (void *cls,
|
|||||||
*ret = GNUNET_SYSERR;
|
*ret = GNUNET_SYSERR;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
method = TALER_payto_get_method (ai->payto_uri);
|
|
||||||
if (GNUNET_OK ==
|
if (GNUNET_OK ==
|
||||||
load_fee (method))
|
load_fee (ai->method))
|
||||||
{
|
{
|
||||||
GNUNET_assert (-1 !=
|
GNUNET_assert (-1 !=
|
||||||
json_array_append_new (wire_accounts_array,
|
json_array_append_new (wire_accounts_array,
|
||||||
@ -166,13 +169,11 @@ load_account (void *cls,
|
|||||||
{
|
{
|
||||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"Wire fees not specified for `%s'\n",
|
"Wire fees not specified for `%s'\n",
|
||||||
method);
|
ai->method);
|
||||||
*ret = GNUNET_SYSERR;
|
*ret = GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
GNUNET_free (method);
|
|
||||||
}
|
}
|
||||||
|
else if (GNUNET_YES == ai->debit_enabled)
|
||||||
if (GNUNET_YES == ai->debit_enabled)
|
|
||||||
{
|
{
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
load_fee (ai->method))
|
load_fee (ai->method))
|
||||||
@ -251,7 +252,6 @@ json_t *
|
|||||||
TEH_WIRE_get_fees (const char *method)
|
TEH_WIRE_get_fees (const char *method)
|
||||||
{
|
{
|
||||||
struct TALER_EXCHANGEDB_AggregateFees *af;
|
struct TALER_EXCHANGEDB_AggregateFees *af;
|
||||||
json_t *j;
|
|
||||||
struct GNUNET_TIME_Absolute now;
|
struct GNUNET_TIME_Absolute now;
|
||||||
|
|
||||||
af = TALER_EXCHANGEDB_fees_read (TEH_cfg,
|
af = TALER_EXCHANGEDB_fees_read (TEH_cfg,
|
||||||
@ -273,9 +273,13 @@ TEH_WIRE_get_fees (const char *method)
|
|||||||
GNUNET_STRINGS_absolute_time_to_string (now));
|
GNUNET_STRINGS_absolute_time_to_string (now));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
j = fees_to_json (af);
|
{
|
||||||
TALER_EXCHANGEDB_fees_free (af);
|
json_t *j;
|
||||||
return j;
|
|
||||||
|
j = fees_to_json (af);
|
||||||
|
TALER_EXCHANGEDB_fees_free (af);
|
||||||
|
return j;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user