summaryrefslogtreecommitdiff
path: root/src/backenddb
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-05-17 22:52:27 +0200
committerChristian Grothoff <christian@grothoff.org>2020-05-17 22:52:27 +0200
commitdc6a6c0ad87a34198a49ea31b39c2eb2bd1e0acb (patch)
tree6a0c706c619a3ada56b7d8bf4169be9b5af48fca /src/backenddb
parentde6225f820a6e1627786874d8df9df99b5f5e4bc (diff)
downloadmerchant-dc6a6c0ad87a34198a49ea31b39c2eb2bd1e0acb.tar.gz
merchant-dc6a6c0ad87a34198a49ea31b39c2eb2bd1e0acb.tar.bz2
merchant-dc6a6c0ad87a34198a49ea31b39c2eb2bd1e0acb.zip
misc. fixes
Diffstat (limited to 'src/backenddb')
-rw-r--r--src/backenddb/merchant-0001.sql2
-rw-r--r--src/backenddb/plugin_merchantdb_postgres.c136
2 files changed, 68 insertions, 70 deletions
diff --git a/src/backenddb/merchant-0001.sql b/src/backenddb/merchant-0001.sql
index 9eb60e5c..5d502802 100644
--- a/src/backenddb/merchant-0001.sql
+++ b/src/backenddb/merchant-0001.sql
@@ -236,7 +236,7 @@ CREATE TABLE IF NOT EXISTS merchant_contract_terms
,paid BOOLEAN DEFAULT FALSE NOT NULL
,wired BOOLEAN DEFAULT FALSE NOT NULL
,fulfillment_url VARCHAR NOT NULL
- ,session_id VARCHAR NOT NULL
+ ,session_id VARCHAR DEFAULT '' NOT NULL
,UNIQUE (merchant_serial, order_id)
,UNIQUE (merchant_serial, h_contract_terms)
);
diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c
index 8c1646a7..c69507d6 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -3646,7 +3646,6 @@ postgres_lookup_transfers (void *cls,
by_time = ( (before.abs_value_us !=
GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us) ||
(after.abs_value_us != GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us) );
-
check_connection (pg);
GNUNET_snprintf (stmt,
sizeof (stmt),
@@ -3657,8 +3656,6 @@ postgres_lookup_transfers (void *cls,
params = (by_time)
? ( (NULL != payto_uri) ? params_payto_et : params_et)
: ( (NULL != payto_uri) ? params_payto : params_none);
-
- // FIXME: write SQL (_desc-variant!)
qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
stmt,
params,
@@ -3670,6 +3667,58 @@ postgres_lookup_transfers (void *cls,
}
+/**
+ * Store information about wire fees charged by an exchange,
+ * including signature (so we have proof).
+ *
+ * @param cls closure
+ * @paramm exchange_pub public key of the exchange
+ * @param h_wire_method hash of wire method
+ * @param wire_fee wire fee charged
+ * @param closing_fee closing fee charged (irrelevant for us,
+ * but needed to check signature)
+ * @param start_date start of fee being used
+ * @param end_date end of fee being used
+ * @param exchange_sig signature of exchange over fee structure
+ * @return transaction status code
+ */
+static enum GNUNET_DB_QueryStatus
+postgres_store_wire_fee_by_exchange (
+ void *cls,
+ const struct TALER_MasterPublicKeyP *master_pub,
+ const struct GNUNET_HashCode *h_wire_method,
+ const struct TALER_Amount *wire_fee,
+ const struct TALER_Amount *closing_fee,
+ struct GNUNET_TIME_Absolute start_date,
+ struct GNUNET_TIME_Absolute end_date,
+ const 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_auto_from_type (h_wire_method),
+ TALER_PQ_query_param_amount (wire_fee),
+ TALER_PQ_query_param_amount (closing_fee),
+ GNUNET_PQ_query_param_absolute_time (&start_date),
+ GNUNET_PQ_query_param_absolute_time (&end_date),
+ GNUNET_PQ_query_param_auto_from_type (master_sig),
+ GNUNET_PQ_query_param_end
+ };
+
+ /* no preflight check here, run in its own transaction by the caller */
+ check_connection (pg);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Storing wire fee for %s starting at %s of %s\n",
+ TALER_B2S (master_pub),
+ GNUNET_STRINGS_absolute_time_to_string (start_date),
+ TALER_amount2s (wire_fee));
+ return GNUNET_PQ_eval_prepared_non_select (pg->conn,
+ "insert_wire_fee",
+ params);
+}
+
+
/* ********************* OLD API ************************** */
/**
@@ -3885,58 +3934,6 @@ postgres_get_authorized_tip_amount (void *cls,
/**
- * Store information about wire fees charged by an exchange,
- * including signature (so we have proof).
- *
- * @param cls closure
- * @paramm exchange_pub public key of the exchange
- * @param h_wire_method hash of wire method
- * @param wire_fee wire fee charged
- * @param closing_fee closing fee charged (irrelevant for us,
- * but needed to check signature)
- * @param start_date start of fee being used
- * @param end_date end of fee being used
- * @param exchange_sig signature of exchange over fee structure
- * @return transaction status code
- */
-static enum GNUNET_DB_QueryStatus
-postgres_store_wire_fee_by_exchange (
- void *cls,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct GNUNET_HashCode *h_wire_method,
- const struct TALER_Amount *wire_fee,
- const struct TALER_Amount *closing_fee,
- struct GNUNET_TIME_Absolute start_date,
- struct GNUNET_TIME_Absolute end_date,
- const 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_auto_from_type (h_wire_method),
- TALER_PQ_query_param_amount (wire_fee),
- TALER_PQ_query_param_amount (closing_fee),
- GNUNET_PQ_query_param_absolute_time (&start_date),
- GNUNET_PQ_query_param_absolute_time (&end_date),
- GNUNET_PQ_query_param_auto_from_type (master_sig),
- GNUNET_PQ_query_param_end
- };
-
- /* no preflight check here, run in its own transaction by the caller */
- check_connection (pg);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Storing wire fee for %s starting at %s of %s\n",
- TALER_B2S (master_pub),
- GNUNET_STRINGS_absolute_time_to_string (start_date),
- TALER_amount2s (wire_fee));
- return GNUNET_PQ_eval_prepared_non_select (pg->conn,
- "insert_wire_fee",
- params);
-}
-
-
-/**
* Lookup proof information about a wire transfer.
*
* @param cls closure
@@ -6303,6 +6300,21 @@ libtaler_plugin_merchantdb_postgres_init (void *cls)
" ORDER BY credit_serial DESC"
" LIMIT $3",
3),
+ /* For postgres_store_wire_fee_by_exchange() */
+ GNUNET_PQ_make_prepare ("insert_wire_fee",
+ "INSERT INTO merchant_exchange_wire_fees"
+ "(master_pub"
+ ",h_wire_method"
+ ",wire_fee_val"
+ ",wire_fee_frac"
+ ",closing_fee_val"
+ ",closing_fee_frac"
+ ",start_date"
+ ",end_date"
+ ",master_sig)"
+ " VALUES "
+ "($1, $2, $3, $4, $5, $6, $7, $8, $9)",
+ 9),
/* OLD API: */
#if 0
@@ -6326,20 +6338,6 @@ libtaler_plugin_merchantdb_postgres_init (void *cls)
" VALUES "
"($1, $2, $3, $4, $5)",
5),
- GNUNET_PQ_make_prepare ("insert_wire_fee",
- "INSERT INTO exchange_wire_fees"
- "(exchange_pub"
- ",h_wire_method"
- ",wire_fee_val"
- ",wire_fee_frac"
- ",closing_fee_val"
- ",closing_fee_frac"
- ",start_date"
- ",end_date"
- ",exchange_sig)"
- " VALUES "
- "($1, $2, $3, $4, $5, $6, $7, $8, $9)",
- 9),
GNUNET_PQ_make_prepare ("find_contract_terms_from_hash",
"SELECT"
" contract_terms"