summaryrefslogtreecommitdiff
path: root/src/exchange/taler-exchange-httpd_db.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-06-19 17:53:42 +0200
committerChristian Grothoff <christian@grothoff.org>2017-06-19 17:53:42 +0200
commit51ee20102fa3818e9e4a4113a59ad700cb7eea42 (patch)
tree1a357666eb4811fbacc3fd72e5dc94a7556f9196 /src/exchange/taler-exchange-httpd_db.c
parent92e6744ac032a3c4c4118ac6b251f769c5478aa6 (diff)
downloadexchange-51ee20102fa3818e9e4a4113a59ad700cb7eea42.tar.gz
exchange-51ee20102fa3818e9e4a4113a59ad700cb7eea42.tar.bz2
exchange-51ee20102fa3818e9e4a4113a59ad700cb7eea42.zip
address #5010 for /payback
Diffstat (limited to 'src/exchange/taler-exchange-httpd_db.c')
-rw-r--r--src/exchange/taler-exchange-httpd_db.c143
1 files changed, 0 insertions, 143 deletions
diff --git a/src/exchange/taler-exchange-httpd_db.c b/src/exchange/taler-exchange-httpd_db.c
index 9e95ff40a..bfe2112c4 100644
--- a/src/exchange/taler-exchange-httpd_db.c
+++ b/src/exchange/taler-exchange-httpd_db.c
@@ -1622,147 +1622,4 @@ TEH_DB_execute_track_transaction (struct MHD_Connection *connection,
}
-/**
- * Execute a "/payback". The validity of the coin and signature have
- * already been checked. The database must now check that the coin is
- * not (double) spent, and execute the transaction (record details,
- * generate success or failure response).
- *
- * @param connection the MHD connection to handle
- * @param coin information about the coin
- * @param value how much are coins of the @a coin's denomination worth?
- * @param h_blind blinded coin to use for the lookup
- * @param coin_blind blinding factor used (for later verification by the auditor)
- * @param coin_sig signature of the coin (to be stored)
- * @return MHD result code
- */
-int
-TEH_DB_execute_payback (struct MHD_Connection *connection,
- const struct TALER_CoinPublicInfo *coin,
- const struct TALER_Amount *value,
- const struct GNUNET_HashCode *h_blind,
- const struct TALER_DenominationBlindingKeyP *coin_blind,
- const struct TALER_CoinSpendSignatureP *coin_sig)
-{
- int ret;
- struct TALER_EXCHANGEDB_Session *session;
- struct TALER_EXCHANGEDB_TransactionList *tl;
- struct TALER_ReservePublicKeyP reserve_pub;
- struct TALER_Amount amount;
- struct TALER_Amount spent;
- struct GNUNET_TIME_Absolute now;
- enum GNUNET_DB_QueryStatus qs;
-
- if (NULL == (session = TEH_plugin->get_session (TEH_plugin->cls)))
- {
- GNUNET_break (0);
- return TEH_RESPONSE_reply_internal_db_error (connection,
- TALER_EC_DB_SETUP_FAILED);
- }
-
- START_TRANSACTION (session, connection);
-
- /* Check whether a payback is allowed, and if so, to which
- reserve / account the money should go */
- ret = TEH_plugin->get_reserve_by_h_blind (TEH_plugin->cls,
- session,
- h_blind,
- &reserve_pub);
- if (GNUNET_SYSERR == ret)
- {
- GNUNET_break (0);
- TEH_plugin->rollback (TEH_plugin->cls,
- session);
- return TEH_RESPONSE_reply_internal_db_error (connection,
- TALER_EC_PAYBACK_DB_FETCH_FAILED);
- }
- if (GNUNET_NO == ret)
- {
- GNUNET_break_op (0);
- TEH_plugin->rollback (TEH_plugin->cls,
- session);
- return TEH_RESPONSE_reply_payback_unknown (connection,
- TALER_EC_PAYBACK_WITHDRAW_NOT_FOUND);
- }
-
- /* Calculate remaining balance. */
- qs = TEH_plugin->get_coin_transactions (TEH_plugin->cls,
- session,
- &coin->coin_pub,
- &tl);
- (void) qs; /* FIXME #5010 */
- TALER_amount_get_zero (value->currency,
- &spent);
- if (GNUNET_OK !=
- TEH_DB_calculate_transaction_list_totals (tl,
- &spent,
- &spent))
- {
- GNUNET_break (0);
- TEH_plugin->rollback (TEH_plugin->cls,
- session);
- TEH_plugin->free_coin_transaction_list (TEH_plugin->cls,
- tl);
- return TEH_RESPONSE_reply_internal_db_error (connection,
- TALER_EC_PAYBACK_HISTORY_DB_ERROR);
- }
- if (GNUNET_SYSERR ==
- TALER_amount_subtract (&amount,
- value,
- &spent))
- {
- GNUNET_break (0);
- TEH_plugin->rollback (TEH_plugin->cls,
- session);
- TEH_plugin->free_coin_transaction_list (TEH_plugin->cls,
- tl);
- return TEH_RESPONSE_reply_internal_db_error (connection,
- TALER_EC_PAYBACK_COIN_BALANCE_NEGATIVE);
- }
- if ( (0 == amount.fraction) &&
- (0 == amount.value) )
- {
- TEH_plugin->rollback (TEH_plugin->cls,
- session);
- ret = TEH_RESPONSE_reply_coin_insufficient_funds (connection,
- TALER_EC_PAYBACK_COIN_BALANCE_ZERO,
- tl);
- TEH_plugin->free_coin_transaction_list (TEH_plugin->cls,
- tl);
- return ret;
- }
- TEH_plugin->free_coin_transaction_list (TEH_plugin->cls,
- tl);
- now = GNUNET_TIME_absolute_get ();
- (void) GNUNET_TIME_round_abs (&now);
-
- /* add coin to list of wire transfers for payback */
- ret = TEH_plugin->insert_payback_request (TEH_plugin->cls,
- session,
- &reserve_pub,
- coin,
- coin_sig,
- coin_blind,
- &amount,
- h_blind,
- now);
- if (GNUNET_SYSERR == ret)
- {
- TALER_LOG_WARNING ("Failed to store /payback information in database\n");
- TEH_plugin->rollback (TEH_plugin->cls,
- session);
- return TEH_RESPONSE_reply_internal_db_error (connection,
- TALER_EC_PAYBACK_DB_PUT_FAILED);
- }
-
- COMMIT_TRANSACTION(session, connection);
-
- return TEH_RESPONSE_reply_payback_success (connection,
- &coin->coin_pub,
- &reserve_pub,
- &amount,
- now);
-}
-
-
/* end of taler-exchange-httpd_db.c */