gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-exchange] branch master updated: -misc p2p fixes


From: gnunet
Subject: [taler-exchange] branch master updated: -misc p2p fixes
Date: Sun, 24 Apr 2022 15:30:00 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new aedd2014 -misc p2p fixes
aedd2014 is described below

commit aedd2014ec50e2b52cad76d9c40c218ed0c9ccfc
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Apr 24 15:29:50 2022 +0200

    -misc p2p fixes
---
 src/exchange/taler-exchange-httpd_purses_merge.c   |  3 +++
 src/exchangedb/exchange-0001-part.sql              |  1 +
 src/exchangedb/plugin_exchangedb_postgres.c        | 11 +++++++----
 src/include/taler_exchange_service.h               |  2 --
 src/lib/exchange_api_purse_create_with_deposit.c   |  9 ++++-----
 src/lib/exchange_api_purse_merge.c                 | 21 +++++++++++++--------
 src/testing/test_exchange_p2p.c                    |  2 +-
 src/testing/testing_api_cmd_purse_create_deposit.c | 21 +++++++++------------
 src/testing/testing_api_cmd_purse_merge.c          |  9 ++++-----
 src/util/wallet_signatures.c                       |  2 +-
 10 files changed, 43 insertions(+), 38 deletions(-)

diff --git a/src/exchange/taler-exchange-httpd_purses_merge.c 
b/src/exchange/taler-exchange-httpd_purses_merge.c
index b998a3b1..ee8a7375 100644
--- a/src/exchange/taler-exchange-httpd_purses_merge.c
+++ b/src/exchange/taler-exchange-httpd_purses_merge.c
@@ -388,6 +388,9 @@ TEH_handler_purses_merge (
     break;
   }
   /* parse 'payto_uri' into pcc.reserve_pub and provider_url */
