fix #3636, and add amount parsing functionality to spec-parser
This commit is contained in:
parent
884fff1297
commit
1d7bb2d091
@ -680,6 +680,16 @@ GNUNET_MINT_parse_navigate_json (struct MHD_Connection *connection,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case JNAV_RET_AMOUNT:
|
||||||
|
{
|
||||||
|
struct TALER_Amount *where = va_arg (argp, void *);
|
||||||
|
|
||||||
|
ret = TALER_MINT_parse_amount_json (connection,
|
||||||
|
(json_t *) root,
|
||||||
|
where);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
ret = (MHD_YES ==
|
ret = (MHD_YES ==
|
||||||
@ -721,6 +731,8 @@ TALER_MINT_parse_json_data (struct MHD_Connection *connection,
|
|||||||
ret = GNUNET_YES;
|
ret = GNUNET_YES;
|
||||||
for (i=0; NULL != spec[i].field_name; i++)
|
for (i=0; NULL != spec[i].field_name; i++)
|
||||||
{
|
{
|
||||||
|
if (GNUNET_YES != ret)
|
||||||
|
break;
|
||||||
switch (spec[i].command)
|
switch (spec[i].command)
|
||||||
{
|
{
|
||||||
case JNAV_FIELD:
|
case JNAV_FIELD:
|
||||||
@ -730,8 +742,6 @@ TALER_MINT_parse_json_data (struct MHD_Connection *connection,
|
|||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
case JNAV_RET_DATA:
|
case JNAV_RET_DATA:
|
||||||
if (GNUNET_YES != ret)
|
|
||||||
break;
|
|
||||||
ret = GNUNET_MINT_parse_navigate_json (connection,
|
ret = GNUNET_MINT_parse_navigate_json (connection,
|
||||||
root,
|
root,
|
||||||
JNAV_FIELD,
|
JNAV_FIELD,
|
||||||
@ -741,8 +751,6 @@ TALER_MINT_parse_json_data (struct MHD_Connection *connection,
|
|||||||
spec[i].destination_size_in);
|
spec[i].destination_size_in);
|
||||||
break;
|
break;
|
||||||
case JNAV_RET_DATA_VAR:
|
case JNAV_RET_DATA_VAR:
|
||||||
if (GNUNET_YES != ret)
|
|
||||||
break;
|
|
||||||
ptr = NULL;
|
ptr = NULL;
|
||||||
ret = GNUNET_MINT_parse_navigate_json (connection,
|
ret = GNUNET_MINT_parse_navigate_json (connection,
|
||||||
root,
|
root,
|
||||||
@ -754,8 +762,6 @@ TALER_MINT_parse_json_data (struct MHD_Connection *connection,
|
|||||||
spec[i].destination = ptr;
|
spec[i].destination = ptr;
|
||||||
break;
|
break;
|
||||||
case JNAV_RET_TYPED_JSON:
|
case JNAV_RET_TYPED_JSON:
|
||||||
if (GNUNET_YES != ret)
|
|
||||||
break;
|
|
||||||
ptr = NULL;
|
ptr = NULL;
|
||||||
ret = GNUNET_MINT_parse_navigate_json (connection,
|
ret = GNUNET_MINT_parse_navigate_json (connection,
|
||||||
root,
|
root,
|
||||||
@ -767,8 +773,6 @@ TALER_MINT_parse_json_data (struct MHD_Connection *connection,
|
|||||||
*((void**)spec[i].destination) = ptr;
|
*((void**)spec[i].destination) = ptr;
|
||||||
break;
|
break;
|
||||||
case JNAV_RET_RSA_PUBLIC_KEY:
|
case JNAV_RET_RSA_PUBLIC_KEY:
|
||||||
if (GNUNET_YES != ret)
|
|
||||||
break;
|
|
||||||
ptr = NULL;
|
ptr = NULL;
|
||||||
ret = GNUNET_MINT_parse_navigate_json (connection,
|
ret = GNUNET_MINT_parse_navigate_json (connection,
|
||||||
root,
|
root,
|
||||||
@ -779,8 +783,6 @@ TALER_MINT_parse_json_data (struct MHD_Connection *connection,
|
|||||||
spec[i].destination = ptr;
|
spec[i].destination = ptr;
|
||||||
break;
|
break;
|
||||||
case JNAV_RET_RSA_SIGNATURE:
|
case JNAV_RET_RSA_SIGNATURE:
|
||||||
if (GNUNET_YES != ret)
|
|
||||||
break;
|
|
||||||
ptr = NULL;
|
ptr = NULL;
|
||||||
ret = GNUNET_MINT_parse_navigate_json (connection,
|
ret = GNUNET_MINT_parse_navigate_json (connection,
|
||||||
root,
|
root,
|
||||||
@ -790,6 +792,16 @@ TALER_MINT_parse_json_data (struct MHD_Connection *connection,
|
|||||||
&ptr);
|
&ptr);
|
||||||
spec[i].destination = ptr;
|
spec[i].destination = ptr;
|
||||||
break;
|
break;
|
||||||
|
case JNAV_RET_AMOUNT:
|
||||||
|
GNUNET_assert (sizeof (struct TALER_Amount) ==
|
||||||
|
spec[i].destination_size_in);
|
||||||
|
ret = GNUNET_MINT_parse_navigate_json (connection,
|
||||||
|
root,
|
||||||
|
JNAV_FIELD,
|
||||||
|
spec[i].field_name,
|
||||||
|
JNAV_RET_AMOUNT,
|
||||||
|
&spec[i].destination);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (GNUNET_YES != ret)
|
if (GNUNET_YES != ret)
|
||||||
@ -854,6 +866,11 @@ TALER_MINT_release_parsed_data (struct GNUNET_MINT_ParseFieldSpec *spec)
|
|||||||
*(void**) spec[i].destination = NULL;
|
*(void**) spec[i].destination = NULL;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case JNAV_RET_AMOUNT:
|
||||||
|
memset (spec[i].destination,
|
||||||
|
0,
|
||||||
|
sizeof (struct TALER_Amount));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,13 @@ enum TALER_MINT_JsonNavigationCommand
|
|||||||
* Return a `struct GNUNET_CRYPTO_rsa_Signature` which was
|
* Return a `struct GNUNET_CRYPTO_rsa_Signature` which was
|
||||||
* encoded as variable-size base32crockford encoded data.
|
* encoded as variable-size base32crockford encoded data.
|
||||||
*/
|
*/
|
||||||
JNAV_RET_RSA_SIGNATURE
|
JNAV_RET_RSA_SIGNATURE,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a `struct TALER_Amount` which was
|
||||||
|
* encoded within its own json object.
|
||||||
|
*/
|
||||||
|
JNAV_RET_AMOUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -270,6 +276,14 @@ TALER_MINT_release_parsed_data (struct GNUNET_MINT_ParseFieldSpec *spec);
|
|||||||
*/
|
*/
|
||||||
#define TALER_MINT_PARSE_RSA_SIGNATURE(field,ptrsig) { field, ptrsig, 0, 0, JNAV_RET_RSA_SIGNATURE, 0 }
|
#define TALER_MINT_PARSE_RSA_SIGNATURE(field,ptrsig) { field, ptrsig, 0, 0, JNAV_RET_RSA_SIGNATURE, 0 }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate line in parser specification for an amount.
|
||||||
|
*
|
||||||
|
* @param field name of the field
|
||||||
|
* @param amount a `struct TALER_Amount *` to initialize
|
||||||
|
*/
|
||||||
|
#define TALER_MINT_PARSE_AMOUNT(field,amount) { field, amount, sizeof(*amount), 0, JNAV_RET_AMOUNT, 0 }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate line in parser specification indicating the end of the spec.
|
* Generate line in parser specification indicating the end of the spec.
|
||||||
*/
|
*/
|
||||||
|
@ -237,19 +237,15 @@ get_coin_public_info (struct MHD_Connection *connection,
|
|||||||
TALER_MINT_PARSE_RSA_SIGNATURE ("denom_sig", &sig),
|
TALER_MINT_PARSE_RSA_SIGNATURE ("denom_sig", &sig),
|
||||||
TALER_MINT_PARSE_RSA_PUBLIC_KEY ("denom_pub", &pk),
|
TALER_MINT_PARSE_RSA_PUBLIC_KEY ("denom_pub", &pk),
|
||||||
TALER_MINT_PARSE_FIXED ("confirm_sig", &melt_sig),
|
TALER_MINT_PARSE_FIXED ("confirm_sig", &melt_sig),
|
||||||
/* FIXME: #3636! */
|
TALER_MINT_PARSE_AMOUNT ("value_with_fee", &amount),
|
||||||
TALER_MINT_PARSE_END
|
TALER_MINT_PARSE_END
|
||||||
};
|
};
|
||||||
|
|
||||||
memset (&amount, 0, sizeof (amount)); // FIXME: #3636!
|
|
||||||
ret = TALER_MINT_parse_json_data (connection,
|
ret = TALER_MINT_parse_json_data (connection,
|
||||||
coin_info,
|
coin_info,
|
||||||
spec);
|
spec);
|
||||||
if (GNUNET_OK != ret)
|
if (GNUNET_OK != ret)
|
||||||
return ret;
|
return ret;
|
||||||
/* FIXME: include amount of coin value to be melted here (#3636!) and
|
|
||||||
in what we return!? */
|
|
||||||
|
|
||||||
/* check mint signature on the coin */
|
/* check mint signature on the coin */
|
||||||
r_public_info->denom_sig = sig;
|
r_public_info->denom_sig = sig;
|
||||||
r_public_info->denom_pub = pk;
|
r_public_info->denom_pub = pk;
|
||||||
|
Loading…
Reference in New Issue
Block a user