-simplify parsing, make code compile without new util API

This commit is contained in:
Christian Grothoff 2015-07-08 08:54:55 +02:00
parent b7e2e10712
commit 296e27b92a
4 changed files with 20 additions and 42 deletions

View File

@ -29,6 +29,7 @@
#include "taler_util.h" #include "taler_util.h"
#include "taler_signatures.h" #include "taler_signatures.h"
#include "taler_mint_service.h" #include "taler_mint_service.h"
#include <gnunet/gnunet_util_lib.h>
#include <microhttpd.h> #include <microhttpd.h>
@ -629,7 +630,7 @@ interpreter_run (void *cls,
GNUNET_CRYPTO_eddsa_key_get_public (&cmd->details.withdraw_sign.coin_priv.eddsa_priv, GNUNET_CRYPTO_eddsa_key_get_public (&cmd->details.withdraw_sign.coin_priv.eddsa_priv,
&coin_pub.eddsa_pub); &coin_pub.eddsa_pub);
cmd->details.withdraw_sign.blinding_key.rsa_blinding_key cmd->details.withdraw_sign.blinding_key.rsa_blinding_key
= GNUNET_CRYPTO_rsa_blinding_key_create (GNUNET_CRYPTO_rsa_public_key_len (cmd->details.withdraw_sign.pk->key.rsa_public_key)); = GNUNET_CRYPTO_rsa_blinding_key_create (1024); // FIXME: GNUNET_CRYPTO_rsa_public_key_len (cmd->details.withdraw_sign.pk->key.rsa_public_key));
cmd->details.withdraw_sign.wsh cmd->details.withdraw_sign.wsh
= TALER_MINT_withdraw_sign (mint, = TALER_MINT_withdraw_sign (mint,

View File

@ -1029,18 +1029,9 @@ TMH_PARSE_amount_json (struct MHD_Connection *connection,
json_t *f, json_t *f,
struct TALER_Amount *amount) struct TALER_Amount *amount)
{ {
json_int_t value; if (GNUNET_OK !=
json_int_t fraction; TALER_json_to_amount (f,
const char *currency; amount))
memset (amount,
0,
sizeof (struct TALER_Amount));
if (-1 == json_unpack (f,
"{s:I, s:I, s:s}",
"value", &value,
"fraction", &fraction,
"currency", &currency))
{ {
TALER_LOG_WARNING ("Failed to parse JSON amount specification\n"); TALER_LOG_WARNING ("Failed to parse JSON amount specification\n");
if (MHD_YES != if (MHD_YES !=
@ -1051,21 +1042,7 @@ TMH_PARSE_amount_json (struct MHD_Connection *connection,
return GNUNET_SYSERR; return GNUNET_SYSERR;
return GNUNET_NO; return GNUNET_NO;
} }
if ( (value < 0) || if (0 != strcmp (amount->currency,
(fraction < 0) ||
(value > UINT64_MAX) ||
(fraction > UINT32_MAX) )
{
TALER_LOG_WARNING ("Amount specified not in allowed range\n");
if (MHD_YES !=
TMH_RESPONSE_reply_json_pack (connection,
MHD_HTTP_BAD_REQUEST,
"{s:s}",
"error", "Amount outside of allowed range"))
return GNUNET_SYSERR;
return GNUNET_NO;
}
if (0 != strcmp (currency,
TMH_mint_currency_string)) TMH_mint_currency_string))
{ {
TALER_LOG_WARNING ("Currency specified not supported by this mint\n"); TALER_LOG_WARNING ("Currency specified not supported by this mint\n");
@ -1074,15 +1051,14 @@ TMH_PARSE_amount_json (struct MHD_Connection *connection,
MHD_HTTP_BAD_REQUEST, MHD_HTTP_BAD_REQUEST,
"{s:s, s:s}", "{s:s, s:s}",
"error", "Currency not supported", "error", "Currency not supported",
"currency", currency)) "currency", amount->currency))
{
memset (amount, 0, sizeof (struct TALER_Amount));
return GNUNET_SYSERR; return GNUNET_SYSERR;
}
memset (amount, 0, sizeof (struct TALER_Amount));
return GNUNET_NO; return GNUNET_NO;
} }
amount->value = (uint64_t) value;
amount->fraction = (uint32_t) fraction;
GNUNET_assert (strlen (TMH_mint_currency_string) < TALER_CURRENCY_LEN);
strcpy (amount->currency, TMH_mint_currency_string);
(void) TALER_amount_normalize (amount);
return GNUNET_OK; return GNUNET_OK;
} }

View File

@ -0,0 +1 @@
p<EFBFBD>^<5E>-<2D>33<33><33>XX<>!<04>\0q<30><71><EFBFBD><EFBFBD><18>mU<6D>_<EFBFBD><5F>

View File

@ -291,7 +291,7 @@ TALER_json_to_amount (json_t *json,
memset (r_amount, memset (r_amount,
0, 0,
sizeof (struct TALER_Amount)); sizeof (struct TALER_Amount));
if (-1 == json_unpack (json, if (0 != json_unpack (json,
"{s:I, s:I, s:s}", "{s:I, s:I, s:s}",
"value", &value, "value", &value,
"fraction", &fraction, "fraction", &fraction,