diff options
-rw-r--r-- | src/exchange/taler-exchange-httpd_payback.c | 3 | ||||
-rw-r--r-- | src/exchangedb/plugin_exchangedb_postgres.c | 52 | ||||
-rw-r--r-- | src/include/taler_exchangedb_plugin.h | 17 |
3 files changed, 66 insertions, 6 deletions
diff --git a/src/exchange/taler-exchange-httpd_payback.c b/src/exchange/taler-exchange-httpd_payback.c index 60ce75f48..45f8c2fc8 100644 --- a/src/exchange/taler-exchange-httpd_payback.c +++ b/src/exchange/taler-exchange-httpd_payback.c @@ -247,13 +247,10 @@ payback_transaction (void *cls, reserve / account the money should go */ if (pc->refreshed) { - GNUNET_assert (0); // FIXME #5777: not implemented in DB! -#if 0 qs = TEH_plugin->get_old_coin_by_h_blind (TEH_plugin->cls, session, &pc->h_blind, &pc->target.old_coin_pub); -#endif if (0 > qs) { if (GNUNET_DB_STATUS_HARD_ERROR == qs) diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index cbf4c0938..b308f7744 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -1761,6 +1761,17 @@ postgres_prepare (PGconn *db_conn) " LIMIT 1" " FOR UPDATE;", 1), + /* Used in #postgres_get_old_coin_by_h_blind() */ + GNUNET_PQ_make_prepare ("old_coin_by_h_blind", + "SELECT" + " rcom.old_coin_pub" + " FROM refresh_revealed_coins" + " JOIN refresh_commitments rcom" + " USING (rc)" + " WHERE coin_ev=$1" + " LIMIT 1" + " FOR UPDATE;", + 1), /* used in #postgres_commit */ GNUNET_PQ_make_prepare ("do_commit", "COMMIT", @@ -7156,9 +7167,42 @@ postgres_get_reserve_by_h_blind (void *cls, }; return GNUNET_PQ_eval_prepared_singleton_select (session->conn, - "reserve_by_h_blind", - params, - rs); + "reserve_by_h_blind", + params, + rs); +} + + +/** + * Obtain information about which old coin a coin was refreshed + * given the hash of the blinded (fresh) coin. + * + * @param cls closure + * @param session a session + * @param h_blind_ev hash of the blinded coin + * @param[out] reserve_pub set to information about the reserve (on success only) + * @return transaction status code + */ +static enum GNUNET_DB_QueryStatus +postgres_get_old_coin_by_h_blind (void *cls, + struct TALER_EXCHANGEDB_Session *session, + const struct GNUNET_HashCode *h_blind_ev, + struct TALER_CoinSpendPublicKeyP *old_coin_pub) +{ + struct GNUNET_PQ_QueryParam params[] = { + GNUNET_PQ_query_param_auto_from_type (h_blind_ev), + GNUNET_PQ_query_param_end + }; + struct GNUNET_PQ_ResultSpec rs[] = { + GNUNET_PQ_result_spec_auto_from_type ("old_coin_pub", + old_coin_pub), + GNUNET_PQ_result_spec_end + }; + + return GNUNET_PQ_eval_prepared_singleton_select (session->conn, + "old_coin_by_h_blind", + params, + rs); } @@ -7764,6 +7808,8 @@ libtaler_plugin_exchangedb_postgres_init (void *cls) = &postgres_insert_payback_refresh_request; plugin->get_reserve_by_h_blind = &postgres_get_reserve_by_h_blind; + plugin->get_old_coin_by_h_blind + = &postgres_get_old_coin_by_h_blind; plugin->insert_denomination_revocation = &postgres_insert_denomination_revocation; plugin->get_denomination_revocation diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h index 8450fb04f..104ae8059 100644 --- a/src/include/taler_exchangedb_plugin.h +++ b/src/include/taler_exchangedb_plugin.h @@ -2430,6 +2430,23 @@ struct TALER_EXCHANGEDB_Plugin /** + * Obtain information about which old coin a coin was refreshed + * given the hash of the blinded (fresh) coin. + * + * @param cls closure + * @param session a session + * @param h_blind_ev hash of the blinded coin + * @param[out] old_coin_pub set to information about the old coin (on success only) + * @return transaction status code + */ + enum GNUNET_DB_QueryStatus + (*get_old_coin_by_h_blind)(void *cls, + struct TALER_EXCHANGEDB_Session *session, + const struct GNUNET_HashCode *h_blind_ev, + struct TALER_CoinSpendPublicKeyP *old_coin_pub); + + + /** * Store information that a denomination key was revoked * in the database. * |