summaryrefslogtreecommitdiff
path: root/src/exchange
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-04-01 23:43:55 +0200
committerChristian Grothoff <christian@grothoff.org>2017-04-01 23:43:55 +0200
commitb293bda4acfe01f6254670779b8ac97e8b55990c (patch)
treebdbabdacf686d5529218b84ec18ee09ea251994c /src/exchange
parentc329b92ccf1c461e4032e75164b6ffa6bb509a69 (diff)
downloadexchange-b293bda4acfe01f6254670779b8ac97e8b55990c.tar.gz
exchange-b293bda4acfe01f6254670779b8ac97e8b55990c.tar.bz2
exchange-b293bda4acfe01f6254670779b8ac97e8b55990c.zip
implement DB plugin function to obtain reserve information, migrate logic to simplified API spec (#3887); use plugin API in /payback DB implementation
Diffstat (limited to 'src/exchange')
-rw-r--r--src/exchange/taler-exchange-httpd_db.c31
-rw-r--r--src/exchange/taler-exchange-httpd_db.h2
-rw-r--r--src/exchange/taler-exchange-httpd_payback.c1
-rw-r--r--src/exchange/taler-exchange-httpd_responses.c13
-rw-r--r--src/exchange/taler-exchange-httpd_responses.h4
5 files changed, 31 insertions, 20 deletions
diff --git a/src/exchange/taler-exchange-httpd_db.c b/src/exchange/taler-exchange-httpd_db.c
index eb7058bb2..fe417663d 100644
--- a/src/exchange/taler-exchange-httpd_db.c
+++ b/src/exchange/taler-exchange-httpd_db.c
@@ -2269,6 +2269,7 @@ TEH_DB_execute_track_transaction (struct MHD_Connection *connection,
* @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
*/
@@ -2277,13 +2278,13 @@ 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_EXCHANGEDB_CollectableBlindcoin collectable;
- char wire_subject[42]; // FIXME: size? (#3887)
+ struct TALER_ReservePublicKeyP reserve_pub;
struct TALER_Amount amount;
struct TALER_Amount spent;
struct GNUNET_TIME_Absolute payback_deadline;
@@ -2297,12 +2298,12 @@ TEH_DB_execute_payback (struct MHD_Connection *connection,
START_TRANSACTION (session, connection);
- /* FIXME (#3887): not _exactly_ the right call, we need to get the
- reserve's incoming wire transfer data, not 'collectable' */
- ret = TEH_plugin->get_withdraw_info (TEH_plugin->cls,
- session,
- h_blind,
- &collectable);
+ /* 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);
@@ -2358,8 +2359,16 @@ TEH_DB_execute_payback (struct MHD_Connection *connection,
TEH_plugin->free_coin_transaction_list (TEH_plugin->cls,
tl);
- /* FIXME: add coin to list of wire transfers for payback */
- // ret = TEH_plugin->(); // #3887
+ /* 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,
+ h_blind,
+ &amount,
+ &payback_deadline);
if (GNUNET_SYSERR == ret)
{
TALER_LOG_WARNING ("Failed to store /payback information in database\n");
@@ -2373,7 +2382,7 @@ TEH_DB_execute_payback (struct MHD_Connection *connection,
return TEH_RESPONSE_reply_payback_success (connection,
&coin->coin_pub,
- wire_subject,
+ &reserve_pub,
&amount,
payback_deadline);
}
diff --git a/src/exchange/taler-exchange-httpd_db.h b/src/exchange/taler-exchange-httpd_db.h
index 520a6f59e..d2a0168db 100644
--- a/src/exchange/taler-exchange-httpd_db.h
+++ b/src/exchange/taler-exchange-httpd_db.h
@@ -246,6 +246,7 @@ TEH_DB_execute_track_transaction (struct MHD_Connection *connection,
* @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
* @return MHD result code
*/
@@ -254,6 +255,7 @@ 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);
diff --git a/src/exchange/taler-exchange-httpd_payback.c b/src/exchange/taler-exchange-httpd_payback.c
index 31235729e..b4b664f94 100644
--- a/src/exchange/taler-exchange-httpd_payback.c
+++ b/src/exchange/taler-exchange-httpd_payback.c
@@ -134,6 +134,7 @@ verify_and_execute_payback (struct MHD_Connection *connection,
coin,
&value,
&h_blind,
+ coin_bks,
coin_sig);
}
diff --git a/src/exchange/taler-exchange-httpd_responses.c b/src/exchange/taler-exchange-httpd_responses.c
index efe3ee091..96587c4d1 100644
--- a/src/exchange/taler-exchange-httpd_responses.c
+++ b/src/exchange/taler-exchange-httpd_responses.c
@@ -1320,7 +1320,8 @@ TEH_RESPONSE_reply_payback_unknown (struct MHD_Connection *connection,
* A wallet asked for /payback, return the successful response.
*
* @param connection connection to the client
- * @param wire_subject the wire subject we will use for the pay back operation
+ * @param coin_pub coin for which we are processing the payback request
+ * @param reserve_pub public key of the reserve that will receive the payback
* @param amount the amount we will wire back
* @param payback_deadline deadline by which the exchange promises to pay
* @return MHD result code
@@ -1328,7 +1329,7 @@ TEH_RESPONSE_reply_payback_unknown (struct MHD_Connection *connection,
int
TEH_RESPONSE_reply_payback_success (struct MHD_Connection *connection,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
- const char *wire_subject,
+ const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_Amount *amount,
struct GNUNET_TIME_Absolute payback_deadline)
{
@@ -1342,16 +1343,14 @@ TEH_RESPONSE_reply_payback_success (struct MHD_Connection *connection,
TALER_amount_hton (&pc.payback_amount,
amount);
pc.coin_pub = *coin_pub;
- GNUNET_CRYPTO_hash (wire_subject,
- strlen (wire_subject),
- &pc.h_wire_subject);
+ pc.reserve_pub = *reserve_pub;
TEH_KS_sign (&pc.purpose,
&pub,
&sig);
return TEH_RESPONSE_reply_json_pack (connection,
MHD_HTTP_OK,
- "{s:s, s:o, s:o, s:o, s:o}",
- "wire_subject", wire_subject,
+ "{s:o, s:o, s:o, s:o, s:o}",
+ "reserve_pub", GNUNET_JSON_from_data_auto (reserve_pub),
"payback_deadline", GNUNET_JSON_from_time_abs (payback_deadline),
"amount", TALER_JSON_from_amount (amount),
"exchange_sig", GNUNET_JSON_from_data_auto (&sig),
diff --git a/src/exchange/taler-exchange-httpd_responses.h b/src/exchange/taler-exchange-httpd_responses.h
index e12229565..6b68949e5 100644
--- a/src/exchange/taler-exchange-httpd_responses.h
+++ b/src/exchange/taler-exchange-httpd_responses.h
@@ -577,7 +577,7 @@ TEH_RESPONSE_reply_payback_unknown (struct MHD_Connection *connection,
*
* @param connection connection to the client
* @param coin_pub coin for which we are processing the payback request
- * @param wire_subject the wire subject we will use for the pay back operation
+ * @param reserve_pub public key of the reserve that will receive the payback
* @param amount the amount we will wire back
* @param payback_deadline deadline by which the exchange promises to pay
* @return MHD result code
@@ -585,7 +585,7 @@ TEH_RESPONSE_reply_payback_unknown (struct MHD_Connection *connection,
int
TEH_RESPONSE_reply_payback_success (struct MHD_Connection *connection,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
- const char *wire_subject,
+ const struct TALER_ReservePublicKeyP *reserve_pub,
const struct TALER_Amount *amount,
struct GNUNET_TIME_Absolute payback_deadline);