gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] branch master updated: revise truth upload logic to pr


From: gnunet
Subject: [taler-anastasis] branch master updated: revise truth upload logic to properly handle payment request
Date: Fri, 05 Feb 2021 15:44:07 +0100

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

grothoff pushed a commit to branch master
in repository anastasis.

The following commit(s) were added to refs/heads/master by this push:
     new c2ed55b  revise truth upload logic to properly handle payment request
c2ed55b is described below

commit c2ed55b7f5b63989c6e264beb0c393732ad36c5f
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Fri Feb 5 15:44:05 2021 +0100

    revise truth upload logic to properly handle payment request
---
 src/include/anastasis.h                    |   8 ++-
 src/include/anastasis_crypto_lib.h         |   6 +-
 src/include/anastasis_service.h            |  41 ++++++-----
 src/include/anastasis_testing_lib.h        |  27 +++----
 src/lib/anastasis_backup.c                 | 111 +++++++----------------------
 src/reducer/anastasis_api_backup_redux.c   |  33 +++++----
 src/restclient/anastasis_api_truth_store.c |  84 +++++++++-------------
 src/testing/testing_cmd_truth_upload.c     |  73 ++++++++-----------
 8 files changed, 155 insertions(+), 228 deletions(-)

diff --git a/src/include/anastasis.h b/src/include/anastasis.h
index d18b2ce..5a15a1d 100644
--- a/src/include/anastasis.h
+++ b/src/include/anastasis.h
@@ -395,13 +395,13 @@ struct ANASTASIS_Truth;
  * @param cls closure for callback
  * @param ec status code of the request (success, failure, payment required)
  * @param t truth object to create policies, NULL on failure
- * @param taler_pay_url URL to make a payment, NULL if no payment is required
+ * @param ud upload details, useful to continue in case of errors, NULL on 
success
  */
 typedef void
 (*ANASTASIS_TruthCallback)(void *cls,
                            enum ANASTASIS_ErrorCode ec,
                            struct ANASTASIS_Truth *t,
-                           const char *taler_pay_url);
+                           const struct ANASTASIS_UploadDetails *ud);
 
 
 /**
@@ -417,6 +417,8 @@ typedef void
  * @param salt the server salt
  * @param truth_data contains the truth for this challenge i.e. phone number, 
email address
  * @param truth_data_size size of the data
+ * @param payment_requested true if the client wants to pay more for the 
account now
+ * @param paid_order_id payment identifier of last payment
  * @param tc opens the truth callback which contains the status of the upload
  * @param tc_cls closure for the callback
  */
@@ -430,6 +432,8 @@ ANASTASIS_truth_upload (struct GNUNET_CURL_Context *ctx,
                         const struct ANASTASIS_CRYPTO_PowSalt *salt,
                         const void *truth_data,
                         size_t truth_data_size,
+                        bool payment_requested,
+                        const char *paid_order_id,
                         ANASTASIS_TruthCallback tc,
                         void *tc_cls);
 
