gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated: payment backend and errors


From: gnunet
Subject: [taler-anastasis] branch master updated: payment backend and errors
Date: Fri, 20 Nov 2020 14:30:01 +0100

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

ds-meister pushed a commit to branch master
in repository anastasis.

The following commit(s) were added to refs/heads/master by this push:
     new a1490e9  payment backend and errors
a1490e9 is described below

commit a1490e99ff0b7dd58a375ffc3c0549a81ef4a63d
Author: Dominik Meister <dominik.meister@hotmail.ch>
AuthorDate: Fri Nov 20 14:29:48 2020 +0100

    payment backend and errors
---
 src/backend/anastasis-httpd_truth.c     | 166 +++++++++++++++++---------------
 src/include/anastasis_database_plugin.h |  15 +--
 src/include/anastasis_service.h         |   2 +
 src/include/anastasis_testing_lib.h     |   6 +-
 src/lib/anastasis_api_challenge_run.c   |  52 +++++++---
 src/lib/test_anastasis_api.c            |  18 ++--
 src/lib/testing_api_cmd_challenge_run.c |  61 +++++++++++-
 src/stasis/plugin_anastasis_postgres.c  |  34 +++----
 8 files changed, 220 insertions(+), 134 deletions(-)

diff --git a/src/backend/anastasis-httpd_truth.c 
b/src/backend/anastasis-httpd_truth.c
index 9c8fe88..c6f19e4 100644
--- a/src/backend/anastasis-httpd_truth.c
+++ b/src/backend/anastasis-httpd_truth.c
@@ -105,10 +105,6 @@ struct GetContext
    * The claim token
    */
   struct TALER_ClaimTokenP claim_token;
-  /**
-   * Information about the payment
-   */
-  struct ANASTASIS_DB_ChallengePayment cp;
 
   /**
    * true if client provided a payment secret / order ID?
@@ -226,8 +222,6 @@ proposal_cb (void *cls,
 {
   struct GetContext *gc = cls;
   enum ANASTASIS_DB_QueryStatus qs;
-/*FIXME
- puc->po = NULL; */
 
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "Resuming connection with order `%s'\n",
@@ -270,7 +264,7 @@ proposal_cb (void *cls,
   qs = db->record_challenge_payment (db->cls,
                                      &gc->truth_public_key,
                                      &gc->payment_identifier,
-                                     &AH_annual_fee);
+                                     &gc->challenge_cost);
   if (0 >= qs)
   {
     GNUNET_break (0);
@@ -341,7 +335,7 @@ ongoing_payment_cb (void *cls,
 
   (void) amount;
   if (0 != TALER_amount_cmp (amount,
-                             &AH_annual_fee))
+                             &gc->challenge_cost))
     return; /* can't re-use, fees changed */
   if ( (NULL == gc->existing_order_id) ||
        (gc->existing_order_timestamp.abs_value_us < timestamp.abs_value_us) )
