gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] branch master updated: allow for token envelopes being


From: gnunet
Subject: [taler-merchant] branch master updated: allow for token envelopes being null
Date: Thu, 13 Jun 2024 17:33:50 +0200

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

christian-blaettler pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new d72b878a allow for token envelopes being null
d72b878a is described below

commit d72b878a0e33aa1f312547c56c75fcd6f7cd6cc1
Author: Christian Blättler <blatc2@bfh.ch>
AuthorDate: Thu Jun 13 17:33:43 2024 +0200

    allow for token envelopes being null
---
 .../taler-merchant-httpd_post-orders-ID-pay.c      | 32 ++++++++++++++++++----
 1 file changed, 27 insertions(+), 5 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c 
b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
index 08e4b6d8..5af827e7 100644
--- a/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
+++ b/src/backend/taler-merchant-httpd_post-orders-ID-pay.c
@@ -2394,6 +2394,7 @@ static enum GNUNET_GenericReturnValue
 sign_token_envelopes (struct PayContext *pc,
                       struct TALER_MerchantContractTokenFamilyKey *key,
                       struct TALER_TokenIssuePrivateKeyP *priv,
+                      bool critical,
                       unsigned int index,
                       unsigned int expected_num)
 {
@@ -2403,20 +2404,32 @@ sign_token_envelopes (struct PayContext *pc,
   {
     unsigned int pos = index + j;
 
-    /* TODO: Handle missing envelopes for non-critical output tokens. */
     if (pos > pc->token_envelopes_cnt || pos > pc->output_tokens_len) {
+      GNUNET_assert (0); /* this should not happen */
+      return GNUNET_NO;
+    }
+
+    struct TokenEnvelope *env = &pc->token_envelopes[pos];
+
+    if (NULL == env)
+    {
+      if (!critical)
+      {
+        continue;
+      }
+
+      /* critical token families require a token envelope. */
       GNUNET_break (0);
       pay_end (pc,
               TALER_MHD_reply_with_error (pc->connection,
                                           MHD_HTTP_BAD_REQUEST,
                                           TALER_EC_GENERIC_PARAMETER_MALFORMED,
-                                          "Token envelope array is missing "
-                                          "required token envelope"));
+                                          "Token envelope for critical "
+                                          "token family missing"));
       return GNUNET_NO;
     }
 
-    struct TokenEnvelope *env = &pc->token_envelopes[index + j];
-    struct SignedOutputToken *output = &pc->output_tokens[index + j];
+    struct SignedOutputToken *output = &pc->output_tokens[pos];
 
     TALER_token_issue_sign (priv,
                             &env->blinded_token,
@@ -2622,6 +2635,9 @@ phase_validate_tokens (struct PayContext *pc)
       if (GNUNET_OK != sign_token_envelopes (pc,
                                              &key,
                                              &details.priv,
+                                             /* TODO: Use critical field 
stored in database here instead. */
+                                             details.token_family.kind ==
+                                               
TALER_MERCHANTDB_TFK_Subscription,
                                              i,
                                              output.details.token.count))
       {
@@ -3435,6 +3451,12 @@ phase_parse_pay (struct PayContext *pc)
 
     json_array_foreach (tokens_evs, tokens_ev_index, token_ev)
     {
+      if (json_is_null (token_ev))
+      {
+        // Skip null envelopes
+        continue;
+      }
+
       struct TokenEnvelope *ev = &pc->token_envelopes[tokens_ev_index];
       struct GNUNET_JSON_Specification ispec[] = {
         TALER_JSON_spec_token_envelope ("token_ev",

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