diff options
author | Christian Grothoff <grothoff@gnunet.org> | 2023-11-10 10:53:11 +0100 |
---|---|---|
committer | Christian Grothoff <grothoff@gnunet.org> | 2023-11-10 10:53:11 +0100 |
commit | 67f06263a370a92002540c9fd56c5c0ca646d34a (patch) | |
tree | d908065c63d39950f5756718a743c2ef29d44ef8 /src/testing/testing_api_cmd_purse_create_deposit.c | |
parent | dc9803173f998fb63077f38e7db723a01eb71028 (diff) | |
download | exchange-67f06263a370a92002540c9fd56c5c0ca646d34a.tar.xz |
implement coin history for purse-with-deposit
Diffstat (limited to 'src/testing/testing_api_cmd_purse_create_deposit.c')
-rw-r--r-- | src/testing/testing_api_cmd_purse_create_deposit.c | 80 |
1 files changed, 56 insertions, 24 deletions
diff --git a/src/testing/testing_api_cmd_purse_create_deposit.c b/src/testing/testing_api_cmd_purse_create_deposit.c index cf9929465..4740f9801 100644 --- a/src/testing/testing_api_cmd_purse_create_deposit.c +++ b/src/testing/testing_api_cmd_purse_create_deposit.c @@ -44,10 +44,20 @@ struct Coin unsigned int coin_index; /** + * Public key of the deposited coin. + */ + struct TALER_CoinSpendPublicKeyP coin_pub; + + /** * Amount to deposit (with fee). */ struct TALER_Amount deposit_with_fee; + /** + * Entry in the coin's history generated by this operation. + */ + struct TALER_EXCHANGE_CoinHistoryEntry che; + }; @@ -193,9 +203,15 @@ deposit_run (void *cls, (void) cmd; ds->is = is; + GNUNET_CRYPTO_eddsa_key_create (&ds->purse_priv.eddsa_priv); + GNUNET_CRYPTO_eddsa_key_create (&ds->merge_priv.eddsa_priv); + GNUNET_CRYPTO_ecdhe_key_create (&ds->contract_priv.ecdhe_priv); + GNUNET_CRYPTO_eddsa_key_get_public (&ds->purse_priv.eddsa_priv, + &ds->purse_pub.eddsa_pub); + for (unsigned int i = 0; i<ds->num_coin_references; i++) { - const struct Coin *cr = &ds->coin_references[i]; + struct Coin *cr = &ds->coin_references[i]; struct TALER_EXCHANGE_PurseDeposit *pd = &deposits[i]; const struct TALER_TESTING_Command *coin_cmd; const struct TALER_CoinSpendPrivateKeyP *coin_priv; @@ -239,14 +255,20 @@ deposit_run (void *cls, pd->coin_priv = *coin_priv; pd->amount = cr->deposit_with_fee; pd->h_denom_pub = denom_pub->h_key; + GNUNET_CRYPTO_eddsa_key_get_public (&coin_priv->eddsa_priv, + &cr->coin_pub.eddsa_pub); + cr->che.type = TALER_EXCHANGE_CTT_PURSE_DEPOSIT; + cr->che.amount = cr->deposit_with_fee; + GNUNET_CRYPTO_eddsa_key_get_public ( + &ds->purse_priv.eddsa_priv, + &cr->che.details.purse_deposit.purse_pub.eddsa_pub); + cr->che.details.purse_deposit.exchange_base_url + = TALER_TESTING_get_exchange_url (is); + TALER_age_commitment_hash ( + &age_commitment_proof->commitment, + &cr->che.details.purse_deposit.phac); } - GNUNET_CRYPTO_eddsa_key_create (&ds->purse_priv.eddsa_priv); - GNUNET_CRYPTO_eddsa_key_create (&ds->merge_priv.eddsa_priv); - GNUNET_CRYPTO_ecdhe_key_create (&ds->contract_priv.ecdhe_priv); - GNUNET_CRYPTO_eddsa_key_get_public (&ds->purse_priv.eddsa_priv, - &ds->purse_pub.eddsa_pub); - ds->purse_expiration = GNUNET_TIME_absolute_to_timestamp ( GNUNET_TIME_relative_to_absolute (ds->rel_expiration)); @@ -323,23 +345,33 @@ deposit_traits (void *cls, unsigned int index) { struct PurseCreateDepositState *ds = cls; - struct TALER_TESTING_Trait traits[] = { - TALER_TESTING_make_trait_merge_priv (&ds->merge_priv), - TALER_TESTING_make_trait_contract_priv (&ds->contract_priv), - TALER_TESTING_make_trait_purse_priv (&ds->purse_priv), - TALER_TESTING_make_trait_purse_pub (&ds->purse_pub), - TALER_TESTING_make_trait_contract_terms (ds->contract_terms), - TALER_TESTING_make_trait_deposit_amount (0, - &ds->target_amount), - TALER_TESTING_make_trait_timestamp (index, - &ds->purse_expiration), - TALER_TESTING_trait_end () - }; - - return TALER_TESTING_get_trait (traits, - ret, - trait, - index); + if (index >= ds->num_coin_references) + return GNUNET_NO; + + { + const struct Coin *co = &ds->coin_references[index]; + struct TALER_TESTING_Trait traits[] = { + TALER_TESTING_make_trait_merge_priv (&ds->merge_priv), + TALER_TESTING_make_trait_contract_priv (&ds->contract_priv), + TALER_TESTING_make_trait_coin_history (index, + &co->che), + TALER_TESTING_make_trait_coin_pub (index, + &co->coin_pub), + TALER_TESTING_make_trait_purse_priv (&ds->purse_priv), + TALER_TESTING_make_trait_purse_pub (&ds->purse_pub), + TALER_TESTING_make_trait_contract_terms (ds->contract_terms), + TALER_TESTING_make_trait_deposit_amount (0, + &ds->target_amount), + TALER_TESTING_make_trait_timestamp (index, + &ds->purse_expiration), + TALER_TESTING_trait_end () + }; + + return TALER_TESTING_get_trait (traits, + ret, + trait, + index); + } } |