@@ -464,7 +458,8 @@ begin_payment (struct GetContext *gc,
 
   qs = db->lookup_challenge_payment (db->cls,
                                      &gc->truth_public_key,
-                                     &gc->cp);
+                                     &ongoing_payment_cb,
+                                     gc);
   if (qs < 0)
   {
     struct MHD_Response *resp;
@@ -526,6 +521,7 @@ begin_payment (struct GetContext *gc,
   return MHD_YES;
 }
 
+
 /**
  * We got some query status from the DB.  Handle the error cases.
  * May perform asynchronous operations by suspending the connection
@@ -591,6 +587,7 @@ handle_database_error (struct GetContext *gc,
   return MHD_NO;
 }
 
+
 /**
  * @param connection the MHD connection to handle
  * @param url handles a URL of the format 
"/truth/$TRUTH_PUBLIC_KEY[&response=$RESPONSE]"
@@ -622,45 +619,68 @@ AH_handler_truth_get (struct MHD_Connection *connection,
 
   if (NULL != gc)
   {
-    enum ANASTASIS_AUTHORIZATION_Result ret;
-
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "authorization process started \n");
+    if (NULL != gc->resp)
+    {
+      MHD_RESULT ret;
 
-    /* second/third call, continue processing */
-    GNUNET_assert (NULL != gc->as);
-    ret = gc->authorization->process (gc->as,
-                                      connection);
-    switch (ret)
+      /* We generated a response asynchronously, queue that */
+      GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                  "Returning asynchronously generated response with HTTP 
status %u\n",
+                  gc->response_code);
+      ret = MHD_queue_response (connection,
+                                gc->response_code,
+                                gc->resp);
+      GNUNET_break (MHD_YES == ret);
+      MHD_destroy_response (gc->resp);
+      gc->resp = NULL;
+      return ret;
+    }
+    if (gc->as != NULL)
     {
-    case ANASTASIS_AUTHORIZATION_RES_SUCCESS:
-      /* Challenge sent successfully */
-      // FIXME: mark in DB that we did it (now, for 
code_retransmission_frequency!)
-      gc->authorization->cleanup (gc->as);
-      gc->as = NULL;
-      return MHD_YES;
-    case ANASTASIS_AUTHORIZATION_RES_FAILED:
-      /* Challenge transmission failed, our fault! */
-      // FIXME: give at least a refund!?
-      gc->authorization->cleanup (gc->as);
-      gc->as = NULL;
-      return MHD_YES;
-    case ANASTASIS_AUTHORIZATION_RES_SUSPENDED:
-      /* connection was suspended again, odd that this happens */
-      GNUNET_break (0); /* mark oddity: why did plugin resume and then suspend 
again? */
-      return MHD_YES;
-    case ANASTASIS_AUTHORIZATION_RES_SUCCESS_REPLY_FAILED:
-      /* Challenge sent successfully */
-      // FIXME: mark in DB that we did it (now, for 
code_retransmission_frequency!)
-      gc->authorization->cleanup (gc->as);
-      gc->as = NULL;
-      return MHD_NO;
-    case ANASTASIS_AUTHORIZATION_RES_FAILED_REPLY_FAILED:
-      gc->authorization->cleanup (gc->as);
-      gc->as = NULL;
-      return MHD_NO;
+      enum ANASTASIS_AUTHORIZATION_Result ret;
+
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "authorization process started \n");
+
+      ret = gc->authorization->process (gc->as,
+                                        connection);
+      switch (ret)
+      {
+      case ANASTASIS_AUTHORIZATION_RES_SUCCESS:
+        /* Challenge sent successfully */
+        // FIXME: mark in DB that we did it (now, for 
code_retransmission_frequency!)
+        gc->authorization->cleanup (gc->as);
+        gc->as = NULL;
+        return MHD_YES;
+      case ANASTASIS_AUTHORIZATION_RES_FAILED:
+        /* Challenge transmission failed, our fault! */
+        // FIXME: give at least a refund!?
+        gc->authorization->cleanup (gc->as);
+        gc->as = NULL;
+        return MHD_YES;
+      case ANASTASIS_AUTHORIZATION_RES_SUSPENDED:
+        /* connection was suspended again, odd that this happens */
+        GNUNET_break (0); /* mark oddity: why did plugin resume and then 
suspend again? */
+        return MHD_YES;
+      case ANASTASIS_AUTHORIZATION_RES_SUCCESS_REPLY_FAILED:
+        /* Challenge sent successfully */
+        // FIXME: mark in DB that we did it (now, for 
code_retransmission_frequency!)
+        gc->authorization->cleanup (gc->as);
+        gc->as = NULL;
+        return MHD_NO;
+      case ANASTASIS_AUTHORIZATION_RES_FAILED_REPLY_FAILED:
+        gc->authorization->cleanup (gc->as);
+        gc->as = NULL;
+        return MHD_NO;
+      }
     }
   }
+  else
+  {
+    gc = GNUNET_new (struct GetContext);
+    hc->ctx = gc;
+    gc->connection = connection;
+  }
   {
     const char *pay_id;
 
@@ -768,7 +788,25 @@ AH_handler_truth_get (struct MHD_Connection *connection,
                                     &decrypted_truth,
                                     &decrypted_truth_size);
   }
