diff --git a/src/mintdb/perf_taler_mintdb_init.c b/src/mintdb/perf_taler_mintdb_init.c index 2fe978f64..5c18c664e 100644 --- a/src/mintdb/perf_taler_mintdb_init.c +++ b/src/mintdb/perf_taler_mintdb_init.c @@ -534,24 +534,13 @@ PERF_TALER_MINTDB_coin_public_info_free (struct TALER_CoinPublicInfo *cpi) */ struct TALER_MINTDB_RefreshMelt * PERF_TALER_MINTDB_refresh_melt_init (struct GNUNET_HashCode *session, - struct TALER_MINTDB_DenominationKeyIssueInformation *dki) + struct PERF_TALER_MINTDB_Coin *coin) { struct TALER_MINTDB_RefreshMelt *melt; - struct GNUNET_CRYPTO_EddsaPrivateKey *coin_key; - struct TALER_CoinPublicInfo cpi; - struct TALER_CoinSpendSignatureP coin_spent; + struct TALER_CoinSpendSignatureP coin_sig; struct TALER_Amount amount; struct TALER_Amount amount_with_fee; - coin_key = GNUNET_CRYPTO_eddsa_key_create (); - cpi.denom_pub = dki->denom_pub; - GNUNET_CRYPTO_eddsa_key_get_public (coin_key, - &cpi.coin_pub.eddsa_pub); - GNUNET_assert (NULL != - (cpi.denom_sig.rsa_signature = - GNUNET_CRYPTO_rsa_sign (dki->denom_priv.rsa_private_key, - &cpi.coin_pub.eddsa_pub, - sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)))); { struct { @@ -562,22 +551,21 @@ PERF_TALER_MINTDB_refresh_melt_init (struct GNUNET_HashCode *session, to_sign.purpose.purpose = GNUNET_SIGNATURE_PURPOSE_TEST; to_sign.purpose.size = htonl (sizeof (to_sign)); to_sign.session = *session; - GNUNET_CRYPTO_eddsa_sign (coin_key, + GNUNET_CRYPTO_eddsa_sign (&coin->priv, &to_sign.purpose, - &coin_spent.eddsa_signature); + &coin_sig.eddsa_signature); } - GNUNET_assert (GNUNET_OK == TALER_string_to_amount (CURRENCY ":10.0", + GNUNET_assert (GNUNET_OK == TALER_string_to_amount (CURRENCY ":1.1", &amount)); GNUNET_assert (GNUNET_OK == TALER_string_to_amount (CURRENCY ":0.1", &amount_with_fee)); melt = GNUNET_new (struct TALER_MINTDB_RefreshMelt); - melt->coin = cpi; - melt->coin_sig = coin_spent; + melt->coin = coin->public_info; + melt->coin_sig = coin_sig; melt->session_hash = *session; melt->amount_with_fee = amount; melt->melt_fee = amount_with_fee; - GNUNET_free (coin_key); return melt; } diff --git a/src/mintdb/perf_taler_mintdb_init.h b/src/mintdb/perf_taler_mintdb_init.h index 7a96f66d8..c159770fc 100644 --- a/src/mintdb/perf_taler_mintdb_init.h +++ b/src/mintdb/perf_taler_mintdb_init.h @@ -183,7 +183,7 @@ PERF_TALER_MINTDB_coin_free ( */ struct TALER_MINTDB_RefreshMelt * PERF_TALER_MINTDB_refresh_melt_init (struct GNUNET_HashCode *session, - struct TALER_MINTDB_DenominationKeyIssueInformation *dki); + struct PERF_TALER_MINTDB_Coin *coin); /** diff --git a/src/mintdb/perf_taler_mintdb_interpreter.c b/src/mintdb/perf_taler_mintdb_interpreter.c index e9ee05e33..45a3002a5 100644 --- a/src/mintdb/perf_taler_mintdb_interpreter.c +++ b/src/mintdb/perf_taler_mintdb_interpreter.c @@ -678,7 +678,100 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state) } break; - default : + case PERF_TALER_MINTDB_CMD_GET_COIN_TRANSACTION: + { + int coin_index; + struct PERF_TALER_MINTDB_Coin *coin; + struct TALER_MINTDB_TransactionList *transactions; + + coin_index = cmd_find (state->cmd, + state->cmd[state->i].details.get_coin_transaction.label_coin); + GNUNET_assert (GNUNET_SYSERR != coin_index); + coin = state->cmd[coin_index].exposed.data.coin; + transactions = state->plugin->get_coin_transactions (state->plugin->cls, + state->session, + &coin->public_info.coin_pub); + state->plugin->free_coin_transaction_list (state->plugin->cls, + transactions); + } + break; + + case PERF_TALER_MINTDB_CMD_CREATE_REFRESH_SESSION: + { + struct GNUNET_HashCode hash; + struct TALER_MINTDB_RefreshSession *refresh_session; + + refresh_session = PERF_TALER_MINTDB_refresh_session_init (); + GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, + &hash); + state->plugin->create_refresh_session (state->session, + state->session, + &hash, + refresh_session); + state->cmd[state->i].exposed.data.session_hash = hash; + PERF_TALER_MINTDB_refresh_session_free (refresh_session); + GNUNET_free (refresh_session); + } + break; + + case PERF_TALER_MINTDB_CMD_GET_REFRESH_SESSION: + { + int hash_index; + struct GNUNET_HashCode hash; + struct TALER_MINTDB_RefreshSession refresh; + + hash_index = cmd_find (state->cmd, + state->cmd[state->i].details.get_refresh_session.label_hash); + hash = state->cmd[hash_index].exposed.data.session_hash; + state->plugin->get_refresh_session (state->session, + state->session, + &hash, + &refresh); + } + break; + + case PERF_TALER_MINTDB_CMD_INSERT_REFRESH_MELT: + { + int hash_index; + int coin_index; + struct GNUNET_HashCode hash; + struct TALER_MINTDB_RefreshMelt *melt; + struct PERF_TALER_MINTDB_Coin *coin; + + hash_index = cmd_find (state->cmd, + state->cmd[state->i].details.insert_refresh_melt.label_hash); + coin_index = cmd_find (state->cmd, + state->cmd[state->i].details.insert_refresh_melt.label_coin); + hash = state->cmd[hash_index].exposed.data.session_hash; + coin = state->cmd[coin_index].exposed.data.coin; + melt = PERF_TALER_MINTDB_refresh_melt_init (&hash, + coin); + state->plugin->insert_refresh_melt (state->plugin->cls, + state->session, + 1, + melt); + state->cmd[state->i].exposed.data.session_hash = hash; + } + break; + + case PERF_TALER_MINTDB_CMD_GET_REFRESH_MELT: + { + int hash_index; + struct GNUNET_HashCode hash; + struct TALER_MINTDB_RefreshMelt melt; + + hash_index = cmd_find (state->cmd, + state->cmd[state->i].details.get_refresh_melt.label_hash); + hash = state->cmd[hash_index].exposed.data.session_hash; + state->plugin->get_refresh_melt (state->plugin->cls, + state->session, + &hash, + 1, + &melt); + } + break; + + default: break; } }