diff --git a/src/include/anastasis_crypto_lib.h 
b/src/include/anastasis_crypto_lib.h
index 254528b..f645b67 100644
--- a/src/include/anastasis_crypto_lib.h
+++ b/src/include/anastasis_crypto_lib.h
@@ -298,9 +298,9 @@ ANASTASIS_CRYPTO_keyshare_decrypt (
 
 
 /**
- * Encrypts the truth data which contains the hashed answer or the phone 
number..
- * It is encrypted with AES256, the key is generated with the user 
identification as
- * entropy source and the salt "ect".
+ * Encrypts the truth data which contains the hashed answer or the
+ * phone number.  It is encrypted with AES256, the key is generated
+ * with the user identification as entropy source and the salt "ect".
  *
  * @param truth_enc_key master key used for encryption of the truth (see 
interface EscrowMethod)
  * @param truth truth which will be encrypted
diff --git a/src/include/anastasis_service.h b/src/include/anastasis_service.h
index b360383..e0cb416 100644
--- a/src/include/anastasis_service.h
+++ b/src/include/anastasis_service.h
@@ -339,6 +339,7 @@ typedef void
                                    unsigned int http_status,
                                    const struct ANASTASIS_DownloadDetails *dd);
 
+
 /**
  * Does a GET /policy.
  *
@@ -357,6 +358,7 @@ ANASTASIS_policy_lookup (
   ANASTASIS_PolicyLookupCallback cb,
   void *cb_cls);
 
+
 /**
  * Does a GET /policy for a specific version.
  *
@@ -377,6 +379,7 @@ ANASTASIS_policy_lookup_version (
   void *cb_cls,
   uint32_t *version);
 
+
 /**
  * Cancel a GET /policy request.
  *
@@ -417,25 +420,24 @@ typedef void
  * @param prev_recovery_data_hash hash of the previous policy update, NULL for 
the first upload ever
  * @param recovery_data policy data to be stored
  * @param recovery_data_size number of bytes in @a recovery_data
- * @param payment_requested #GNUNET_YES if the client wants to pay more for 
the account now
+ * @param payment_requested true if the client wants to pay more for the 
account now
  * @param paid_order_id payment identifier of last payment
  * @param cb callback processing the response from /policy
  * @param cb_cls closure for cb
  * @return handle for the operation
  */
 struct ANASTASIS_PolicyStoreOperation *
-ANASTASIS_policy_store (struct GNUNET_CURL_Context *ctx,
-                        const char *backend_url,
-                        const struct
-                        ANASTASIS_CRYPTO_AccountPrivateKeyP *anastasis_priv,
-                        const struct
-                        GNUNET_HashCode *prev_recovery_data_hash,
-                        const void *recovery_data,
-                        size_t recovery_data_size,
-                        int payment_requested,
-                        const struct ANASTASIS_PaymentSecretP *payment_secret,
-                        ANASTASIS_PolicyStoreCallback cb,
-                        void *cb_cls);
+ANASTASIS_policy_store (
+  struct GNUNET_CURL_Context *ctx,
+  const char *backend_url,
+  const struct ANASTASIS_CRYPTO_AccountPrivateKeyP *anastasis_priv,
+  const struct GNUNET_HashCode *prev_recovery_data_hash,
+  const void *recovery_data,
+  size_t recovery_data_size,
+  int payment_requested,
+  const struct ANASTASIS_PaymentSecretP *payment_secret,
+  ANASTASIS_PolicyStoreCallback cb,
+  void *cb_cls);
 
 
 /**
@@ -469,6 +471,7 @@ typedef void
   unsigned int http_status,
   char *response_string);
 
+
 /**
  * Cancel a GET /truth request.
  *
@@ -478,6 +481,7 @@ void
 ANASTASIS_challenge_run_cancel (
   struct ANASTASIS_ChallengeRunOperation *cro);
 
+
 /**
  * Does a GET /truth to start a challenge (not question)
  *
@@ -500,11 +504,13 @@ ANASTASIS_challenge_run (
   ANASTASIS_ChallengeRunCallback cb,
   void *cb_cls);
 
+
 /**
  * Handle for a GET /truth operation.
  */
 struct ANASTASIS_KeyShareLookupOperation;
 
+
 /**
  * Callback to process a GET /truth request
  *
@@ -587,8 +593,8 @@ typedef void
  * @param truth_public_key Identfication of the Truth Upload
  * @param prev_truth_data_hash hash of the previous truth upload, NULL for the 
first upload ever
  * @param truth_data contains the data which is stored on the Server in JSON 
Format
- * @param payment_requested
- * @param paid_order_id
+ * @param payment_requested true if we want to pay, even if not yet required
+ * @param paid_order_id provides order ID of a previous payment for this truth
  * @param cb callback processing the response from /truth
  * @param cb_cls closure for cb
  * @return handle for the operation
@@ -598,12 +604,13 @@ ANASTASIS_truth_store (
   struct GNUNET_CURL_Context *ctx,
   const char *backend_url,
   const struct ANASTASIS_CRYPTO_TruthPublicKeyP *truth_public_key,
-  json_t *truth_data,
-  int payment_requested,
+  const json_t *truth_data,
+  bool payment_requested,
   const char *paid_order_id,
   ANASTASIS_TruthStoreCallback cb,
   void *cb_cls);
 
+
 /**
  * Cancel a POST /truth request.
  *
diff --git a/src/include/anastasis_testing_lib.h 
b/src/include/anastasis_testing_lib.h
index 85334d5..11823a4 100644
--- a/src/include/anastasis_testing_lib.h
+++ b/src/include/anastasis_testing_lib.h
@@ -554,6 +554,7 @@ ANASTASIS_TESTING_make_trait_truth (unsigned int index,
 json_t *
 ANASTASIS_TESTING_make_id_data_example (const char *id_data);
 
+
 /**
  * Make the "truth upload" command.
  *
@@ -565,24 +566,26 @@ ANASTASIS_TESTING_make_id_data_example (const char 
*id_data);
  * @param mime_type mime type of truth_data
  * @param truth_data some truth data (e.g. hash of answer to a secret question)
  * @param truth_data_size size of truth_data
+ * @param paid_order_id already paid order ID for this truth upload, or NULL
  * @param http_status expected HTTP status
  * @param tso truth upload options
  * @param upload_ref reference to the previous upload
  * @return the command
  */
 struct TALER_TESTING_Command
-ANASTASIS_TESTING_cmd_truth_upload (const char *label,
-                                    const char *anastasis_url,
-                                    json_t *id_data,
-                                    const char *method,
-                                    const char *instructions,
-                                    const char *mime_type,
-                                    const void *truth_data,
-                                    size_t truth_data_size,
-                                    unsigned int http_status,
-                                    enum
-                                    ANASTASIS_TESTING_TruthStoreOption tso,
-                                    const char *upload_ref);
+ANASTASIS_TESTING_cmd_truth_upload (
+  const char *label,
+  const char *anastasis_url,
+  json_t *id_data,
+  const char *method,
+  const char *instructions,
+  const char *mime_type,
+  const void *truth_data,
+  size_t truth_data_size,
+  const char *paid_order_id,
+  unsigned int http_status,
+  enum ANASTASIS_TESTING_TruthStoreOption tso,
+  const char *upload_ref);
 
 
 /* ********************* test policy create ********************* */
diff --git a/src/lib/anastasis_backup.c b/src/lib/anastasis_backup.c
index 24ac098..bebb58f 100644
--- a/src/lib/anastasis_backup.c
+++ b/src/lib/anastasis_backup.c
@@ -134,75 +134,20 @@ truth_store_callback (void *cls,
     ANASTASIS_truth_upload_cancel (tu);
     return;
   }
-  switch (ud->us)
+  if (ANASTASIS_US_SUCCESS == ud->us)
   {
-  case ANASTASIS_US_SUCCESS:
     tu->tc (tu->tc_cls,
             ANASTASIS_US_SUCCESS,
             tu->t,
             NULL);
     tu->t = NULL;
-    break;
-  case ANASTASIS_US_PAYMENT_REQUIRED:
-    {
-      struct TALER_MERCHANT_PayUriData pd;
-
-      if (GNUNET_OK !=
-          TALER_MERCHANT_parse_pay_uri (ud->details.payment_request,
-                                        &pd))
-      {
-        GNUNET_break_op (0);
-        tu->tc (tu->tc_cls,
-                ANASTASIS_US_SERVER_ERROR,
-                NULL,
-                pd.order_id);
-      }
-      else
-      {
-        GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                    "At truth upload order ID from Anastasis service is %s\n",
-                    pd.order_id);
-        tu->tc (tu->tc_cls,
-                ANASTASIS_US_PAYMENT_REQUIRED,
-                NULL,
-                pd.order_id);
-        TALER_MERCHANT_parse_pay_uri_free (&pd);
-      }
-    }
-    break;
-  case ANASTASIS_US_CONFLICTING_TRUTH:
-    tu->tc (tu->tc_cls,
-            ANASTASIS_US_CONFLICTING_TRUTH,
-            NULL,
-            NULL);
-    GNUNET_break (0);
-    break;
-  case ANASTASIS_US_HTTP_ERROR:
-    tu->tc (tu->tc_cls,
-            ANASTASIS_US_HTTP_ERROR,
-            NULL,
-            NULL);
-    break;
-  case ANASTASIS_US_CLIENT_ERROR:
-    GNUNET_break (0);
-    tu->tc (tu->tc_cls,
-            ANASTASIS_US_CLIENT_ERROR,
-            NULL,
-            NULL);
-    break;
-  case ANASTASIS_US_SERVER_ERROR:
-    tu->tc (tu->tc_cls,
-            ANASTASIS_US_SERVER_ERROR,
-            NULL,
-            NULL);
-    break;
-  default:
-    GNUNET_break (0);
+  }
+  else
+  {
     tu->tc (tu->tc_cls,
-            ANASTASIS_US_CLIENT_ERROR,
+            ud->us,
             NULL,
-            NULL);
-    break;
+            ud);
   }
   ANASTASIS_truth_upload_cancel (tu);
 }