+
+  /* Check if the cost is zero to skip the payment */
+  if (0 == strcmp ("question",
+                   method))
+  {
+    if (0 == TALER_amount_cmp (&AH_question_cost, &zero_amount))
+      zero_cost = true;
+  }
+  if (0 == strcmp ("file",
+                   method))
+  {
+    if (0 == TALER_amount_cmp (&AH_file_cost, &zero_amount))
+      zero_cost = true;
+  }
+
+
   /* Check database to see if the transaction is permissible */
+
+  if (! zero_cost)
   {
     struct GNUNET_HashCode hc;
     enum ANASTASIS_DB_QueryStatus qs;
@@ -821,49 +859,26 @@ AH_handler_truth_get (struct MHD_Connection *connection,
                   TALER_B2S (&gc->payment_identifier));
 
 
-
       if (0 == strcmp ("question",
                        method))
       {
-        if (0 == TALER_amount_cmp (&AH_question_cost, &zero_amount))
-          zero_cost = true;
         gc->challenge_cost = AH_question_cost;
       }
       if (0 == strcmp ("file",
                        method))
       {
-        if (0 == TALER_amount_cmp (&AH_file_cost, &zero_amount))
-          zero_cost = true;
         gc->challenge_cost = AH_file_cost;
       }
 
-      if (zero_cost)
-      {
-        qs = db->record_challenge_payment (db->cls,
-                                           &truth_public_key,
-                                           &gc->payment_identifier,
-                                           &gc->challenge_cost);
-        if (qs >= 0)
-        {
-          qs = db->update_challenge_payment (db->cls,
-                                             &truth_public_key,
-                                             &gc->payment_identifier);
-        }
-        if (qs < 0)
-          return handle_database_error (gc,
-                                        qs);
-      }
-      else
-      {
-        GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                    "At %s:%d Payment is required, starting payment process\n",
-                    __FILE__,
-                    __LINE__);
-        return begin_payment (gc,
-                              GNUNET_YES);
-      }
+      GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                  "At %s:%d Payment is required, starting payment process\n",
+                  __FILE__,
+                  __LINE__);
+      return begin_payment (gc,
+                            GNUNET_YES);
     }
   }
+
   /* check if the client insists on paying */
   {
     const char *order_req;
@@ -901,7 +916,7 @@ AH_handler_truth_get (struct MHD_Connection *connection,
                                          MHD_HTTP_BAD_REQUEST,
                                          // FIXME: find error code
                                          TALER_EC_SYNC_BAD_IF_MATCH,
-                                         "Authentication failed");   // FIXME: 
How much should we tell?
+                                         "Authentication failed"); // FIXME: 
How much should we tell?
     }
     else
     {
@@ -1036,7 +1051,6 @@ AH_handler_truth_get (struct MHD_Connection *connection,
       // FIXME: queue PROPER reply...
       return MHD_NO;
     }
-    gc = GNUNET_new (struct GetContext);
     gc->connection = connection;
     gc->authorization = authorization;
     gc->as = as;
diff --git a/src/include/anastasis_database_plugin.h 
b/src/include/anastasis_database_plugin.h
index 57fbc73..1239646 100644
--- a/src/include/anastasis_database_plugin.h
+++ b/src/include/anastasis_database_plugin.h
@@ -48,18 +48,9 @@ struct ANASTASIS_DB_Truth
   const char *method;
 };
 
