diff options
Diffstat (limited to 'src/testing/testing_api_cmd_withdraw.c')
-rw-r--r-- | src/testing/testing_api_cmd_withdraw.c | 40 |
1 files changed, 15 insertions, 25 deletions
diff --git a/src/testing/testing_api_cmd_withdraw.c b/src/testing/testing_api_cmd_withdraw.c index 69a47cb5e..2550e55a4 100644 --- a/src/testing/testing_api_cmd_withdraw.c +++ b/src/testing/testing_api_cmd_withdraw.c @@ -144,10 +144,10 @@ struct WithdrawState /** * If age > 0, put here the corresponding age commitment with its proof and - * its hash, respectivelly, NULL otherwise. + * its hash, respectivelly. */ - struct TALER_AgeCommitmentProof *age_commitment_proof; - struct TALER_AgeCommitmentHash *h_age_commitment; + struct TALER_AgeCommitmentProof age_commitment_proof; + struct TALER_AgeCommitmentHash h_age_commitment; /** * Reserve history entry that corresponds to this operation. @@ -438,7 +438,7 @@ withdraw_run (void *cls, struct TALER_EXCHANGE_WithdrawCoinInput wci = { .pk = ws->pk, .ps = &ws->ps, - .ach = ws->h_age_commitment + .ach = 0 < ws->age ? &ws->h_age_commitment : NULL }; ws->wsh = TALER_EXCHANGE_withdraw ( TALER_TESTING_interpreter_get_context (is), @@ -489,16 +489,8 @@ withdraw_cleanup (void *cls, TALER_EXCHANGE_destroy_denomination_key (ws->pk); ws->pk = NULL; } - if (NULL != ws->age_commitment_proof) - { - TALER_age_commitment_proof_free (ws->age_commitment_proof); - ws->age_commitment_proof = NULL; - } - if (NULL != ws->h_age_commitment) - { - GNUNET_free (ws->h_age_commitment); - ws->h_age_commitment = NULL; - } + if (ws->age > 0) + TALER_age_commitment_proof_free (&ws->age_commitment_proof); GNUNET_free (ws->exchange_url); GNUNET_free (ws->reserve_payto_uri); GNUNET_free (ws); @@ -545,9 +537,13 @@ withdraw_traits (void *cls, TALER_TESTING_make_trait_payto_uri (ws->reserve_payto_uri), TALER_TESTING_make_trait_exchange_url (ws->exchange_url), TALER_TESTING_make_trait_age_commitment_proof (0, - ws->age_commitment_proof), + 0 < ws->age + ? &ws->age_commitment_proof + : NULL), TALER_TESTING_make_trait_h_age_commitment (0, - ws->h_age_commitment), + 0 < ws->age + ? &ws->h_age_commitment + : NULL), TALER_TESTING_trait_end () }; @@ -573,13 +569,9 @@ TALER_TESTING_cmd_withdraw_amount (const char *label, ws->age = age; if (0 < age) { - struct TALER_AgeCommitmentProof *acp; - struct TALER_AgeCommitmentHash *hac; struct GNUNET_HashCode seed; struct TALER_AgeMask mask; - acp = GNUNET_new (struct TALER_AgeCommitmentProof); - hac = GNUNET_new (struct TALER_AgeCommitmentHash); mask = TALER_extensions_get_age_restriction_mask (); GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, &seed, @@ -590,7 +582,7 @@ TALER_TESTING_cmd_withdraw_amount (const char *label, &mask, age, &seed, - acp)) + &ws->age_commitment_proof)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to generate age commitment for age %d at %s\n", @@ -598,10 +590,8 @@ TALER_TESTING_cmd_withdraw_amount (const char *label, label); GNUNET_assert (0); } - TALER_age_commitment_hash (&acp->commitment, - hac); - ws->age_commitment_proof = acp; - ws->h_age_commitment = hac; + TALER_age_commitment_hash (&ws->age_commitment_proof.commitment, + &ws->h_age_commitment); } ws->reserve_reference = reserve_reference; |