withdraw test prepared for age restriction
- TALER_TESTING_find_pk takes boolean age_restricted - struct RefreshMeltState carries age commitment of melted coin - melt_run calls TALER_age_commitment_derive, if necessary
This commit is contained in:
parent
e41c71f6ea
commit
5e93e244bd
@ -66,11 +66,13 @@ TALER_TESTING_make_wire_details (const char *payto);
|
||||
*
|
||||
* @param keys array of keys to search
|
||||
* @param amount coin value to look for
|
||||
* @param age_restricted must the denomination be age restricted?
|
||||
* @return NULL if no matching key was found
|
||||
*/
|
||||
const struct TALER_EXCHANGE_DenomPublicKey *
|
||||
TALER_TESTING_find_pk (const struct TALER_EXCHANGE_Keys *keys,
|
||||
const struct TALER_Amount *amount);
|
||||
const struct TALER_Amount *amount,
|
||||
bool age_restricted);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -121,6 +121,11 @@ struct RefreshMeltState
|
||||
*/
|
||||
const struct TALER_CoinSpendPrivateKeyP *melt_priv;
|
||||
|
||||
/*
|
||||
* Age commitment for the coin, NULL if not applicable.
|
||||
*/
|
||||
const struct TALER_AgeCommitment *age_commitment;
|
||||
|
||||
/**
|
||||
* Task scheduled to try later.
|
||||
*/
|
||||
@ -1048,8 +1053,9 @@ melt_run (void *cls,
|
||||
TALER_TESTING_interpreter_fail (rms->is);
|
||||
return;
|
||||
}
|
||||
fresh_pk = TALER_TESTING_find_pk
|
||||
(TALER_EXCHANGE_get_keys (is->exchange), &fresh_amount);
|
||||
fresh_pk = TALER_TESTING_find_pk (TALER_EXCHANGE_get_keys (is->exchange),
|
||||
&fresh_amount,
|
||||
melt_denom_pub->age_restricted);
|
||||
if (NULL == fresh_pk)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
@ -1071,14 +1077,34 @@ melt_run (void *cls,
|
||||
&fresh_pk->key);
|
||||
} /* end for */
|
||||
GNUNET_assert (NULL == rms->refresh_data);
|
||||
rms->refresh_data
|
||||
= TALER_EXCHANGE_refresh_prepare (rms->melt_priv,
|
||||
&melt_amount,
|
||||
melt_sig,
|
||||
melt_denom_pub,
|
||||
NULL, /* FIXME-oec */
|
||||
num_fresh_coins,
|
||||
rms->fresh_pks);
|
||||
{
|
||||
struct TALER_AgeCommitment *ac = NULL;
|
||||
|
||||
GNUNET_assert (melt_denom_pub->age_restricted ==
|
||||
(NULL != rms->age_commitment));
|
||||
|
||||
if (NULL != rms->age_commitment)
|
||||
{
|
||||
uint32_t seed = GNUNET_CRYPTO_random_u32 (
|
||||
GNUNET_CRYPTO_QUALITY_WEAK,
|
||||
UINT32_MAX);
|
||||
|
||||
GNUNET_assert (GNUNET_OK ==
|
||||
TALER_age_commitment_derive (
|
||||
rms->age_commitment,
|
||||
seed,
|
||||
ac));
|
||||
}
|
||||
|
||||
rms->refresh_data
|
||||
= TALER_EXCHANGE_refresh_prepare (rms->melt_priv,
|
||||
&melt_amount,
|
||||
melt_sig,
|
||||
melt_denom_pub,
|
||||
ac,
|
||||
num_fresh_coins,
|
||||
rms->fresh_pks);
|
||||
}
|
||||
if (NULL == rms->refresh_data)
|
||||
{
|
||||
GNUNET_break (0);
|
||||
|
@ -415,7 +415,8 @@ withdraw_run (void *cls,
|
||||
if (NULL == ws->pk)
|
||||
{
|
||||
dpk = TALER_TESTING_find_pk (TALER_EXCHANGE_get_keys (is->exchange),
|
||||
&ws->amount);
|
||||
&ws->amount,
|
||||
false); /* FIXME- oec */
|
||||
if (NULL == dpk)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
|
@ -416,11 +416,13 @@ TALER_TESTING_prepare_exchange (const char *config_filename,
|
||||
*
|
||||
* @param keys array of keys to search
|
||||
* @param amount coin value to look for
|
||||
* @param age_restricted must denomination support age restriction?
|
||||
* @return NULL if no matching key was found
|
||||
*/
|
||||
const struct TALER_EXCHANGE_DenomPublicKey *
|
||||
TALER_TESTING_find_pk (const struct TALER_EXCHANGE_Keys *keys,
|
||||
const struct TALER_Amount *amount)
|
||||
const struct TALER_Amount *amount,
|
||||
bool age_restricted)
|
||||
{
|
||||
struct GNUNET_TIME_Timestamp now;
|
||||
struct TALER_EXCHANGE_DenomPublicKey *pk;
|
||||
@ -437,7 +439,8 @@ TALER_TESTING_find_pk (const struct TALER_EXCHANGE_Keys *keys,
|
||||
pk->valid_from)) &&
|
||||
(GNUNET_TIME_timestamp_cmp (now,
|
||||
<,
|
||||
pk->withdraw_valid_until)) )
|
||||
pk->withdraw_valid_until)) &&
|
||||
(age_restricted == pk->age_restricted) )
|
||||
return pk;
|
||||
}
|
||||
/* do 2nd pass to check if expiration times are to blame for
|
||||
@ -453,7 +456,8 @@ TALER_TESTING_find_pk (const struct TALER_EXCHANGE_Keys *keys,
|
||||
pk->valid_from) ||
|
||||
GNUNET_TIME_timestamp_cmp (now,
|
||||
>,
|
||||
pk->withdraw_valid_until) ) )
|
||||
pk->withdraw_valid_until) ) &&
|
||||
(age_restricted == pk->age_restricted) )
|
||||
{
|
||||
GNUNET_log
|
||||
(GNUNET_ERROR_TYPE_WARNING,
|
||||
|
Loading…
Reference in New Issue
Block a user