@@ -218,6 +163,8 @@ ANASTASIS_truth_upload (struct GNUNET_CURL_Context *ctx,
                         const struct ANASTASIS_CRYPTO_PowSalt *salt,
                         const void *truth_data,
                         size_t truth_data_size,
+                        bool payment_requested,
+                        const char *paid_order_id,
                         ANASTASIS_TruthCallback tc,
                         void *tc_cls)
 {
@@ -257,29 +204,24 @@ ANASTASIS_truth_upload (struct GNUNET_CURL_Context *ctx,
   GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG,
                               &t->truth_key,
                               sizeof (struct ANASTASIS_CRYPTO_TruthKeyP));
-  // FIXME: this seems VERY wrong, may be motivated from secure question???
-  {
-    struct GNUNET_HashCode hashed_answer;
-
-    GNUNET_CRYPTO_hash (truth_data,
-                        truth_data_size,
-                        &hashed_answer);
-    ANASTASIS_CRYPTO_truth_encrypt (&t->truth_key,
-                                    &hashed_answer,
-                                    sizeof(hashed_answer),
-                                    &encrypted_truth,
-                                    &encrypted_truth_size);
-  }
+  ANASTASIS_CRYPTO_truth_encrypt (&t->truth_key,
+                                  truth_data,
+                                  truth_data_size,
+                                  &encrypted_truth,
+                                  &encrypted_truth_size);
   truth = json_pack ("{s:o," /* encrypted KeyShare */
                      " s:s," /* method */
                      " s:o," /* nonce */
                      " s:s}", /* truth_mime */
-                     "keyshare_data", GNUNET_JSON_from_data_auto (
-                       encrypted_key_share),
-                     "method", method,
-                     "encrypted_truth", GNUNET_JSON_from_data (
-                       encrypted_truth, encrypted_truth_size),
-                     "truth_mime", mime_type);
+                     "keyshare_data",
+                     GNUNET_JSON_from_data_auto (encrypted_key_share),
+                     "method",
+                     method,
+                     "encrypted_truth",
+                     GNUNET_JSON_from_data (encrypted_truth,
+                                            encrypted_truth_size),
+                     "truth_mime",
+                     mime_type);
   GNUNET_free (encrypted_key_share);
   GNUNET_free (encrypted_truth);
   if (NULL == truth)