+  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+              "Received payto: `%s'\n",
+              pcc.payto_uri);
   if ( (0 != strncmp (pcc.payto_uri,
                       "payto://taler/",
                       strlen ("payto://taler/"))) &&
diff --git a/src/exchangedb/exchange-0001-part.sql 
b/src/exchangedb/exchange-0001-part.sql
index 0a333880..4785964d 100644
--- a/src/exchangedb/exchange-0001-part.sql
+++ b/src/exchangedb/exchange-0001-part.sql
@@ -2647,6 +2647,7 @@ PERFORM
 IF NOT FOUND
 THEN
   out_no_balance=TRUE;
+  out_conflict=FALSE;
   RETURN;
 END IF;
 out_no_balance=FALSE;
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c 
b/src/exchangedb/plugin_exchangedb_postgres.c
index 93d71e59..d27ff778 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -13066,7 +13066,7 @@ postgres_select_contract (void *cls,
                                           purse_pub),
     GNUNET_PQ_result_spec_auto_from_type ("contract_sig",
                                           econtract_sig),
-    GNUNET_PQ_result_spec_variable_size ("econtract",
+    GNUNET_PQ_result_spec_variable_size ("e_contract",
                                          econtract,
                                          econtract_size),
     GNUNET_PQ_result_spec_end
@@ -13111,7 +13111,7 @@ postgres_select_contract_by_purse (void *cls,
                                           pub_ckey),
     GNUNET_PQ_result_spec_auto_from_type ("contract_sig",
                                           econtract_sig),
-    GNUNET_PQ_result_spec_variable_size ("econtract",
+    GNUNET_PQ_result_spec_variable_size ("e_contract",
                                          econtract,
                                          econtract_size),
     GNUNET_PQ_result_spec_end
@@ -13430,8 +13430,9 @@ postgres_do_purse_deposit (
   bool *conflict)
 {
   struct PostgresClosure *pg = cls;
+  uint64_t partner_id = 0;
   struct GNUNET_PQ_QueryParam params[] = {
-    GNUNET_PQ_query_param_uint64 (0), /* FIXME: partner ID */
+    GNUNET_PQ_query_param_uint64 (&partner_id),
     GNUNET_PQ_query_param_auto_from_type (purse_pub),
     TALER_PQ_query_param_amount (amount),
     GNUNET_PQ_query_param_auto_from_type (coin_pub),
@@ -13537,7 +13538,9 @@ postgres_do_purse_merge (
     GNUNET_PQ_query_param_auto_from_type (merge_sig),
     GNUNET_PQ_query_param_timestamp (&merge_timestamp),
     GNUNET_PQ_query_param_auto_from_type (reserve_sig),
-    GNUNET_PQ_query_param_string (partner_url),
+    (NULL == partner_url)
+    ? GNUNET_PQ_query_param_null ()
+    : GNUNET_PQ_query_param_string (partner_url),
     GNUNET_PQ_query_param_auto_from_type (reserve_pub),
     GNUNET_PQ_query_param_end
   };
diff --git a/src/include/taler_exchange_service.h 
b/src/include/taler_exchange_service.h
index 6bb29807..a3600775 100644
--- a/src/include/taler_exchange_service.h
+++ b/src/include/taler_exchange_service.h
@@ -4256,7 +4256,6 @@ struct TALER_EXCHANGE_PurseDeposit
  * @param merge_priv the merge credential
  * @param contract_priv key needed to obtain and decrypt the contract
  * @param contract_terms contract the purse is about
- * @param purse_expiration when will the unmerged purse expire
  * @param num_deposits length of the @a deposits array
  * @param deposits array of deposits to make into the purse
  * @param upload_contract true to upload the contract; must
@@ -4273,7 +4272,6 @@ TALER_EXCHANGE_purse_create_with_deposit (
   const struct TALER_PurseMergePrivateKeyP *merge_priv,
   const struct TALER_ContractDiffiePrivateP *contract_priv,
   const json_t *contract_terms,
-  struct GNUNET_TIME_Timestamp purse_expiration,
   unsigned int num_deposits,
   const struct TALER_EXCHANGE_PurseDeposit *deposits,
   bool upload_contract,
diff --git a/src/lib/exchange_api_purse_create_with_deposit.c 
b/src/lib/exchange_api_purse_create_with_deposit.c
index f6f8c2d8..60f0f736 100644
--- a/src/lib/exchange_api_purse_create_with_deposit.c
+++ b/src/lib/exchange_api_purse_create_with_deposit.c
@@ -242,7 +242,6 @@ TALER_EXCHANGE_purse_create_with_deposit (
   const struct TALER_PurseMergePrivateKeyP *merge_priv,
   const struct TALER_ContractDiffiePrivateP *contract_priv,
   const json_t *contract_terms,
-  struct GNUNET_TIME_Timestamp purse_expiration,
   unsigned int num_deposits,
   const struct TALER_EXCHANGE_PurseDeposit *deposits,
   bool upload_contract,
@@ -265,10 +264,10 @@ TALER_EXCHANGE_purse_create_with_deposit (
   pch->exchange = exchange;
   pch->cb = cb;
   pch->cb_cls = cb_cls;
-  // FIXME: get expiration from pay deadline of contract?
-  pch->purse_expiration = purse_expiration;
   {
     struct GNUNET_JSON_Specification spec[] = {
+      GNUNET_JSON_spec_timestamp ("pay_deadline",
+                                  &pch->purse_expiration),
       TALER_JSON_spec_amount_any ("amount",
                                   &pch->purse_value_after_fees),
       GNUNET_JSON_spec_mark_optional (
@@ -390,7 +389,7 @@ TALER_EXCHANGE_purse_create_with_deposit (
                                           jdeposit));
   }
   GNUNET_free (url);
-  TALER_wallet_purse_create_sign (purse_expiration,
+  TALER_wallet_purse_create_sign (pch->purse_expiration,
                                   &pch->h_contract_terms,
                                   &pch->merge_pub,
                                   min_age,
@@ -443,7 +442,7 @@ TALER_EXCHANGE_purse_create_with_deposit (
       GNUNET_JSON_pack_data_auto ("h_contract_terms",
                                   &pch->h_contract_terms),
       GNUNET_JSON_pack_timestamp ("purse_expiration",
-                                  purse_expiration),
+                                  pch->purse_expiration),
       GNUNET_JSON_pack_array_steal ("deposits",
                                     deposit_arr));
     GNUNET_free (econtract);
diff --git a/src/lib/exchange_api_purse_merge.c 
b/src/lib/exchange_api_purse_merge.c
index e541afab..2dc9e4ca 100644
--- a/src/lib/exchange_api_purse_merge.c
+++ b/src/lib/exchange_api_purse_merge.c
@@ -272,7 +272,10 @@ TALER_EXCHANGE_account_merge (
   pch->h_contract_terms = *h_contract_terms;
   pch->purse_expiration = purse_expiration;
   pch->purse_value_after_fees = *purse_value_after_fees;
-  pch->provider_url = GNUNET_strdup (reserve_exchange_url);
+  if (NULL == reserve_exchange_url)
+    pch->provider_url = GNUNET_strdup (exchange->url);
+  else
+    pch->provider_url = GNUNET_strdup (reserve_exchange_url);
   GNUNET_CRYPTO_eddsa_key_get_public (&reserve_priv->eddsa_priv,
                                       &pch->reserve_pub.eddsa_pub);
 
@@ -305,31 +308,33 @@ TALER_EXCHANGE_account_merge (
       pub_str,
       sizeof (pub_str));
     *end = '\0';
-    if (0 == strncmp (reserve_exchange_url,
+    if (0 == strncmp (pch->provider_url,
                       "http://";,
                       strlen ("http://";)))
     {
       is_http = true;
-      exchange_url = &reserve_exchange_url[strlen ("http://";)];
+      exchange_url = &pch->provider_url[strlen ("http://";)];
     }
-    else if (0 == strncmp (reserve_exchange_url,
+    else if (0 == strncmp (pch->provider_url,
                            "https://";,
                            strlen ("https://";)))
     {
       is_http = false;
-      exchange_url = &reserve_exchange_url[strlen ("https://";)];
+      exchange_url = &pch->provider_url[strlen ("https://";)];
     }
     else
     {
       GNUNET_break (0);
+      GNUNET_free (pch->provider_url);
       GNUNET_free (pch);
       return NULL;
     }
+    /* exchange_url includes trailing '/' */
     GNUNET_asprintf (&reserve_url,
-                     "payto://%s/%s/%s",
+                     "payto://%s/%s%s",
                      is_http ? "taler+http" : "taler",
-                     pub_str,
-                     exchange_url);
+                     exchange_url,
+                     pub_str);
   }
   pch->url = TEAH_path_to_url (exchange,
                                arg_str);
diff --git a/src/testing/test_exchange_p2p.c b/src/testing/test_exchange_p2p.c
index b16b2f0a..e4b334aa 100644
--- a/src/testing/test_exchange_p2p.c
+++ b/src/testing/test_exchange_p2p.c
@@ -158,7 +158,7 @@ run (void *cls,
       true, /* upload contract */
       GNUNET_TIME_UNIT_MINUTES, /* expiration */
       "withdraw-coin-1",
-      "EUR:1", /* FIXME: check amount vs. fees! */
+      "EUR:1.01", /* FIXME: check amount vs. fees! */
       NULL),
     TALER_TESTING_cmd_contract_get (
       "purse-get-contract",
diff --git a/src/testing/testing_api_cmd_purse_create_deposit.c 
b/src/testing/testing_api_cmd_purse_create_deposit.c
index 13b2dffa..ef98c905 100644
--- a/src/testing/testing_api_cmd_purse_create_deposit.c
+++ b/src/testing/testing_api_cmd_purse_create_deposit.c
@@ -259,17 +259,23 @@ deposit_run (void *cls,
   GNUNET_CRYPTO_eddsa_key_create (&ds->purse_priv.eddsa_priv);
   GNUNET_CRYPTO_eddsa_key_create (&ds->merge_priv.eddsa_priv);
   GNUNET_CRYPTO_ecdhe_key_create (&ds->contract_priv.ecdhe_priv);
-  ds->purse_expiration
-    = GNUNET_TIME_relative_to_timestamp (ds->rel_expiration);
   GNUNET_CRYPTO_eddsa_key_get_public (&ds->purse_priv.eddsa_priv,
                                       &ds->purse_pub.eddsa_pub);
+
+  ds->purse_expiration =
+    GNUNET_TIME_absolute_to_timestamp (
+      GNUNET_TIME_relative_to_absolute (ds->rel_expiration));
+  GNUNET_assert (0 ==
+                 json_object_set_new (
+                   ds->contract_terms,
+                   "pay_deadline",
+                   GNUNET_JSON_from_timestamp (ds->purse_expiration)));
   ds->dh = TALER_EXCHANGE_purse_create_with_deposit (
     is->exchange,
     &ds->purse_priv,
     &ds->merge_priv,
     &ds->contract_priv,
     ds->contract_terms,
-    ds->purse_expiration,
     ds->num_coin_references,
     deposits,
     ds->upload_contract,
@@ -361,7 +367,6 @@ TALER_TESTING_cmd_purse_create_with_deposit (
   ...)
 {
   struct PurseCreateDepositState *ds;
-  struct GNUNET_TIME_Timestamp pay_deadline;
 
   ds = GNUNET_new (struct PurseCreateDepositState);
   ds->rel_expiration = purse_expiration;
@@ -378,14 +383,6 @@ TALER_TESTING_cmd_purse_create_with_deposit (
                 label);
     GNUNET_assert (0);
   }
-  pay_deadline =
-    GNUNET_TIME_absolute_to_timestamp (
-      GNUNET_TIME_relative_to_absolute (purse_expiration));
-  GNUNET_assert (0 ==
-                 json_object_set_new (
-                   ds->contract_terms,
-                   "pay_deadline",
-                   GNUNET_JSON_from_timestamp (pay_deadline)));
   {
     va_list ap;
     unsigned int i;
diff --git a/src/testing/testing_api_cmd_purse_merge.c 
b/src/testing/testing_api_cmd_purse_merge.c
index a17f8a9d..27aa120e 100644
--- a/src/testing/testing_api_cmd_purse_merge.c
+++ b/src/testing/testing_api_cmd_purse_merge.c
@@ -128,7 +128,7 @@ merge_run (void *cls,
   const struct TALER_PurseMergePrivateKeyP *merge_priv;
   const json_t *ct;
   struct TALER_PrivateContractHashP h_contract_terms;
-  uint32_t min_age;
+  uint32_t min_age = 0;
   struct TALER_Amount value_after_fees;
   struct GNUNET_TIME_Timestamp purse_expiration;
   const struct TALER_TESTING_Command *ref;
@@ -172,6 +172,8 @@ merge_run (void *cls,
   }
   {
     struct GNUNET_JSON_Specification spec[] = {
+      GNUNET_JSON_spec_timestamp ("pay_deadline",
+                                  &purse_expiration),
       TALER_JSON_spec_amount_any ("amount",
                                   &value_after_fees),
       GNUNET_JSON_spec_mark_optional (
@@ -192,9 +194,6 @@ merge_run (void *cls,
     }
   }
 
-  // FIXME: how to get purse_expiration nicely!?!?
-  // See create_with_deposit FIXME: from pay deadline?
-
   if (NULL == ds->reserve_ref)
   {
     GNUNET_CRYPTO_eddsa_key_create (&ds->reserve_priv.eddsa_priv);
@@ -204,7 +203,7 @@ merge_run (void *cls,
     const struct TALER_ReservePrivateKeyP *rp;
 
     ref = TALER_TESTING_interpreter_lookup_command (ds->is,
-                                                    ds->merge_ref);
+                                                    ds->reserve_ref);
     GNUNET_assert (NULL != ref);
     if (GNUNET_OK !=
         TALER_TESTING_get_trait_reserve_priv (ref,
diff --git a/src/util/wallet_signatures.c b/src/util/wallet_signatures.c
index f0ff2dc8..ce757b75 100644
--- a/src/util/wallet_signatures.c
+++ b/src/util/wallet_signatures.c
@@ -1033,7 +1033,7 @@ TALER_wallet_purse_merge_verify (
   TALER_payto_hash (reserve_url,
                     &pm.h_payto);
   return GNUNET_CRYPTO_eddsa_verify (
-    TALER_SIGNATURE_WALLET_ACCOUNT_MERGE,
+    TALER_SIGNATURE_WALLET_PURSE_MERGE,
     &pm,
     &merge_sig->eddsa_signature,
     &merge_pub->eddsa_pub);

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]