summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-10-25 22:40:11 +0100
committerChristian Grothoff <christian@grothoff.org>2020-10-25 22:40:11 +0100
commit46bfed8c3b1463c26ac0404188e9ff0613177c57 (patch)
treecf044d8150b44d3c81fc8b3142aabd375308ffbc /src
parent60f118f535ba3f6ce9ec5e91d422913f5f7aee4c (diff)
downloadmerchant-46bfed8c3b1463c26ac0404188e9ff0613177c57.tar.gz
merchant-46bfed8c3b1463c26ac0404188e9ff0613177c57.tar.bz2
merchant-46bfed8c3b1463c26ac0404188e9ff0613177c57.zip
benefit from #6524 implementation in GNUnet
Diffstat (limited to 'src')
-rw-r--r--src/backenddb/merchant-0001.sql4
-rw-r--r--src/backenddb/plugin_merchantdb_postgres.c39
-rw-r--r--src/testing/testing_api_cmd_merchant_get_order.c5
3 files changed, 9 insertions, 39 deletions
diff --git a/src/backenddb/merchant-0001.sql b/src/backenddb/merchant-0001.sql
index f75cbb28..a39a2436 100644
--- a/src/backenddb/merchant-0001.sql
+++ b/src/backenddb/merchant-0001.sql
@@ -242,7 +242,7 @@ CREATE TABLE IF NOT EXISTS merchant_contract_terms
,refund_deadline INT8 NOT NULL
,paid BOOLEAN DEFAULT FALSE NOT NULL
,wired BOOLEAN DEFAULT FALSE NOT NULL
- ,fulfillment_url VARCHAR NOT NULL
+ ,fulfillment_url VARCHAR
,session_id VARCHAR DEFAULT '' NOT NULL
,UNIQUE (merchant_serial, order_id)
,UNIQUE (merchant_serial, h_contract_terms)
@@ -264,7 +264,7 @@ COMMENT ON COLUMN merchant_contract_terms.paid
COMMENT ON COLUMN merchant_contract_terms.wired
IS 'true implies the exchange wired us the full amount for all non-refunded payments under this contract';
COMMENT ON COLUMN merchant_contract_terms.fulfillment_url
- IS 'also included in contract_terms, but we need it here to SELECT on it during repurchase detection';
+ IS 'also included in contract_terms, but we need it here to SELECT on it during repurchase detection; can be NULL if the contract has no fulfillment URL';
COMMENT ON COLUMN merchant_contract_terms.session_id
IS 'last session_id from we confirmed the paying client to use, empty string for none';
COMMENT ON COLUMN merchant_contract_terms.pay_deadline
diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c
index 4726979e..1a52c79e 100644
--- a/src/backenddb/plugin_merchantdb_postgres.c
+++ b/src/backenddb/plugin_merchantdb_postgres.c
@@ -1489,31 +1489,6 @@ postgres_lookup_contract_terms (void *cls,
/**
- * Create a dummy URL for the 'fulfillment' URL that consist
- * of random letters. Used because we do not like putting NULL
- * into the database, but do need to ensure that a query
- * never matches this URL.
- *
- * @return randomized URL starting with "void://", changes at
- * ever call to this function
- */
-static const char *
-make_dummy_url ()
-{
- static char buf[128] = "void://";
- struct GNUNET_HashCode hc;
-
- GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_NONCE,
- &hc);
- GNUNET_STRINGS_data_to_string (&hc,
- sizeof (hc),
- &buf[7],
- sizeof (buf) - 8);
- return buf;
-}
-
-
-/**
* Store contract terms given its @a order_id. Note that some attributes are
* expected to be calculated inside of the function, like the hash of the
* contract terms (to be hashed), the creation_time and pay_deadline (to be
@@ -1571,8 +1546,6 @@ postgres_insert_contract_terms (void *cls,
fulfillment_url =
json_string_value (json_object_get (contract_terms,
"fulfillment_url"));
- if (NULL == fulfillment_url)
- fulfillment_url = make_dummy_url ();
check_connection (pg);
{
struct GNUNET_PQ_QueryParam params[] = {
@@ -1582,7 +1555,9 @@ postgres_insert_contract_terms (void *cls,
GNUNET_PQ_query_param_auto_from_type (&h_contract_terms),
GNUNET_PQ_query_param_absolute_time (&pay_deadline),
GNUNET_PQ_query_param_absolute_time (&refund_deadline),
- GNUNET_PQ_query_param_string (fulfillment_url),
+ (NULL == fulfillment_url)
+ ? GNUNET_PQ_query_param_null ()
+ : GNUNET_PQ_query_param_string (fulfillment_url),
GNUNET_PQ_query_param_end
};
@@ -1651,9 +1626,6 @@ postgres_update_contract_terms (void *cls,
fulfillment_url =
json_string_value (json_object_get (contract_terms,
"fulfillment_url"));
- if (NULL == fulfillment_url)
- fulfillment_url = make_dummy_url ();
-
check_connection (pg);
{
struct GNUNET_PQ_QueryParam params[] = {
@@ -1663,7 +1635,9 @@ postgres_update_contract_terms (void *cls,
GNUNET_PQ_query_param_auto_from_type (&h_contract_terms),
GNUNET_PQ_query_param_absolute_time (&pay_deadline),
GNUNET_PQ_query_param_absolute_time (&refund_deadline),
- GNUNET_PQ_query_param_string (fulfillment_url),
+ (NULL == fulfillment_url)
+ ? GNUNET_PQ_query_param_null ()
+ : GNUNET_PQ_query_param_string (fulfillment_url),
GNUNET_PQ_query_param_end
};
@@ -3284,6 +3258,7 @@ postgres_lookup_order_by_fulfillment (void *cls,
order_id),
GNUNET_PQ_result_spec_end
};
+
return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
"lookup_order_by_fulfillment",
params,
diff --git a/src/testing/testing_api_cmd_merchant_get_order.c b/src/testing/testing_api_cmd_merchant_get_order.c
index 55a54532..fa9b6fb4 100644
--- a/src/testing/testing_api_cmd_merchant_get_order.c
+++ b/src/testing/testing_api_cmd_merchant_get_order.c
@@ -140,11 +140,6 @@ merchant_get_order_cb (
{
/* FIXME, deeper checks should be implemented here. */
struct MerchantGetOrderState *gos = cls;
- const struct TALER_TESTING_Command *order_cmd;
-
- order_cmd = TALER_TESTING_interpreter_lookup_command (
- gos->is,
- gos->order_reference);
gos->ogh = NULL;
if (gos->http_status != hr->http_status)