-/**
- * @brief Specification for a challenge payment object.
- */
-struct ANASTASIS_DB_ChallengePayment
-{
-  const char *payment_identifier;
-  const struct TALER_Amount *amount;
-};
-
 
 /**
- * Function called on all pending payments for an account.
+ * Function called on all pending payments for an account or challenge.
  *
  * @param cls closure
  * @param timestamp for how long have we been waiting
@@ -473,8 +464,8 @@ struct ANASTASIS_DatabasePlugin
                               const struct
                               ANASTASIS_CRYPTO_TruthPublicKeyP
                               *truth_public_key,
-                              struct
-                              ANASTASIS_DB_ChallengePayment *cp);
+                              ANASTASIS_DB_PaymentPendingIterator it,
+                              void *it_cls);
   /**
    * Update payment status of challenge
    *
diff --git a/src/include/anastasis_service.h b/src/include/anastasis_service.h
index 3ed64f7..b0e6a26 100644
--- a/src/include/anastasis_service.h
+++ b/src/include/anastasis_service.h
@@ -495,6 +495,8 @@ ANASTASIS_challenge_run (
   const char *backend_url,
   const struct ANASTASIS_CRYPTO_TruthPublicKeyP *truth_public_key,
   const struct ANASTASIS_CRYPTO_TruthKeyP *truth_key,
+  const struct ANASTASIS_PaymentSecretP *payment_secret,
+  bool payment_requested,
   ANASTASIS_ChallengeRunCallback cb,
   void *cb_cls);
 
diff --git a/src/include/anastasis_testing_lib.h 
b/src/include/anastasis_testing_lib.h
index 0751e25..3ba7673 100644
--- a/src/include/anastasis_testing_lib.h
+++ b/src/include/anastasis_testing_lib.h
@@ -211,6 +211,7 @@ ANASTASIS_TESTING_get_trait_code (const struct
 struct TALER_TESTING_Trait
 ANASTASIS_TESTING_make_trait_code (unsigned int index,
                                    const char *code);
+
 /**
  * Prepare the merchant execution.  Create tables and check if
  * the port is available.
@@ -449,6 +450,7 @@ ANASTASIS_TESTING_cmd_keyshare_lookup (const char *label,
                                        int payment_requested,
                                        const char *upload_ref,
                                        int lookup_mode);
+
 /**
  * Make the "challenge run" command.
  *
@@ -458,6 +460,7 @@ ANASTASIS_TESTING_cmd_keyshare_lookup (const char *label,
  * @param http_status expected HTTP status.
  * @param key key to decrypt truth
  * @param upload_ref reference to upload command
+ * @param payment_ref reference to payment command
  * @return the command
  */
 struct TALER_TESTING_Command
@@ -466,7 +469,8 @@ ANASTASIS_TESTING_cmd_challenge_run (const char *label,
                                      unsigned int http_status,
                                      const struct
                                      ANASTASIS_CRYPTO_TruthKeyP key,
-                                     const char *upload_ref);
+                                     const char *upload_ref,
+                                     const char *payment_ref);
 
 /**
  * Obtain a salt from @a cmd.
diff --git a/src/lib/anastasis_api_challenge_run.c 
b/src/lib/anastasis_api_challenge_run.c
index 6a5d2ba..43ea3db 100644
--- a/src/lib/anastasis_api_challenge_run.c
+++ b/src/lib/anastasis_api_challenge_run.c
@@ -240,23 +240,14 @@ handle_header (char *buffer,
 }
 
 
-/**
- * Does a GET /truth to start a challenge (non question challenges).
- *
- * @param ctx execution context
- * @param backend_url base URL of the backend
- * @param truth_public_key identification of the Truth
- * @param truth_key Key used to Decrypt the Truth on the Server
- * @param cb callback which will work the response gotten from the backend
- * @param cb_cls closure to pass to the callback
- * @return handle for this operation, NULL upon errors
- */
 struct ANASTASIS_ChallengeRunOperation *
 ANASTASIS_challenge_run (
   struct GNUNET_CURL_Context *ctx,
   const char *backend_url,
   const struct ANASTASIS_CRYPTO_TruthPublicKeyP *truth_public_key,
   const struct ANASTASIS_CRYPTO_TruthKeyP *truth_key,
+  const struct ANASTASIS_PaymentSecretP *payment_secret,
+  bool payment_requested,
   ANASTASIS_ChallengeRunCallback cb,
   void *cb_cls)
 {
@@ -288,6 +279,30 @@ ANASTASIS_challenge_run (
       return NULL;
     }
     job_headers = ext;
+
+    /* Setup Payment-Identifier header */
+    if (NULL != payment_secret)
+    {
+      char *paid_order_id;
+
+      paid_order_id = GNUNET_STRINGS_data_to_string_alloc (
+        payment_secret,
+        sizeof (*payment_secret));
+      GNUNET_asprintf (&hdr,
+                       "Payment-Identifier: %s",
+                       paid_order_id);
+      GNUNET_free (paid_order_id);
+      ext = curl_slist_append (job_headers,
+                               hdr);
+      GNUNET_free (hdr);
+      if (NULL == ext)
+      {
+        GNUNET_break (0);
+        curl_slist_free_all (job_headers);
+        return NULL;
+      }
+      job_headers = ext;
+    }
   }
   cro = GNUNET_new (struct ANASTASIS_ChallengeRunOperation);
   cro->ctx = ctx;
