merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit 52de2d37fa7e5f46ed52a6719b40d80d2349720f
parent 16abbebef705c31af9731fff5cd619227e92b680
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sat, 11 Jun 2016 20:48:47 +0200

fixing #4160

Diffstat:
Msrc/backend/taler-merchant-httpd_responses.c | 2+-
Msrc/backend/taler-merchant-httpd_track-transaction.c | 4++++
Msrc/backend/taler-merchant-httpd_track-transfer.c | 2++
Msrc/backenddb/plugin_merchantdb_postgres.c | 14++++++++++++--
Msrc/backenddb/test_merchantdb.c | 3+++
Msrc/include/taler_merchantdb_plugin.h | 4++++
Msrc/lib/merchant_api_track_transaction.c | 9++++++---
7 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_responses.c b/src/backend/taler-merchant-httpd_responses.c @@ -400,7 +400,7 @@ TMH_RESPONSE_make_track_transaction_ok (unsigned int num_transfers, } GNUNET_assert (0 == json_array_append_new (j_transfers, - json_pack ("{s:o, s:o}", + json_pack ("{s:o, s:o, s:o}", "wtid", GNUNET_JSON_from_data_auto (&transfer->wtid), "execution_time", GNUNET_JSON_from_time_abs (transfer->execution_time), "coins", j_coins))); diff --git a/src/backend/taler-merchant-httpd_track-transaction.c b/src/backend/taler-merchant-httpd_track-transaction.c @@ -356,6 +356,7 @@ wire_deposits_cb (void *cls, db->store_transfer_to_proof (db->cls, tctx->exchange_uri, &tctx->current_wtid, + tctx->current_execution_time, exchange_pub, json)) { @@ -692,6 +693,7 @@ transaction_cb (void *cls, * @param coin_pub public key of the coin * @param wtid identifier of the wire transfer in which the exchange * send us the money for the coin deposit + * @param execution_time when was the wire transfer executed? * @param exchange_proof proof from exchange about what the deposit was for * NULL if we have not asked for this signature */ @@ -700,6 +702,7 @@ transfer_cb (void *cls, uint64_t transaction_id, const struct TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_WireTransferIdentifierRawP *wtid, + struct GNUNET_TIME_Absolute execution_time, const json_t *exchange_proof) { struct TrackCoinContext *tcc = cls; @@ -708,6 +711,7 @@ transfer_cb (void *cls, &tcc->coin_pub, sizeof (struct TALER_CoinSpendPublicKeyP))); tcc->wtid = *wtid; + tcc->execution_time = execution_time; tcc->have_wtid = GNUNET_YES; } diff --git a/src/backend/taler-merchant-httpd_track-transfer.c b/src/backend/taler-merchant-httpd_track-transfer.c @@ -277,6 +277,8 @@ wire_transfer_cb (void *cls, db->store_transfer_to_proof (db->cls, rctx->uri, &rctx->wtid, + GNUNET_TIME_UNIT_ZERO_ABS + /* FIXME: unknowable with current APIs */, exchange_pub, json)) { diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c @@ -183,6 +183,7 @@ postgres_initialize (void *cls) "CREATE TABLE IF NOT EXISTS merchant_proofs (" " exchange_uri VARCHAR NOT NULL" ",wtid BYTEA CHECK (LENGTH(wtid)=32)" + ",execution_time INT8 NOT NULL" ",signkey_pub BYTEA NOT NULL CHECK (LENGTH(signkey_pub)=32)" ",proof BYTEA NOT NULL" ",PRIMARY KEY (wtid, exchange_uri)" @@ -248,10 +249,11 @@ postgres_initialize (void *cls) "INSERT INTO merchant_proofs" "(exchange_uri" ",wtid" + ",execution_time" ",signkey_pub" ",proof) VALUES " - "($1, $2, $3, $4)", - 4); + "($1, $2, $3, $4, $5)", + 5); /* Setup prepared "SELECT" statements */ PG_PREPARE (pg, @@ -287,6 +289,7 @@ postgres_initialize (void *cls) "SELECT" " coin_pub" ",wtid" + ",merchant_proofs.execution_time" ",merchant_proofs.proof" " FROM merchant_transfers" " JOIN merchant_proofs USING (wtid)" @@ -481,6 +484,7 @@ postgres_store_coin_to_transfer (void *cls, * @param cls closure * @param exchange_uri URI of the exchange * @param wtid identifier of the wire transfer + * @param execution_time when was @a wtid executed * @param signkey_pub public key used by the exchange for @a exchange_proof * @param exchange_proof proof from exchange about what the deposit was for * @return #GNUNET_OK on success, #GNUNET_SYSERR upon error @@ -489,6 +493,7 @@ static int postgres_store_transfer_to_proof (void *cls, const char *exchange_uri, const struct TALER_WireTransferIdentifierRawP *wtid, + struct GNUNET_TIME_Absolute execution_time, const struct TALER_ExchangePublicKeyP *signkey_pub, const json_t *exchange_proof) { @@ -499,6 +504,7 @@ postgres_store_transfer_to_proof (void *cls, struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_string (exchange_uri), GNUNET_PQ_query_param_auto_from_type (wtid), + GNUNET_PQ_query_param_absolute_time (&execution_time), GNUNET_PQ_query_param_auto_from_type (signkey_pub), TALER_PQ_query_param_json (exchange_proof), GNUNET_PQ_query_param_end @@ -742,6 +748,7 @@ postgres_find_transfers_by_id (void *cls, { struct TALER_CoinSpendPublicKeyP coin_pub; struct TALER_WireTransferIdentifierRawP wtid; + struct GNUNET_TIME_Absolute execution_time; json_t *proof; struct GNUNET_PQ_ResultSpec rs[] = { @@ -749,6 +756,8 @@ postgres_find_transfers_by_id (void *cls, &coin_pub), GNUNET_PQ_result_spec_auto_from_type ("wtid", &wtid), + GNUNET_PQ_result_spec_absolute_time ("execution_time", + &execution_time), TALER_PQ_result_spec_json ("proof", &proof), GNUNET_PQ_result_spec_end @@ -767,6 +776,7 @@ postgres_find_transfers_by_id (void *cls, transaction_id, &coin_pub, &wtid, + execution_time, proof); GNUNET_PQ_cleanup_result (rs); } diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c @@ -203,6 +203,7 @@ deposit_cb (void *cls, * @param coin_pub public key of the coin * @param wtid identifier of the wire transfer in which the exchange * send us the money for the coin deposit + * @param execution_time when was the @a wtid transfer executed * @param exchange_proof proof from exchange about what the deposit was for * NULL if we have not asked for this signature */ @@ -211,6 +212,7 @@ transfer_cb (void *cls, uint64_t atransaction_id, const struct TALER_CoinSpendPublicKeyP *acoin_pub, const struct TALER_WireTransferIdentifierRawP *awtid, + struct GNUNET_TIME_Absolute execution_time, const json_t *exchange_proof) { CHECK (atransaction_id == transaction_id); @@ -309,6 +311,7 @@ run (void *cls) plugin->store_transfer_to_proof (plugin->cls, EXCHANGE_URI, &wtid, + GNUNET_TIME_UNIT_ZERO_ABS, &signkey_pub, transfer_proof)); FAILIF (GNUNET_OK != diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h @@ -86,6 +86,7 @@ typedef void * @param coin_pub public key of the coin * @param wtid identifier of the wire transfer in which the exchange * send us the money for the coin deposit + * @param execution_time when was the wire transfer executed? * @param exchange_proof proof from exchange about what the deposit was for * NULL if we have not asked for this signature */ @@ -94,6 +95,7 @@ typedef void uint64_t transaction_id, const struct TALER_CoinSpendPublicKeyP *coin_pub, const struct TALER_WireTransferIdentifierRawP *wtid, + struct GNUNET_TIME_Absolute execution_time, const json_t *exchange_proof); @@ -214,6 +216,7 @@ struct TALER_MERCHANTDB_Plugin * @param cls closure * @param exchange_uri from which exchange did we get the @a exchange_proof * @param wtid identifier of the wire transfer + * @param execution_time when was @a wtid executed * @param signkey_pub public key used by the exchange for @a exchange_proof * @param exchange_proof proof from exchange about what the deposit was for * @return #GNUNET_OK on success, #GNUNET_SYSERR upon error @@ -222,6 +225,7 @@ struct TALER_MERCHANTDB_Plugin (*store_transfer_to_proof) (void *cls, const char *exchange_uri, const struct TALER_WireTransferIdentifierRawP *wtid, + struct GNUNET_TIME_Absolute execution_time, const struct TALER_ExchangePublicKeyP *signkey_pub, const json_t *exchange_proof); diff --git a/src/lib/merchant_api_track_transaction.c b/src/lib/merchant_api_track_transaction.c @@ -110,9 +110,12 @@ parse_track_transaction_ok (struct TALER_MERCHANT_TrackTransactionHandle *tdo, json_t *coins; unsigned int j; struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_fixed_auto ("wtid", &transfer->wtid), - GNUNET_JSON_spec_absolute_time ("execution_time", &transfer->execution_time), - GNUNET_JSON_spec_json ("coins", &coins), + GNUNET_JSON_spec_fixed_auto ("wtid", + &transfer->wtid), + GNUNET_JSON_spec_absolute_time ("execution_time", + &transfer->execution_time), + GNUNET_JSON_spec_json ("coins", + &coins), GNUNET_JSON_spec_end() };