summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-05-06 19:32:36 +0200
committerChristian Grothoff <christian@grothoff.org>2020-05-06 19:32:36 +0200
commitc84339de2d37076cfd114ae1a097cf084d36b7a0 (patch)
treea01ac1f7b5fda6780b3198dbc73bf8c580ab8c60
parent2ba0fedd391988610d6d18d9e5b61ac00c9f663e (diff)
downloadmerchant-c84339de2d37076cfd114ae1a097cf084d36b7a0.tar.gz
merchant-c84339de2d37076cfd114ae1a097cf084d36b7a0.tar.bz2
merchant-c84339de2d37076cfd114ae1a097cf084d36b7a0.zip
fix ftbfs
-rw-r--r--src/backend/taler-merchant-httpd_private-post-transfers.c96
-rw-r--r--src/backenddb/plugin_merchantdb_postgres.c164
-rw-r--r--src/include/taler_merchantdb_plugin.h97
3 files changed, 204 insertions, 153 deletions
diff --git a/src/backend/taler-merchant-httpd_private-post-transfers.c b/src/backend/taler-merchant-httpd_private-post-transfers.c
index ce76a6f2..2f22d051 100644
--- a/src/backend/taler-merchant-httpd_private-post-transfers.c
+++ b/src/backend/taler-merchant-httpd_private-post-transfers.c
@@ -255,43 +255,17 @@ build_deposits_response (void *cls,
struct TrackTransferContext *rctx = cls;
struct Entry *entry = value;
json_t *element;
- json_t *contract_terms;
- json_t *order_id;
- TMH_db->preflight (TMH_db->cls);
- if (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- TMH_db->find_contract_terms_from_hash (TMH_db->cls,
- &contract_terms,
- key,
- &rctx->mi->pubkey))
- {
- GNUNET_break_op (0);
- return GNUNET_NO;
- }
-
- order_id = json_object_get (contract_terms,
- "order_id");
- if (NULL == order_id)
- {
- GNUNET_break_op (0);
- json_decref (contract_terms);
- return GNUNET_NO;
- }
- element = json_pack ("{s:O, s:o, s:o}",
- "order_id", order_id,
+ element = json_pack ("{s:s, s:o, s:o}",
+ "order_id", entry->order_id,
"deposit_value", TALER_JSON_from_amount (
&entry->deposit_value),
"deposit_fee", TALER_JSON_from_amount (
&entry->deposit_fee));
- json_decref (contract_terms);
- if (NULL == element)
- {
- GNUNET_break_op (0);
- return GNUNET_NO;
- }
- GNUNET_break (0 ==
- json_array_append_new (rctx->deposits_response,
- element));
+ GNUNET_assert (NULL != element);
+ GNUNET_assert (0 ==
+ json_array_append_new (rctx->deposits_response,
+ element));
return GNUNET_YES;
}
@@ -368,6 +342,7 @@ transform_response (const json_t *result,
current_entry = GNUNET_new (struct Entry);
current_entry->deposit_value = iter_value;
current_entry->deposit_fee = iter_fee;
+ current_entry->order_id = "FIXME";
if (GNUNET_SYSERR ==
GNUNET_CONTAINER_multihashmap_put (map,
@@ -595,25 +570,12 @@ check_wire_fee (struct TrackTransferContext *rctx,
*
* @param cls closure
* @param hr HTTP response details
- * @param exchange_pub public key of the exchange used to sign @a json
- * @param h_wire hash of the wire transfer address the transfer went to, or NULL on error
- * @param execution_time time when the exchange claims to have performed the wire transfer
- * @param total_amount total amount of the wire transfer, or NULL if the exchange could
- * not provide any @a wtid (set only if @a http_status is #MHD_HTTP_OK)
- * @param wire_fee wire fee that was charged by the exchange
- * @param details_length length of the @a details array
- * @param details array with details about the combined transactions
+ * @param td transfer data
*/
static void
wire_transfer_cb (void *cls,
const struct TALER_EXCHANGE_HttpResponse *hr,
- const struct TALER_ExchangePublicKeyP *exchange_pub,
- const struct GNUNET_HashCode *h_wire,
- struct GNUNET_TIME_Absolute execution_time,
- const struct TALER_Amount *total_amount,
- const struct TALER_Amount *wire_fee,
- unsigned int details_length,
- const struct TALER_TrackTransferDetails *details)
+ const struct TALER_EXCHANGE_TransferData *td)
{
struct TrackTransferContext *rctx = cls;
json_t *jresponse;
@@ -641,11 +603,7 @@ wire_transfer_cb (void *cls,
rctx->exchange_url,
rctx->payto_uri,
&rctx->wtid,
- total_amount,
- wire_fee,
- execution_time,
- details_length,
- details);
+ td);
if (0 > qs)
{
/* Special report if retries insufficient */
@@ -667,8 +625,8 @@ wire_transfer_cb (void *cls,
if (GNUNET_SYSERR ==
check_wire_fee (rctx,
hr->reply,
- execution_time,
- wire_fee))
+ td->execution_time,
+ &td->wire_fee))
return;
/* Now we want to double-check that any (Taler coin) deposit
@@ -679,7 +637,7 @@ wire_transfer_cb (void *cls,
* details_length is how many (Taler coin) deposits have been
* aggregated into _this_ wire transfer.
*///
- for (unsigned int i = 0; i<details_length; i++)
+ for (unsigned int i = 0; i < td->details_length; i++)
{
rctx->current_offset = i;
rctx->current_detail = &details[i];
@@ -688,8 +646,9 @@ wire_transfer_cb (void *cls,
TMH_db->preflight (TMH_db->cls);
qs = TMH_db->find_payments_by_hash_and_coin (TMH_db->cls,
&details[i].h_contract_terms,
- &rctx->mi->pubkey,
- &details[i].coin_pub,
+ &rctx->hc->instance->settings.
+ id,
+ &td->details[i].coin_pub,
&check_transfer,
rctx);
if (0 > qs)
@@ -699,8 +658,8 @@ wire_transfer_cb (void *cls,
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR != qs);
/* Always report on hard error as well to enable diagnostics */
GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);
- resume_track_transfer_with_response
- (rctx,
+ resume_track_transfer_with_response (
+ rctx,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_MHD_make_json_pack ("{s:I, s:s}",
"code",
@@ -724,8 +683,8 @@ wire_transfer_cb (void *cls,
/* Internal error: how can we have called #check_transfer()
but still have no result? */
GNUNET_break (0);
- resume_track_transfer_with_response
- (rctx,
+ resume_track_transfer_with_response (
+ rctx,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_MHD_make_json_pack ("{s:I, s:s, s:I, s:s}",
"code",
@@ -741,8 +700,8 @@ wire_transfer_cb (void *cls,
/* #check_transfer() failed, report conflict! */
GNUNET_break_op (0);
GNUNET_assert (NULL != rctx->response);
- resume_track_transfer_with_response
- (rctx,
+ resume_track_transfer_with_response (
+ rctx,
MHD_HTTP_FAILED_DEPENDENCY,
rctx->response);
rctx->response = NULL;
@@ -754,8 +713,8 @@ wire_transfer_cb (void *cls,
{
TMH_db->preflight (TMH_db->cls);
qs = TMH_db->store_coin_to_transfer (TMH_db->cls,
- &details[i].h_contract_terms,
- &details[i].coin_pub,
+ &td->details[i].h_contract_terms,
+ &td->details[i].coin_pub,
&rctx->wtid);
if (GNUNET_DB_STATUS_SOFT_ERROR != qs)
break;
@@ -766,8 +725,8 @@ wire_transfer_cb (void *cls,
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR != qs);
/* Always report on hard error as well to enable diagnostics */
GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);
- resume_track_transfer_with_response
- (rctx,
+ resume_track_transfer_with_response (
+ rctx,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_MHD_make_json_pack ("{s:I, s:s}",
"code",
@@ -1057,7 +1016,8 @@ TMH_private_post_transfers (const struct TMH_RequestHandler *rh,
rctx->exchange_url,
&rctx->wtid,
&rctx->amount,
- rctx->payto_uri);
+ rctx->payto_uri,
+ true /* confirmed! */);
if (0 > qs)
{
/* Simple select queries should not cause serialization issues */
diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c
index ef7deabb..e6bc5306 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -2692,6 +2692,108 @@ postgres_lookup_order_by_fulfillment (void *cls,
}
+/**
+ * Insert information about a wire transfer the merchant has received.
+ *
+ * @param cls closure
+ * @param exchange_url which exchange made the transfer
+ * @param wtid identifier of the wire transfer
+ * @param credit_amount how much did we receive
+ * @param payto_uri what is the merchant's bank account that received the transfer
+ * @param confirmed whether the transfer was confirmed by the merchant or
+ * was merely claimed by the exchange at this point
+ * @return transaction status
+ */
+static enum GNUNET_DB_QueryStatus
+postgres_insert_transfer (
+ void *cls,
+ const char *exchange_url,
+ const struct TALER_WireTransferIdentifierRawP *wtid,
+ const struct TALER_Amount *credit_amount,
+ const char *payto_uri,
+ bool confirmed)
+{
+}
+
+
+/**
+ * Insert information about a wire transfer the merchant has received.
+ *
+ * @param cls closure
+ * @param exchange_url which exchange made the transfer
+ * @param payto_uri what is the merchant's bank account that received the transfer
+ * @param wtid identifier of the wire transfer
+ * @param td transfer details to store
+ * @return transaction status
+ */
+static enum GNUNET_DB_QueryStatus
+postgres_insert_transfer_details (
+ void *cls,
+ const char *exchange_url, // FIXME: do we need the URL? We have exchange_pub!
+ const char *payto_uri,
+ const struct TALER_WireTransferIdentifierRawP *wtid,
+ const struct TALER_EXCHANGE_TransferData *td)
+{
+}
+
+
+/**
+ * Obtain information about wire fees charged by an exchange,
+ * including signature (so we have proof).
+ *
+ * @param cls closure
+ * @param master_pub public key of the exchange
+ * @param h_wire_method hash of wire method
+ * @param contract_date date of the contract to use for the lookup
+ * @param[out] wire_fee wire fee charged
+ * @param[out] closing_fee closing fee charged (irrelevant for us,
+ * but needed to check signature)
+ * @param[out] start_date start of fee being used
+ * @param[out] end_date end of fee being used
+ * @param[out] master_sig signature of exchange over fee structure
+ * @return transaction status code
+ */
+static enum GNUNET_DB_QueryStatus
+postgres_lookup_wire_fee (void *cls,
+ const struct TALER_MasterPublicKeyP *master_pub,
+ const char *wire_method,
+ struct GNUNET_TIME_Absolute contract_date,
+ struct TALER_Amount *wire_fee,
+ struct TALER_Amount *closing_fee,
+ struct GNUNET_TIME_Absolute *start_date,
+ struct GNUNET_TIME_Absolute *end_date,
+ struct TALER_MasterSignatureP *master_sig)
+{
+ struct PostgresClosure *pg = cls;
+ struct GNUNET_PQ_QueryParam params[] = {
+ GNUNET_PQ_query_param_auto_from_type (master_pub),
+ GNUNET_PQ_query_param_string (wire_method), // FIXME: hash first?
+ GNUNET_PQ_query_param_absolute_time (&contract_date),
+ GNUNET_PQ_query_param_end
+ };
+ struct GNUNET_PQ_ResultSpec rs[] = {
+ TALER_PQ_RESULT_SPEC_AMOUNT ("wire_fee",
+ wire_fee),
+ TALER_PQ_RESULT_SPEC_AMOUNT ("closing_fee",
+ closing_fee),
+ GNUNET_PQ_result_spec_absolute_time ("start_date",
+ start_date),
+ GNUNET_PQ_result_spec_absolute_time ("end_date",
+ end_date),
+ GNUNET_PQ_result_spec_auto_from_type ("master_sig",
+ master_sig),
+ GNUNET_PQ_result_spec_end
+ };
+
+ check_connection (pg);
+ // FIXME: SQL needs updating: wire_method, etc!
+ return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
+ "lookup_wire_fee",
+ params,
+ rs);
+}
+
+
/* ********************* OLD API ************************** */
/**
@@ -3521,62 +3623,6 @@ postgres_store_wire_fee_by_exchange (
/**
- * Obtain information about wire fees charged by an exchange,
- * including signature (so we have proof).
- *
- * @param cls closure
- * @param exchange_pub public key of the exchange
- * @param h_wire_method hash of wire method
- * @param contract_date date of the contract to use for the lookup
- * @param[out] wire_fee wire fee charged
- * @param[out] closing_fee closing fee charged (irrelevant for us,
- * but needed to check signature)
- * @param[out] start_date start of fee being used
- * @param[out] end_date end of fee being used
- * @param[out] exchange_sig signature of exchange over fee structure
- * @return transaction status code
- */
-static enum GNUNET_DB_QueryStatus
-postgres_lookup_wire_fee (void *cls,
- const struct TALER_MasterPublicKeyP *exchange_pub,
- const struct GNUNET_HashCode *h_wire_method,
- struct GNUNET_TIME_Absolute contract_date,
- struct TALER_Amount *wire_fee,
- struct TALER_Amount *closing_fee,
- struct GNUNET_TIME_Absolute *start_date,
- struct GNUNET_TIME_Absolute *end_date,
- struct TALER_MasterSignatureP *exchange_sig)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (exchange_pub),
- GNUNET_PQ_query_param_auto_from_type (h_wire_method),
- GNUNET_PQ_query_param_absolute_time (&contract_date),
- GNUNET_PQ_query_param_end
- };
- struct GNUNET_PQ_ResultSpec rs[] = {
- TALER_PQ_RESULT_SPEC_AMOUNT ("wire_fee",
- wire_fee),
- TALER_PQ_RESULT_SPEC_AMOUNT ("closing_fee",
- closing_fee),
- GNUNET_PQ_result_spec_absolute_time ("start_date",
- start_date),
- GNUNET_PQ_result_spec_absolute_time ("end_date",
- end_date),
- GNUNET_PQ_result_spec_auto_from_type ("exchange_sig",
- exchange_sig),
- GNUNET_PQ_result_spec_end
- };
-
- check_connection (pg);
- return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
- "lookup_wire_fee",
- params,
- rs);
-}
-
-
-/**
* Lookup proof information about a wire transfer.
*
* @param cls closure
@@ -5896,6 +5942,11 @@ libtaler_plugin_merchantdb_postgres_init (void *cls)
plugin->insert_refund_proof = &postgres_insert_refund_proof;
plugin->lookup_refund_proof = &postgres_lookup_refund_proof;
plugin->lookup_order_by_fulfillment = &postgres_lookup_order_by_fulfillment;
+ /* WIP: */
+ plugin->insert_transfer = &postgres_insert_transfer;
+ plugin->insert_transfer_details = &postgres_insert_transfer_details;
+ plugin->lookup_wire_fee = &postgres_lookup_wire_fee;
+
/* OLD API: */
plugin->store_coin_to_transfer = &postgres_store_coin_to_transfer;
plugin->store_transfer_to_proof = &postgres_store_transfer_to_proof;
@@ -5906,7 +5957,6 @@ libtaler_plugin_merchantdb_postgres_init (void *cls)
plugin->find_deposits_by_wtid = &postgres_find_deposits_by_wtid;
plugin->find_proof_by_wtid = &postgres_find_proof_by_wtid;
plugin->get_authorized_tip_amount = &postgres_get_authorized_tip_amount;
- plugin->lookup_wire_fee = &postgres_lookup_wire_fee;
plugin->enable_tip_reserve_TR = &postgres_enable_tip_reserve_TR;
plugin->authorize_tip_TR = &postgres_authorize_tip_TR;
plugin->lookup_tip_by_id = &postgres_lookup_tip_by_id;
diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h
index 6e2f8005..e0f76999 100644
--- a/src/include/taler_merchantdb_plugin.h
+++ b/src/include/taler_merchantdb_plugin.h
@@ -24,6 +24,7 @@
#include <gnunet/gnunet_util_lib.h>
#include <gnunet/gnunet_db_lib.h>
+#include <taler/taler_exchange_service.h>
#include <jansson.h>
/**
@@ -1194,6 +1195,74 @@ struct TALER_MERCHANTDB_Plugin
const char *session_id,
char **order_id);
+ /**
+ * Insert information about a wire transfer the merchant has received.
+ *
+ * @param cls closure
+ * @param exchange_url which exchange made the transfer
+ * @param wtid identifier of the wire transfer
+ * @param credit_amount how much did we receive
+ * @param payto_uri what is the merchant's bank account that received the transfer
+ * @param confirmed whether the transfer was confirmed by the merchant or
+ * was merely claimed by the exchange at this point
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_transfer)(
+ void *cls,
+ const char *exchange_url,
+ const struct TALER_WireTransferIdentifierRawP *wtid,
+ const struct TALER_Amount *credit_amount,
+ const char *payto_uri,
+ bool confirmed);
+
+
+ /**
+ * Insert information about a wire transfer the merchant has received.
+ *
+ * @param cls closure
+ * @param exchange_url which exchange made the transfer
+ * @param payto_uri what is the merchant's bank account that received the transfer
+ * @param wtid identifier of the wire transfer
+ * @param td transfer details to store
+ * @return transaction status
+ */
+ enum GNUNET_DB_QueryStatus
+ (*insert_transfer_details)(
+ void *cls,
+ const char *exchange_url, // FIXME: do we need the URL? We have exchange_pub!
+ const char *payto_uri,
+ const struct TALER_WireTransferIdentifierRawP *wtid,
+ const struct TALER_EXCHANGE_TransferData *td);
+
+
+ /**
+ * Obtain information about wire fees charged by an exchange,
+ * including signature (so we have proof).
+ *
+ * @param cls closure
+ * @param master_pub master public key of the exchange
+ * @param h_wire_method hash of wire method
+ * @param contract_date date of the contract to use for the lookup
+ * @param[out] wire_fee wire fee charged
+ * @param[out] closing_fee closing fee charged (irrelevant for us,
+ * but needed to check signature)
+ * @param[out] start_date start of fee being used
+ * @param[out] end_date end of fee being used
+ * @param[out] master_sig signature of exchange over fee structure
+ * @return transaction status code
+ */
+ enum GNUNET_DB_QueryStatus
+ (*lookup_wire_fee)(void *cls,
+ const struct TALER_MasterPublicKeyP *master_pub,
+ const char *wire_method,
+ struct GNUNET_TIME_Absolute contract_date,
+ struct TALER_Amount *wire_fee,
+ struct TALER_Amount *closing_fee,
+ struct GNUNET_TIME_Absolute *start_date,
+ struct GNUNET_TIME_Absolute *end_date,
+ struct TALER_MasterSignatureP *master_sig);
+
/* ****************** OLD API ******************** */
@@ -1450,34 +1519,6 @@ struct TALER_MERCHANTDB_Plugin
/**
- * Obtain information about wire fees charged by an exchange,
- * including signature (so we have proof).
- *
- * @param cls closure
- * @param exchange_pub public key of the exchange
- * @param h_wire_method hash of wire method
- * @param contract_date date of the contract to use for the lookup
- * @param[out] wire_fee wire fee charged
- * @param[out] closing_fee closing fee charged (irrelevant for us,
- * but needed to check signature)
- * @param[out] start_date start of fee being used
- * @param[out] end_date end of fee being used
- * @param[out] exchange_sig signature of exchange over fee structure
- * @return transaction status code
- */
- enum GNUNET_DB_QueryStatus
- (*lookup_wire_fee)(void *cls,
- const struct TALER_MasterPublicKeyP *exchange_pub,
- const struct GNUNET_HashCode *h_wire_method,
- struct GNUNET_TIME_Absolute contract_date,
- struct TALER_Amount *wire_fee,
- struct TALER_Amount *closing_fee,
- struct GNUNET_TIME_Absolute *start_date,
- struct GNUNET_TIME_Absolute *end_date,
- struct TALER_MasterSignatureP *exchange_sig);
-
-
- /**
* Obtain refund proofs associated with a refund operation on a
* coin.
*