@@ -303,10 +318,15 @@ ANASTASIS_challenge_run (
   GNUNET_asprintf (&path,
                    "truth/%s",
                    pub_key_str);
-
-  cro->url = TALER_url_join (backend_url,
-                             path,
-                             NULL);
+  cro->url = (GNUNET_YES == payment_requested)
+             ? TALER_url_join (backend_url,
+                               path,
+                               "pay",
+                               "y",
+                               NULL)
+             : TALER_url_join (backend_url,
+                               path,
+                               NULL);
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Url get request (challenge run): %s\n",
@@ -330,4 +350,6 @@ ANASTASIS_challenge_run (
   curl_slist_free_all (job_headers);
   return cro;
 }
+
+
 /* end of anastasis_api_challenge_run.c */
diff --git a/src/lib/test_anastasis_api.c b/src/lib/test_anastasis_api.c
index 62742f0..9bf86c5 100644
--- a/src/lib/test_anastasis_api.c
+++ b/src/lib/test_anastasis_api.c
@@ -44,7 +44,7 @@
 /**
  * Exchange base URL.  Could also be taken from config.
  */
-#define EXCHANGE_URL "http://localhost:8081/";
+#define EXCHANGE_URL "http:// localhost:8081/"
 
 
 /**
@@ -289,21 +289,22 @@ run (void *cls,
                                          MHD_HTTP_PAYMENT_REQUIRED,
                                          ANASTASIS_TESTING_make_truthkey (
                                            "Truth-Key-2"),
-                                         "truth-store-2"),
+                                         "truth-store-2",
+                                         NULL),
     /* what would we have to pay? */
-    TALER_TESTING_cmd_merchant_claim_order ("fetch-proposal",
+    TALER_TESTING_cmd_merchant_claim_order ("fetch-proposal-2",
                                             merchant_url,
                                             MHD_HTTP_OK,
                                             "challenge-run-1",
                                             NULL),
     /* make the payment */
-    TALER_TESTING_cmd_merchant_pay_order ("pay-account",
+    TALER_TESTING_cmd_merchant_pay_order ("pay-account-2",
                                           merchant_url,
                                           MHD_HTTP_OK,
-                                          "fetch-proposal",
-                                          "withdraw-coin-1",
+                                          "fetch-proposal-2",
+                                          "withdraw-coin-2",
+                                          "EUR:1.01",
                                           "EUR:1",
-                                          "EUR:1", /* must match ANNUAL_FEE in 
config! */
                                           NULL),
 
     ANASTASIS_TESTING_cmd_challenge_run ("challenge-run-2",
@@ -311,7 +312,8 @@ run (void *cls,
                                          MHD_HTTP_OK,
                                          ANASTASIS_TESTING_make_truthkey (
                                            "Truth-Key-2"),
-                                         "truth-store-2"),
+                                         "truth-store-2",
+                                         "challenge-run-1"),
 
     ANASTASIS_TESTING_cmd_keyshare_lookup ("keyshare-lookup-2",
                                            anastasis_url,
diff --git a/src/lib/testing_api_cmd_challenge_run.c 
b/src/lib/testing_api_cmd_challenge_run.c
index 4162855..d673233 100644
--- a/src/lib/testing_api_cmd_challenge_run.c
+++ b/src/lib/testing_api_cmd_challenge_run.c
@@ -86,6 +86,14 @@ struct ChallengeRunState
    * Reference to upload command we expect to lookup.
    */
   const char *upload_reference;
+  /**
+   * Reference to payment command we expect to lookup.
+   */
+  const char *payment_ref;
+  /**
+   * True if @e payment_order_req is initialized.
+   */
+  bool payment_order_set;
   /**
    * code we read in the file generated by the plugin
    */
@@ -101,7 +109,7 @@ struct ChallengeRunState
 static void
 challenge_run_cb (void *cls,
                   unsigned int http_status,
-                  const char *response_string)
+                  char *response_string)
 {
   struct ChallengeRunState *crs = cls;
   crs->cro = NULL;
@@ -155,6 +163,7 @@ challenge_run_cb (void *cls,
                 "Order ID from Anastasis service is `%s'\n",
                 crs->payment_order_id);
     TALER_TESTING_interpreter_next (crs->is);
+    return;
   }
 
 
@@ -178,6 +187,7 @@ challenge_run_cb (void *cls,
   TALER_TESTING_interpreter_next (crs->is);
 }
 
+
 /**
  * Offer internal data to other commands.
  *
@@ -224,7 +234,7 @@ challenge_run (void *cls,
                struct TALER_TESTING_Interpreter *is)
 {
   struct ChallengeRunState *crs = cls;
-
+  crs->payment_order_set = false;
   crs->is = is;
   if (NULL != crs->upload_reference)
   {
@@ -261,6 +271,44 @@ challenge_run (void *cls,
     }
   }
 
+  if (NULL != crs->payment_ref)
+  {
+    const struct TALER_TESTING_Command *payment_cmd;
+    payment_cmd = TALER_TESTING_interpreter_lookup_command
+                    (is,
+                    crs->payment_ref);
+    if (NULL == payment_cmd)
+    {
+      GNUNET_break (0);
+      TALER_TESTING_interpreter_fail (crs->is);
+      return;
+    }
+    const char *order_id;
+
+    if (GNUNET_OK !=
+        TALER_TESTING_get_trait_order_id (payment_cmd,
+                                          0,
+                                          &order_id))
+    {
+      GNUNET_break (0);
+      TALER_TESTING_interpreter_fail (crs->is);
+      return;
+    }
+
+    if (GNUNET_OK !=
+        GNUNET_STRINGS_string_to_data (order_id,
+                                       strlen (order_id),
+                                       &crs->payment_order_req,
+                                       sizeof (struct
+                                               ANASTASIS_PaymentSecretP)))
+    {
+      GNUNET_break_op (0);
+      TALER_TESTING_interpreter_fail (crs->is);
+      return;
+    }
+    crs->payment_order_set = true;
+  }
+
   char *pub_key_str;
   pub_key_str = GNUNET_STRINGS_data_to_string_alloc (crs->truth_public_key,
                                                      sizeof (*crs->
@@ -273,6 +321,10 @@ challenge_run (void *cls,
                                       crs->anastasis_url,
                                       crs->truth_public_key,
                                       &crs->truth_key,
+                                      crs->payment_order_set
+                                      ? &crs->payment_order_req
+                                      : NULL,
+                                      crs->payment_order_set,
                                       &challenge_run_cb,
                                       crs);
   if (NULL == crs->cro)
@@ -308,6 +360,7 @@ challenge_run_cleanup (void *cls,
   GNUNET_free (crs);
 }
 
+
 /**
  * Make the "challenge run" command.
  *
@@ -325,7 +378,8 @@ ANASTASIS_TESTING_cmd_challenge_run
   const char *anastasis_url,
   unsigned int http_status,
   const struct ANASTASIS_CRYPTO_TruthKeyP key,
-  const char *upload_ref)
+  const char *upload_ref,
+  const char *payment_ref)
 {
   struct ChallengeRunState *crs;
 
@@ -339,6 +393,7 @@ ANASTASIS_TESTING_cmd_challenge_run
   crs->anastasis_url = anastasis_url;
   crs->upload_reference = upload_ref;
   crs->truth_key = key;
+  crs->payment_ref = payment_ref;
   {
     struct TALER_TESTING_Command cmd = {
       .cls = crs,
diff --git a/src/stasis/plugin_anastasis_postgres.c 
b/src/stasis/plugin_anastasis_postgres.c
index b518b62..0805267 100644
--- a/src/stasis/plugin_anastasis_postgres.c
+++ b/src/stasis/plugin_anastasis_postgres.c
@@ -366,7 +366,7 @@ payment_by_account_cb (void *cls,
     struct ANASTASIS_PaymentSecretP payment_identifier;
     struct TALER_Amount amount;
     struct GNUNET_PQ_ResultSpec rs[] = {
-      GNUNET_PQ_result_spec_absolute_time ("timestamp",
+      GNUNET_PQ_result_spec_absolute_time ("creation_date",
                                            &timestamp),
       GNUNET_PQ_result_spec_auto_from_type ("payment_identifier",
                                             &payment_identifier),
@@ -1053,10 +1053,7 @@ postgres_record_challenge_payment (void *cls,
               __FILE__,
               __LINE__,
               TALER_B2S (truth_public_key));
-  /*dummy function to check if truth is available*/
-  void *truth;
-  size_t truth_size;
-
+/*
   {
     // because of constraint at truth_id, first we have to verify
     // if the challenge exists
@@ -1065,9 +1062,6 @@ postgres_record_challenge_payment (void *cls,
       GNUNET_PQ_query_param_end
     };
     struct GNUNET_PQ_ResultSpec rs[] = {
-      GNUNET_PQ_result_spec_variable_size ("encrypted_truth",
-                                           &truth,
-                                           &truth_size),
       GNUNET_PQ_result_spec_end
     };
     qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
@@ -1078,13 +1072,10 @@ postgres_record_challenge_payment (void *cls,
     {
       return qs;
     }
-    // free truth because not not needed
-    if (NULL != truth)
-      GNUNET_free (truth);
   }
-
+*/
   if (GNUNET_OK != begin_transaction (pg,
-                                      "store_truth"))
+                                      "challenge_payment_insert"))
   {
     GNUNET_break (0);
     return ANASTASIS_DB_STATUS_HARD_ERROR;
@@ -1720,12 +1711,13 @@ postgres_lookup_challenge_payment (void *cls,
                                    const struct
                                    ANASTASIS_CRYPTO_TruthPublicKeyP
                                    *truth_public_key,
-                                   struct
-                                   ANASTASIS_DB_ChallengePayment *cp)
+                                   ANASTASIS_DB_PaymentPendingIterator it,
+                                   void *it_cls)
 {
   struct PostgresClosure *pg = cls;
   enum ANASTASIS_DB_QueryStatus qs;
   struct ANASTASIS_PaymentSecretP payment_identifier;
+  struct GNUNET_TIME_Absolute timestamp;
   struct TALER_Amount amount;
 
   struct GNUNET_PQ_QueryParam params[] = {
@@ -1734,6 +1726,8 @@ postgres_lookup_challenge_payment (void *cls,
   };
 
   struct GNUNET_PQ_ResultSpec rs[] = {
+    GNUNET_PQ_result_spec_absolute_time ("creation_date",
+                                         &timestamp),
     GNUNET_PQ_result_spec_auto_from_type ("payment_identifier",
                                           &payment_identifier),
     TALER_PQ_result_spec_amount ("amount",
@@ -1765,9 +1759,10 @@ postgres_lookup_challenge_payment (void *cls,
   order_id = GNUNET_STRINGS_data_to_string_alloc (&payment_identifier,
                                                   sizeof (struct
                                                           
ANASTASIS_PaymentSecretP));
-  cp->payment_identifier = order_id;
-  cp->amount = &amount;
-  return ANASTASIS_DB_STATUS_SUCCESS_ONE_RESULT;
+  it (it_cls,
+      timestamp,
+      order_id,
+      &amount);
 }
 
 
@@ -2037,7 +2032,8 @@ libanastasis_plugin_db_postgres_init (void *cls)
                             1),
     GNUNET_PQ_make_prepare ("challenge_pending_payment_select",
                             "SELECT"
-                            " payment_identifier"
+                            " creation_date"
+                            ",payment_identifier"
                             ",amount_val"
                             ",amount_frac"
                             " FROM anastasis_challenge_payment"

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