gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated: -some FIXMEs from API review


From: gnunet
Subject: [taler-exchange] branch master updated: -some FIXMEs from API review
Date: Thu, 02 Jun 2022 12:59:20 +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 5dd03fe3 -some FIXMEs from API review
5dd03fe3 is described below

commit 5dd03fe359f541f7e1e4849ed4bd38259200f4df
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Thu Jun 2 12:59:06 2022 +0200

    -some FIXMEs from API review
---
 src/exchange/taler-exchange-httpd_purses_create.c  | 37 ++++++++++++----------
 src/exchange/taler-exchange-httpd_purses_deposit.c |  1 +
 src/exchange/taler-exchange-httpd_purses_merge.c   | 20 +++++++++---
 src/exchange/taler-exchange-httpd_reserves_purse.c |  7 ++++
 4 files changed, 43 insertions(+), 22 deletions(-)

diff --git a/src/exchange/taler-exchange-httpd_purses_create.c 
b/src/exchange/taler-exchange-httpd_purses_create.c
index dba4fa4a..b46d2795 100644
--- a/src/exchange/taler-exchange-httpd_purses_create.c
+++ b/src/exchange/taler-exchange-httpd_purses_create.c
@@ -225,17 +225,18 @@ create_transaction (void *cls,
   TALER_amount_set_zero (pcc->amount.currency,
                          &purse_fee);
   /* 1) create purse */
-  qs = TEH_plugin->insert_purse_request (TEH_plugin->cls,
-                                         pcc->purse_pub,
-                                         &pcc->merge_pub,
-                                         pcc->purse_expiration,
-                                         &pcc->h_contract_terms,
-                                         pcc->min_age,
-                                         
TALER_WAMF_MODE_MERGE_FULLY_PAID_PURSE,
-                                         &purse_fee,
-                                         &pcc->amount,
-                                         &pcc->purse_sig,
-                                         &in_conflict);
+  qs = TEH_plugin->insert_purse_request (
+    TEH_plugin->cls,
+    pcc->purse_pub,
+    &pcc->merge_pub,
+    pcc->purse_expiration,
+    &pcc->h_contract_terms,
+    pcc->min_age,
+    TALER_WAMF_MODE_MERGE_FULLY_PAID_PURSE,
+    &purse_fee,
+    &pcc->amount,
+    &pcc->purse_sig,
+    &in_conflict);
   if (qs < 0)
   {
     if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
@@ -409,12 +410,13 @@ create_transaction (void *cls,
     void *econtract;
     struct GNUNET_HashCode h_econtract;
 
-    qs = TEH_plugin->select_contract_by_purse (TEH_plugin->cls,
-                                               pcc->purse_pub,
-                                               &pub_ckey,
-                                               &econtract_sig,
-                                               &econtract_size,
-                                               &econtract);
+    qs = TEH_plugin->select_contract_by_purse (
+      TEH_plugin->cls,
+      pcc->purse_pub,
+      &pub_ckey,
+      &econtract_sig,
+      &econtract_size,
+      &econtract);
     if (qs <= 0)
     {
       if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
@@ -478,6 +480,7 @@ parse_coin (struct MHD_Connection *connection,
       GNUNET_JSON_spec_fixed_auto ("h_age_commitment",
                                    &coin->cpi.h_age_commitment),
       &coin->cpi.no_age_commitment),
+    // FIXME-Oec: proof of age is missing.
     GNUNET_JSON_spec_fixed_auto ("coin_sig",
                                  &coin->coin_sig),
     GNUNET_JSON_spec_fixed_auto ("coin_pub",
diff --git a/src/exchange/taler-exchange-httpd_purses_deposit.c 
b/src/exchange/taler-exchange-httpd_purses_deposit.c
index f1f6ecab..051df85c 100644
--- a/src/exchange/taler-exchange-httpd_purses_deposit.c
+++ b/src/exchange/taler-exchange-httpd_purses_deposit.c
@@ -310,6 +310,7 @@ parse_coin (struct MHD_Connection *connection,
       GNUNET_JSON_spec_fixed_auto ("h_age_commitment",
                                    &coin->cpi.h_age_commitment),
       &coin->cpi.no_age_commitment),
+    // FIXME-Oec: proof of age is missing!
     GNUNET_JSON_spec_fixed_auto ("coin_sig",
                                  &coin->coin_sig),
     GNUNET_JSON_spec_fixed_auto ("coin_pub",
diff --git a/src/exchange/taler-exchange-httpd_purses_merge.c 
b/src/exchange/taler-exchange-httpd_purses_merge.c
index 397492d0..b0055eda 100644
--- a/src/exchange/taler-exchange-httpd_purses_merge.c
+++ b/src/exchange/taler-exchange-httpd_purses_merge.c
@@ -139,11 +139,14 @@ reply_merge_success (struct MHD_Connection *connection,
       TALER_amount_cmp (&pcc->balance,
                         &pcc->target_amount))
   {
+    GNUNET_break (0);
     return TALER_MHD_REPLY_JSON_PACK (
       connection,
-      MHD_HTTP_ACCEPTED,
+      MHD_HTTP_INTERNAL_SERVER_ERROR,
       TALER_JSON_pack_amount ("balance",
-                              &pcc->balance));
+                              &pcc->balance),
+      TALER_JSON_pack_amount ("target_amount",
+                              &pcc->target_amount));
   }
   if ( (NULL == pcc->provider_url) ||
        (0 == strcmp (pcc->provider_url,
@@ -221,6 +224,7 @@ merge_transaction (void *cls,
   bool no_balance = true;
   bool no_partner = true;
 
+  // FIXME: add KYC-check logic!
   qs = TEH_plugin->do_purse_merge (TEH_plugin->cls,
                                    pcc->purse_pub,
                                    &pcc->merge_sig,
@@ -248,7 +252,7 @@ merge_transaction (void *cls,
   {
     *mhd_ret =
       TALER_MHD_reply_with_error (connection,
-                                  MHD_HTTP_BAD_REQUEST,
+                                  MHD_HTTP_NOT_FOUND,
                                   
TALER_EC_EXCHANGE_MERGE_PURSE_PARTNER_UNKNOWN,
                                   pcc->provider_url);
     return GNUNET_DB_STATUS_HARD_ERROR;
@@ -303,6 +307,7 @@ merge_transaction (void *cls,
     GNUNET_free (partner_url);
     return GNUNET_DB_STATUS_HARD_ERROR;
   }
+  // FIXME: if ! kyc check, return 451!
   return qs;
 }
 
@@ -488,7 +493,7 @@ TEH_handler_purses_merge (
     GNUNET_free (pcc.provider_url);
     return TALER_MHD_reply_with_error (
       connection,
-      MHD_HTTP_BAD_REQUEST,
+      MHD_HTTP_FORBIDDEN,
       TALER_EC_EXCHANGE_PURSE_MERGE_INVALID_MERGE_SIGNATURE,
       NULL);
   }
@@ -514,12 +519,17 @@ TEH_handler_purses_merge (
       GNUNET_free (pcc.provider_url);
       return TALER_MHD_reply_with_error (
         connection,
-        MHD_HTTP_BAD_REQUEST,
+        MHD_HTTP_FORBIDDEN,
         TALER_EC_EXCHANGE_PURSE_MERGE_INVALID_RESERVE_SIGNATURE,
         NULL);
     }
   }
 
+  if (GNUNET_TIME_absolute_is_past (pcc.purse_expiration.abs_time))
+  {
+    // FIXME: idempotency check, otherwise generate 410!
+  }
+
   /* execute transaction */
   {
     MHD_RESULT mhd_ret;
diff --git a/src/exchange/taler-exchange-httpd_reserves_purse.c 
b/src/exchange/taler-exchange-httpd_reserves_purse.c
index b4035b55..09ef3b37 100644
--- a/src/exchange/taler-exchange-httpd_reserves_purse.c
+++ b/src/exchange/taler-exchange-httpd_reserves_purse.c
@@ -174,6 +174,7 @@ reply_purse_success (struct MHD_Connection *connection,
                                     ec,
                                     NULL);
   }
+  // FIXME: share logic with /purses/$PID/create API!
   return TALER_MHD_REPLY_JSON_PACK (
     connection,
     MHD_HTTP_OK,
@@ -211,6 +212,9 @@ purse_transaction (void *cls,
 
   {
     bool in_conflict = true;
+
+    // FIXME: also check KYC state of the account
+    // FIXME: distinguish reserve-not-found!
     /* 1) store purse */
     qs = TEH_plugin->insert_purse_request (TEH_plugin->cls,
                                            &rpc->purse_pub,
@@ -289,6 +293,9 @@ purse_transaction (void *cls,
                                         &merge_pub));
       return GNUNET_DB_STATUS_HARD_ERROR;
     }
+
+    // FIXME: return 404 if reserve-not-found!
+    // FIXME: if KYC check failed, generate 451 response!
   }
 
   /* 2) create purse with reserve (and debit reserve for purse creation!) */

-- 
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]