@@ -293,10 +235,11 @@ ANASTASIS_truth_upload (struct GNUNET_CURL_Context *ctx,
                                    t->url,
                                    &pub_key,
                                    truth,
-                                   GNUNET_NO, // FIXME: tu->payment_requested,
-                                   NULL, // FIXME: tu->paid_order_id,
+                                   payment_requested,
+                                   paid_order_id,
                                    &truth_store_callback,
                                    tu);
+  json_decref (truth);
   if (NULL == tu->tso)
   {
     GNUNET_break (0);
@@ -494,8 +437,6 @@ ANASTASIS_policy_destroy (struct ANASTASIS_Policy *p)
 }
 
 
-struct ANASTASIS_SecretShare;
-
 /**
  * State for a "policy store" CMD.
  */
@@ -609,7 +550,7 @@ struct PolicyStoreState
    */
   unsigned int http_status;
 
-  int payment_requested;
+  bool payment_requested;
 
   /**
    * Status of the transaction
diff --git a/src/reducer/anastasis_api_backup_redux.c 
b/src/reducer/anastasis_api_backup_redux.c
index 5263008..5696af0 100644
--- a/src/reducer/anastasis_api_backup_redux.c
+++ b/src/reducer/anastasis_api_backup_redux.c
@@ -1711,17 +1711,19 @@ upload_rec_documents (json_t *state,
 
 
 /**
-* Upload information
-* caller MUST free 't' using ANASTASIS_truth_free()
-*
-* @param cls closure for callback
-* @param t Truth object (contains provider url and truth public key)
-*/
+ * Upload information
+ * caller MUST free 't' using ANASTASIS_truth_free()
+ *
+ * @param cls closure for callback
+ * @param ec status code of the request (success, failure, payment required)
+ * @param t Truth object (contains provider url and truth public key)
+ * @param ud upload details, useful to continue in case of errors, NULL on 
success
+ */
 static void
 truth_upload_cb (void *cls,
                  enum ANASTASIS_ErrorCode ec,
                  struct ANASTASIS_Truth *t,
-                 const char *taler_pay_url)
+                 const struct ANASTASIS_UploadDetails *ud)
 {
   struct TruthUploadState *tus = cls;
   json_t *p;
@@ -1735,22 +1737,13 @@ truth_upload_cb (void *cls,
     json_t *truth_uploads;
     json_t *p;
 
-    if (NULL == taler_pay_url)
-    {
-      ANASTASIS_redux_fail (tus->cb,
-                            tus->cb_cls,
-                            TALER_EC_ANASTASIS_REDUCER_ACTION_INVALID, // 
FIXME: Error Code
-                            "enter_secret or pay");
-      return;
-    }
-
     truth_uploads = json_object_get (tus->state,
                                      "truth_uploads");
     p = json_pack ("{s:I,s:s}",
                    "status",
                    (json_int_t) MHD_HTTP_PAYMENT_REQUIRED,
                    "pay_url",
-                   taler_pay_url);
+                   ud->details.payment_request);
     GNUNET_assert (NULL != p);
     {
       GNUNET_snprintf (buf,
@@ -1863,6 +1856,8 @@ upload_truths (json_t *state,
               &tus_arr[i]->backend_salt,
               tus_arr[i]->truth_data,
               tus_arr[i]->truth_data_size,
+              false,
+              NULL,
               &truth_upload_cb,
               tus_arr[i]);
             if (NULL == tus_arr[i]->tuo)
@@ -1897,6 +1892,8 @@ upload_truths (json_t *state,
                                                     &tus_arr[i]->backend_salt,
                                                     tus_arr[i]->truth_data,
                                                     
tus_arr[i]->truth_data_size,
+                                                    false,
+                                                    NULL,
                                                     &truth_upload_cb,
                                                     tus_arr[i]);
           if (NULL == tus_arr[i]->tuo)
@@ -1981,6 +1978,8 @@ upload_truths (json_t *state,
                                          &tus->backend_salt,
                                          tus->truth_data,
                                          tus->truth_data_size,
+                                         false,
+                                         NULL,
                                          &truth_upload_cb,
                                          tus);
       if (NULL == tus->tuo)
diff --git a/src/restclient/anastasis_api_truth_store.c 
b/src/restclient/anastasis_api_truth_store.c
index 5ab0204..f69c583 100644
--- a/src/restclient/anastasis_api_truth_store.c
+++ b/src/restclient/anastasis_api_truth_store.c
@@ -245,71 +245,58 @@ handle_header (char *buffer,
 
 
 struct ANASTASIS_TruthStoreOperation *
-ANASTASIS_truth_store (struct GNUNET_CURL_Context *ctx,
-                       const char *backend_url,
-                       const struct
-                       ANASTASIS_CRYPTO_TruthPublicKeyP *truth_public_key,
-                       json_t *truth_data,
-                       int payment_requested,
-                       const char *paid_order_id,
-                       ANASTASIS_TruthStoreCallback cb,
-                       void *cb_cls)
+ANASTASIS_truth_store (
+  struct GNUNET_CURL_Context *ctx,
+  const char *backend_url,
+  const struct ANASTASIS_CRYPTO_TruthPublicKeyP *truth_public_key,
+  const json_t *truth_data,
+  bool payment_requested,
+  const char *paid_order_id,
+  ANASTASIS_TruthStoreCallback cb,
+  void *cb_cls)
 {
   struct ANASTASIS_TruthStoreOperation *tso;
   CURL *eh;
   char *json_str;
 
-  json_str = json_dumps (truth_data,
-                         JSON_COMPACT);
-
   /* Finished setting up headers */
   tso = GNUNET_new (struct ANASTASIS_TruthStoreOperation);
   {
-    if (NULL != truth_public_key)
-    {
-      char *pub_key_str;
-      char *path;
-
-      pub_key_str = GNUNET_STRINGS_data_to_string_alloc (truth_public_key,
-                                                         sizeof (*
-                                                                 
truth_public_key));
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                  "truth public key in truth store :  %s\n",
-                  pub_key_str);
+    char *pub_key_str;
+    char *path;
 
-      GNUNET_asprintf (&path,
-                       "truth/%s",
-                       pub_key_str);
-      tso->url = (GNUNET_YES == payment_requested)
-                 ? TALER_url_join (backend_url,
-                                   path,
-                                   "pay",
-                                   "y",
-                                   (NULL != paid_order_id)
+    pub_key_str = GNUNET_STRINGS_data_to_string_alloc (
+      truth_public_key,
+      sizeof (*truth_public_key));
+    GNUNET_asprintf (&path,
+                     "truth/%s",
+                     pub_key_str);
+    tso->url =
+      payment_requested
+      ? TALER_url_join (backend_url,
+                        path,
+                        "pay",
+                        "y",
+                        (NULL != paid_order_id)
                                    ? "paying"
                                    : NULL,
-                                   paid_order_id,
-                                   NULL)
-                 : TALER_url_join (backend_url,
-                                   path,
-                                   (NULL != paid_order_id)
+                        paid_order_id,
+                        NULL)
+      : TALER_url_join (backend_url,
+                        path,
+                        (NULL != paid_order_id)
                                    ? "paying"
                                    : NULL,
-                                   paid_order_id,
-                                   NULL);
-      GNUNET_free (path);
-      GNUNET_free (pub_key_str);
-    }
-    else
-    {
-      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                  "No public key set");
-      return NULL;
-    }
+                        paid_order_id,
+                        NULL);
+    GNUNET_free (path);
+    GNUNET_free (pub_key_str);
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "URL before curl:  %s\n",
               tso->url);
+  json_str = json_dumps (truth_data,
+                         JSON_COMPACT);
   tso->ctx = ctx;
   tso->data = json_str;
   tso->cb = cb;
@@ -337,6 +324,5 @@ ANASTASIS_truth_store (struct GNUNET_CURL_Context *ctx,
                                       GNUNET_NO,
                                       &handle_truth_store_finished,
                                       tso);
-  json_decref (truth_data);
   return tso;
 }
diff --git a/src/testing/testing_cmd_truth_upload.c 
b/src/testing/testing_cmd_truth_upload.c
index 5625008..49912c9 100644
--- a/src/testing/testing_cmd_truth_upload.c
+++ b/src/testing/testing_cmd_truth_upload.c
@@ -73,6 +73,11 @@ struct TruthUploadState
    */
   const void *truth_data;
 
+  /**
+   * Already paid order ID for this upload, or NULL
+   */
+  const char *paid_order_id;
+
   /**
    * Size of truth_data
    */
@@ -111,17 +116,18 @@ struct TruthUploadState
 
 
 /**
-* Upload information
-* caller MUST free 't' using ANASTASIS_truth_free()
-*
-* @param cls closure for callback
-* @param t Truth object (contains provider url and truth public key)
-*/
+ * Upload information
+ * caller MUST free 't' using ANASTASIS_truth_free()
+ *
+ * @param cls closure for callback
+ * @param t Truth object (contains provider url and truth public key)
+ * @param ud upload details, useful to continue in case of errors, NULL on 
success
+ */
 static void
 truth_upload_cb (void *cls,
                  enum ANASTASIS_ErrorCode ec,
                  struct ANASTASIS_Truth *t,
-                 const char *taler_pay_url)
+                 const struct ANASTASIS_UploadDetails *ud)
 {
   struct TruthUploadState *tus = cls;
 
@@ -153,6 +159,7 @@ truth_upload_run (void *cls,
   struct TruthUploadState *tus = cls;
   const struct TALER_TESTING_Command *ref;
   const struct ANASTASIS_CRYPTO_PowSalt *salt;
+  struct ANASTASIS_CRYPTO_UserIdentifierP user_id;
 
   tus->is = is;
   if (NULL != tus->upload_reference)
@@ -177,7 +184,6 @@ truth_upload_run (void *cls,
     }
   }
 
-  struct ANASTASIS_CRYPTO_UserIdentifierP user_id;
   ANASTASIS_CRYPTO_user_identifier_derive (tus->id_data,
                                            salt,
                                            &user_id);
@@ -191,9 +197,10 @@ truth_upload_run (void *cls,
                                      salt,
                                      tus->truth_data,
                                      tus->truth_data_size,
+                                     false, /* force payment */
+                                     tus->paid_order_id,
                                      &truth_upload_cb,
                                      tus);
-
   if (NULL == tus->tuo)
   {
     GNUNET_break (0);
@@ -263,12 +270,6 @@ truth_upload_traits (void *cls,
 }
 
 
-/**
- * Creates a sample of id_data.
- *
- * @param id_data some sample data (e.g. AHV, name, surname, ...)
- * @return truth in json format
- */
 json_t *
 ANASTASIS_TESTING_make_id_data_example (const char *id_data)
 {
@@ -282,35 +283,20 @@ ANASTASIS_TESTING_make_id_data_example (const char 
*id_data)
 }
 
 
-/**
- * Make the "truth upload" command.
- *
- * @param label command label
- * @param anastasis_url base URL of the anastasis serving our requests.
- * @param id_data ID data to generate user identifier
- * @param method specifies escrow method
- * @param instructions specifies what the client/user has to do
- * @param mime_type mime type of truth_data
- * @param truth_data some truth data (e.g. hash of answer to a secret question)
- * @param truth_data_size size of truth_data
- * @param http_status expected HTTP status
- * @param tso truth upload options
- * @param upload_ref reference to the previous upload
- * @return the command
- */
 struct TALER_TESTING_Command
-ANASTASIS_TESTING_cmd_truth_upload (const char *label,
-                                    const char *anastasis_url,
-                                    json_t *id_data,
-                                    const char *method,
-                                    const char *instructions,
-                                    const char *mime_type,
-                                    const void *truth_data,
-                                    size_t truth_data_size,
-                                    unsigned int http_status,
-                                    enum
-                                    ANASTASIS_TESTING_TruthStoreOption tso,
-                                    const char *upload_ref)
+ANASTASIS_TESTING_cmd_truth_upload (
+  const char *label,
+  const char *anastasis_url,
+  json_t *id_data,
+  const char *method,
+  const char *instructions,
+  const char *mime_type,
+  const void *truth_data,
+  size_t truth_data_size,
+  const char *paid_order_id,
+  unsigned int http_status,
+  enum ANASTASIS_TESTING_TruthStoreOption tso,
+  const char *upload_ref)
 {
   struct TruthUploadState *tus;
 
@@ -324,6 +310,7 @@ ANASTASIS_TESTING_cmd_truth_upload (const char *label,
   tus->method = method;
   tus->instructions = instructions;
   tus->mime_type = mime_type;
+  tus->paid_order_id = paid_order_id;
   tus->truth_data_size = truth_data_size;
   tus->truth_data = truth_data;
 

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